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
3 // found in the LICENSE file.
5 #include "base/memory/shared_memory.h"
6 #include "content/common/content_export.h"
7 #include "content/common/media/video_capture.h"
8 #include "content/public/common/common_param_traits.h"
9 #include "gpu/command_buffer/common/mailbox_holder.h"
10 #include "ipc/ipc_message_macros.h"
11 #include "media/base/video_capture_types.h"
12 #include "media/base/video_frame.h"
14 #undef IPC_MESSAGE_EXPORT
15 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
16 #define IPC_MESSAGE_START VideoCaptureMsgStart
18 IPC_ENUM_TRAITS_MAX_VALUE(content::VideoCaptureState
,
19 content::VIDEO_CAPTURE_STATE_LAST
)
20 IPC_ENUM_TRAITS_MAX_VALUE(media::ResolutionChangePolicy
,
21 media::RESOLUTION_POLICY_LAST
)
22 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelFormat
, media::PIXEL_FORMAT_MAX
)
23 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoFrame::StorageType
,
24 media::VideoFrame::STORAGE_LAST
)
25 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoCapturePixelFormat
,
26 media::VIDEO_CAPTURE_PIXEL_FORMAT_MAX
)
27 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelStorage
, media::PIXEL_STORAGE_MAX
)
29 IPC_STRUCT_TRAITS_BEGIN(media::VideoCaptureParams
)
30 IPC_STRUCT_TRAITS_MEMBER(requested_format
)
31 IPC_STRUCT_TRAITS_MEMBER(resolution_change_policy
)
32 IPC_STRUCT_TRAITS_END()
34 IPC_STRUCT_BEGIN(VideoCaptureMsg_BufferReady_Params
)
35 IPC_STRUCT_MEMBER(int, device_id
)
36 IPC_STRUCT_MEMBER(int, buffer_id
)
37 IPC_STRUCT_MEMBER(base::TimeTicks
, timestamp
)
38 IPC_STRUCT_MEMBER(base::DictionaryValue
, metadata
)
39 IPC_STRUCT_MEMBER(media::VideoPixelFormat
, pixel_format
)
40 IPC_STRUCT_MEMBER(media::VideoFrame::StorageType
, storage_type
)
41 IPC_STRUCT_MEMBER(gfx::Size
, coded_size
)
42 IPC_STRUCT_MEMBER(gfx::Rect
, visible_rect
)
43 IPC_STRUCT_MEMBER(gpu::MailboxHolder
, mailbox_holder
)
46 // TODO(nick): device_id in these messages is basically just a route_id. We
47 // should shift to IPC_MESSAGE_ROUTED and use MessageRouter in the filter impls.
49 // Notify the renderer process about the state update such as
51 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_StateChanged
,
53 content::VideoCaptureState
/* new state */)
55 // Tell the renderer process that a new buffer is allocated for video capture.
56 IPC_MESSAGE_CONTROL4(VideoCaptureMsg_NewBuffer
,
58 base::SharedMemoryHandle
/* handle */,
62 // Tell the renderer process that it should release a buffer previously
63 // allocated by VideoCaptureMsg_NewBuffer.
64 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_FreeBuffer
,
68 // Tell the renderer process that a Buffer is available from video capture, and
69 // send the associated VideoFrame constituient parts as IPC parameters.
70 IPC_MESSAGE_CONTROL1(VideoCaptureMsg_BufferReady
,
71 VideoCaptureMsg_BufferReady_Params
)
73 // Notify the renderer about a device's supported formats; this is a response
74 // to a VideoCaptureHostMsg_GetDeviceSupportedFormats request.
75 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceSupportedFormatsEnumerated
,
77 media::VideoCaptureFormats
/* supported_formats */)
79 // Notify the renderer about a device's format(s) in use; this is a response
80 // to a VideoCaptureHostMsg_GetDeviceFormatInUse request.
81 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceFormatsInUseReceived
,
83 media::VideoCaptureFormats
/* formats_in_use */)
85 // Start a video capture as |device_id|, a new id picked by the renderer
86 // process. The session to be started is determined by |params.session_id|.
87 IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Start
,
89 media::VideoCaptureSessionId
, /* session_id */
90 media::VideoCaptureParams
/* params */)
92 // Pause the video capture specified by |device_id|.
93 IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Pause
,
96 // Resume the video capture specified by |device_id|, |session_id| and
98 IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Resume
,
100 media::VideoCaptureSessionId
, /* session_id */
101 media::VideoCaptureParams
/* params */)
103 // Close the video capture specified by |device_id|.
104 IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Stop
,
107 // Tell the browser process that the renderer has finished reading from
108 // a buffer previously delivered by VideoCaptureMsg_BufferReady.
109 IPC_MESSAGE_CONTROL4(VideoCaptureHostMsg_BufferReady
,
112 uint32
/* syncpoint */,
113 double /* consumer_resource_utilization */)
115 // Get the formats supported by a device referenced by |capture_session_id|.
116 IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceSupportedFormats
,
118 media::VideoCaptureSessionId
/* session_id */)
120 // Get the format(s) in use by a device referenced by |capture_session_id|.
121 IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceFormatsInUse
,
123 media::VideoCaptureSessionId
/* session_id */)