Home | History | Annotate | Download | only in media
      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.
      4 
      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/video/capture/video_capture_types.h"
     12 
     13 #undef IPC_MESSAGE_EXPORT
     14 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
     15 #define IPC_MESSAGE_START VideoCaptureMsgStart
     16 
     17 IPC_ENUM_TRAITS_MAX_VALUE(content::VideoCaptureState,
     18                           content::VIDEO_CAPTURE_STATE_LAST)
     19 
     20 IPC_STRUCT_TRAITS_BEGIN(media::VideoCaptureParams)
     21   IPC_STRUCT_TRAITS_MEMBER(requested_format)
     22   IPC_STRUCT_TRAITS_MEMBER(allow_resolution_change)
     23 IPC_STRUCT_TRAITS_END()
     24 
     25 // TODO(nick): device_id in these messages is basically just a route_id. We
     26 // should shift to IPC_MESSAGE_ROUTED and use MessageRouter in the filter impls.
     27 
     28 // Notify the renderer process about the state update such as
     29 // Start/Pause/Stop.
     30 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_StateChanged,
     31                      int /* device id */,
     32                      content::VideoCaptureState /* new state */)
     33 
     34 // Tell the renderer process that a new buffer is allocated for video capture.
     35 IPC_MESSAGE_CONTROL4(VideoCaptureMsg_NewBuffer,
     36                      int /* device id */,
     37                      base::SharedMemoryHandle /* handle */,
     38                      int /* length */,
     39                      int /* buffer_id */)
     40 
     41 // Tell the renderer process that it should release a buffer previously
     42 // allocated by VideoCaptureMsg_NewBuffer.
     43 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_FreeBuffer,
     44                      int /* device id */,
     45                      int /* buffer_id */)
     46 
     47 // Tell the renderer process that a buffer is available from video capture.
     48 IPC_MESSAGE_CONTROL4(VideoCaptureMsg_BufferReady,
     49                      int /* device id */,
     50                      int /* buffer_id */,
     51                      media::VideoCaptureFormat /* format */,
     52                      base::TimeTicks /* timestamp */)
     53 
     54 // Tell the renderer process that a texture mailbox buffer is available from
     55 // video capture.
     56 IPC_MESSAGE_CONTROL5(VideoCaptureMsg_MailboxBufferReady,
     57                      int /* device_id */,
     58                      int /* buffer_id */,
     59                      gpu::MailboxHolder /* mailbox_holder */,
     60                      media::VideoCaptureFormat /* format */,
     61                      base::TimeTicks /* timestamp */)
     62 
     63 // Notify the renderer about a device's supported formats; this is a response
     64 // to a VideoCaptureHostMsg_GetDeviceSupportedFormats request.
     65 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceSupportedFormatsEnumerated,
     66                      int /* device_id */,
     67                      media::VideoCaptureFormats /* supported_formats */)
     68 
     69 // Notify the renderer about a device's format(s) in use; this is a response
     70 // to a VideoCaptureHostMsg_GetDeviceFormatInUse request.
     71 IPC_MESSAGE_CONTROL2(VideoCaptureMsg_DeviceFormatsInUseReceived,
     72                      int /* device_id */,
     73                      media::VideoCaptureFormats /* formats_in_use */)
     74 
     75 // Start a video capture as |device_id|, a new id picked by the renderer
     76 // process. The session to be started is determined by |params.session_id|.
     77 IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_Start,
     78                      int /* device_id */,
     79                      media::VideoCaptureSessionId, /* session_id */
     80                      media::VideoCaptureParams /* params */)
     81 
     82 // Pause the video capture specified by |device_id|.
     83 IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Pause,
     84                      int /* device_id */)
     85 
     86 // Close the video capture specified by |device_id|.
     87 IPC_MESSAGE_CONTROL1(VideoCaptureHostMsg_Stop,
     88                      int /* device_id */)
     89 
     90 // Tell the browser process that the renderer has finished reading from
     91 // a buffer previously delivered by VideoCaptureMsg_BufferReady.
     92 IPC_MESSAGE_CONTROL3(VideoCaptureHostMsg_BufferReady,
     93                      int /* device_id */,
     94                      int /* buffer_id */,
     95                      std::vector<uint32> /* syncpoints */)
     96 
     97 // Get the formats supported by a device referenced by |capture_session_id|.
     98 IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceSupportedFormats,
     99                      int /* device_id */,
    100                      media::VideoCaptureSessionId /* session_id */)
    101 
    102 // Get the format(s) in use by a device referenced by |capture_session_id|.
    103 IPC_MESSAGE_CONTROL2(VideoCaptureHostMsg_GetDeviceFormatsInUse,
    104                      int /* device_id */,
    105                      media::VideoCaptureSessionId /* session_id */)
    106