Add new APIs for watermarking
Bug: 263762255
Test: m
Change-Id: I7eeaa58f0a3a1056f33e22aba42540636794ade1
diff --git a/tv/input/OWNERS b/tv/input/OWNERS
index a02291a..ae65f67 100644
--- a/tv/input/OWNERS
+++ b/tv/input/OWNERS
@@ -1,3 +1,4 @@
+# Bug component: 105688
hgchen@google.com
shubang@google.com
quxiangfang@google.com
diff --git a/tv/input/aidl/Android.bp b/tv/input/aidl/Android.bp
index 1987174..2591151 100644
--- a/tv/input/aidl/Android.bp
+++ b/tv/input/aidl/Android.bp
@@ -14,6 +14,7 @@
imports: [
"android.hardware.common-V2",
"android.media.audio.common.types-V1",
+ "android.hardware.common.fmq-V1",
],
stability: "vintf",
backend: {
diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl
index f8d5e05..84fe2fb 100644
--- a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl
+++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInput.aidl
@@ -38,6 +38,8 @@
android.hardware.tv.input.TvStreamConfig[] getStreamConfigurations(in int deviceId);
android.hardware.common.NativeHandle openStream(in int deviceId, in int streamId);
void setCallback(in android.hardware.tv.input.ITvInputCallback callback);
+ void setTvMessageEnabled(int deviceId, int streamId, in android.hardware.tv.input.TvMessageEventType type, boolean enabled);
+ void getTvMessageQueueDesc(out android.hardware.common.fmq.MQDescriptor<byte,android.hardware.common.fmq.SynchronizedReadWrite> queue, int deviceId, int streamId);
const int STATUS_UNKNOWN = 1;
const int STATUS_NO_RESOURCE = 2;
const int STATUS_INVALID_ARGUMENTS = 3;
diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl
index 7f2aff6..9747013 100644
--- a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl
+++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/ITvInputCallback.aidl
@@ -35,4 +35,5 @@
@VintfStability
interface ITvInputCallback {
void notify(in android.hardware.tv.input.TvInputEvent event);
+ void notifyTvMessageEvent(in android.hardware.tv.input.TvMessageEvent event);
}
diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessage.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessage.aidl
new file mode 100644
index 0000000..637b01c
--- /dev/null
+++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessage.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright 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 <name>-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.tv.input;
+@VintfStability
+parcelable TvMessage {
+ String subType;
+ long groupId;
+ int dataLengthBytes;
+}
diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEvent.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEvent.aidl
new file mode 100644
index 0000000..94fe665
--- /dev/null
+++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEvent.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright 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 <name>-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.tv.input;
+@VintfStability
+parcelable TvMessageEvent {
+ android.hardware.tv.input.TvMessageEventType type;
+ int streamId;
+ android.hardware.tv.input.TvMessage[] messages;
+}
diff --git a/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEventType.aidl b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEventType.aidl
new file mode 100644
index 0000000..a033903
--- /dev/null
+++ b/tv/input/aidl/aidl_api/android.hardware.tv.input/current/android/hardware/tv/input/TvMessageEventType.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright 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 <name>-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.tv.input;
+@Backing(type="int") @VintfStability
+enum TvMessageEventType {
+ WATERMARK = 1,
+ CLOSED_CAPTION = 2,
+ OTHER = 3,
+}
diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl
index 31d6586..cbaf066 100644
--- a/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl
+++ b/tv/input/aidl/android/hardware/tv/input/ITvInput.aidl
@@ -17,7 +17,10 @@
package android.hardware.tv.input;
import android.hardware.common.NativeHandle;
+import android.hardware.common.fmq.MQDescriptor;
+import android.hardware.common.fmq.SynchronizedReadWrite;
import android.hardware.tv.input.ITvInputCallback;
+import android.hardware.tv.input.TvMessageEventType;
import android.hardware.tv.input.TvStreamConfig;
@VintfStability
@@ -73,4 +76,32 @@
* @throws ServiceSpecificException with values from the ITvInput::STATUS_* constants
*/
void setCallback(in ITvInputCallback callback);
+
+ /**
+ * Enables or disables TV message detection for the specified stream on the device.
+ *
+ * @param deviceId The ID of the device that contains the stream to set the flag for.
+ * @param streamId The ID of the stream to set the flag for.
+ * @param type The type of {@link android.hardware.tv.input.TvMessageEventType}.
+ * @param enabled {@code true} if you want to enable TV message detection
+ * {@code false} otherwise.
+ */
+ void setTvMessageEnabled(
+ int deviceId, int streamId, in TvMessageEventType type, boolean enabled);
+
+ /**
+ * Gets the TV message queue for the specified stream on the device.
+ *
+ * The FMQ is used to relay events that are parsed from the specified stream to the
+ * app or service responsible for processing the message. The HAL implementation
+ * is expected to parse these messages and add them to the queue as new events are
+ * detected from the stream based on whether or not they are enabled by
+ * {@link #setTvMessageEnabled(int, int, TvMessageEventType, boolean)}.
+ *
+ * @param deviceId The ID of the device that contains the stream to get the queue for.
+ * @param streamId THe ID of the stream to get the queue for.
+ * @return The descriptor of the TV message queue.
+ */
+ void getTvMessageQueueDesc(
+ out MQDescriptor<byte, SynchronizedReadWrite> queue, int deviceId, int streamId);
}
diff --git a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
index fc7492d..5d47317 100644
--- a/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
+++ b/tv/input/aidl/android/hardware/tv/input/ITvInputCallback.aidl
@@ -17,6 +17,7 @@
package android.hardware.tv.input;
import android.hardware.tv.input.TvInputEvent;
+import android.hardware.tv.input.TvMessageEvent;
@VintfStability
interface ITvInputCallback {
@@ -27,4 +28,11 @@
* @param event Event passed to the client.
*/
void notify(in TvInputEvent event);
+ /**
+ * Notifies the client that an TV message event has occurred. For possible event types,
+ * check TvMessageEventType.
+ *
+ * @param event Event passed to the client.
+ */
+ void notifyTvMessageEvent(in TvMessageEvent event);
}
diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl
new file mode 100644
index 0000000..6df1f9a
--- /dev/null
+++ b/tv/input/aidl/android/hardware/tv/input/TvMessage.aidl
@@ -0,0 +1,35 @@
+/*
+ * Copyright 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.tv.input;
+
+@VintfStability
+parcelable TvMessage {
+ /**
+ * Extended data type, like “ATSC A/336 Watermark”, “ATSC_CC”, etc. This is opaque
+ * to the framework.
+ */
+ String subType;
+ /**
+ * This group id is used to optionally identify messages that belong together, such as
+ * headers and bodies of the same event. For messages that do not have a group, this value
+ * should be -1.
+ *
+ * As -1 is a reserved value, -1 should not be used as a valid groupId.
+ */
+ long groupId;
+ int dataLengthBytes;
+}
diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessageEvent.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessageEvent.aidl
new file mode 100644
index 0000000..74a078a
--- /dev/null
+++ b/tv/input/aidl/android/hardware/tv/input/TvMessageEvent.aidl
@@ -0,0 +1,28 @@
+/*
+ * Copyright 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.tv.input;
+
+import android.hardware.tv.input.TvMessage;
+import android.hardware.tv.input.TvMessageEventType;
+
+@VintfStability
+parcelable TvMessageEvent {
+ TvMessageEventType type;
+
+ int streamId;
+ TvMessage[] messages;
+}
diff --git a/tv/input/aidl/android/hardware/tv/input/TvMessageEventType.aidl b/tv/input/aidl/android/hardware/tv/input/TvMessageEventType.aidl
new file mode 100644
index 0000000..5a5f472
--- /dev/null
+++ b/tv/input/aidl/android/hardware/tv/input/TvMessageEventType.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright 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.tv.input;
+
+@VintfStability
+@Backing(type="int")
+enum TvMessageEventType {
+ WATERMARK = 1,
+ CLOSED_CAPTION = 2,
+ OTHER = 3,
+}
diff --git a/tv/input/aidl/default/Android.bp b/tv/input/aidl/default/Android.bp
index 66148c8..05af6a9 100644
--- a/tv/input/aidl/default/Android.bp
+++ b/tv/input/aidl/default/Android.bp
@@ -13,6 +13,10 @@
init_rc: ["input-default.rc"],
vintf_fragments: ["input-default.xml"],
vendor: true,
+ cflags: [
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
srcs: [
"TvInput.cpp",
"service.cpp",
@@ -23,9 +27,11 @@
shared_libs: [
"libbase",
"liblog",
+ "libfmq",
"libutils",
"libcutils",
"libbinder_ndk",
"android.hardware.tv.input-V1-ndk",
+ "android.hardware.common.fmq-V1-ndk",
],
}
diff --git a/tv/input/aidl/default/TvInput.cpp b/tv/input/aidl/default/TvInput.cpp
index ed12cbc..47f8be5 100644
--- a/tv/input/aidl/default/TvInput.cpp
+++ b/tv/input/aidl/default/TvInput.cpp
@@ -65,6 +65,21 @@
return ::ndk::ScopedAStatus::ok();
}
+::ndk::ScopedAStatus TvInput::setTvMessageEnabled(int32_t deviceId, int32_t streamId,
+ TvMessageEventType in_type, bool enabled) {
+ ALOGV("%s", __FUNCTION__);
+ // TODO: Implement this
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus TvInput::getTvMessageQueueDesc(
+ MQDescriptor<int8_t, SynchronizedReadWrite>* out_queue, int32_t in_deviceId,
+ int32_t in_streamId) {
+ ALOGV("%s", __FUNCTION__);
+ // TODO: Implement this
+ return ::ndk::ScopedAStatus::ok();
+}
+
::ndk::ScopedAStatus TvInput::getStreamConfigurations(int32_t in_deviceId,
vector<TvStreamConfig>* _aidl_return) {
ALOGV("%s", __FUNCTION__);
diff --git a/tv/input/aidl/default/TvInput.h b/tv/input/aidl/default/TvInput.h
index a72bca3..9cb7ae6 100644
--- a/tv/input/aidl/default/TvInput.h
+++ b/tv/input/aidl/default/TvInput.h
@@ -19,6 +19,8 @@
#include <aidl/android/hardware/tv/input/BnTvInput.h>
#include <utils/KeyedVector.h>
+#include <aidl/android/hardware/tv/input/TvMessageEventType.h>
+#include <fmq/AidlMessageQueue.h>
#include <map>
#include "TvInputDeviceInfoWrapper.h"
#include "TvStreamConfigWrapper.h"
@@ -26,6 +28,9 @@
using namespace android;
using namespace std;
using ::aidl::android::hardware::common::NativeHandle;
+using ::aidl::android::hardware::common::fmq::MQDescriptor;
+using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
+using ::android::AidlMessageQueue;
namespace aidl {
namespace android {
@@ -38,6 +43,11 @@
TvInput();
::ndk::ScopedAStatus setCallback(const shared_ptr<ITvInputCallback>& in_callback) override;
+ ::ndk::ScopedAStatus setTvMessageEnabled(int32_t deviceId, int32_t streamId,
+ TvMessageEventType in_type, bool enabled) override;
+ ::ndk::ScopedAStatus getTvMessageQueueDesc(
+ MQDescriptor<int8_t, SynchronizedReadWrite>* out_queue, int32_t in_deviceId,
+ int32_t in_streamId) override;
::ndk::ScopedAStatus getStreamConfigurations(int32_t in_deviceId,
vector<TvStreamConfig>* _aidl_return) override;
::ndk::ScopedAStatus openStream(int32_t in_deviceId, int32_t in_streamId,
diff --git a/tv/input/aidl/vts/functional/Android.bp b/tv/input/aidl/vts/functional/Android.bp
index 9829b6d..22487ea 100644
--- a/tv/input/aidl/vts/functional/Android.bp
+++ b/tv/input/aidl/vts/functional/Android.bp
@@ -9,10 +9,16 @@
cc_test {
name: "VtsHalTvInputTargetTest",
- defaults: ["VtsHalTargetTestDefaults","use_libaidlvintf_gtest_helper_static",],
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ cflags: [
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
srcs: ["VtsHalTvInputTargetTest.cpp"],
static_libs: [
- "android.hardware.tv.input-V1-ndk",
"android.media.audio.common.types-V1-ndk",
"android.hardware.common-V2-ndk",
"libaidlcommonsupport",
@@ -24,6 +30,9 @@
shared_libs: [
"libbinder_ndk",
"libvndksupport",
+ "libfmq",
+ "android.hardware.common.fmq-V1-ndk",
+ "android.hardware.tv.input-V1-ndk",
],
require_root: true,
}
diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
index ec83e29..9c26069 100644
--- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
+++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp
@@ -43,6 +43,11 @@
return ::ndk::ScopedAStatus::ok();
}
+::ndk::ScopedAStatus TvInputAidlTest::TvInputCallback::notifyTvMessageEvent(
+ const TvMessageEvent& in_event) {
+ return ::ndk::ScopedAStatus::ok();
+}
+
void TvInputAidlTest::SetUp() {
if (AServiceManager_isDeclared(GetParam().c_str())) {
::ndk::SpAIBinder binder(AServiceManager_waitForService(GetParam().c_str()));
diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
index c76e568..693d49d 100644
--- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
+++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.h
@@ -25,15 +25,19 @@
#include <aidl/android/hardware/tv/input/ITvInput.h>
#include <aidl/android/hardware/tv/input/TvInputDeviceInfo.h>
#include <aidl/android/hardware/tv/input/TvInputEvent.h>
+#include <aidl/android/hardware/tv/input/TvMessageEvent.h>
+#include <aidl/android/hardware/tv/input/TvMessageEventType.h>
#include <aidl/android/hardware/tv/input/TvStreamConfig.h>
+#include <fmq/AidlMessageQueue.h>
#include <log/log.h>
#include <utils/KeyedVector.h>
using namespace aidl::android::hardware::tv::input;
using namespace std;
-
using ::aidl::android::hardware::common::NativeHandle;
+using ::aidl::android::hardware::common::fmq::MQDescriptor;
+using ::android::AidlMessageQueue;
#define WAIT_FOR_EVENT_TIMEOUT 5
#define DEFAULT_ID INT32_MIN
@@ -46,6 +50,7 @@
public:
TvInputCallback(shared_ptr<TvInputAidlTest> parent);
::ndk::ScopedAStatus notify(const TvInputEvent& in_event) override;
+ ::ndk::ScopedAStatus notifyTvMessageEvent(const TvMessageEvent& in_event) override;
private:
shared_ptr<TvInputAidlTest> parent_;