OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 media::VideoCaptureParams& params); | 48 const media::VideoCaptureParams& params); |
49 | 49 |
50 // 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. |
51 // 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| |
52 // indicates when the frame was painted. | 52 // indicates when the frame was painted. |
53 // 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. |
54 typedef base::Callback<void(base::Time timestamp, bool success)> | 54 typedef base::Callback<void(base::TimeTicks timestamp, bool success)> |
55 CaptureFrameCallback; | 55 CaptureFrameCallback; |
56 | 56 |
57 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event, | 57 bool ObserveEventAndDecideCapture(VideoCaptureOracle::Event event, |
58 base::Time event_time, | 58 base::TimeTicks event_time, |
59 scoped_refptr<media::VideoFrame>* storage, | 59 scoped_refptr<media::VideoFrame>* storage, |
60 CaptureFrameCallback* callback); | 60 CaptureFrameCallback* callback); |
61 | 61 |
62 base::TimeDelta capture_period() const { | 62 base::TimeDelta capture_period() const { |
63 return oracle_->capture_period(); | 63 return oracle_->capture_period(); |
64 } | 64 } |
65 | 65 |
66 // Updates capture resolution based on the supplied source size and the | 66 // Updates capture resolution based on the supplied source size and the |
67 // maximum frame size. | 67 // maximum frame size. |
68 void UpdateCaptureSize(const gfx::Size& source_size); | 68 void UpdateCaptureSize(const gfx::Size& source_size); |
69 | 69 |
70 // Stop new captures from happening (but doesn't forget the client). | 70 // Stop new captures from happening (but doesn't forget the client). |
71 void Stop(); | 71 void Stop(); |
72 | 72 |
73 // Signal an error to the client. | 73 // Signal an error to the client. |
74 void ReportError(); | 74 void ReportError(); |
75 | 75 |
76 private: | 76 private: |
77 friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>; | 77 friend class base::RefCountedThreadSafe<ThreadSafeCaptureOracle>; |
78 virtual ~ThreadSafeCaptureOracle(); | 78 virtual ~ThreadSafeCaptureOracle(); |
79 | 79 |
80 // Callback invoked on completion of all captures. | 80 // Callback invoked on completion of all captures. |
81 void DidCaptureFrame( | 81 void DidCaptureFrame( |
82 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 82 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
83 int frame_number, | 83 int frame_number, |
84 base::Time timestamp, | 84 base::TimeTicks timestamp, |
85 bool success); | 85 bool success); |
86 // Protects everything below it. | 86 // Protects everything below it. |
87 base::Lock lock_; | 87 base::Lock lock_; |
88 | 88 |
89 // Recipient of our capture activity. | 89 // Recipient of our capture activity. |
90 scoped_ptr<media::VideoCaptureDevice::Client> client_; | 90 scoped_ptr<media::VideoCaptureDevice::Client> client_; |
91 | 91 |
92 // Makes the decision to capture a frame. | 92 // Makes the decision to capture a frame. |
93 const scoped_ptr<VideoCaptureOracle> oracle_; | 93 const scoped_ptr<VideoCaptureOracle> oracle_; |
94 | 94 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // system with direct access to |client_|. | 182 // system with direct access to |client_|. |
183 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 183 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
184 | 184 |
185 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceImpl); | 185 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceImpl); |
186 }; | 186 }; |
187 | 187 |
188 | 188 |
189 } // namespace content | 189 } // namespace content |
190 | 190 |
191 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_ | 191 #endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_DEVICE_IMPL_H_ |
OLD | NEW |