Add record and playback to Tuner HAL
bug: 135708935
Test: Manual
Change-Id: Ibe8a51be31f455cc15b380748a0810e2706e5c1e
diff --git a/tv/tuner/1.0/IDemux.hal b/tv/tuner/1.0/IDemux.hal
index 2d7b275..e03095b 100644
--- a/tv/tuner/1.0/IDemux.hal
+++ b/tv/tuner/1.0/IDemux.hal
@@ -180,5 +180,220 @@
* UNKNOWN_ERROR if failed for other reasons.
*/
close() generates (Result result);
-};
+ /**
+ * Add output to the demux
+ *
+ * It is used by the client to record output data from selected filters.
+ *
+ * @param bufferSize the buffer size of the output to be added. It's used to
+ * create a FMQ(Fast Message Queue) to hold data from selected filters.
+ * @param cb the callback for the demux to be used to send notifications
+ * back to the client.
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * OUT_OF_MEMORY if failed for not enough memory.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ addOutput(uint32_t bufferSize, IDemuxCallback cb) generates (Result result);
+
+ /**
+ * Get the descriptor of the output's FMQ
+ *
+ * It is used by the client to get the descriptor of the output's Fast
+ * Message Queue. The data in FMQ is muxed packets output from selected
+ * filters. The packet's format is specifed by DemuxDataFormat in
+ * DemuxOutputSettings.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * UNKNOWN_ERROR if failed for other reasons.
+ * @return queue the descriptor of the output's FMQ
+ */
+ getOutputQueueDesc() generates (Result result, fmq_sync<uint8_t> queue);
+
+ /**
+ * Configure the demux's output.
+ *
+ * It is used by the client to configure the demux's output for recording.
+ *
+ * @param settings the settings of the demux's output.
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ configureOutput(DemuxOutputSettings settings) generates (Result result);
+
+ /**
+ * Attach one filter to the demux's output.
+ *
+ * It is used by the client to mux one filter's output to demux's output.
+ *
+ * @param filterId the ID of the attached filter.
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ attachOutputTsFilter(DemuxFilterId filterId) generates (Result result);
+
+ /**
+ * Detach one filter from the demux's output.
+ *
+ * It is used by the client to remove one filter's output from demux's
+ * output.
+ *
+ * @param filterId the ID of the detached filter.
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ detachOutputTsFilter(DemuxFilterId filterId) generates (Result result);
+
+ /**
+ * Start to take data to the demux's output.
+ *
+ * It is used by the client to ask the output to start to take data from
+ * attached filters.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ startOutput() generates (Result result);
+
+ /**
+ * Stop to take data to the demux's output.
+ *
+ * It is used by the client to ask the output to stop to take data from
+ * attached filters.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ stopOutput() generates (Result result);
+
+ /**
+ * Flush unconsumed data in the demux's output.
+ *
+ * It is used by the client to ask the demux to flush the data which is
+ * already produced but not consumed yet in the demux's output.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ flushOutput() generates (Result result);
+
+ /**
+ * Remove the demux's output.
+ *
+ * It is used by the client to remove the demux's output.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ removeOutput() generates (Result result);
+
+ /**
+ * Add input to the demux
+ *
+ * It is used by the client to add the demux's input for playback content.
+ *
+ * @param bufferSize the buffer size of the demux's input to be added.
+ * It's used to create a FMQ(Fast Message Queue) to hold input data.
+ * @param cb the callback for the demux to be used to send notifications
+ * back to the client.
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * OUT_OF_MEMORY if failed for not enough memory.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ addInput(uint32_t bufferSize, IDemuxCallback cb) generates (Result result);
+
+ /**
+ * Get the descriptor of the input's FMQ
+ *
+ * It is used by the client to get the descriptor of the input's Fast
+ * Message Queue. The data in FMQ is fed by client. Data format is specifed
+ * by DemuxDataFormat in DemuxInputSettings.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * UNKNOWN_ERROR if failed for other reasons.
+ * @return queue the descriptor of the output's FMQ
+ */
+ getInputQueueDesc() generates (Result result, fmq_sync<uint8_t> queue);
+
+ /**
+ * Configure the demux's input.
+ *
+ * It is used by the client to configure the demux's input for playback.
+ *
+ * @param settings the settings of the demux's input.
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ configureInput(DemuxInputSettings settings) generates (Result result);
+
+ /**
+ * Start to consume the data from the demux's input.
+ *
+ * It is used by the client to ask the demux to start to consume data from
+ * the demux's input.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ startInput() generates (Result result);
+
+ /**
+ * Stop to consume the data from the demux's input.
+ *
+ * It is used by the client to ask the demux to stop to consume data from
+ * the demux's input.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ stopInput() generates (Result result);
+
+ /**
+ * Flush unconsumed data in the demux's input.
+ *
+ * It is used by the client to ask the demux to flush the data which is
+ * already produced but not consumed yet in the demux's input.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ flushInput() generates (Result result);
+
+ /**
+ * Remove the demux's input.
+ *
+ * It is used by the client to remove the demux's input.
+ *
+ * @return result Result status of the operation.
+ * SUCCESS if successful,
+ * INVALID_STATE if failed for wrong state.
+ * UNKNOWN_ERROR if failed for other reasons.
+ */
+ removeInput() generates (Result result);
+};
diff --git a/tv/tuner/1.0/IDemuxCallback.hal b/tv/tuner/1.0/IDemuxCallback.hal
index 7efd2c3..55e8420 100644
--- a/tv/tuner/1.0/IDemuxCallback.hal
+++ b/tv/tuner/1.0/IDemuxCallback.hal
@@ -15,5 +15,19 @@
* @param status a new status of the demux filter.
*/
oneway onFilterStatus(DemuxFilterId filterId, DemuxFilterStatus status);
+
+ /**
+ * Notify the client a new status of the demux's output.
+ *
+ * @param status a new status of the demux's output.
+ */
+ oneway onOutputStatus(DemuxOutputStatus status);
+
+ /**
+ * Notify the client a new status of the demux's input.
+ *
+ * @param status a new status of the demux's input.
+ */
+ oneway onInputStatus(DemuxInputStatus status);
};
diff --git a/tv/tuner/1.0/types.hal b/tv/tuner/1.0/types.hal
index 94e70f5..77f7ead 100644
--- a/tv/tuner/1.0/types.hal
+++ b/tv/tuner/1.0/types.hal
@@ -479,3 +479,99 @@
* framework and apps.
*/
typedef vec<uint8_t> TunerKeyToken;
+
+/**
+ * A data format in demux's output or input according to ISO/IEC 13818-1.
+ */
+@export
+enum DemuxDataFormat : uint32_t {
+ /* Data is Transport Stream. */
+ TS,
+ /* Data is Packetized Elementary Stream. */
+ PES,
+ /* Data is Elementary Stream. */
+ ES,
+};
+
+/**
+ * A status of the demux's output.
+ */
+typedef DemuxFilterStatus DemuxOutputStatus;
+
+/**
+ * The Settings for the demux's output.
+ */
+struct DemuxOutputSettings {
+ /**
+ * Register for interested status events so that the HAL can send these
+ * status events back to client.
+ */
+ bitfield<DemuxOutputStatus> statusMask;
+ /**
+ * Unconsumed data size in bytes in the output. The HAL uses it to trigger
+ * DemuxOutputStatus::LOW_WATER.
+ */
+ uint32_t lowThreshold;
+ /**
+ * Unconsumed data size in bytes in the output. The HAL uses it to trigger
+ * DemuxOutputStatus::High_WATER.
+ */
+ uint32_t highThreshold;
+ /**
+ * The data format in the output.
+ */
+ DemuxDataFormat dataFormat;
+ /**
+ * The packet size in bytes in the output.
+ */
+ uint8_t packetSize;
+};
+
+/**
+ * A status of the demux's input.
+ */
+@export
+enum DemuxInputStatus : uint32_t {
+ /**
+ * The space of the demux's input is empty.
+ */
+ SPACE_EMPTY = 1 << 0,
+ /**
+ * The spece of the demux's input is almost empty.
+ */
+ SPACE_ALMOST_EMPTY = 1 << 1,
+ /**
+ * The space of the demux's input is almost full.
+ */
+ SPACE_ALMOST_FULL = 1 << 2,
+ /**
+ * The space of the demux's input is full.
+ */
+ SPACE_FULL = 1 << 3,
+};
+
+struct DemuxInputSettings {
+ /**
+ * Register for interested status events so that the HAL can send these
+ * status events back to client.
+ */
+ bitfield<DemuxInputStatus> statusMask;
+ /**
+ * Unused space size in bytes in the input. The HAL uses it to trigger
+ * DemuxInputStatus::SPACE_ALMOST_EMPTY.
+ */
+ uint32_t lowThreshold;
+ /**
+ * Unused space size in bytes in the input. The HAL uses it to trigger
+ * DemuxInputStatus::SPACE_ALMOST_FULL.
+ */
+ uint32_t highThreshold;
+ /**
+ * The data format in the input.
+ */
+ DemuxDataFormat dataFormat;
+ /**
+ * The packet size in bytes in the input.
+ */
+ uint8_t packetSize;
+};