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

Side by Side Diff: content/browser/media/capture/content_video_capture_device_core.h

Issue 267813002: Revert of Use texture-backed VideoFrame pipeline for Aura desktop capturing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/media/capture/content_video_capture_device_core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_
6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ 6 #define CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "content/browser/media/capture/video_capture_oracle.h" 14 #include "content/browser/media/capture/video_capture_oracle.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "media/base/video_frame.h"
17 #include "media/video/capture/video_capture_device.h" 16 #include "media/video/capture/video_capture_device.h"
18 17
19 namespace media { 18 namespace media {
20 class VideoCaptureParams;
21 class VideoFrame; 19 class VideoFrame;
22 } // namespace media 20 } // namespace media
23 21
24 namespace content { 22 namespace content {
25 23
24 const int kMinFrameWidth = 2;
25 const int kMinFrameHeight = 2;
26
26 // Returns the nearest even integer closer to zero. 27 // Returns the nearest even integer closer to zero.
27 template<typename IntType> 28 template<typename IntType>
28 IntType MakeEven(IntType x) { 29 IntType MakeEven(IntType x) {
29 return x & static_cast<IntType>(-2); 30 return x & static_cast<IntType>(-2);
30 } 31 }
31 32
32 // TODO(nick): Remove this once frame subscription is supported on Aura and 33 // TODO(nick): Remove this once frame subscription is supported on Aura and
33 // Linux. 34 // Linux.
34 #if (defined(OS_WIN) || defined(OS_MACOSX)) || defined(USE_AURA) 35 #if (defined(OS_WIN) || defined(OS_MACOSX)) || defined(USE_AURA)
35 const bool kAcceleratedSubscriberIsSupported = true; 36 const bool kAcceleratedSubscriberIsSupported = true;
36 #else 37 #else
37 const bool kAcceleratedSubscriberIsSupported = false; 38 const bool kAcceleratedSubscriberIsSupported = false;
38 #endif 39 #endif
39 40
40 class VideoCaptureMachine; 41 class VideoCaptureMachine;
41 42
42 // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps 43 // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps
43 // the VideoCaptureOracle, which decides which frames to capture, and a 44 // the VideoCaptureOracle, which decides which frames to capture, and a
44 // VideoCaptureDevice::Client, which allocates and receives the captured 45 // VideoCaptureDevice::Client, which allocates and receives the captured
45 // frames, in a lock to synchronize state between the two. 46 // frames, in a lock to synchronize state between the two.
46 class ThreadSafeCaptureOracle 47 class ThreadSafeCaptureOracle
47 : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> { 48 : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> {
48 public: 49 public:
49 ThreadSafeCaptureOracle(scoped_ptr<media::VideoCaptureDevice::Client> client, 50 ThreadSafeCaptureOracle(scoped_ptr<media::VideoCaptureDevice::Client> client,
50 scoped_ptr<VideoCaptureOracle> oracle, 51 scoped_ptr<VideoCaptureOracle> oracle,
51 const media::VideoCaptureParams& params); 52 const media::VideoCaptureParams& params);
52 53
53 // Called when a captured frame is available or an error has occurred. 54 // Called when a captured frame is available or an error has occurred.
54 // If |success| is true then |frame| is valid and |timestamp| indicates when 55 // If |success| is true then the frame provided is valid and |timestamp|
55 // the frame was painted. 56 // indicates when the frame was painted.
56 // If |success| is false, all other parameters are invalid. 57 // If |success| is false, both the frame provided and |timestamp| are invalid.
57 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>& frame, 58 typedef base::Callback<void(base::TimeTicks timestamp, bool success)>
58 base::TimeTicks timestamp, 59 CaptureFrameCallback;
59 bool success)> CaptureFrameCallback;
60 60
61 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event, 61 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event,
62 base::TimeTicks event_time, 62 base::TimeTicks event_time,
63 scoped_refptr<media::VideoFrame>* storage, 63 scoped_refptr<media::VideoFrame>* storage,
64 CaptureFrameCallback* callback); 64 CaptureFrameCallback* callback);
65 65
66 base::TimeDelta capture_period() const { 66 base::TimeDelta capture_period() const {
67 return oracle_->capture_period(); 67 return oracle_->capture_period();
68 } 68 }
69 69
70 // Returns the current capture resolution. 70 // Returns the current capture resolution.
71 gfx::Size GetCaptureSize() const; 71 gfx::Size GetCaptureSize() const;
72 72
73 // Updates capture resolution based on the supplied source size and the 73 // Updates capture resolution based on the supplied source size and the
74 // maximum frame size. 74 // maximum frame size.
75 void UpdateCaptureSize(const gfx::Size& source_size); 75 void UpdateCaptureSize(const gfx::Size& source_size);
76 76
77 // Stop new captures from happening (but doesn't forget the client). 77 // Stop new captures from happening (but doesn't forget the client).
78 void Stop(); 78 void Stop();
79 79
80 // Signal an error to the client. 80 // Signal an error to the client.
81 void ReportError(const std::string& reason); 81 void ReportError(const std::string& reason);
82 82
83 private: 83 private:
84 friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>; 84 friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>;
85 virtual ~ThreadSafeCaptureOracle(); 85 virtual ~ThreadSafeCaptureOracle();
86 86
87 // Callback invoked on completion of all captures. 87 // Callback invoked on completion of all captures.
88 void DidCaptureFrame( 88 void DidCaptureFrame(
89 int frame_number,
90 const scoped_refptr<media::VideoCaptureDevice::Client::Buffer>& buffer, 89 const scoped_refptr<media::VideoCaptureDevice::Client::Buffer>& buffer,
91 const scoped_refptr<media::VideoFrame>& frame, 90 const scoped_refptr<media::VideoFrame>& frame,
91 int frame_number,
92 base::TimeTicks timestamp, 92 base::TimeTicks timestamp,
93 bool success); 93 bool success);
94 94
95 // Protects everything below it. 95 // Protects everything below it.
96 mutable base::Lock lock_; 96 mutable base::Lock lock_;
97 97
98 // Recipient of our capture activity. 98 // Recipient of our capture activity.
99 scoped_ptr<media::VideoCaptureDevice::Client> client_; 99 scoped_ptr<media::VideoCaptureDevice::Client> client_;
100 100
101 // Makes the decision to capture a frame. 101 // Makes the decision to capture a frame.
102 const scoped_ptr<VideoCaptureOracle> oracle_; 102 const scoped_ptr<VideoCaptureOracle> oracle_;
103 103
104 // The video capture parameters used to construct the oracle proxy. 104 // The video capture parameters used to construct the oracle proxy.
105 media::VideoCaptureParams params_; 105 const media::VideoCaptureParams params_;
106 106
107 // Indicates if capture size has been updated after construction. 107 // Indicates if capture size has been updated after construction.
108 bool capture_size_updated_; 108 bool capture_size_updated_;
109 109
110 // The current capturing format, as a media::VideoFrame::Format. 110 // The current capturing resolution and frame rate.
111 media::VideoFrame::Format video_frame_format_; 111 gfx::Size capture_size_;
112 int frame_rate_;
112 }; 113 };
113 114
114 // Keeps track of the video capture source frames and executes copying on the 115 // Keeps track of the video capture source frames and executes copying on the
115 // UI BrowserThread. 116 // UI BrowserThread.
116 class VideoCaptureMachine { 117 class VideoCaptureMachine {
117 public: 118 public:
118 VideoCaptureMachine() : started_(false) {} 119 VideoCaptureMachine() : started_(false) {}
119 virtual ~VideoCaptureMachine() {} 120 virtual ~VideoCaptureMachine() {}
120 121
121 // This should only be checked on the UI thread. 122 // This should only be checked on the UI thread.
122 bool started() const { return started_; } 123 bool started() const { return started_; }
123 124
124 // Starts capturing. Returns true if succeeded. 125 // Starts capturing. Returns true if succeeded.
125 // Must be run on the UI BrowserThread. 126 // Must be run on the UI BrowserThread.
126 virtual bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, 127 virtual bool Start(
127 const media::VideoCaptureParams& params) = 0; 128 const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy) = 0;
128 129
129 // Stops capturing. Must be run on the UI BrowserThread. 130 // Stops capturing. Must be run on the UI BrowserThread.
130 // |callback| is invoked after the capturing has stopped. 131 // |callback| is invoked after the capturing has stopped.
131 virtual void Stop(const base::Closure& callback) = 0; 132 virtual void Stop(const base::Closure& callback) = 0;
132 133
133 protected: 134 protected:
134 bool started_; 135 bool started_;
135 136
136 private: 137 private:
137 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine); 138 DISALLOW_COPY_AND_ASSIGN(VideoCaptureMachine);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // component of the/ system with direct access to |client_|. 193 // component of the/ system with direct access to |client_|.
193 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; 194 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
194 195
195 DISALLOW_COPY_AND_ASSIGN(ContentVideoCaptureDeviceCore); 196 DISALLOW_COPY_AND_ASSIGN(ContentVideoCaptureDeviceCore);
196 }; 197 };
197 198
198 199
199 } // namespace content 200 } // namespace content
200 201
201 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_ 202 #endif // CONTENT_BROWSER_MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_DEVICE_CORE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/capture/content_video_capture_device_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698