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

Side by Side Diff: media/video/capture/video_capture_proxy.h

Issue 23551011: From Video Capture, abolish OnFrameInfo and enable resolution changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes from bbudge Created 7 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/video/capture/video_capture.h" 10 #include "media/video/capture/video_capture.h"
(...skipping 10 matching lines...) Expand all
21 // would be the thread where the instance of this class is created. The 21 // would be the thread where the instance of this class is created. The
22 // "proxied" handler is then called on that thread. 22 // "proxied" handler is then called on that thread.
23 // Since the VideoCapture is living on the "Video Capture" thread, querying its 23 // Since the VideoCapture is living on the "Video Capture" thread, querying its
24 // state from the "main thread" is fundamentally racy. Instead this class keeps 24 // state from the "main thread" is fundamentally racy. Instead this class keeps
25 // track of the state every time it is called by the VideoCapture (on the VC 25 // track of the state every time it is called by the VideoCapture (on the VC
26 // thread), and forwards that information to the main thread. 26 // thread), and forwards that information to the main thread.
27 class MEDIA_EXPORT VideoCaptureHandlerProxy 27 class MEDIA_EXPORT VideoCaptureHandlerProxy
28 : public VideoCapture::EventHandler { 28 : public VideoCapture::EventHandler {
29 public: 29 public:
30 struct VideoCaptureState { 30 struct VideoCaptureState {
31 VideoCaptureState() : started(false), width(0), height(0), frame_rate(0) {} 31 VideoCaptureState() : started(false), frame_rate(0) {}
32 bool started; 32 bool started;
33 int width;
34 int height;
35 int frame_rate; 33 int frame_rate;
36 }; 34 };
37 35
38 // Called on main thread. 36 // Called on main thread.
39 VideoCaptureHandlerProxy( 37 VideoCaptureHandlerProxy(
40 VideoCapture::EventHandler* proxied, 38 VideoCapture::EventHandler* proxied,
41 scoped_refptr<base::MessageLoopProxy> main_message_loop); 39 scoped_refptr<base::MessageLoopProxy> main_message_loop);
42 virtual ~VideoCaptureHandlerProxy(); 40 virtual ~VideoCaptureHandlerProxy();
43 41
44 // Retrieves the state of the VideoCapture. Must be called on main thread. 42 // Retrieves the state of the VideoCapture. Must be called on main thread.
45 const VideoCaptureState& state() const { return state_; } 43 const VideoCaptureState& state() const { return state_; }
46 44
47 // VideoCapture::EventHandler implementation, called on VC thread. 45 // VideoCapture::EventHandler implementation, called on VC thread.
48 virtual void OnStarted(VideoCapture* capture) OVERRIDE; 46 virtual void OnStarted(VideoCapture* capture) OVERRIDE;
49 virtual void OnStopped(VideoCapture* capture) OVERRIDE; 47 virtual void OnStopped(VideoCapture* capture) OVERRIDE;
50 virtual void OnPaused(VideoCapture* capture) OVERRIDE; 48 virtual void OnPaused(VideoCapture* capture) OVERRIDE;
51 virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE; 49 virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE;
52 virtual void OnRemoved(VideoCapture* capture) OVERRIDE; 50 virtual void OnRemoved(VideoCapture* capture) OVERRIDE;
53 virtual void OnFrameReady(VideoCapture* capture, 51 virtual void OnFrameReady(VideoCapture* capture,
54 const scoped_refptr<VideoFrame>& frame) OVERRIDE; 52 const scoped_refptr<VideoFrame>& frame) OVERRIDE;
55 virtual void OnDeviceInfoReceived(
56 VideoCapture* capture,
57 const VideoCaptureParams& device_info) OVERRIDE;
58 53
59 private: 54 private:
60 // Called on main thread. 55 // Called on main thread.
61 void OnStartedOnMainThread( 56 void OnStartedOnMainThread(
62 VideoCapture* capture, 57 VideoCapture* capture,
63 const VideoCaptureState& state); 58 const VideoCaptureState& state);
64 void OnStoppedOnMainThread( 59 void OnStoppedOnMainThread(
65 VideoCapture* capture, 60 VideoCapture* capture,
66 const VideoCaptureState& state); 61 const VideoCaptureState& state);
67 void OnPausedOnMainThread( 62 void OnPausedOnMainThread(
68 VideoCapture* capture, 63 VideoCapture* capture,
69 const VideoCaptureState& state); 64 const VideoCaptureState& state);
70 void OnErrorOnMainThread( 65 void OnErrorOnMainThread(
71 VideoCapture* capture, 66 VideoCapture* capture,
72 const VideoCaptureState& state, 67 const VideoCaptureState& state,
73 int error_code); 68 int error_code);
74 void OnRemovedOnMainThread( 69 void OnRemovedOnMainThread(
75 VideoCapture* capture, 70 VideoCapture* capture,
76 const VideoCaptureState& state); 71 const VideoCaptureState& state);
77 void OnFrameReadyOnMainThread(VideoCapture* capture, 72 void OnFrameReadyOnMainThread(VideoCapture* capture,
78 const VideoCaptureState& state, 73 const VideoCaptureState& state,
79 const scoped_refptr<VideoFrame>& frame); 74 const scoped_refptr<VideoFrame>& frame);
80 void OnDeviceInfoReceivedOnMainThread(VideoCapture* capture,
81 const VideoCaptureState& state,
82 const VideoCaptureParams& device_info);
83 75
84 // Only accessed from main thread. 76 // Only accessed from main thread.
85 VideoCapture::EventHandler* proxied_; 77 VideoCapture::EventHandler* proxied_;
86 VideoCaptureState state_; 78 VideoCaptureState state_;
87 79
88 scoped_refptr<base::MessageLoopProxy> main_message_loop_; 80 scoped_refptr<base::MessageLoopProxy> main_message_loop_;
89 }; 81 };
90 82
91 } // namespace media 83 } // namespace media
92 84
93 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_ 85 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_PROXY_H_
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_device_unittest.cc ('k') | media/video/capture/video_capture_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698