Chromium Code Reviews| Index: media/video/capture/video_capture_device.h |
| diff --git a/media/video/capture/video_capture_device.h b/media/video/capture/video_capture_device.h |
| index 0eaf39ed7cc404941952ba4a8b9ce2639c99b9ee..9e01ca32ac3f5ea3f2f44bf468ae2d4ec7d8811f 100644 |
| --- a/media/video/capture/video_capture_device.h |
| +++ b/media/video/capture/video_capture_device.h |
| @@ -120,6 +120,7 @@ class MEDIA_EXPORT VideoCaptureDevice { |
| class MEDIA_EXPORT EventHandler { |
| public: |
| + virtual ~EventHandler() {} |
| // Reserve an output buffer into which a video frame can be captured |
| // directly. If all buffers are currently busy, returns NULL. |
| @@ -187,14 +188,11 @@ class MEDIA_EXPORT VideoCaptureDevice { |
| // Called when the native resolution of VideoCaptureDevice has been changed |
| // and it needs to inform its client of the new frame size. |
| virtual void OnFrameInfoChanged(const VideoCaptureCapability& info) {}; |
| - |
| - protected: |
| - virtual ~EventHandler() {} |
| }; |
| // Creates a VideoCaptureDevice object. |
| // Return NULL if the hardware is not available. |
| static VideoCaptureDevice* Create(const Name& device_name); |
| - virtual ~VideoCaptureDevice() {} |
| + virtual ~VideoCaptureDevice(); |
| // Gets the names of all video capture devices connected to this computer. |
| static void GetDeviceNames(Names* device_names); |
| @@ -202,10 +200,51 @@ class MEDIA_EXPORT VideoCaptureDevice { |
| // Prepare the camera for use. After this function has been called no other |
| // applications can use the camera. On completion EventHandler::OnFrameInfo() |
| // is called informing of the resulting resolution and frame rate. |
| + // StopAndDeAllocate() must be called before the object is deleted. |
| + virtual void AllocateAndStart( |
| + const VideoCaptureCapability& capture_format, |
| + scoped_ptr<EventHandler> observer) = 0; |
| + |
| + // Deallocates the camera. This means other applications can use it, and that |
| + // the camera could be re-acquired by another VideoCaptureDevice instance if |
| + // one were to be created immediately after this call. After this call the |
| + // device should free the |observer| passed into AllocateAndStart as soon as |
| + // possible, but may do so asynchronously. |
| + virtual void StopAndDeAllocate() = 0; |
| +}; |
| + |
| +// VideoCaptureDevice1 is a bridge to an older API against which |
| +// VideoCaptureDevices were implemented. Differences between VideoCaptureDevice |
| +// (new style) and VideoCaptureDevice1 (old style) are as follows: |
| +// |
| +// [1] The Stop+DeAllocate calls are merged in the new style. |
| +// [2] The Allocate+Start calls are merged in the new style. |
| +// [3] New style devices own their EventHandler* pointers, allowing handlers |
| +// remain valid even after the device is stopped. Whereas old style devices |
|
Ami GONE FROM CHROMIUM
2013/09/13 21:17:59
s/remain/to remain/
ncarter (slow)
2013/09/14 00:07:24
Done.
|
| +// may not dereference their handlers after DeAllocate(). |
|
Ami GONE FROM CHROMIUM
2013/09/13 21:17:59
I don't follow. AFAICT from the commentary above
ncarter (slow)
2013/09/14 00:07:24
I think I figured out what was missing. I made the
|
| +// [4] device_name() is eliminated from the new-style interface. |
| +// |
| +// TODO(nick): Remove this bridge class. It exists to enable incremental |
| +// migration to an alternative VideoCaptureDevice API. |
| +class MEDIA_EXPORT VideoCaptureDevice1 : public VideoCaptureDevice { |
| + public: |
| + VideoCaptureDevice1(); |
| + virtual ~VideoCaptureDevice1(); |
| + |
| + // VideoCaptureDevice implementation. |
| + virtual void AllocateAndStart( |
| + const VideoCaptureCapability& capture_format, |
| + scoped_ptr<EventHandler> client) OVERRIDE; |
| + virtual void StopAndDeAllocate() OVERRIDE; |
| + |
| + // Gets the names of all video capture devices |
|
Ami GONE FROM CHROMIUM
2013/09/13 21:17:59
stray?
ncarter (slow)
2013/09/14 00:07:24
Done.
|
| + // Prepare the camera for use. After this function has been called no other |
| + // applications can use the camera. On completion EventHandler::OnFrameInfo() |
| + // is called informing of the resulting resolution and frame rate. |
| // DeAllocate() must be called before this function can be called again and |
| // before the object is deleted. |
| virtual void Allocate(const VideoCaptureCapability& capture_format, |
| - EventHandler* observer) = 0; |
| + EventHandler* client) = 0; |
| // Start capturing video frames. Allocate must be called before this function. |
| virtual void Start() = 0; |
| @@ -221,6 +260,10 @@ class MEDIA_EXPORT VideoCaptureDevice { |
| // Get the name of the capture device. |
| virtual const Name& device_name() = 0; |
| + |
| + private: |
| + // The device client which proxies device events to the controller. |
| + scoped_ptr<EventHandler> client_; |
|
Ami GONE FROM CHROMIUM
2013/09/13 21:17:59
This thing is known as a "Handler" (by the type),
ncarter (slow)
2013/09/14 00:07:24
"Client" is right term and it might have been a mi
|
| }; |
| } // namespace media |