| Index: media/capture/thread_safe_capture_oracle.h
|
| diff --git a/content/browser/media/capture/content_video_capture_device_core.h b/media/capture/thread_safe_capture_oracle.h
|
| similarity index 42%
|
| rename from content/browser/media/capture/content_video_capture_device_core.h
|
| rename to media/capture/thread_safe_capture_oracle.h
|
| index 0590e5157b101f5218e4a39c5acb874cd6de36ec..0c3b77ad153431fad61d0d5b65b0e73580b48fda 100644
|
| --- a/content/browser/media/capture/content_video_capture_device_core.h
|
| +++ b/media/capture/thread_safe_capture_oracle.h
|
| @@ -2,52 +2,46 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_
|
| -#define CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_
|
| +#ifndef MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_
|
| +#define MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_
|
|
|
| #include <string>
|
|
|
| +#include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "base/memory/weak_ptr.h"
|
| -#include "base/threading/thread.h"
|
| -#include "base/threading/thread_checker.h"
|
| -#include "content/browser/media/capture/capture_resolution_chooser.h"
|
| -#include "content/browser/media/capture/video_capture_oracle.h"
|
| -#include "content/common/content_export.h"
|
| +#include "media/base/media_export.h"
|
| #include "media/base/video_frame.h"
|
| +#include "media/capture/capture_resolution_chooser.h"
|
| +#include "media/capture/video_capture_oracle.h"
|
| #include "media/video/capture/video_capture_device.h"
|
|
|
| namespace media {
|
| +
|
| struct VideoCaptureParams;
|
| class VideoFrame;
|
| -} // namespace media
|
| -
|
| -namespace content {
|
| -
|
| -class VideoCaptureMachine;
|
|
|
| // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps
|
| // the VideoCaptureOracle, which decides which frames to capture, and a
|
| // VideoCaptureDevice::Client, which allocates and receives the captured
|
| // frames, in a lock to synchronize state between the two.
|
| -class ThreadSafeCaptureOracle
|
| +class MEDIA_EXPORT ThreadSafeCaptureOracle
|
| : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> {
|
| public:
|
| - ThreadSafeCaptureOracle(scoped_ptr<media::VideoCaptureDevice::Client> client,
|
| - const media::VideoCaptureParams& params);
|
| + ThreadSafeCaptureOracle(scoped_ptr<VideoCaptureDevice::Client> client,
|
| + const VideoCaptureParams& params);
|
|
|
| // Called when a captured frame is available or an error has occurred.
|
| // If |success| is true then |frame| is valid and |timestamp| indicates when
|
| // the frame was painted.
|
| // If |success| is false, all other parameters are invalid.
|
| - typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& frame,
|
| + typedef base::Callback<void(const scoped_refptr<VideoFrame>& frame,
|
| base::TimeTicks timestamp,
|
| bool success)> CaptureFrameCallback;
|
|
|
| bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event,
|
| const gfx::Rect& damage_rect,
|
| base::TimeTicks event_time,
|
| - scoped_refptr<media::VideoFrame>* storage,
|
| + scoped_refptr<VideoFrame>* storage,
|
| CaptureFrameCallback* callback);
|
|
|
| base::TimeDelta min_capture_period() const {
|
| @@ -78,10 +72,10 @@ class ThreadSafeCaptureOracle
|
| // Callback invoked on completion of all captures.
|
| void DidCaptureFrame(
|
| int frame_number,
|
| - scoped_ptr<media::VideoCaptureDevice::Client::Buffer> buffer,
|
| + scoped_ptr<VideoCaptureDevice::Client::Buffer> buffer,
|
| base::TimeTicks capture_begin_time,
|
| base::TimeDelta estimated_frame_duration,
|
| - const scoped_refptr<media::VideoFrame>& frame,
|
| + const scoped_refptr<VideoFrame>& frame,
|
| base::TimeTicks timestamp,
|
| bool success);
|
|
|
| @@ -94,97 +88,18 @@ class ThreadSafeCaptureOracle
|
| mutable base::Lock lock_;
|
|
|
| // Recipient of our capture activity.
|
| - scoped_ptr<media::VideoCaptureDevice::Client> client_;
|
| + scoped_ptr<VideoCaptureDevice::Client> client_;
|
|
|
| // Makes the decision to capture a frame.
|
| VideoCaptureOracle oracle_;
|
|
|
| // The video capture parameters used to construct the oracle proxy.
|
| - const media::VideoCaptureParams params_;
|
| + const VideoCaptureParams params_;
|
|
|
| // Determines video capture frame sizes.
|
| CaptureResolutionChooser resolution_chooser_;
|
| };
|
|
|
| -// Keeps track of the video capture source frames and executes copying on the
|
| -// UI BrowserThread.
|
| -class VideoCaptureMachine {
|
| - public:
|
| - VideoCaptureMachine() {}
|
| - virtual ~VideoCaptureMachine() {}
|
| -
|
| - // Starts capturing. Returns true if succeeded.
|
| - // Must be run on the UI BrowserThread.
|
| - virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy,
|
| - const media::VideoCaptureParams& params) = 0;
|
| -
|
| - // Stops capturing. Must be run on the UI BrowserThread.
|
| - // |callback| is invoked after the capturing has stopped.
|
| - virtual void Stop(const base::Closure& callback) = 0;
|
| -
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine);
|
| -};
|
| -
|
| -// The "meat" of a content video capturer.
|
| -//
|
| -// Separating this from the "shell classes" WebContentsVideoCaptureDevice and
|
| -// DesktopCaptureDeviceAura allows safe destruction without needing to block any
|
| -// threads, as well as code sharing.
|
| -//
|
| -// ContentVideoCaptureDeviceCore manages a simple state machine and the pipeline
|
| -// (see notes at top of this file). It times the start of successive captures
|
| -// and facilitates the processing of each through the stages of the
|
| -// pipeline.
|
| -class CONTENT_EXPORT ContentVideoCaptureDeviceCore
|
| - : public base::SupportsWeakPtr<ContentVideoCaptureDeviceCore> {
|
| - public:
|
| - ContentVideoCaptureDeviceCore(
|
| - scoped_ptr<VideoCaptureMachine> capture_machine);
|
| - virtual ~ContentVideoCaptureDeviceCore();
|
| -
|
| - // Asynchronous requests to change ContentVideoCaptureDeviceCore state.
|
| - void AllocateAndStart(const media::VideoCaptureParams& params,
|
| - scoped_ptr<media::VideoCaptureDevice::Client> client);
|
| - void StopAndDeAllocate();
|
| -
|
| - private:
|
| - // Flag indicating current state.
|
| - enum State {
|
| - kIdle,
|
| - kCapturing,
|
| - kError
|
| - };
|
| -
|
| - void TransitionStateTo(State next_state);
|
| -
|
| - // Called back in response to StartCaptureMachine(). |success| is true if
|
| - // capture machine succeeded to start.
|
| - void CaptureStarted(bool success);
|
| -
|
| - // Stops capturing and notifies client_ of an error state.
|
| - void Error(const std::string& reason);
|
| -
|
| - // Tracks that all activity occurs on the media stream manager's thread.
|
| - base::ThreadChecker thread_checker_;
|
| -
|
| - // Current lifecycle state.
|
| - State state_;
|
| -
|
| - // Tracks the CaptureMachine that's doing work on our behalf on the UI thread.
|
| - // This value should never be dereferenced by this class, other than to
|
| - // create and destroy it on the UI thread.
|
| - scoped_ptr<VideoCaptureMachine> capture_machine_;
|
| -
|
| - // Our thread-safe capture oracle which serves as the gateway to the video
|
| - // capture pipeline. Besides the VideoCaptureDevice itself, it is the only
|
| - // component of the system with direct access to |client_|.
|
| - scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ContentVideoCaptureDeviceCore);
|
| -};
|
| -
|
| -
|
| -} // namespace content
|
| +} // namespace media
|
|
|
| -#endif // CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_
|
| +#endif // MEDIA_CAPTURE_THREAD_SAFE_CAPTURE_ORACLE_H_
|
|
|