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 // VideoCaptureController is the glue between VideoCaptureHost, | 5 // VideoCaptureController is the glue between VideoCaptureHost, |
6 // VideoCaptureManager and VideoCaptureDevice. | 6 // VideoCaptureManager and VideoCaptureDevice. |
7 // It provides functions for VideoCaptureHost to start a VideoCaptureDevice and | 7 // It provides functions for VideoCaptureHost to start a VideoCaptureDevice and |
8 // is responsible for keeping track of shared DIBs and filling them with I420 | 8 // is responsible for keeping track of shared DIBs and filling them with I420 |
9 // video frames for IPC communication between VideoCaptureHost and | 9 // video frames for IPC communication between VideoCaptureHost and |
10 // VideoCaptureMessageFilter. | 10 // VideoCaptureMessageFilter. |
(...skipping 21 matching lines...) Expand all Loading... |
32 namespace media_stream { | 32 namespace media_stream { |
33 class VideoCaptureManager; | 33 class VideoCaptureManager; |
34 } // namespace media_stream | 34 } // namespace media_stream |
35 | 35 |
36 class VideoCaptureController | 36 class VideoCaptureController |
37 : public base::RefCountedThreadSafe<VideoCaptureController>, | 37 : public base::RefCountedThreadSafe<VideoCaptureController>, |
38 public media::VideoCaptureDevice::EventHandler { | 38 public media::VideoCaptureDevice::EventHandler { |
39 public: | 39 public: |
40 VideoCaptureController( | 40 VideoCaptureController( |
41 media_stream::VideoCaptureManager* video_capture_manager); | 41 media_stream::VideoCaptureManager* video_capture_manager); |
42 virtual ~VideoCaptureController(); | |
43 | 42 |
44 // Start video capturing and try to use the resolution specified in | 43 // Start video capturing and try to use the resolution specified in |
45 // |params|. | 44 // |params|. |
46 // When capturing has started, the |event_handler| receives a call OnFrameInfo | 45 // When capturing has started, the |event_handler| receives a call OnFrameInfo |
47 // with resolution that best matches the requested that the video | 46 // with resolution that best matches the requested that the video |
48 // capture device support. | 47 // capture device support. |
49 void StartCapture(const VideoCaptureControllerID& id, | 48 void StartCapture(const VideoCaptureControllerID& id, |
50 VideoCaptureControllerEventHandler* event_handler, | 49 VideoCaptureControllerEventHandler* event_handler, |
51 base::ProcessHandle render_process, | 50 base::ProcessHandle render_process, |
52 const media::VideoCaptureParams& params); | 51 const media::VideoCaptureParams& params); |
(...skipping 14 matching lines...) Expand all Loading... |
67 int buffer_id); | 66 int buffer_id); |
68 | 67 |
69 // Implement media::VideoCaptureDevice::EventHandler. | 68 // Implement media::VideoCaptureDevice::EventHandler. |
70 virtual void OnIncomingCapturedFrame(const uint8* data, | 69 virtual void OnIncomingCapturedFrame(const uint8* data, |
71 int length, | 70 int length, |
72 base::Time timestamp) OVERRIDE; | 71 base::Time timestamp) OVERRIDE; |
73 virtual void OnError() OVERRIDE; | 72 virtual void OnError() OVERRIDE; |
74 virtual void OnFrameInfo( | 73 virtual void OnFrameInfo( |
75 const media::VideoCaptureDevice::Capability& info) OVERRIDE; | 74 const media::VideoCaptureDevice::Capability& info) OVERRIDE; |
76 | 75 |
| 76 protected: |
| 77 virtual ~VideoCaptureController(); |
| 78 |
77 private: | 79 private: |
| 80 friend class base::RefCountedThreadSafe<VideoCaptureController>; |
| 81 |
78 struct ControllerClient; | 82 struct ControllerClient; |
79 typedef std::list<ControllerClient*> ControllerClients; | 83 typedef std::list<ControllerClient*> ControllerClients; |
80 | 84 |
81 // Callback when manager has stopped device. | 85 // Callback when manager has stopped device. |
82 void OnDeviceStopped(); | 86 void OnDeviceStopped(); |
83 | 87 |
84 // Worker functions on IO thread. | 88 // Worker functions on IO thread. |
85 void DoIncomingCapturedFrameOnIOThread(int buffer_id, base::Time timestamp); | 89 void DoIncomingCapturedFrameOnIOThread(int buffer_id, base::Time timestamp); |
86 void DoFrameInfoOnIOThread(const media::VideoCaptureDevice::Capability info); | 90 void DoFrameInfoOnIOThread(const media::VideoCaptureDevice::Capability info); |
87 void DoErrorOnIOThread(); | 91 void DoErrorOnIOThread(); |
88 void DoDeviceStateOnIOThread(bool in_use); | |
89 void DoDeviceStoppedOnIOThread(); | 92 void DoDeviceStoppedOnIOThread(); |
90 | 93 |
91 // Send frame info and init buffers to |client|. | 94 // Send frame info and init buffers to |client|. |
92 void SendFrameInfoAndBuffers(ControllerClient* client, int buffer_size); | 95 void SendFrameInfoAndBuffers(ControllerClient* client, int buffer_size); |
93 | 96 |
94 // Helpers. | 97 // Helpers. |
95 // Find a client of |id| and |handler| in |clients|. | 98 // Find a client of |id| and |handler| in |clients|. |
96 ControllerClient* FindClient( | 99 ControllerClient* FindClient( |
97 const VideoCaptureControllerID& id, | 100 const VideoCaptureControllerID& id, |
98 VideoCaptureControllerEventHandler* handler, | 101 VideoCaptureControllerEventHandler* handler, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 133 |
131 media_stream::VideoCaptureManager* video_capture_manager_; | 134 media_stream::VideoCaptureManager* video_capture_manager_; |
132 | 135 |
133 bool device_in_use_; | 136 bool device_in_use_; |
134 video_capture::State state_; | 137 video_capture::State state_; |
135 | 138 |
136 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController); | 139 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureController); |
137 }; | 140 }; |
138 | 141 |
139 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ | 142 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_H_ |
OLD | NEW |