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

Side by Side Diff: content/browser/renderer_host/media/video_capture_device_impl.h

Issue 100313002: Fix screen capture slowness in Chrome OS feedback report. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments by sergeyu. Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_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"
(...skipping 27 matching lines...) Expand all
38 38
39 // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps 39 // Thread-safe, refcounted proxy to the VideoCaptureOracle. This proxy wraps
40 // the VideoCaptureOracle, which decides which frames to capture, and a 40 // the VideoCaptureOracle, which decides which frames to capture, and a
41 // VideoCaptureDevice::Client, which allocates and receives the captured 41 // VideoCaptureDevice::Client, which allocates and receives the captured
42 // frames, in a lock to synchronize state between the two. 42 // frames, in a lock to synchronize state between the two.
43 class ThreadSafeCaptureOracle 43 class ThreadSafeCaptureOracle
44 : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> { 44 : public base::RefCountedThreadSafe<ThreadSafeCaptureOracle> {
45 public: 45 public:
46 ThreadSafeCaptureOracle(scoped_ptr<media::VideoCaptureDevice::Client> client, 46 ThreadSafeCaptureOracle(scoped_ptr<media::VideoCaptureDevice::Client> client,
47 scoped_ptr<VideoCaptureOracle> oracle, 47 scoped_ptr<VideoCaptureOracle> oracle,
48 const gfx::Size& capture_size, 48 const media::VideoCaptureParams& params);
49 int frame_rate);
50 49
51 // Called when a captured frame is available or an error has occurred. 50 // Called when a captured frame is available or an error has occurred.
52 // If |success| is true then the frame provided is valid and |timestamp| 51 // If |success| is true then the frame provided is valid and |timestamp|
53 // indicates when the frame was painted. 52 // indicates when the frame was painted.
54 // If |success| is false, both the frame provided and |timestamp| are invalid. 53 // If |success| is false, both the frame provided and |timestamp| are invalid.
55 typedef base::Callback<void(base::Time timestamp, bool success)> 54 typedef base::Callback<void(base::Time timestamp, bool success)>
56 CaptureFrameCallback; 55 CaptureFrameCallback;
57 56
58 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event, 57 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event,
59 base::Time event_time, 58 base::Time event_time,
60 scoped_refptr<media::VideoFrame>* storage, 59 scoped_refptr<media::VideoFrame>* storage,
61 CaptureFrameCallback* callback); 60 CaptureFrameCallback* callback);
62 61
63 base::TimeDelta capture_period() const { 62 base::TimeDelta capture_period() const {
64 return oracle_->capture_period(); 63 return oracle_->capture_period();
65 } 64 }
66 65
66 // Updates capture resolution based on the supplied source size and the
67 // maximum frame size.
68 void UpdateCaptureSize(const gfx::Size& source_size);
69
67 // Stop new captures from happening (but doesn't forget the client). 70 // Stop new captures from happening (but doesn't forget the client).
68 void Stop(); 71 void Stop();
69 72
70 // Signal an error to the client. 73 // Signal an error to the client.
71 void ReportError(); 74 void ReportError();
72 75
73 private: 76 private:
74 friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>; 77 friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>;
75 virtual ~ThreadSafeCaptureOracle(); 78 virtual ~ThreadSafeCaptureOracle();
76 79
77 // Callback invoked on completion of all captures. 80 // Callback invoked on completion of all captures.
78 void DidCaptureFrame( 81 void DidCaptureFrame(
79 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, 82 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer,
80 int frame_number, 83 int frame_number,
81 base::Time timestamp, 84 base::Time timestamp,
82 bool success); 85 bool success);
83 // Protects everything below it. 86 // Protects everything below it.
84 base::Lock lock_; 87 base::Lock lock_;
85 88
86 // Recipient of our capture activity. 89 // Recipient of our capture activity.
87 scoped_ptr<media::VideoCaptureDevice::Client> client_; 90 scoped_ptr<media::VideoCaptureDevice::Client> client_;
88 91
89 // Makes the decision to capture a frame. 92 // Makes the decision to capture a frame.
90 const scoped_ptr<VideoCaptureOracle> oracle_; 93 const scoped_ptr<VideoCaptureOracle> oracle_;
91 94
95 // The video capture parameters used to construct the oracle proxy.
96 const media::VideoCaptureParams params_;
97
98 // Indicates if capture size has been updated after construction.
99 bool capture_size_updated_;
100
92 // The current capturing resolution and frame rate. 101 // The current capturing resolution and frame rate.
93 const gfx::Size capture_size_; 102 gfx::Size capture_size_;
94 const int frame_rate_; 103 int frame_rate_;
95 }; 104 };
96 105
97 // Keeps track of the video capture source frames and executes copying on the 106 // Keeps track of the video capture source frames and executes copying on the
98 // UI BrowserThread. 107 // UI BrowserThread.
99 class VideoCaptureMachine { 108 class VideoCaptureMachine {
100 public: 109 public:
101 VideoCaptureMachine() : started_(false) {} 110 VideoCaptureMachine() : started_(false) {}
102 virtual ~VideoCaptureMachine() {} 111 virtual ~VideoCaptureMachine() {}
103 112
104 // This should only be checked on the UI thread. 113 // This should only be checked on the UI thread.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // system with direct access to |client_|. 182 // system with direct access to |client_|.
174 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; 183 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_;
175 184
176 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceImpl); 185 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceImpl);
177 }; 186 };
178 187
179 188
180 } // namespace content 189 } // namespace content
181 190
182 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_ 191 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698