CCodec: add more doc to PipelineWatcher
Test: builds
Change-Id: Id6534cd2b4f5c68ee568ada06a8c2bb73584c275
diff --git a/media/codec2/sfplugin/PipelineWatcher.cpp b/media/codec2/sfplugin/PipelineWatcher.cpp
index cdcc41b..df81d49 100644
--- a/media/codec2/sfplugin/PipelineWatcher.cpp
+++ b/media/codec2/sfplugin/PipelineWatcher.cpp
@@ -139,8 +139,8 @@
std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
durations.push_back(elapsed);
}
- nth_element(durations.begin(), durations.end(), durations.begin() + n,
- std::greater<Clock::duration>());
+ std::nth_element(durations.begin(), durations.end(), durations.begin() + n,
+ std::greater<Clock::duration>());
return durations[n];
}
diff --git a/media/codec2/sfplugin/PipelineWatcher.h b/media/codec2/sfplugin/PipelineWatcher.h
index 1c127e4..1e23147 100644
--- a/media/codec2/sfplugin/PipelineWatcher.h
+++ b/media/codec2/sfplugin/PipelineWatcher.h
@@ -26,7 +26,8 @@
namespace android {
/**
- * PipelineWatcher watches the status of the work.
+ * PipelineWatcher watches the pipeline and infers the status of work items from
+ * events.
*/
class PipelineWatcher {
public:
@@ -39,21 +40,81 @@
mSmoothnessFactor(0) {}
~PipelineWatcher() = default;
+ /**
+ * \param value the new input delay value
+ * \return this object
+ */
PipelineWatcher &inputDelay(uint32_t value);
+
+ /**
+ * \param value the new pipeline delay value
+ * \return this object
+ */
PipelineWatcher &pipelineDelay(uint32_t value);
+
+ /**
+ * \param value the new output delay value
+ * \return this object
+ */
PipelineWatcher &outputDelay(uint32_t value);
+
+ /**
+ * \param value the new smoothness factor value
+ * \return this object
+ */
PipelineWatcher &smoothnessFactor(uint32_t value);
+ /**
+ * Client queued a work item to the component.
+ *
+ * \param frameIndex input frame index of this work
+ * \param buffers input buffers of the queued work item
+ * \param queuedAt time when the client queued the buffer
+ */
void onWorkQueued(
uint64_t frameIndex,
std::vector<std::shared_ptr<C2Buffer>> &&buffers,
const Clock::time_point &queuedAt);
+
+ /**
+ * The component released input buffers from a work item.
+ *
+ * \param frameIndex input frame index
+ * \param arrayIndex index of the buffer at the original |buffers| in
+ * onWorkQueued().
+ * \return buffers[arrayIndex]
+ */
std::shared_ptr<C2Buffer> onInputBufferReleased(
uint64_t frameIndex, size_t arrayIndex);
+
+ /**
+ * The component finished processing a work item.
+ *
+ * \param frameIndex input frame index
+ */
void onWorkDone(uint64_t frameIndex);
+
+ /**
+ * Flush the pipeline.
+ */
void flush();
+ /**
+ * \return true if pipeline does not need more work items to proceed
+ * smoothly, considering delays and smoothness factor;
+ * false otherwise.
+ */
bool pipelineFull() const;
+
+ /**
+ * Return elapsed processing time of a work item, nth from the longest
+ * processing time to the shortest.
+ *
+ * \param now current timestamp
+ * \param n nth work item, from the longest processing time to the
+ * shortest. It's a 0-based index.
+ * \return elapsed processing time of nth work item.
+ */
Clock::duration elapsed(const Clock::time_point &now, size_t n) const;
private: