| 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 MEDIA_EXPORT VideoCaptureHandlerProxy | 28 class VideoCaptureHandlerProxy : public VideoCapture::EventHandler { |
| 29 : public VideoCapture::EventHandler { | |
| 30 public: | 29 public: |
| 31 struct VideoCaptureState { | 30 struct VideoCaptureState { |
| 32 VideoCaptureState() : started(false), width(0), height(0), frame_rate(0) {} | 31 VideoCaptureState() : started(false), width(0), height(0), frame_rate(0) {} |
| 33 bool started; | 32 bool started; |
| 34 int width; | 33 int width; |
| 35 int height; | 34 int height; |
| 36 int frame_rate; | 35 int frame_rate; |
| 37 }; | 36 }; |
| 38 | 37 |
| 39 // Called on main thread. | 38 // Called on main thread. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 VideoCapture::EventHandler* proxied_; | 85 VideoCapture::EventHandler* proxied_; |
| 87 VideoCaptureState state_; | 86 VideoCaptureState state_; |
| 88 | 87 |
| 89 scoped_refptr<base::MessageLoopProxy> main_message_loop_; | 88 scoped_refptr<base::MessageLoopProxy> main_message_loop_; |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 } // namespace media | 91 } // namespace media |
| 93 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::VideoCaptureHandlerProxy); | 92 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::VideoCaptureHandlerProxy); |
| 94 | 93 |
| 95 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ | 94 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ |
| OLD | NEW |