Chromium Code Reviews| Index: media/capture/video/video_capture_device_client.h |
| diff --git a/media/capture/video/video_capture_device_client.h b/media/capture/video/video_capture_device_client.h |
| index 9a36f9d5425e58ae8c594ed103eb7633fdd56760..f24e7bfcebae338a79e0233530812d2c0c452458 100644 |
| --- a/media/capture/video/video_capture_device_client.h |
| +++ b/media/capture/video/video_capture_device_client.h |
| @@ -15,10 +15,10 @@ |
| #include "base/memory/weak_ptr.h" |
| #include "media/capture/capture_export.h" |
| #include "media/capture/video/video_capture_device.h" |
| +#include "media/capture/video/video_frame_receiver.h" |
| namespace media { |
| class VideoCaptureBufferPool; |
| -class VideoFrameReceiver; |
| class VideoCaptureJpegDecoder; |
| using VideoCaptureJpegDecoderFactoryCB = |
| @@ -40,33 +40,40 @@ using VideoCaptureJpegDecoderFactoryCB = |
| // manages the necessary entities to interact with the GPU process, notably an |
| // offscreen Context to avoid janking the UI thread. |
| class CAPTURE_EXPORT VideoCaptureDeviceClient |
| - : public media::VideoCaptureDevice::Client, |
| + : public VideoCaptureDevice::Client, |
| + public FrameReceiverObserver, |
| public base::SupportsWeakPtr<VideoCaptureDeviceClient> { |
| public: |
| VideoCaptureDeviceClient( |
| std::unique_ptr<VideoFrameReceiver> receiver, |
| scoped_refptr<VideoCaptureBufferPool> buffer_pool, |
| - const VideoCaptureJpegDecoderFactoryCB& jpeg_decoder_factory); |
| + const VideoCaptureJpegDecoderFactoryCB& jpeg_decoder_factory, |
| + scoped_refptr<base::SingleThreadTaskRunner> |
| + utilization_reporting_task_runner); |
| ~VideoCaptureDeviceClient() override; |
| + void SetConsumerLoadObserver(ConsumerLoadObserver* load_observer); |
| + |
| // VideoCaptureDevice::Client implementation. |
| void OnIncomingCapturedData(const uint8_t* data, |
| int length, |
| const media::VideoCaptureFormat& frame_format, |
| int rotation, |
| base::TimeTicks reference_time, |
| - base::TimeDelta timestamp) override; |
| + base::TimeDelta timestamp, |
| + int frame_id = 0) override; |
| std::unique_ptr<Buffer> ReserveOutputBuffer( |
| const gfx::Size& dimensions, |
| media::VideoPixelFormat format, |
| media::VideoPixelStorage storage) override; |
| void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
| - const media::VideoCaptureFormat& frame_format, |
| + const VideoCaptureFormat& format, |
| base::TimeTicks reference_time, |
| - base::TimeDelta timestamp) override; |
| - void OnIncomingCapturedVideoFrame( |
| - std::unique_ptr<Buffer> buffer, |
| - scoped_refptr<media::VideoFrame> frame) override; |
| + base::TimeDelta timestamp, |
| + int frame_id) override; |
| + void OnIncomingCapturedVideoFrame(std::unique_ptr<Buffer> buffer, |
| + scoped_refptr<media::VideoFrame> frame, |
| + int frame_id) override; |
| std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
| const gfx::Size& dimensions, |
| media::VideoPixelFormat format, |
| @@ -76,6 +83,10 @@ class CAPTURE_EXPORT VideoCaptureDeviceClient |
| void OnLog(const std::string& message) override; |
| double GetBufferPoolUtilization() const override; |
| + // FrameReceiverObserver implementation. |
| + void OnReceiverReportingUtilization(int buffer_id, |
| + double utilization) override; |
| + |
| private: |
| // Reserve output buffer into which I420 contents can be copied directly. |
| // The dimensions of the frame is described by |dimensions|, and requested |
| @@ -99,7 +110,11 @@ class CAPTURE_EXPORT VideoCaptureDeviceClient |
| int length, |
| const VideoCaptureFormat& frame_format, |
| base::TimeTicks reference_time, |
| - base::TimeDelta timestamp); |
| + base::TimeDelta timestamp, |
| + int frame_id); |
| + |
| + void EraseEntryFromBufferIdToFrameIdMap(int buffer_id_to_drop); |
| + void AddEntryToBufferIdToFrameIdMap(int buffer_id, int frame_id); |
| // The receiver to which we post events. |
| const std::unique_ptr<VideoFrameReceiver> receiver_; |
| @@ -113,6 +128,14 @@ class CAPTURE_EXPORT VideoCaptureDeviceClient |
| // The pool of shared-memory buffers used for capturing. |
| const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| + ConsumerLoadObserver* optional_load_observer_; |
| + // Read and write access to |buffer_id_to_frame_id_map_| is sequentialized to |
| + // |utilization_reporting_task_runner_|, since the corresponding calls may |
| + // arrive from different threads. |
| + const scoped_refptr<base::SingleThreadTaskRunner> |
| + utilization_reporting_task_runner_; |
| + std::map<int, int> buffer_id_to_frame_id_map_; |
|
miu
2016/12/01 05:25:18
Instead of this map, can you tag the frame feedbac
chfremer
2016/12/02 01:28:29
Excellent suggestions. This greatly simplifies thi
|
| + |
| #if DCHECK_IS_ON() |
| // Counter used to track the number of times consecutive capture buffers are |
| // dropped. |