Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: content/browser/renderer_host/media/video_capture_controller.h

Issue 2518143004: [Mojo Video Capture] Replace RESOURCE_UTILIZATION with interface ReceiverLoadObserver (Closed)
Patch Set: Fixed usage of VerifyAndClearExpectations Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/video_capture_controller.h
diff --git a/content/browser/renderer_host/media/video_capture_controller.h b/content/browser/renderer_host/media/video_capture_controller.h
index 8aaf97cdc9dc142489b2b89d41f8ce36d8d03433..931fa358acf8e8e59a0354048ded5dac045121ce 100644
--- a/content/browser/renderer_host/media/video_capture_controller.h
+++ b/content/browser/renderer_host/media/video_capture_controller.h
@@ -72,6 +72,14 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
base::WeakPtr<VideoCaptureController> GetWeakPtrForIOThread();
+ // Factory code creating instances of VideoCaptureController may optionally
+ // set a ConsumerFeedbackObserver. Setting the observer is done in this method
+ // separate from the constructor to allow clients to create and use instances
+ // before they can provide the observer. (This is the case with
+ // VideoCaptureManager).
+ void SetConsumerFeedbackObserver(
+ std::unique_ptr<media::ConsumerFeedbackObserver> observer);
+
// Return a new VideoCaptureDeviceClient to forward capture events to this
// instance.
std::unique_ptr<media::VideoCaptureDevice::Client> NewDeviceClient();
@@ -139,6 +147,33 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
struct ControllerClient;
typedef std::list<std::unique_ptr<ControllerClient>> ControllerClients;
+ class BufferState {
+ public:
+ explicit BufferState(
+ int buffer_id,
+ int frame_feedback_id,
+ media::ConsumerFeedbackObserver* consumer_feedback_observer,
+ const scoped_refptr<media::VideoCaptureBufferPool>& buffer_pool,
+ const scoped_refptr<media::VideoFrame>& frame);
+ ~BufferState();
+ BufferState(const BufferState& other);
+ void RecordConsumerUtilization(double utilization);
+ void IncreaseConsumerCount();
+ void DecreaseConsumerCount();
+ bool HasZeroConsumerHoldCount();
+ void SetConsumerFeedbackObserver(
+ media::ConsumerFeedbackObserver* consumer_feedback_observer);
+
+ private:
+ const int buffer_id_;
+ const int frame_feedback_id_;
+ media::ConsumerFeedbackObserver* consumer_feedback_observer_;
+ const scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_;
+ const scoped_refptr<media::VideoFrame> frame_;
+ double max_consumer_utilization_;
+ int consumer_hold_count_;
+ };
+
// Notify renderer that a new buffer has been created.
void DoNewBufferOnIOThread(ControllerClient* client,
media::VideoCaptureDevice::Client::Buffer* buffer,
@@ -156,6 +191,10 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
// The pool of shared-memory buffers used for capturing.
const scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_;
+ std::unique_ptr<media::ConsumerFeedbackObserver> consumer_feedback_observer_;
+
+ std::map<int, BufferState> buffer_id_to_state_map_;
+
// All clients served by this controller.
ControllerClients controller_clients_;

Powered by Google App Engine
This is Rietveld 408576698