OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ | 5 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ |
6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ | 6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "media/video/capture/video_capture.h" | 11 #include "media/video/capture/video_capture.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class MessageLoopProxy; | 14 class MessageLoopProxy; |
15 } | 15 } |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 // This is a helper class to proxy a VideoCapture::EventHandler. In the renderer | 19 // This is a helper class to proxy a VideoCapture::EventHandler. In the renderer |
20 // process, the VideoCaptureImpl calls its handler on a "Video Capture" thread, | 20 // process, the VideoCaptureImpl calls its handler on a "Video Capture" thread, |
21 // this class allows seamless proxying to another thread ("main thread"), which | 21 // this class allows seamless proxying to another thread ("main thread"), which |
22 // would be the thread where the instance of this class is created. The | 22 // would be the thread where the instance of this class is created. The |
23 // "proxied" handler is then called on that thread. | 23 // "proxied" handler is then called on that thread. |
24 // Since the VideoCapture is living on the "Video Capture" thread, querying its | 24 // Since the VideoCapture is living on the "Video Capture" thread, querying its |
25 // state from the "main thread" is fundamentally racy. Instead this class keeps | 25 // state from the "main thread" is fundamentally racy. Instead this class keeps |
26 // track of the state every time it is called by the VideoCapture (on the VC | 26 // track of the state every time it is called by the VideoCapture (on the VC |
27 // thread), and forwards that information to the main thread. | 27 // thread), and forwards that information to the main thread. |
28 class VideoCaptureHandlerProxy : public VideoCapture::EventHandler { | 28 class MEDIA_EXPORT VideoCaptureHandlerProxy |
| 29 : public VideoCapture::EventHandler { |
29 public: | 30 public: |
30 struct VideoCaptureState { | 31 struct VideoCaptureState { |
31 VideoCaptureState() : started(false), width(0), height(0), frame_rate(0) {} | 32 VideoCaptureState() : started(false), width(0), height(0), frame_rate(0) {} |
32 bool started; | 33 bool started; |
33 int width; | 34 int width; |
34 int height; | 35 int height; |
35 int frame_rate; | 36 int frame_rate; |
36 }; | 37 }; |
37 | 38 |
38 // Called on main thread. | 39 // Called on main thread. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 VideoCapture::EventHandler* proxied_; | 86 VideoCapture::EventHandler* proxied_; |
86 VideoCaptureState state_; | 87 VideoCaptureState state_; |
87 | 88 |
88 scoped_refptr<base::MessageLoopProxy> main_message_loop_; | 89 scoped_refptr<base::MessageLoopProxy> main_message_loop_; |
89 }; | 90 }; |
90 | 91 |
91 } // namespace media | 92 } // namespace media |
92 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::VideoCaptureHandlerProxy); | 93 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::VideoCaptureHandlerProxy); |
93 | 94 |
94 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ | 95 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ |
OLD | NEW |