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 // IPC messages for the media streaming.
      6 // Multiply-included message file, hence no include guard.
      7 
      8 #include <string>
      9 
     10 #include "content/common/content_export.h"
     11 #include "content/common/media/media_stream_options.h"
     12 #include "ipc/ipc_message_macros.h"
     13 #include "url/gurl.h"
     14 
     15 #undef IPC_MESSAGE_EXPORT
     16 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
     17 #define IPC_MESSAGE_START MediaStreamMsgStart
     18 
     19 IPC_ENUM_TRAITS_MAX_VALUE(content::MediaStreamType,
     20                           content::NUM_MEDIA_TYPES - 1)
     21 
     22 IPC_ENUM_TRAITS_MAX_VALUE(content::VideoFacingMode,
     23                           content::NUM_MEDIA_VIDEO_FACING_MODE - 1)
     24 
     25 IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions::Constraint)
     26   IPC_STRUCT_TRAITS_MEMBER(name)
     27   IPC_STRUCT_TRAITS_MEMBER(value)
     28 IPC_STRUCT_TRAITS_END()
     29 
     30 IPC_STRUCT_TRAITS_BEGIN(content::StreamOptions)
     31   IPC_STRUCT_TRAITS_MEMBER(audio_requested)
     32   IPC_STRUCT_TRAITS_MEMBER(mandatory_audio)
     33   IPC_STRUCT_TRAITS_MEMBER(optional_audio)
     34   IPC_STRUCT_TRAITS_MEMBER(video_requested)
     35   IPC_STRUCT_TRAITS_MEMBER(mandatory_video)
     36   IPC_STRUCT_TRAITS_MEMBER(optional_video)
     37 IPC_STRUCT_TRAITS_END()
     38 
     39 IPC_STRUCT_TRAITS_BEGIN(content::StreamDeviceInfo)
     40   IPC_STRUCT_TRAITS_MEMBER(device.type)
     41   IPC_STRUCT_TRAITS_MEMBER(device.name)
     42   IPC_STRUCT_TRAITS_MEMBER(device.id)
     43   IPC_STRUCT_TRAITS_MEMBER(device.video_facing)
     44   IPC_STRUCT_TRAITS_MEMBER(device.matched_output_device_id)
     45   IPC_STRUCT_TRAITS_MEMBER(device.input.sample_rate)
     46   IPC_STRUCT_TRAITS_MEMBER(device.input.channel_layout)
     47   IPC_STRUCT_TRAITS_MEMBER(device.input.frames_per_buffer)
     48   IPC_STRUCT_TRAITS_MEMBER(device.input.effects)
     49   IPC_STRUCT_TRAITS_MEMBER(device.matched_output.sample_rate)
     50   IPC_STRUCT_TRAITS_MEMBER(device.matched_output.channel_layout)
     51   IPC_STRUCT_TRAITS_MEMBER(device.matched_output.frames_per_buffer)
     52   IPC_STRUCT_TRAITS_MEMBER(session_id)
     53 IPC_STRUCT_TRAITS_END()
     54 
     55 // Message sent from the browser to the renderer
     56 
     57 // The browser has generated a stream successfully.
     58 IPC_MESSAGE_ROUTED4(MediaStreamMsg_StreamGenerated,
     59                     int /* request id */,
     60                     std::string /* label */,
     61                     content::StreamDeviceInfoArray /* audio_device_list */,
     62                     content::StreamDeviceInfoArray /* video_device_list */)
     63 
     64 // The browser has failed to generate a stream.
     65 IPC_MESSAGE_ROUTED1(MediaStreamMsg_StreamGenerationFailed,
     66                     int /* request id */)
     67 
     68 // The browser reports that a media device has been stopped. Stopping was
     69 // triggered from the browser process.
     70 IPC_MESSAGE_ROUTED2(MediaStreamMsg_DeviceStopped,
     71                     std::string /* label */,
     72                     content::StreamDeviceInfo /* the device */)
     73 
     74 // The browser has enumerated devices. If no devices are found
     75 // |device_list| is empty.
     76 // Used by Pepper.
     77 // TODO(vrk,wjia): Move this to pepper code.
     78 IPC_MESSAGE_ROUTED2(MediaStreamMsg_DevicesEnumerated,
     79                     int /* request id */,
     80                     content::StreamDeviceInfoArray /* device_list */)
     81 
     82 // TODO(wjia): should DeviceOpen* messages be merged with
     83 // StreamGenerat* ones?
     84 // The browser has opened a device successfully.
     85 IPC_MESSAGE_ROUTED3(MediaStreamMsg_DeviceOpened,
     86                     int /* request id */,
     87                     std::string /* label */,
     88                     content::StreamDeviceInfo /* the device */)
     89 
     90 // The browser has failed to open a device.
     91 IPC_MESSAGE_ROUTED1(MediaStreamMsg_DeviceOpenFailed,
     92                     int /* request id */)
     93 
     94 // Response to enumerate devices request.
     95 IPC_MESSAGE_CONTROL2(MediaStreamMsg_GetSourcesACK,
     96                      int /* request id */,
     97                      content::StreamDeviceInfoArray /* device_list */)
     98 
     99 // Messages sent from the renderer to the browser.
    100 
    101 // Request a new media stream.
    102 IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_GenerateStream,
    103                      int /* render view id */,
    104                      int /* request id */,
    105                      content::StreamOptions /* components */,
    106                      GURL /* security origin */)
    107 
    108 // Request to cancel the request for a new media stream.
    109 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelGenerateStream,
    110                      int /* render view id */,
    111                      int /* request id */)
    112 
    113 // Request to close a device that has been opened by GenerateStream.
    114 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_StopStreamDevice,
    115                      int /* render view id */,
    116                      std::string /*device_id*/)
    117 
    118 // Request to enumerate devices.
    119 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_GetSources,
    120                      int /* request id */,
    121                      GURL /* origin */)
    122 
    123 
    124 // Request to enumerate devices.
    125 // Used by Pepper.
    126 // TODO(vrk,wjia): Move this to pepper code.
    127 IPC_MESSAGE_CONTROL4(MediaStreamHostMsg_EnumerateDevices,
    128                      int /* render view id */,
    129                      int /* request id */,
    130                      content::MediaStreamType /* type */,
    131                      GURL /* security origin */)
    132 
    133 // Request to stop enumerating devices.
    134 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CancelEnumerateDevices,
    135                      int /* render view id */,
    136                      int /* request id */)
    137 
    138 // Request to open the device.
    139 IPC_MESSAGE_CONTROL5(MediaStreamHostMsg_OpenDevice,
    140                      int /* render view id */,
    141                      int /* request id */,
    142                      std::string /* device_id */,
    143                      content::MediaStreamType /* type */,
    144                      GURL /* security origin */)
    145 
    146 // Request to close a device.
    147 IPC_MESSAGE_CONTROL2(MediaStreamHostMsg_CloseDevice,
    148                      int /* render view id */,
    149                      std::string /*label*/)
    150