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 d54e26fd9b1b809879c7a041cea297739a27c9eb..791a85cec2c6be9f3f5aa66730ba88848cbc35f8 100644 |
--- a/content/browser/renderer_host/media/video_capture_controller.h |
+++ b/content/browser/renderer_host/media/video_capture_controller.h |
@@ -1,41 +1,6 @@ |
// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// |
-// VideoCaptureController is the glue between a VideoCaptureDevice and all |
-// VideoCaptureHosts that have connected to it. A controller exists on behalf of |
-// one (and only one) VideoCaptureDevice; both are owned by the |
-// VideoCaptureManager. |
-// |
-// The VideoCaptureController is responsible for: |
-// |
-// * Allocating and keeping track of shared memory buffers, and filling them |
-// with I420 video frames for IPC communication between VideoCaptureHost (in |
-// the browser process) and VideoCaptureMessageFilter (in the renderer |
-// process). |
-// * Broadcasting the events from a single VideoCaptureDevice, fanning them |
-// out to multiple clients. |
-// * Keeping track of the clients on behalf of the VideoCaptureManager, making |
-// it possible for the Manager to delete the Controller and its Device when |
-// there are no clients left. |
-// |
-// Interactions between VideoCaptureController and other classes: |
-// |
-// * VideoCaptureController indirectly observes a VideoCaptureDevice |
-// by means of its proxy, VideoCaptureDeviceClient, which implements |
-// the VideoCaptureDevice::Client interface. The proxy forwards |
-// observed events to the VideoCaptureController on the IO thread. |
-// * A VideoCaptureController interacts with its clients (VideoCaptureHosts) |
-// via the VideoCaptureControllerEventHandler interface. |
-// * Conversely, a VideoCaptureControllerEventHandler (typically, |
-// VideoCaptureHost) will interact directly with VideoCaptureController to |
-// return leased buffers by means of the ReturnBuffer() public method of |
-// VCC. |
-// * VideoCaptureManager (which owns the VCC) interacts directly with |
-// VideoCaptureController through its public methods, to add and remove |
-// clients. |
-// |
-// VideoCaptureController is not thread safe and operates on the IO thread only. |
#ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ |
#define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ |
@@ -54,12 +19,10 @@ |
#include "media/capture/video/video_frame_receiver.h" |
#include "media/capture/video_capture_types.h" |
-namespace media { |
-class FrameBufferPool; |
-} |
- |
namespace content { |
+// Implementation of media::VideoFrameReceiver that distributes received frames |
+// to potentially multiple connected clients. |
class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
public: |
VideoCaptureController(); |
@@ -67,11 +30,6 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
base::WeakPtr<VideoCaptureController> GetWeakPtrForIOThread(); |
- // A FrameBufferPool may optionally be set in order to receive notifications |
- // when a frame is starting to get consumed and has finished getting consumed. |
- void SetFrameBufferPool( |
- std::unique_ptr<media::FrameBufferPool> frame_buffer_pool); |
- |
// Factory code creating instances of VideoCaptureController may optionally |
// set a VideoFrameConsumerFeedbackObserver. Setting the observer is done in |
// this method separate from the constructor to allow clients to create and |
@@ -129,12 +87,20 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
bool has_received_frames() const { return has_received_frames_; } |
// Implementation of media::VideoFrameReceiver interface: |
- void OnIncomingCapturedVideoFrame( |
- media::VideoCaptureDevice::Client::Buffer buffer, |
- scoped_refptr<media::VideoFrame> frame) override; |
+ void OnNewBufferHandle( |
+ int buffer_id, |
+ std::unique_ptr<media::VideoCaptureDevice::Client::Buffer::HandleProvider> |
+ handle_provider) override; |
+ void OnFrameReadyInBuffer( |
+ int buffer_id, |
+ int frame_feedback_id, |
+ std::unique_ptr< |
+ media::VideoCaptureDevice::Client::Buffer::ScopedAccessPermission> |
+ buffer_read_permission, |
+ media::mojom::VideoFrameInfoPtr frame_info) override; |
+ void OnBufferRetired(int buffer_id) override; |
void OnError() override; |
void OnLog(const std::string& message) override; |
- void OnBufferRetired(int buffer_id) override; |
private: |
struct ControllerClient; |
@@ -146,10 +112,10 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
int buffer_context_id, |
int buffer_id, |
media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer, |
- media::FrameBufferPool* frame_buffer_pool); |
+ mojo::ScopedSharedBufferHandle handle); |
~BufferContext(); |
- BufferContext(const BufferContext& other); |
- BufferContext& operator=(const BufferContext& other); |
+ BufferContext(BufferContext&& other); |
+ BufferContext& operator=(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_; } |
@@ -159,13 +125,18 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
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 set_read_permission( |
+ std::unique_ptr< |
+ media::VideoCaptureDevice::Client::Buffer::ScopedAccessPermission> |
+ buffer_read_permission) { |
+ buffer_read_permission_ = std::move(buffer_read_permission); |
} |
void RecordConsumerUtilization(double utilization); |
void IncreaseConsumerCount(); |
void DecreaseConsumerCount(); |
- bool HasZeroConsumerHoldCount(); |
+ bool HasZeroConsumerHoldCount() const; |
miu
2017/02/15 22:15:00
nit: Looking at the definition of the "Has" method
chfremer
2017/02/16 23:37:56
Done.
|
+ bool HasConsumers() const; |
miu
2017/02/15 22:15:00
Your call, but HasConsumers() seems to be identica
chfremer
2017/02/16 23:37:56
Done.
|
+ mojo::ScopedSharedBufferHandle CreateHandleCopy(); |
private: |
int buffer_context_id_; |
@@ -173,9 +144,12 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
bool is_retired_; |
int frame_feedback_id_; |
media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer_; |
- media::FrameBufferPool* frame_buffer_pool_; |
+ mojo::ScopedSharedBufferHandle buffer_handle_; |
double max_consumer_utilization_; |
int consumer_hold_count_; |
+ std::unique_ptr< |
+ media::VideoCaptureDevice::Client::Buffer::ScopedAccessPermission> |
+ buffer_read_permission_; |
}; |
// Find a client of |id| and |handler| in |clients|. |
@@ -198,8 +172,6 @@ class CONTENT_EXPORT VideoCaptureController : public media::VideoFrameReceiver { |
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_; |