diff --git a/compatibility_matrices/exclude/fcm_exclude.cpp b/compatibility_matrices/exclude/fcm_exclude.cpp index cb77c7b0e0..cf1e138090 100644 --- a/compatibility_matrices/exclude/fcm_exclude.cpp +++ b/compatibility_matrices/exclude/fcm_exclude.cpp @@ -61,6 +61,7 @@ bool ShouldCheckMissingHalsInFcm(const std::string& package) { "android.hardware.graphics.common", "android.hardware.input.common", "android.hardware.keymaster", + "android.hardware.media.bufferpool2", "android.hardware.radio", "android.hardware.uwb.fira_android", diff --git a/media/bufferpool/aidl/Android.bp b/media/bufferpool/aidl/Android.bp new file mode 100644 index 0000000000..3b2ea3cd62 --- /dev/null +++ b/media/bufferpool/aidl/Android.bp @@ -0,0 +1,35 @@ +// Copyright (C) 2022 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +aidl_interface { + name: "android.hardware.media.bufferpool2", + vendor_available: true, + srcs: ["android/hardware/media/bufferpool2/*.aidl"], + imports: [ + "android.hardware.common-V2", + "android.hardware.common.fmq-V1", + ], + stability: "vintf", + backend: { + cpp: { + enabled: false, + }, + java: { + enabled: false, + }, + ndk: { + enabled: true, + }, + }, +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/Buffer.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/Buffer.aidl new file mode 100644 index 0000000000..4ea0bba7fc --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/Buffer.aidl @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@VintfStability +parcelable Buffer { + int id; + android.hardware.common.NativeHandle buffer; +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferInvalidationMessage.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferInvalidationMessage.aidl new file mode 100644 index 0000000000..181286c197 --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferInvalidationMessage.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@FixedSize @VintfStability +parcelable BufferInvalidationMessage { + int messageId; + int fromBufferId; + int toBufferId; +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferStatus.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferStatus.aidl new file mode 100644 index 0000000000..13174ffe09 --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferStatus.aidl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@Backing(type="int") @VintfStability +enum BufferStatus { + NOT_USED = 0, + USED = 1, + TRANSFER_TO = 2, + TRANSFER_FROM = 3, + TRANSFER_TIMEOUT = 4, + TRANSFER_LOST = 5, + TRANSFER_FETCH = 6, + TRANSFER_OK = 7, + TRANSFER_ERROR = 8, + INVALIDATION_ACK = 9, +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferStatusMessage.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferStatusMessage.aidl new file mode 100644 index 0000000000..7e79a368d1 --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/BufferStatusMessage.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@FixedSize @VintfStability +parcelable BufferStatusMessage { + long transactionId; + int bufferId; + android.hardware.media.bufferpool2.BufferStatus status; + long connectionId; + long targetConnectionId; + long timestampUs; +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IAccessor.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IAccessor.aidl new file mode 100644 index 0000000000..4053797dcf --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IAccessor.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@VintfStability +interface IAccessor { + android.hardware.media.bufferpool2.IAccessor.ConnectionInfo connect(in android.hardware.media.bufferpool2.IObserver observer); + @VintfStability + parcelable ConnectionInfo { + android.hardware.media.bufferpool2.IConnection connection; + long connectionId; + int msgId; + android.hardware.common.fmq.MQDescriptor toFmqDesc; + android.hardware.common.fmq.MQDescriptor fromFmqDesc; + } +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl new file mode 100644 index 0000000000..54896d4fbf --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IClientManager.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@VintfStability +interface IClientManager { + long registerSender(in android.hardware.media.bufferpool2.IAccessor bufferPool); +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IConnection.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IConnection.aidl new file mode 100644 index 0000000000..300fcbae9b --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IConnection.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@VintfStability +interface IConnection { + android.hardware.media.bufferpool2.IConnection.FetchResult[] fetch(in android.hardware.media.bufferpool2.IConnection.FetchInfo[] fetchInfos); + parcelable FetchInfo { + long transactionId; + int bufferId; + } + union FetchResult { + android.hardware.media.bufferpool2.Buffer buffer; + android.hardware.media.bufferpool2.ResultStatus failure; + } +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IObserver.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IObserver.aidl new file mode 100644 index 0000000000..2d8cffe70c --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/IObserver.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@VintfStability +interface IObserver { + oneway void onMessage(in long connectionId, in int msgId); +} diff --git a/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/ResultStatus.aidl b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/ResultStatus.aidl new file mode 100644 index 0000000000..73709985c4 --- /dev/null +++ b/media/bufferpool/aidl/aidl_api/android.hardware.media.bufferpool2/current/android/hardware/media/bufferpool2/ResultStatus.aidl @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.media.bufferpool2; +@VintfStability +parcelable ResultStatus { + int resultStatus; + const int OK = 0; + const int NO_MEMORY = 1; + const int ALREADY_EXISTS = 2; + const int NOT_FOUND = 3; + const int CRITICAL_ERROR = 4; +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/Buffer.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/Buffer.aidl new file mode 100644 index 0000000000..976f674878 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/Buffer.aidl @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +import android.hardware.common.NativeHandle; + +/** + * Generic buffer for fast recycling for media/stagefright. + * + * During media pipeline buffer references are created, shared and + * destroyed frequently. The underlying buffers are allocated on demand + * by a buffer pool, and are recycled to the buffer pool when they are + * no longer referenced by the clients. + * + * E.g. ion or gralloc buffer + */ +@VintfStability +parcelable Buffer { + int id; + NativeHandle buffer; +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferInvalidationMessage.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferInvalidationMessage.aidl new file mode 100644 index 0000000000..ad03cd54b8 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferInvalidationMessage.aidl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +/* + * Buffer pool sends a buffer invalidation message to clients in order to + * ensure fast reclamation of the buffers. Buffer pool implementation on + * clients must release the invalidated buffers right away after finishing + * the use of buffers upon receiving a buffer invalidation message. + * Users cannot delay or control timing of the handling/reception of + * invalidation messages. Buffer pool implementation must guarantee timely + * handling of invalidation messages. + */ +@VintfStability +@FixedSize +parcelable BufferInvalidationMessage { + int messageId; + /** + * Buffers from fromBufferId to toBufferId must be invalidated. + * fromBufferId is inclusive, but toBufferId is not inclusive. + * If fromBufferId > toBufferID, wrap happens. In that case + * the wrap is based on UINT32_MAX. + */ + int fromBufferId; + int toBufferId; +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferStatus.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferStatus.aidl new file mode 100644 index 0000000000..b63aee2b55 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferStatus.aidl @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +/** + * Buffer ownership status for the specified client. + * Buffer transfer status for the specified buffer transafer transaction. + * BufferStatus is posted along with BufferStatusMessage from a client to + * the buffer pool for synchronization after status change. + */ +@VintfStability +@Backing(type="int") +enum BufferStatus { + /** + * No longer used by the specified client. + */ + NOT_USED = 0, + /** + * Buffer is acquired by the specified client. + */ + USED = 1, + /** + * Buffer is sent by the specified client. + */ + TRANSFER_TO = 2, + /** + * Buffer transfer is acked by the receiver client. + */ + TRANSFER_FROM = 3, + /** + * Buffer transfer is timed out by receiver client. + */ + TRANSFER_TIMEOUT = 4, + /** + * Buffer transfer is not acked by the receiver. + */ + TRANSFER_LOST = 5, + /** + * Buffer fetch request from the client. + */ + TRANSFER_FETCH = 6, + /** + * Buffer transaction succeeded. + */ + TRANSFER_OK = 7, + /** + * Buffer transaction failure. + */ + TRANSFER_ERROR = 8, + /** + * Buffer invalidation ack. + */ + INVALIDATION_ACK = 9, +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferStatusMessage.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferStatusMessage.aidl new file mode 100644 index 0000000000..e3fd8f0cce --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/BufferStatusMessage.aidl @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +import android.hardware.media.bufferpool2.BufferStatus; + +/** + * Buffer ownership status change message. This message is + * sent via fmq to the buffer pool from client processes. + */ +@VintfStability +@FixedSize +parcelable BufferStatusMessage { + /** + * Transaction Id = (SenderId : sender local transaction Id) + * Transaction Id is created from sender and posted via fmq within + * TRANSFER_TO message. + */ + long transactionId; + int bufferId; + BufferStatus status; + /** + * Used by the buffer pool, not by client. + */ + long connectionId; + /** + * Valid only when TRANSFER_TO is posted. + */ + long targetConnectionId; + /** + * Used by the buffer pool, not by client. + * Monotonic timestamp in Us since fixed point in time as decided + * by the sender of the message + */ + long timestampUs; +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/IAccessor.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IAccessor.aidl new file mode 100644 index 0000000000..0fa5961929 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IAccessor.aidl @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +import android.hardware.common.fmq.MQDescriptor; +import android.hardware.common.fmq.SynchronizedReadWrite; +import android.hardware.common.fmq.UnsynchronizedWrite; + + +import android.hardware.media.bufferpool2.BufferInvalidationMessage; +import android.hardware.media.bufferpool2.BufferStatusMessage; +import android.hardware.media.bufferpool2.IConnection; +import android.hardware.media.bufferpool2.IObserver; + +/** + * IAccessor creates IConnection which is used from IClientManager in order to + * use functionality of the specified buffer pool. + */ +@VintfStability +interface IAccessor { + @VintfStability + /** + * Connection information between the bufferpool process and the receiver + * process. The information is used from the receiver process in order to + * receive buffers from the bufferpool process. + */ + parcelable ConnectionInfo { + /** + * The interface to get shared buffers from the bufferpool. + */ + IConnection connection; + /** + * The identifier for a (sender/receiver) pair during buffer transfer. + * This is system wide unique. + */ + long connectionId; + /** + * Id of the most recent message from bufferpool. This is monotonic. + */ + int msgId; + /** + * The FMQ descriptor for sending buffer status messages back to bufferpool + */ + MQDescriptor toFmqDesc; + /** + * The FMQ descriptor for receiving buffer invalidation messages from bufferpool + */ + MQDescriptor fromFmqDesc; + } + + /** + * Registers a new client and creates IConnection to the buffer pool for + * the client. IConnection and FMQ are used by IClientManager in order to + * communicate with the buffer pool. Via FMQ IClientManager sends + * BufferStatusMessage(s) to the buffer pool. + * + * FMQ is used to send buffer ownership status changes to a buffer pool + * from a buffer pool client. A buffer pool synchronizes FMQ messages when + * there is an aidl request from the clients. Every client has its own + * connection and FMQ to communicate with the buffer pool. So sending an + * FMQ message on behalf of other clients is not possible. + * + * FMQ messages are sent when a buffer is acquired or released. Also, FMQ + * messages are sent when a buffer is transferred from a client to another + * client. FMQ has its own ID from a buffer pool. A client is specified + * with the ID. + * + * To transfer a buffer, a sender must send an FMQ message. The message + * must include a receiver's ID and a transaction ID. A receiver must send + * the transaction ID to fetch a buffer from a buffer pool. Since the + * sender already registered the receiver via an FMQ message, The buffer + * pool must verify the receiver with the transaction ID. In order to + * prevent faking a receiver, a connection to a buffer pool from client is + * made and kept private. Also part of transaction ID is a sender ID in + * order to prevent fake transactions from other clients. This must be + * verified with an FMQ message from a buffer pool. + * + * @param observer The buffer pool event observer from the client. + * Observer is provided to ensure FMQ messages are processed even when + * client processes are idle. Buffer invalidation caused by + * reconfiguration does not call observer. Buffer invalidation caused + * by termination of pipeline call observer in order to ensure + * invalidation is done after pipeline completion. + * @return ConnectionInfo The information regarding the established + * connection + * @@throws ServiceSpecificException with one of the following values: + * ResultStatus::NO_MEMORY - Memory allocation failure occurred. + * ResultStatus::ALREADY_EXISTS - A connection was already made. + * ResultStatus::CRITICAL_ERROR - Other errors. + */ + ConnectionInfo connect(in IObserver observer); +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl new file mode 100644 index 0000000000..bf36e25a55 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IClientManager.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +import android.hardware.media.bufferpool2.IAccessor; + +/** + * IClientManager manages IConnection(s) inside a process. A locally + * created IConnection represents a communication node(receiver) with the + * specified buffer pool(IAccessor). + * IConnection(s) are not exposed to other processes(IClientManager). + * IClientManager instance must be unique within a process. + */ +@VintfStability +interface IClientManager { + /** + * Sets up a buffer receiving communication node for the specified + * buffer pool. A manager must create a IConnection to the buffer + * pool if it does not already have a connection. + * + * @param bufferPool a buffer pool which is specified with the IAccessor. + * The specified buffer pool is the owner of received buffers. + * @return the Id of the communication node to the buffer pool. + * This id is used in FMQ to notify IAccessor that a buffer has been + * sent to that connection during transfers. + * @throws ServiceSpecificException with one of the following values: + * ResultStatus::NO_MEMORY - Memory allocation failure occurred. + * ResultStatus::ALREADY_EXISTS - A sender was registered already. + * ResultStatus::CRITICAL_ERROR - Other errors. + */ + long registerSender(in IAccessor bufferPool); +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/IConnection.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IConnection.aidl new file mode 100644 index 0000000000..d869f47a64 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IConnection.aidl @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +import android.hardware.media.bufferpool2.Buffer; +import android.hardware.media.bufferpool2.ResultStatus; + +/** + * A connection to a buffer pool which handles requests from a buffer pool + * client. The connection must be made in order to receive buffers from + * other buffer pool clients. + */ +@VintfStability +interface IConnection { + + parcelable FetchInfo { + /** + * Unique transaction id for buffer transferring. + */ + long transactionId; + /** + * Id of the buffer to be fetched. + */ + int bufferId; + } + + union FetchResult { + /** + * The fetched buffer on successful fetch. + */ + Buffer buffer; + /** + * The reason of the request failure. Possible values are below. + * + * ResultStatus::NOT_FOUND - A buffer was not found due to invalidation. + * ResultStatus::CRITICAL_ERROR - Other errors. + */ + ResultStatus failure; + } + + /** + * Retrieves buffers using an array of FetchInfo. + * Each element of FetchInfo array contains a bufferId and a transactionId + * for each buffer to fetch. The method must be called from receiving side of buffers + * during transferring only when the specified buffer is neither cached nor used. + * + * The method could have partial failures, in the case other successfully fetched buffers + * will be in returned result along with the failures. The order of the returned result + * will be the same with the fetchInfos. + * + * @param fetchInfos information of buffers to fetch + * @return Requested buffers. + * If there are failures, reasons of failures are also included. + * @throws ServiceSpecificException with one of the following values: + * ResultStatus::NO_MEMORY - Memory allocation failure occurred. + * ResultStatus::CRITICAL_ERROR - Other errors. + */ + FetchResult[] fetch(in FetchInfo[] fetchInfos); +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/IObserver.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IObserver.aidl new file mode 100644 index 0000000000..07d1c3e4a3 --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/IObserver.aidl @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +/** + * IObserver listens on notifications from the buffer pool. On receiving + * notifications, FMQ messages from the specific buffer pool which are already + * in the FMQ are processed. + */ +@VintfStability +interface IObserver { + /** + * The specific buffer pool sent a message to the client. Calling this + * method from the buffer pool enforces a buffer pool client process the + * message. + * + * @param connectionId the connection Id of the specific buffer pool client + * @param msgId Id of the most recent message + */ + oneway void onMessage(in long connectionId, in int msgId); +} diff --git a/media/bufferpool/aidl/android/hardware/media/bufferpool2/ResultStatus.aidl b/media/bufferpool/aidl/android/hardware/media/bufferpool2/ResultStatus.aidl new file mode 100644 index 0000000000..162f9a719a --- /dev/null +++ b/media/bufferpool/aidl/android/hardware/media/bufferpool2/ResultStatus.aidl @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.media.bufferpool2; + +@VintfStability +parcelable ResultStatus { + const int OK = 0; + const int NO_MEMORY = 1; + const int ALREADY_EXISTS = 2; + const int NOT_FOUND = 3; + const int CRITICAL_ERROR = 4; + + int resultStatus; +}