Chromium Code Reviews| 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 // TODO(hclam): This class should be renamed to VideoCaptureService. | |
| 6 | |
| 7 // This class provides access to a video capture device in the browser | 5 // This class provides access to a video capture device in the browser |
| 8 // process through IPC. The main function is to deliver video frames | 6 // process through IPC. The main function is to deliver video frames |
| 9 // to a client. | 7 // to a client. |
| 10 // | 8 // |
| 11 // THREADING | 9 // THREADING |
| 12 // | 10 // |
| 13 // VideoCaptureImplManager lives only on the render thread. All methods | 11 // VideoCaptureService lives only on the render thread. All methods |
| 14 // must be called on this thread. | 12 // must be called on this thread. |
| 15 // | 13 // |
| 16 // VideoFrames are delivered on the IO thread. Callbacks provided by | 14 // VideoFrames are delivered on the IO thread. Callbacks provided by |
| 17 // a client are also called on the IO thread. | 15 // a client are also called on the IO thread. |
| 18 | 16 |
| 19 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | 17 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ |
| 20 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | 18 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ |
|
no sievers
2015/03/06 19:36:09
change this
| |
| 21 | 19 |
| 22 #include <map> | 20 #include <map> |
| 23 | 21 |
| 24 #include "base/callback.h" | 22 #include "base/callback.h" |
| 25 #include "base/memory/linked_ptr.h" | 23 #include "base/memory/linked_ptr.h" |
| 26 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
| 27 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
| 28 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
| 29 #include "base/message_loop/message_loop_proxy.h" | 27 #include "base/message_loop/message_loop_proxy.h" |
| 30 #include "base/synchronization/lock.h" | 28 #include "base/synchronization/lock.h" |
| 31 #include "base/threading/thread_checker.h" | 29 #include "base/threading/thread_checker.h" |
| 32 #include "content/common/content_export.h" | 30 #include "content/common/content_export.h" |
| 33 #include "content/common/media/video_capture.h" | 31 #include "content/common/media/video_capture.h" |
| 34 #include "content/public/renderer/media_stream_video_sink.h" | 32 #include "content/public/renderer/media_stream_video_sink.h" |
| 35 #include "media/base/video_capture_types.h" | 33 #include "media/base/video_capture_types.h" |
| 36 | 34 |
| 37 namespace content { | 35 namespace content { |
| 38 | 36 |
| 39 class VideoCaptureImpl; | 37 class VideoCaptureImpl; |
|
no sievers
2015/03/06 19:36:09
drop this?
| |
| 40 class VideoCaptureMessageFilter; | 38 class VideoCaptureMessageFilter; |
| 41 | 39 |
| 42 class CONTENT_EXPORT VideoCaptureImplManager { | 40 class CONTENT_EXPORT VideoCaptureService { |
| 43 public: | 41 public: |
| 44 VideoCaptureImplManager(); | 42 VideoCaptureService(); |
| 45 virtual ~VideoCaptureImplManager(); | 43 virtual ~VideoCaptureService(); |
| 46 | 44 |
| 47 // Open a device associated with the session ID. | 45 // Open a device associated with the session ID. |
| 48 // This method must be called before any methods with the same ID | 46 // This method must be called before any methods with the same ID |
| 49 // is used. | 47 // is used. |
| 50 // Returns a callback that should be used to release the acquired | 48 // Returns a callback that should be used to release the acquired |
| 51 // resources. | 49 // resources. |
| 52 base::Closure UseDevice(media::VideoCaptureSessionId id); | 50 base::Closure UseDevice(media::VideoCaptureSessionId id); |
| 53 | 51 |
| 54 // Start receiving video frames for the given session ID. | 52 // Start receiving video frames for the given session ID. |
| 55 // | 53 // |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 79 void GetDeviceSupportedFormats( | 77 void GetDeviceSupportedFormats( |
| 80 media::VideoCaptureSessionId id, | 78 media::VideoCaptureSessionId id, |
| 81 const VideoCaptureDeviceFormatsCB& callback); | 79 const VideoCaptureDeviceFormatsCB& callback); |
| 82 | 80 |
| 83 // Get supported formats currently in use for the given session ID. | 81 // Get supported formats currently in use for the given session ID. |
| 84 // |callback| will be called on the IO thread. | 82 // |callback| will be called on the IO thread. |
| 85 void GetDeviceFormatsInUse( | 83 void GetDeviceFormatsInUse( |
| 86 media::VideoCaptureSessionId id, | 84 media::VideoCaptureSessionId id, |
| 87 const VideoCaptureDeviceFormatsCB& callback); | 85 const VideoCaptureDeviceFormatsCB& callback); |
| 88 | 86 |
| 89 // Make all existing VideoCaptureImpl instances stop/resume delivering | 87 // Make all existing VideoCaptureImpl instances stop/resume delivering |
|
no sievers
2015/03/06 19:36:09
still a lot of references to *Impl everywhere here
| |
| 90 // video frames to their clients, depends on flag |suspend|. | 88 // video frames to their clients, depends on flag |suspend|. |
| 91 void SuspendDevices(bool suspend); | 89 void SuspendDevices(bool suspend); |
| 92 | 90 |
| 93 VideoCaptureMessageFilter* video_capture_message_filter() const { | 91 VideoCaptureMessageFilter* video_capture_message_filter() const { |
| 94 return filter_.get(); | 92 return filter_.get(); |
| 95 } | 93 } |
| 96 | 94 |
| 97 protected: | 95 protected: |
| 98 virtual VideoCaptureImpl* CreateVideoCaptureImplForTesting( | 96 virtual VideoCaptureImpl* CreateVideoCaptureImplForTesting( |
|
no sievers
2015/03/06 19:36:09
what about the return types?
| |
| 99 media::VideoCaptureSessionId id, | 97 media::VideoCaptureSessionId id, |
| 100 VideoCaptureMessageFilter* filter) const; | 98 VideoCaptureMessageFilter* filter) const; |
| 101 | 99 |
| 102 private: | 100 private: |
| 103 void StopCapture(int client_id, media::VideoCaptureSessionId id); | 101 void StopCapture(int client_id, media::VideoCaptureSessionId id); |
| 104 void UnrefDevice(media::VideoCaptureSessionId id); | 102 void UnrefDevice(media::VideoCaptureSessionId id); |
| 105 | 103 |
| 106 // The int is used to count clients of the corresponding VideoCaptureImpl. | 104 // The int is used to count clients of the corresponding VideoCaptureImpl. |
| 107 // VideoCaptureImpl objects are owned by this object. But they are | 105 // VideoCaptureImpl objects are owned by this object. But they are |
| 108 // destroyed on the IO thread. These are raw pointers because we destroy | 106 // destroyed on the IO thread. These are raw pointers because we destroy |
| 109 // them manually. | 107 // them manually. |
| 110 typedef std::map<media::VideoCaptureSessionId, | 108 typedef std::map<media::VideoCaptureSessionId, |
| 111 std::pair<int, VideoCaptureImpl*> > | 109 std::pair<int, VideoCaptureImpl*> > |
| 112 VideoCaptureDeviceMap; | 110 VideoCaptureDeviceMap; |
| 113 VideoCaptureDeviceMap devices_; | 111 VideoCaptureDeviceMap devices_; |
| 114 | 112 |
| 115 // This is an internal ID for identifying clients of VideoCaptureImpl. | 113 // This is an internal ID for identifying clients of VideoCaptureImpl. |
| 116 // The ID is global for the render process. | 114 // The ID is global for the render process. |
| 117 int next_client_id_; | 115 int next_client_id_; |
| 118 | 116 |
| 119 scoped_refptr<VideoCaptureMessageFilter> filter_; | 117 scoped_refptr<VideoCaptureMessageFilter> filter_; |
| 120 | 118 |
| 121 // Bound to the render thread. | 119 // Bound to the render thread. |
| 122 base::ThreadChecker thread_checker_; | 120 base::ThreadChecker thread_checker_; |
| 123 | 121 |
| 124 // Bound to the render thread. | 122 // Bound to the render thread. |
| 125 // NOTE: Weak pointers must be invalidated before all other member variables. | 123 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 126 base::WeakPtrFactory<VideoCaptureImplManager> weak_factory_; | 124 base::WeakPtrFactory<VideoCaptureService> weak_factory_; |
| 127 | 125 |
| 128 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplManager); | 126 DISALLOW_COPY_AND_ASSIGN(VideoCaptureService); |
| 129 }; | 127 }; |
| 130 | 128 |
| 131 } // namespace content | 129 } // namespace content |
| 132 | 130 |
| 133 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ | 131 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_MANAGER_H_ |
|
no sievers
2015/03/06 19:36:09
change this
| |
| OLD | NEW |