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"
13 #include "ui/gfx/gpu_memory_buffer.h"
15 #undef IPC_MESSAGE_EXPORT
16 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
17 #define IPC_MESSAGE_START VideoCaptureMsgStart
19 IPC_ENUM_TRAITS_MAX_VALUE(content::VideoCaptureState
,
20 content::VIDEO_CAPTURE_STATE_LAST
)
21 IPC_ENUM_TRAITS_MAX_VALUE(media::ResolutionChangePolicy
,
22 media::RESOLUTION_POLICY_LAST
)
23 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelFormat
, media::PIXEL_FORMAT_MAX
)
24 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoFrame::StorageType
,
25 media::VideoFrame::STORAGE_LAST
)
26 IPC_ENUM_TRAITS_MAX_VALUE(media::VideoPixelStorage
, media::PIXEL_STORAGE_MAX
)
27 IPC_ENUM_TRAITS_MAX_VALUE(media::PowerLineFrequency
,
28 media::PowerLineFrequency::FREQUENCY_MAX
)
30 IPC_STRUCT_TRAITS_BEGIN(media::VideoCaptureParams
)
31 IPC_STRUCT_TRAITS_MEMBER(requested_format
)
32 IPC_STRUCT_TRAITS_MEMBER(resolution_change_policy
)
33 IPC_STRUCT_TRAITS_MEMBER(power_line_frequency
)
34 IPC_STRUCT_TRAITS_END()
36 IPC_STRUCT_BEGIN(VideoCaptureMsg_BufferReady_Params
)
37 IPC_STRUCT_MEMBER(int, device_id
)
38 IPC_STRUCT_MEMBER(int, buffer_id
)
39 IPC_STRUCT_MEMBER(base::TimeTicks
, timestamp
)
40 IPC_STRUCT_MEMBER(base::DictionaryValue
, metadata
)
41 IPC_STRUCT_MEMBER(media::VideoPixelFormat
, pixel_format
)
42 IPC_STRUCT_MEMBER(media::VideoFrame::StorageType
, storage_type
)
43 IPC_STRUCT_MEMBER(gfx::Size
, coded_size
)
44 IPC_STRUCT_MEMBER(gfx::Rect
, visible_rect
)
45 IPC_STRUCT_MEMBER(std::vector
<gpu::MailboxHolder
>, mailbox_holders
)
48 // TODO(nick): device_id in these messages is basically just a route_id. We
49 // should shift to IPC_MESSAGE_ROUTED and use MessageRouter in the filter impls.
51 // Notify the renderer process about the state update such as
53 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_StateChanged
,
55 content::VideoCaptureState
/* new state */)
57 // Tell the renderer process that a new buffer is allocated for video capture.
58 IPC_MESSAGE_CONTROL4(VideoCaptureMsg_NewBuffer
,
60 base::SharedMemoryHandle
/* handle */,
64 // Tell the renderer process that a new GpuMemoryBuffer backed buffer is
65 // allocated for video capture.
66 IPC_MESSAGE_CONTROL4(VideoCaptureMsg_NewBuffer2
,
68 std::vector
<gfx::GpuMemoryBufferHandle
> /* handles */,
69 gfx::Size
/* dimensions */,
72 // Tell the renderer process that it should release a buffer previously
73 // allocated by VideoCaptureMsg_NewBuffer.
74 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_FreeBuffer
,
78 // Tell the renderer process that a Buffer is available from video capture, and
79 // send the associated VideoFrame constituient parts as IPC parameters.
80 IPC_MESSAGE_CONTROL1(VideoCaptureMsg_BufferReady
,
81 VideoCaptureMsg_BufferReady_Params
)
83 // Notify the renderer about a device's supported formats; this is a response
84 // to a VideoCaptureHostMsg_GetDeviceSupportedFormats request.
85 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceSupportedFormatsEnumerated
,
87 media::VideoCaptureFormats
/* supported_formats */)
89 // Notify the renderer about a device's format(s) in use; this is a response
90 // to a VideoCaptureHostMsg_GetDeviceFormatInUse request.
91 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceFormatsInUseReceived
,
93 media::VideoCaptureFormats
/* formats_in_use */)
95 // Start a video capture as |device_id|, a new id picked by the renderer
96 // process. The session to be started is determined by |params.session_id|.
97 IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Start
,
99 media::VideoCaptureSessionId
, /* session_id */
100 media::VideoCaptureParams
/* params */)
102 // Pause the video capture specified by |device_id|.
103 IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Pause
,
106 // Resume the video capture specified by |device_id|, |session_id| and
108 IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Resume
,
110 media::VideoCaptureSessionId
, /* session_id */
111 media::VideoCaptureParams
/* params */)
113 // Close the video capture specified by |device_id|.
114 IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Stop
,
117 // Tell the browser process that the renderer has finished reading from
118 // a buffer previously delivered by VideoCaptureMsg_BufferReady.
119 IPC_MESSAGE_CONTROL4(VideoCaptureHostMsg_BufferReady
,
122 uint32
/* syncpoint */,
123 double /* consumer_resource_utilization */)
125 // Get the formats supported by a device referenced by |capture_session_id|.
126 IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceSupportedFormats
,
128 media::VideoCaptureSessionId
/* session_id */)
130 // Get the format(s) in use by a device referenced by |capture_session_id|.
131 IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceFormatsInUse
,
133 media::VideoCaptureSessionId
/* session_id */)