| OLD | NEW |
| 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 // VideoCaptureManager is used to open/close, start/stop, enumerate available | 5 // VideoCaptureManager is used to open/close, start/stop, enumerate available |
| 6 // video capture devices, and manage VideoCaptureController's. | 6 // video capture devices, and manage VideoCaptureController's. |
| 7 // All functions are expected to be called from Browser::IO thread. Some helper | 7 // All functions are expected to be called from Browser::IO thread. Some helper |
| 8 // functions (*OnDeviceThread) will dispatch operations to the device thread. | 8 // functions (*OnDeviceThread) will dispatch operations to the device thread. |
| 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. | 9 // VideoCaptureManager will open OS dependent instances of VideoCaptureDevice. |
| 10 // A device can only be opened once. | 10 // A device can only be opened once. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // are closed. | 61 // are closed. |
| 62 // They can be called more than once and it's ok to not call at all if the | 62 // They can be called more than once and it's ok to not call at all if the |
| 63 // client is not interested in receiving media::VideoCaptureObserver callacks. | 63 // client is not interested in receiving media::VideoCaptureObserver callacks. |
| 64 // This methods can be called on whatever thread. The callbacks of | 64 // This methods can be called on whatever thread. The callbacks of |
| 65 // media::VideoCaptureObserver arrive on browser IO thread. | 65 // media::VideoCaptureObserver arrive on browser IO thread. |
| 66 void AddVideoCaptureObserver(media::VideoCaptureObserver* observer); | 66 void AddVideoCaptureObserver(media::VideoCaptureObserver* observer); |
| 67 void RemoveAllVideoCaptureObservers(); | 67 void RemoveAllVideoCaptureObservers(); |
| 68 | 68 |
| 69 // Implements MediaStreamProvider. | 69 // Implements MediaStreamProvider. |
| 70 void RegisterListener(MediaStreamProviderListener* listener) override; | 70 void RegisterListener(MediaStreamProviderListener* listener) override; |
| 71 void UnregisterListener() override; | 71 void UnregisterListener(MediaStreamProviderListener* listener) override; |
| 72 int Open(const StreamDeviceInfo& device) override; | 72 int Open(const MediaStreamDevice& device) override; |
| 73 void Close(int capture_session_id) override; | 73 void Close(int capture_session_id) override; |
| 74 | 74 |
| 75 // Called by VideoCaptureHost to locate a capture device for |capture_params|, | 75 // Called by VideoCaptureHost to locate a capture device for |capture_params|, |
| 76 // adding the Host as a client of the device's controller if successful. The | 76 // adding the Host as a client of the device's controller if successful. The |
| 77 // value of |session_id| controls which device is selected; | 77 // value of |session_id| controls which device is selected; |
| 78 // this value should be a session id previously returned by Open(). | 78 // this value should be a session id previously returned by Open(). |
| 79 // | 79 // |
| 80 // If the device is not already started (i.e., no other client is currently | 80 // If the device is not already started (i.e., no other client is currently |
| 81 // capturing from this device), this call will cause a VideoCaptureController | 81 // capturing from this device), this call will cause a VideoCaptureController |
| 82 // and VideoCaptureDevice to be created, possibly asynchronously. | 82 // and VideoCaptureDevice to be created, possibly asynchronously. |
| 83 // | 83 // |
| 84 // On success, the controller is returned via calling |done_cb|, indicating | 84 // On success, the controller is returned via calling |done_cb|, indicating |
| 85 // that the client was successfully added. A NULL controller is passed to | 85 // that the client was successfully added. A NULL controller is passed to |
| 86 // the callback on failure. | 86 // the callback on failure. |done_cb| is not allowed to synchronously call |
| 87 // StopCaptureForClient(). |
| 87 void StartCaptureForClient(media::VideoCaptureSessionId session_id, | 88 void StartCaptureForClient(media::VideoCaptureSessionId session_id, |
| 88 const media::VideoCaptureParams& capture_params, | 89 const media::VideoCaptureParams& capture_params, |
| 89 VideoCaptureControllerID client_id, | 90 VideoCaptureControllerID client_id, |
| 90 VideoCaptureControllerEventHandler* client_handler, | 91 VideoCaptureControllerEventHandler* client_handler, |
| 91 const DoneCB& done_cb); | 92 const DoneCB& done_cb); |
| 92 | 93 |
| 93 // Called by VideoCaptureHost to remove |client_handler|. If this is the last | 94 // Called by VideoCaptureHost to remove |client_handler|. If this is the last |
| 94 // client of the device, the |controller| and its VideoCaptureDevice may be | 95 // client of the device, the |controller| and its VideoCaptureDevice may be |
| 95 // destroyed. The client must not access |controller| after calling this | 96 // destroyed. The client must not access |controller| after calling this |
| 96 // function. | 97 // function. |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 320 |
| 320 std::unique_ptr<base::android::ApplicationStatusListener> | 321 std::unique_ptr<base::android::ApplicationStatusListener> |
| 321 app_status_listener_; | 322 app_status_listener_; |
| 322 bool application_state_has_running_activities_; | 323 bool application_state_has_running_activities_; |
| 323 #endif | 324 #endif |
| 324 | 325 |
| 325 // The message loop of media stream device thread, where VCD's live. | 326 // The message loop of media stream device thread, where VCD's live. |
| 326 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; | 327 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_; |
| 327 | 328 |
| 328 // Only accessed on Browser::IO thread. | 329 // Only accessed on Browser::IO thread. |
| 329 MediaStreamProviderListener* listener_; | 330 base::ObserverList<MediaStreamProviderListener> listeners_; |
| 330 media::VideoCaptureSessionId new_capture_session_id_; | 331 media::VideoCaptureSessionId new_capture_session_id_; |
| 331 | 332 |
| 332 // An entry is kept in this map for every session that has been created via | 333 // An entry is kept in this map for every session that has been created via |
| 333 // the Open() entry point. The keys are session_id's. This map is used to | 334 // the Open() entry point. The keys are session_id's. This map is used to |
| 334 // determine which device to use when StartCaptureForClient() occurs. Used | 335 // determine which device to use when StartCaptureForClient() occurs. Used |
| 335 // only on the IO thread. | 336 // only on the IO thread. |
| 336 SessionMap sessions_; | 337 SessionMap sessions_; |
| 337 | 338 |
| 338 // Currently opened DeviceEntry instances (each owning a VideoCaptureDevice - | 339 // Currently opened DeviceEntry instances (each owning a VideoCaptureDevice - |
| 339 // VideoCaptureController pair). The device may or may not be started. This | 340 // VideoCaptureController pair). The device may or may not be started. This |
| (...skipping 26 matching lines...) Expand all Loading... |
| 366 // Map used by DesktopCapture. | 367 // Map used by DesktopCapture. |
| 367 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> | 368 std::map<media::VideoCaptureSessionId, gfx::NativeViewId> |
| 368 notification_window_ids_; | 369 notification_window_ids_; |
| 369 | 370 |
| 370 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); | 371 DISALLOW_COPY_AND_ASSIGN(VideoCaptureManager); |
| 371 }; | 372 }; |
| 372 | 373 |
| 373 } // namespace content | 374 } // namespace content |
| 374 | 375 |
| 375 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ | 376 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_MANAGER_H_ |
| OLD | NEW |