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

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

Issue 2607203002: [Mojo Video Capture] Retire buffers when Android Chromium goes to the background (Closed)
Patch Set: mcasas comments Created 3 years, 10 months 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
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8eaa31abd2f81322ba46b447c71fba0c7d622c07..d54e26fd9b1b809879c7a041cea297739a27c9eb 100644
--- a/content/browser/renderer_host/media/video_capture_controller.h
+++ b/content/browser/renderer_host/media/video_capture_controller.h
@@ -134,32 +134,43 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
scoped_refptr<media::VideoFrame> frame) override;
void OnError() override;
void OnLog(const std::string& message) override;
- void OnBufferDestroyed(int buffer_id_to_drop) override;
+ void OnBufferRetired(int buffer_id) override;
private:
struct ControllerClient;
typedef std::list<std::unique_ptr<ControllerClient>> ControllerClients;
- class BufferState {
+ class BufferContext {
public:
- explicit BufferState(
+ BufferContext(
+ int buffer_context_id,
int buffer_id,
- int frame_feedback_id,
media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer,
media::FrameBufferPool* frame_buffer_pool);
- ~BufferState();
- BufferState(const BufferState& other);
+ ~BufferContext();
+ BufferContext(const BufferContext& other);
+ BufferContext& operator=(const BufferContext& other);
+ int buffer_context_id() const { return buffer_context_id_; }
+ int buffer_id() const { return buffer_id_; }
+ bool is_retired() const { return is_retired_; }
+ void set_is_retired() { is_retired_ = true; }
+ void set_frame_feedback_id(int id) { frame_feedback_id_ = id; }
+ void set_consumer_feedback_observer(
+ media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer) {
+ consumer_feedback_observer_ = consumer_feedback_observer;
+ }
+ void set_frame_buffer_pool(media::FrameBufferPool* frame_buffer_pool) {
+ frame_buffer_pool_ = frame_buffer_pool;
+ }
void RecordConsumerUtilization(double utilization);
void IncreaseConsumerCount();
void DecreaseConsumerCount();
bool HasZeroConsumerHoldCount();
- void SetFrameFeedbackId(int id);
- void SetConsumerFeedbackObserver(
- media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer);
- void SetFrameBufferPool(media::FrameBufferPool* frame_buffer_pool);
private:
- const int buffer_id_;
+ int buffer_context_id_;
+ int buffer_id_;
+ bool is_retired_;
int frame_feedback_id_;
media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer_;
media::FrameBufferPool* frame_buffer_pool_;
@@ -176,12 +187,23 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
ControllerClient* FindClient(int session_id,
const ControllerClients& clients);
+ std::vector<BufferContext>::iterator FindBufferContextFromBufferContextId(
+ int buffer_context_id);
+ std::vector<BufferContext>::iterator FindUnretiredBufferContextFromBufferId(
+ int buffer_id);
+
+ void OnClientFinishedConsumingBuffer(ControllerClient* client,
+ int buffer_id,
+ double consumer_resource_utilization);
+ void ReleaseBufferContext(
+ const std::vector<BufferContext>::iterator& buffer_state_iter);
+
std::unique_ptr<media::FrameBufferPool> frame_buffer_pool_;
std::unique_ptr<media::VideoFrameConsumerFeedbackObserver>
consumer_feedback_observer_;
- std::map<int, BufferState> buffer_id_to_state_map_;
+ std::vector<BufferContext> buffer_contexts_;
// All clients served by this controller.
ControllerClients controller_clients_;
@@ -190,6 +212,8 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver {
// state which stops the flow of data to clients.
VideoCaptureState state_;
+ int next_buffer_context_id_ = 0;
+
// True if the controller has received a video frame from the device.
bool has_received_frames_;
« no previous file with comments | « no previous file | content/browser/renderer_host/media/video_capture_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698