diff options
-rw-r--r-- | content/common/content_message_generator.h | 1 | ||||
-rw-r--r-- | content/common/video_capture_messages.h | 54 | ||||
-rw-r--r-- | content/content_common.gypi | 1 | ||||
-rw-r--r-- | ipc/ipc_message_utils.h | 1 | ||||
-rw-r--r-- | media/base/video_frame.h | 3 | ||||
-rw-r--r-- | media/media.gyp | 1 | ||||
-rw-r--r-- | media/video/capture/video_capture.h | 118 |
7 files changed, 178 insertions, 1 deletions
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h index 6a29d6c..eab0100 100644 --- a/content/common/content_message_generator.h +++ b/content/common/content_message_generator.h @@ -29,6 +29,7 @@ #include "content/common/resource_messages.h" #include "content/common/speech_input_messages.h" #include "content/common/socket_stream_messages.h" +#include "content/common/video_capture_messages.h" #include "content/common/view_messages.h" #include "content/common/webblob_messages.h" #include "content/common/worker_messages.h" diff --git a/content/common/video_capture_messages.h b/content/common/video_capture_messages.h new file mode 100644 index 0000000..481d295 --- /dev/null +++ b/content/common/video_capture_messages.h @@ -0,0 +1,54 @@ +// 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. + +#include "content/common/common_param_traits.h" +#include "ipc/ipc_message_macros.h" +#include "media/video/capture/video_capture.h" + +#define IPC_MESSAGE_START VideoCaptureMsgStart + +IPC_ENUM_TRAITS(media::VideoCapture::State) + +IPC_STRUCT_TRAITS_BEGIN(media::VideoCapture::CaptureParams) + IPC_STRUCT_TRAITS_MEMBER(width) + IPC_STRUCT_TRAITS_MEMBER(height) + IPC_STRUCT_TRAITS_MEMBER(frame_rate) + IPC_STRUCT_TRAITS_MEMBER(session_id) +IPC_STRUCT_TRAITS_END() + +// Notify the renderer process about the state update such as +// Start/Pause/Stop. +IPC_MESSAGE_ROUTED2(VideoCaptureMsg_StateChanged, + int /* device id */, + media::VideoCapture::State /* new state */) + +// Tell the renderer process that a buffer is available from video capture. +IPC_MESSAGE_ROUTED3(VideoCaptureMsg_BufferReady, + int /* device id */, + TransportDIB::Handle /* DIB */, + base::Time /* timestamp */) + +// Tell the renderer process the width, height and frame rate the camera use. +IPC_MESSAGE_ROUTED2(VideoCaptureMsg_DeviceInfo, + int /* device_id */, + media::VideoCapture::CaptureParams) + +// Start the video capture specified by (routing_id, device_id). +IPC_MESSAGE_ROUTED2(VideoCaptureHostMsg_Start, + int /* device_id */, + media::VideoCapture::CaptureParams) + +// Pause the video capture specified by (routing_id, device_id). +IPC_MESSAGE_ROUTED1(VideoCaptureHostMsg_Pause, + int /* device_id */) + +// Close the video capture specified by (routing_id, device_id). +IPC_MESSAGE_ROUTED1(VideoCaptureHostMsg_Stop, + int /* device_id */) + +// Tell the browser process that the video frame buffer |handle| is ready for +// device (routing_id, device_id) to fill up. +IPC_MESSAGE_ROUTED2(VideoCaptureHostMsg_BufferReady, + int /* device_id */, + TransportDIB::Handle /* handle */) diff --git a/content/content_common.gypi b/content/content_common.gypi index 2c0b552..20fc69f 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -198,6 +198,7 @@ 'common/speech_input_result.h', 'common/unix_domain_socket_posix.cc', 'common/unix_domain_socket_posix.h', + 'common/video_capture_messages.h', 'common/view_messages.h', 'common/web_database_observer_impl.cc', 'common/web_database_observer_impl.h', diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index c7086d2..0b085b9 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -86,6 +86,7 @@ enum IPCMessageStart { PrintMsgStart, SpellCheckMsgStart, ExtensionMsgStart, + VideoCaptureMsgStart, LastIPCMsgStart // Must come last. }; diff --git a/media/base/video_frame.h b/media/base/video_frame.h index b1be562..ab552895 100644 --- a/media/base/video_frame.h +++ b/media/base/video_frame.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// 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. @@ -37,6 +37,7 @@ class VideoFrame : public StreamSample { NV12, // 12bpp YVU planar 1x1 Y, 2x2 UV interleaving samples EMPTY, // An empty frame. ASCII, // A frame with ASCII content. For testing only. + I420, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. }; enum SurfaceType { diff --git a/media/media.gyp b/media/media.gyp index 4f36789..23e1956 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -167,6 +167,7 @@ 'filters/rtc_video_decoder.h', 'filters/video_renderer_base.cc', 'filters/video_renderer_base.h', + 'video/capture/video_capture.h', 'video/ffmpeg_video_allocator.cc', 'video/ffmpeg_video_allocator.h', 'video/ffmpeg_video_decode_engine.cc', diff --git a/media/video/capture/video_capture.h b/media/video/capture/video_capture.h new file mode 100644 index 0000000..f885614 --- /dev/null +++ b/media/video/capture/video_capture.h @@ -0,0 +1,118 @@ +// 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. +// +// This file contains abstract classes used for media filter to handle video +// capture devices. + +#ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ +#define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ + +#include "base/memory/ref_counted.h" +#include "base/time.h" +#include "media/base/video_frame.h" + +namespace media { + +class VideoCapture { + public: + // TODO(wjia): this type should be defined in a common place and + // shared with device manager. + typedef uint64 VideoCaptureId; + + // Current status of the video capture device in the browser process. Browser + // process sends information about the current capture state and error to the + // renderer process using this type. + enum State { + kStarted, + kPaused, + kStopped, + kError, + }; + + // Parameters for starting video capture and device information. + struct CaptureParams { + CaptureParams() {} + ~CaptureParams() {} + + uint32 width; + uint32 height; + uint32 frame_rate; + VideoCaptureId session_id; + }; + + // TODO(wjia): consider merging with media::VideoFrame if possible. + class VideoFrameBuffer : public base::RefCountedThreadSafe<VideoFrameBuffer> { + public: + VideoFrameBuffer() {} + ~VideoFrameBuffer() {} + + uint32 width; + uint32 height; + int stride; + size_t buffer_size; + void* memory_pointer; + base::Time timestamp; + + private: + DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer); + }; + + // TODO(wjia): add error codes. + // Callbacks provided by client for notification of events. + class EventHandler { + public: + // Notify client that video capture has been started. + virtual void OnStarted(VideoCapture* capture) = 0; + + // Notify client that video capture has been stopped. + virtual void OnStopped(VideoCapture* capture) = 0; + + // Notify client that video capture has been paused. + virtual void OnPaused(VideoCapture* capture) = 0; + + // Notify client that video capture has hit some error |error_code|. + virtual void OnError(VideoCapture* capture, int error_code) = 0; + + // Notify client that a buffer is available. + virtual void OnBufferReady(VideoCapture* capture, + scoped_refptr<VideoFrameBuffer> buffer) = 0; + }; + + struct VideoCaptureCapability { + uint32 width; // desired width. + uint32 height; // desired height. + uint32 max_fps; // desired maximum frame rate. + uint32 expected_capture_delay; // expected delay in millisecond. + media::VideoFrame::Format raw_type; // desired video type. + bool interlaced; // need interlace format. + bool resolution_fixed; // indicate requested resolution can't be altered. + }; + + VideoCapture() {} + virtual ~VideoCapture() {} + + // Request video capture to start capturing with |capability|. + // Also register |handler| with video capture for event handling. + virtual void StartCapture(EventHandler* handler, + const VideoCaptureCapability& capability) = 0; + + // Request video capture to stop capturing for client |handler|. + virtual void StopCapture(EventHandler* handler) = 0; + + // TODO(wjia): Add FeedBuffer when buffer sharing is needed between video + // capture and downstream module. + // virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) = 0; + + virtual bool CaptureStarted() = 0; + virtual uint32 CaptureWidth() = 0; + virtual uint32 CaptureHeight() = 0; + virtual uint32 CaptureFrameRate() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(VideoCapture); +}; + +} // namespace media + +#endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ |