Chromium Code Reviews| Index: content/browser/renderer_host/video_capture_host.h |
| =================================================================== |
| --- content/browser/renderer_host/video_capture_host.h (revision 0) |
| +++ content/browser/renderer_host/video_capture_host.h (revision 0) |
| @@ -0,0 +1,144 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +// |
| +// VideoCaptureHost serves video capture related requests from VideCaptureImpl |
|
wjia(left Chromium)
2011/05/11 23:23:31
The counterpart of VideoCaptureHost is VideoCaptur
Per K
2011/05/16 11:49:39
Done.
|
| +// which lives inside the render process and provide access to video capture |
| +// hardware. |
| +// |
| +// This class is owned by BrowserRenderProcessHost, and instantiated on UI |
| +// thread, but all other operations and method calls happen on IO thread. |
| +// |
| +// Here's an example of a typical IPC dialog for video capture: |
| +// |
| +// Renderer VideoCaptureHost |
| +// | | |
| +// | VideoCaptureHostMsg_Start > | |
| +// | < VideoCaptureMsg_DeviceInfo | |
| +// | | |
| +// | < VideoCaptureMsg_StateChanged | |
| +// | (kStarted) | |
| +// | < VideoCaptureMsg_BufferReady | |
| +// | ... | |
| +// | < VideoCaptureMsg_BufferReady | |
| +// | ... | |
| +// | VideoCaptureHostMsg_BufferReady > | |
| +// | VideoCaptureHostMsg_BufferReady > | |
| +// | | |
| +// | ... | |
| +// | | |
| +// | < VideoCaptureMsg_BufferReady | |
| +// | VideoCaptureHostMsg_Stop > | |
| +// | VideoCaptureHostMsg_BufferReady > | |
| +// | < VideoCaptureMsg_StateChanged | |
| +// | (kStopped) | |
| +// v v |
| + |
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ |
| +#define CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ |
| + |
| +#include <list> |
| +#include <map> |
| + |
| +#include "content/browser/browser_message_filter.h" |
| +#include "content/browser/renderer_host/video_capture_memory.h" |
| +#include "ipc/ipc_message.h" |
| +#include "media/video/capture/video_capture.h" |
| + |
| +class VideoCaptureHost : public BrowserMessageFilter, |
| + public VideoCaptureMemory::EventHandler { |
| + public: |
| + VideoCaptureHost(); |
| + |
| + // BrowserMessageFilter implementation. |
| + virtual void OnChannelClosing(); |
| + virtual void OnDestruct() const; |
| + virtual bool OnMessageReceived(const IPC::Message& message, |
| + bool* message_was_ok); |
| + |
| + // VideoCaptureMemory::EventHandler implementation. |
| + virtual void OnError(VideoCaptureMemory::VCEntryId entry); |
| + virtual void OnBufferReady(VideoCaptureMemory::VCEntryId entry, |
| + TransportDIB::Handle handle, |
| + base::Time timestamp); |
| + virtual void OnFrameInfo(VideoCaptureMemory::VCEntryId entry, |
| + int width, |
| + int height, |
| + int frame_per_second); |
| + |
| + private: |
| + friend class BrowserThread; |
| + friend class DeleteTask<VideoCaptureHost>; |
| + friend class MockVideoCaptureHost; |
| + friend class VideoCaptureHostTest; |
| + |
| + typedef std::map<int, VideoCaptureMemory*> VCEntryMap; |
| + |
| + virtual ~VideoCaptureHost(); |
| + |
| + // IPC message: Start capture on the VideoCaptureDevice referenced by |
| + // VideoCaptureParams::session_id. |
| + // device_id is an id created by VideoCaptureImpl to identify a session |
| + // between a VideoCaptureImpl and a VideoCaptureHost. |
| + void OnStartCapture(const IPC::Message& msg, int device_id, |
| + const media::VideoCaptureParams& params); |
| + |
| + // IPC message: Stop capture on device referenced by device_id. |
| + void OnStopCapture(const IPC::Message& msg, int device_id); |
| + |
| + // IPC message: Pause capture on device referenced by device_id. |
| + void OnPauseCapture(const IPC::Message& msg, int device_id); |
| + |
| + // IPC message: Receive an empty buffer from renderer. Send it to device |
| + // referenced by |device_id|. |
| + void OnReceiveEmptyBuffer(const IPC::Message& msg, |
| + int device_id, |
| + TransportDIB::Handle handle); |
| + |
| + // Called by VideoCaptureManager when a device have been stopped. |
| + void OnDeviceStoped(int device_id); |
|
wjia(left Chromium)
2011/05/11 23:23:31
OnDeviceStopped
Per K
2011/05/16 11:49:39
Done.
|
| + |
| + // Removed the VideoCaptureMemory from the list of started devices. |
| + // Called on the IO thread when OnDeviceStoped have been called |
| + // by the VideoCaptureManager. |
| + void DoDeviceStoped(int device_id); |
|
wjia(left Chromium)
2011/05/11 23:23:31
ditto
Per K
2011/05/16 11:49:39
Done.
|
| + |
| + // Send a filled buffer to the VideoCaptureMessageFilter. |
| + void DoSendFilledBuffer(VideoCaptureMemory::VCEntryId entry, |
| + TransportDIB::Handle handle, |
| + base::Time timestamp); |
| + |
| + // Send a information about frame resolution and frame rate |
| + // to the VideoCaptureMessageFilter. |
| + void DoSendFrameInfo(VideoCaptureMemory::VCEntryId entry, |
| + int width, |
| + int height, |
| + int frame_per_second); |
| + |
| + // Handle error coming from VideoCaptureDevice. |
| + void DoHandleError(VideoCaptureMemory::VCEntryId entry); |
| + |
| + // Sends the new state to the VideoCaptureImpl. |
| + void SendDeviceStopped(int32 render_view_id, int device_id); |
| + |
| + // Send an error message to the renderer. |
| + void SendErrorMessage(int32 render_view_id, int device_id); |
| + |
| + // Stop the related VideCaptureDevice. |
| + void StopVideoCapture(VideoCaptureMemory::VCEntryId entry); |
| + |
| + // A helper method to look up a VideoCaptureMemory. Returns NULL if not found. |
| + VideoCaptureMemory* LookupStartedDevicesById(int device_id); |
| + VideoCaptureMemory* LookupStopedDevicesById(int device_id); |
|
wjia(left Chromium)
2011/05/11 23:23:31
ditto
Per K
2011/05/16 11:49:39
Done.
|
| + |
| + // A map of device_id to VideoCaptureMemory objects that is currently |
| + // capturing. |
| + VCEntryMap vc_entries_; |
| + // A map of device_id to VideoCaptureMemory objects that have been stopped |
| + // but not all transport dibs have been returned by VideoCaptureImpl. |
| + VCEntryMap vc_stoped_entries_; |
|
wjia(left Chromium)
2011/05/11 23:23:31
ditto
Per K
2011/05/16 11:49:39
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); |
| +}; |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_VIDEO_CAPTURE_HOST_H_ |