15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 57dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "base/memory/shared_memory.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h" 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/media/video_capture.h" 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/common_param_traits.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "gpu/command_buffer/common/mailbox_holder.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ipc/ipc_message_macros.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "media/video/capture/video_capture_types.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#undef IPC_MESSAGE_EXPORT 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define IPC_MESSAGE_EXPORT CONTENT_EXPORT 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define IPC_MESSAGE_START VideoCaptureMsgStart 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_ENUM_TRAITS_MAX_VALUE(content::VideoCaptureState, 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::VIDEO_CAPTURE_STATE_LAST) 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciIPC_ENUM_TRAITS_MAX_VALUE(media::ResolutionChangePolicy, 211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci media::RESOLUTION_POLICY_LAST) 221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)IPC_STRUCT_TRAITS_BEGIN(media::VideoCaptureParams) 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) IPC_STRUCT_TRAITS_MEMBER(requested_format) 251320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci IPC_STRUCT_TRAITS_MEMBER(resolution_change_policy) 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)IPC_STRUCT_TRAITS_END() 27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// TODO(nick): device_id in these messages is basically just a route_id. We 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// should shift to IPC_MESSAGE_ROUTED and use MessageRouter in the filter impls. 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Notify the renderer process about the state update such as 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Start/Pause/Stop. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL2(VideoCaptureMsg_StateChanged, 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device id */, 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::VideoCaptureState /* new state */) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tell the renderer process that a new buffer is allocated for video capture. 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL4(VideoCaptureMsg_NewBuffer, 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device id */, 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::SharedMemoryHandle /* handle */, 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* length */, 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* buffer_id */) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Tell the renderer process that it should release a buffer previously 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// allocated by VideoCaptureMsg_NewBuffer. 461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)IPC_MESSAGE_CONTROL2(VideoCaptureMsg_FreeBuffer, 471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int /* device id */, 481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) int /* buffer_id */) 491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tell the renderer process that a buffer is available from video capture. 511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciIPC_MESSAGE_CONTROL5(VideoCaptureMsg_BufferReady, 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device id */, 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* buffer_id */, 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) media::VideoCaptureFormat /* format */, 551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci gfx::Rect /* visible_rect */, 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::TimeTicks /* timestamp */) 57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Tell the renderer process that a texture mailbox buffer is available from 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// video capture. 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IPC_MESSAGE_CONTROL5(VideoCaptureMsg_MailboxBufferReady, 61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int /* device_id */, 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int /* buffer_id */, 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gpu::MailboxHolder /* mailbox_holder */, 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) media::VideoCaptureFormat /* format */, 65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::TimeTicks /* timestamp */) 667dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Notify the renderer about a device's supported formats; this is a response 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// to a VideoCaptureHostMsg_GetDeviceSupportedFormats request. 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceSupportedFormatsEnumerated, 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int /* device_id */, 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) media::VideoCaptureFormats /* supported_formats */) 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Notify the renderer about a device's format(s) in use; this is a response 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// to a VideoCaptureHostMsg_GetDeviceFormatInUse request. 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceFormatsInUseReceived, 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int /* device_id */, 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) media::VideoCaptureFormats /* formats_in_use */) 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Start a video capture as |device_id|, a new id picked by the renderer 801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// process. The session to be started is determined by |params.session_id|. 81f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Start, 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device_id */, 83f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) media::VideoCaptureSessionId, /* session_id */ 841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) media::VideoCaptureParams /* params */) 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Pause the video capture specified by |device_id|. 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Pause, 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device_id */) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)// Resume the video capture specified by |device_id|, |session_id| and 9134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)// |params|. 9234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Resume, 9334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles) int, /* device_id */ 9434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles) media::VideoCaptureSessionId, /* session_id */ 9534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles) media::VideoCaptureParams /* params */) 9634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Close the video capture specified by |device_id|. 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Stop, 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device_id */) 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Tell the browser process that the renderer has finished reading from 1021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// a buffer previously delivered by VideoCaptureMsg_BufferReady. 103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_BufferReady, 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int /* device_id */, 105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int /* buffer_id */, 1065f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) uint32 /* syncpoint */) 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Get the formats supported by a device referenced by |capture_session_id|. 1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceSupportedFormats, 1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int /* device_id */, 1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) media::VideoCaptureSessionId /* session_id */) 1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Get the format(s) in use by a device referenced by |capture_session_id|. 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceFormatsInUse, 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int /* device_id */, 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) media::VideoCaptureSessionId /* session_id */) 117