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 android media player.
      6 // Multiply-included message file, hence no include guard.
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/time/time.h"
     13 #include "content/common/content_export.h"
     14 #include "ipc/ipc_message_macros.h"
     15 #include "media/base/android/media_player_android.h"
     16 #include "media/base/media_keys.h"
     17 #include "ui/gfx/rect_f.h"
     18 #include "url/gurl.h"
     19 
     20 #undef IPC_MESSAGE_EXPORT
     21 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
     22 #define IPC_MESSAGE_START MediaPlayerMsgStart
     23 
     24 #include "media/base/android/demuxer_stream_player_params.h"
     25 
     26 IPC_ENUM_TRAITS(media::AudioCodec)
     27 IPC_ENUM_TRAITS(media::DemuxerStream::Status)
     28 IPC_ENUM_TRAITS(media::DemuxerStream::Type)
     29 IPC_ENUM_TRAITS(media::MediaKeys::KeyError)
     30 IPC_ENUM_TRAITS(media::VideoCodec)
     31 
     32 IPC_STRUCT_TRAITS_BEGIN(media::MediaPlayerHostMsg_DemuxerReady_Params)
     33   IPC_STRUCT_TRAITS_MEMBER(audio_codec)
     34   IPC_STRUCT_TRAITS_MEMBER(audio_channels)
     35   IPC_STRUCT_TRAITS_MEMBER(audio_sampling_rate)
     36   IPC_STRUCT_TRAITS_MEMBER(is_audio_encrypted)
     37   IPC_STRUCT_TRAITS_MEMBER(audio_extra_data)
     38 
     39   IPC_STRUCT_TRAITS_MEMBER(video_codec)
     40   IPC_STRUCT_TRAITS_MEMBER(video_size)
     41   IPC_STRUCT_TRAITS_MEMBER(is_video_encrypted)
     42   IPC_STRUCT_TRAITS_MEMBER(video_extra_data)
     43 
     44   IPC_STRUCT_TRAITS_MEMBER(duration_ms)
     45   IPC_STRUCT_TRAITS_MEMBER(key_system)
     46 IPC_STRUCT_TRAITS_END()
     47 
     48 IPC_STRUCT_TRAITS_BEGIN(media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params)
     49   IPC_STRUCT_TRAITS_MEMBER(type)
     50   IPC_STRUCT_TRAITS_MEMBER(access_units)
     51 IPC_STRUCT_TRAITS_END()
     52 
     53 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit)
     54   IPC_STRUCT_TRAITS_MEMBER(status)
     55   IPC_STRUCT_TRAITS_MEMBER(end_of_stream)
     56   IPC_STRUCT_TRAITS_MEMBER(data)
     57   IPC_STRUCT_TRAITS_MEMBER(timestamp)
     58   IPC_STRUCT_TRAITS_MEMBER(key_id)
     59   IPC_STRUCT_TRAITS_MEMBER(iv)
     60   IPC_STRUCT_TRAITS_MEMBER(subsamples)
     61 IPC_STRUCT_TRAITS_END()
     62 
     63 IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry)
     64   IPC_STRUCT_TRAITS_MEMBER(clear_bytes)
     65   IPC_STRUCT_TRAITS_MEMBER(cypher_bytes)
     66 IPC_STRUCT_TRAITS_END()
     67 
     68 IPC_ENUM_TRAITS(media::MediaPlayerAndroid::SourceType)
     69 
     70 // Messages for notifying the render process of media playback status -------
     71 
     72 // Media buffering has updated.
     73 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
     74                     int /* player_id */,
     75                     int /* percent */)
     76 
     77 // A media playback error has occured.
     78 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
     79                     int /* player_id */,
     80                     int /* error */)
     81 
     82 // Playback is completed.
     83 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
     84                     int /* player_id */)
     85 
     86 // Media metadata has changed.
     87 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
     88                     int /* player_id */,
     89                     base::TimeDelta /* duration */,
     90                     int /* width */,
     91                     int /* height */,
     92                     bool /* success */)
     93 
     94 // Media seek is completed.
     95 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaSeekCompleted,
     96                     int /* player_id */,
     97                     base::TimeDelta /* current_time */)
     98 
     99 // Video size has changed.
    100 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
    101                     int /* player_id */,
    102                     int /* width */,
    103                     int /* height */)
    104 
    105 // The current play time has updated.
    106 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaTimeUpdate,
    107                     int /* player_id */,
    108                     base::TimeDelta /* current_time */)
    109 
    110 // The player has been released.
    111 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
    112                     int /* player_id */)
    113 
    114 // The player has entered fullscreen mode.
    115 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidEnterFullscreen,
    116                     int /* player_id */)
    117 
    118 // The player exited fullscreen.
    119 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
    120                     int /* player_id */)
    121 
    122 // The player started playing.
    123 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
    124                     int /* player_id */)
    125 
    126 // The player was paused.
    127 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
    128                     int /* player_id */)
    129 
    130 // Media seek is requested.
    131 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaSeekRequest,
    132                     int /* player_id */,
    133                     base::TimeDelta /* time_to_seek */,
    134                     uint32 /* seek_request_id */)
    135 
    136 // The media source player reads data from demuxer
    137 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ReadFromDemuxer,
    138                     int /* player_id */,
    139                     media::DemuxerStream::Type /* type */)
    140 
    141 // The player needs new config data
    142 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaConfigRequest,
    143                     int /* player_id */)
    144 
    145 // Messages for controllering the media playback in browser process ----------
    146 
    147 // Destroy the media player object.
    148 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
    149                     int /* player_id */)
    150 
    151 // Destroy all the players.
    152 IPC_MESSAGE_ROUTED0(MediaPlayerHostMsg_DestroyAllMediaPlayers)
    153 
    154 // Initialize a media player object with the given player_id.
    155 IPC_MESSAGE_ROUTED4(
    156     MediaPlayerHostMsg_Initialize,
    157     int /* player_id */,
    158     GURL /* url */,
    159     media::MediaPlayerAndroid::SourceType /* source_type */,
    160     GURL /* first_party_for_cookies */)
    161 
    162 // Pause the player.
    163 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Pause, int /* player_id */)
    164 
    165 // Release player resources, but keep the object for future usage.
    166 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release, int /* player_id */)
    167 
    168 // Perform a seek.
    169 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek,
    170                     int /* player_id */,
    171                     base::TimeDelta /* time */)
    172 
    173 // Start the player for playback.
    174 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start, int /* player_id */)
    175 
    176 // Start the player for playback.
    177 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume,
    178                     int /* player_id */,
    179                     double /* volume */)
    180 
    181 // Request the player to enter fullscreen.
    182 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen, int /* player_id */)
    183 
    184 // Request the player to exit fullscreen.
    185 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen, int /* player_id */)
    186 
    187 // Sent when the seek request is received by the WebMediaPlayerAndroid.
    188 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_MediaSeekRequestAck,
    189                     int /* player_id */,
    190                     uint32 /* seek_request_id */)
    191 
    192 // Inform the media source player that the demuxer is ready.
    193 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_DemuxerReady,
    194                     int /* player_id */,
    195                     media::MediaPlayerHostMsg_DemuxerReady_Params)
    196 
    197 // Sent when the data was read from the ChunkDemuxer.
    198 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_ReadFromDemuxerAck,
    199                     int /* player_id */,
    200                     media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params)
    201 
    202 // Inform the media source player of changed media duration from demuxer.
    203 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_DurationChanged,
    204                     int /* player_id */,
    205                     base::TimeDelta /* duration */)
    206 
    207 #if defined(GOOGLE_TV)
    208 // Notify the player about the external surface, requesting it if necessary.
    209 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface,
    210                     int /* player_id */,
    211                     bool /* is_request */,
    212                     gfx::RectF /* rect */)
    213 
    214 #endif
    215 
    216 // Messages for encrypted media extensions API ------------------------------
    217 // TODO(xhwang): Move the following messages to a separate file.
    218 
    219 IPC_MESSAGE_ROUTED2(MediaKeysHostMsg_InitializeCDM,
    220                     int /* media_keys_id */,
    221                     std::vector<uint8> /* uuid */)
    222 
    223 IPC_MESSAGE_ROUTED3(MediaKeysHostMsg_GenerateKeyRequest,
    224                     int /* media_keys_id */,
    225                     std::string /* type */,
    226                     std::vector<uint8> /* init_data */)
    227 
    228 IPC_MESSAGE_ROUTED4(MediaKeysHostMsg_AddKey,
    229                     int /* media_keys_id */,
    230                     std::vector<uint8> /* key */,
    231                     std::vector<uint8> /* init_data */,
    232                     std::string /* session_id */)
    233 
    234 IPC_MESSAGE_ROUTED2(MediaKeysHostMsg_CancelKeyRequest,
    235                     int /* media_keys_id */,
    236                     std::string /* session_id */)
    237 
    238 IPC_MESSAGE_ROUTED2(MediaKeysMsg_KeyAdded,
    239                     int /* media_keys_id */,
    240                     std::string /* session_id */)
    241 
    242 IPC_MESSAGE_ROUTED4(MediaKeysMsg_KeyError,
    243                     int /* media_keys_id */,
    244                     std::string /* session_id */,
    245                     media::MediaKeys::KeyError /* error_code */,
    246                     int /* system_code */)
    247 
    248 IPC_MESSAGE_ROUTED4(MediaKeysMsg_KeyMessage,
    249                     int /* media_keys_id */,
    250                     std::string /* session_id */,
    251                     std::vector<uint8> /* message */,
    252                     std::string /* destination_url */)
    253