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 // IPC messages for android media player.
6 // Multiply-included message file, hence no include guard.
11 #include "base/basictypes.h"
12 #include "base/time/time.h"
13 #include "content/common/content_export.h"
14 #include "content/common/media/media_player_messages_enums_android.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "media/base/android/media_player_android.h"
17 #include "media/base/android/demuxer_stream_player_params.h"
18 #include "media/base/media_keys.h"
19 #include "ui/gfx/rect_f.h"
22 #undef IPC_MESSAGE_EXPORT
23 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
24 #define IPC_MESSAGE_START MediaPlayerMsgStart
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)
32 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerConfigs)
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)
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)
44 IPC_STRUCT_TRAITS_MEMBER(duration_ms)
45 IPC_STRUCT_TRAITS_END()
47 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerData)
48 IPC_STRUCT_TRAITS_MEMBER(type)
49 IPC_STRUCT_TRAITS_MEMBER(access_units)
50 IPC_STRUCT_TRAITS_END()
52 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit)
53 IPC_STRUCT_TRAITS_MEMBER(status)
54 IPC_STRUCT_TRAITS_MEMBER(end_of_stream)
55 IPC_STRUCT_TRAITS_MEMBER(data)
56 IPC_STRUCT_TRAITS_MEMBER(timestamp)
57 IPC_STRUCT_TRAITS_MEMBER(key_id)
58 IPC_STRUCT_TRAITS_MEMBER(iv)
59 IPC_STRUCT_TRAITS_MEMBER(subsamples)
60 IPC_STRUCT_TRAITS_END()
62 IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry)
63 IPC_STRUCT_TRAITS_MEMBER(clear_bytes)
64 IPC_STRUCT_TRAITS_MEMBER(cypher_bytes)
65 IPC_STRUCT_TRAITS_END()
67 IPC_ENUM_TRAITS(MediaPlayerHostMsg_Initialize_Type)
69 // Chrome for Android seek message sequence is:
70 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
71 // This is the beginning of actual seek flow in response to web app requests
72 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
73 // the renderer asks browser to perform actual seek. At most one of these
74 // actual seeks will be in process between this message and renderer's later
75 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
76 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
77 // Once the browser determines the seek is complete, it sends this message to
78 // notify the renderer of seek completion.
80 // Other seek-related IPC messages:
81 // Browser->Renderer MediaPlayerMsg_SeekRequest
82 // Browser requests to begin a seek. All browser-initiated seeks must begin
83 // with this request. Renderer controls actual seek initiation via the normal
84 // seek flow, above, keeping web apps aware of seeks. These requests are
85 // also allowed while another actual seek is in progress.
87 // If the demuxer is located in the renderer, as in media source players, the
88 // browser must ensure the renderer demuxer is appropriately seeked between
89 // receipt of MediaPlayerHostMsg_Seek and transmission of
90 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
91 // messages book-end the renderer-demuxer seek:
92 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
93 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
95 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
96 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
97 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
98 // |is_browser_seek| parameter be true. Regular seek messages must still be
99 // handled even when a hack browser seek is in progress. In this case, the
100 // browser seek request's |time_to_seek| may no longer be buffered and the
101 // demuxer may instead seek to a future buffered time. The resulting
102 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
103 // seeked-to, and is only meaningful for these hack browser seeks.
104 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
105 // keyframe. See http://crbug.com/304234.
107 // Messages for notifying the render process of media playback status -------
109 // Media buffering has updated.
110 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
114 // A media playback error has occurred.
115 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
119 // Playback is completed.
120 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
123 // Media metadata has changed.
124 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
126 base::TimeDelta /* duration */,
131 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
132 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest,
134 base::TimeDelta /* time_to_seek_to */)
136 // Media seek is completed.
137 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted,
139 base::TimeDelta /* current_time */)
141 // Video size has changed.
142 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
147 // The current play time has updated.
148 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaTimeUpdate,
150 base::TimeDelta /* current_time */)
152 // The player has been released.
153 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
156 // The player has entered fullscreen mode.
157 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidEnterFullscreen,
160 // The player exited fullscreen.
161 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
164 // The player started playing.
165 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
168 // The player was paused.
169 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
172 // Requests renderer demuxer seek.
173 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest,
174 int /* demuxer_client_id */,
175 base::TimeDelta /* time_to_seek */,
176 bool /* is_browser_seek */)
178 // The media source player reads data from demuxer
179 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer,
180 int /* demuxer_client_id */,
181 media::DemuxerStream::Type /* type */)
183 // The player needs new config data
184 IPC_MESSAGE_CONTROL1(MediaPlayerMsg_MediaConfigRequest,
185 int /* demuxer_client_id */)
187 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_ConnectedToRemoteDevice,
190 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice,
193 // Instructs the video element to enter fullscreen.
194 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_RequestFullscreen,
197 // Messages for controlling the media playback in browser process ----------
199 // Destroy the media player object.
200 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
203 // Destroy all the players.
204 IPC_MESSAGE_ROUTED0(MediaPlayerHostMsg_DestroyAllMediaPlayers)
206 // Initialize a media player object with the given type and player_id. The other
207 // parameters are used depending on the type of player.
209 // url: the URL to load when initializing a URL player.
211 // first_party_for_cookies: the cookie store to use when loading a URL.
213 // demuxer_client_id: the demuxer associated with this player when initializing
214 // a media source player.
216 MediaPlayerHostMsg_Initialize,
217 MediaPlayerHostMsg_Initialize_Type /* type */,
220 GURL /* first_party_for_cookies */,
221 int /* demuxer_client_id */)
224 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause,
226 bool /* is_media_related_action */)
228 // Release player resources, but keep the object for future usage.
229 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release, int /* player_id */)
232 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek,
234 base::TimeDelta /* time */)
236 // Start the player for playback.
237 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start, int /* player_id */)
239 // Start the player for playback.
240 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume,
244 // Requests the player to enter fullscreen.
245 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen, int /* player_id */)
247 // Requests the player to exit fullscreen.
248 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen, int /* player_id */)
250 // Sent after the renderer demuxer has seeked.
251 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone,
252 int /* demuxer_client_id */,
253 base::TimeDelta /* actual_browser_seek_time */)
255 // Inform the media source player that the demuxer is ready.
256 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady,
257 int /* demuxer_client_id */,
258 media::DemuxerConfigs)
260 // Sent when the data was read from the ChunkDemuxer.
261 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck,
262 int /* demuxer_client_id */,
265 // Inform the media source player of changed media duration from demuxer.
266 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged,
267 int /* demuxer_client_id */,
268 base::TimeDelta /* duration */)
270 #if defined(VIDEO_HOLE)
271 // Notify the player about the external surface, requesting it if necessary.
272 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface,
274 bool /* is_request */,
275 gfx::RectF /* rect */)
276 #endif // defined(VIDEO_HOLE)
278 // Messages for encrypted media extensions API ------------------------------
279 // TODO(xhwang): Move the following messages to a separate file.
281 IPC_MESSAGE_ROUTED3(MediaKeysHostMsg_InitializeCDM,
282 int /* media_keys_id */,
283 std::vector<uint8> /* uuid */,
284 GURL /* frame url */)
286 IPC_MESSAGE_ROUTED4(MediaKeysHostMsg_CreateSession,
287 int /* media_keys_id */,
288 uint32_t /* session_id */,
289 std::string /* type */,
290 std::vector<uint8> /* init_data */)
291 // TODO(jrummell): Use enum for type (http://crbug.com/327449)
293 IPC_MESSAGE_ROUTED3(MediaKeysHostMsg_UpdateSession,
294 int /* media_keys_id */,
295 uint32_t /* session_id */,
296 std::vector<uint8> /* response */)
298 IPC_MESSAGE_ROUTED2(MediaKeysHostMsg_ReleaseSession,
299 int /* media_keys_id */,
300 uint32_t /* session_id */)
302 IPC_MESSAGE_ROUTED1(MediaKeysHostMsg_CancelAllPendingSessionCreations,
303 int /* media_keys_id */)
305 IPC_MESSAGE_ROUTED3(MediaKeysMsg_SessionCreated,
306 int /* media_keys_id */,
307 uint32_t /* session_id */,
308 std::string /* web_session_id */)
310 IPC_MESSAGE_ROUTED4(MediaKeysMsg_SessionMessage,
311 int /* media_keys_id */,
312 uint32_t /* session_id */,
313 std::vector<uint8> /* message */,
314 std::string /* destination_url */)
315 // TODO(jrummell): Use GURL for destination_url (http://crbug.com/326663)
317 IPC_MESSAGE_ROUTED2(MediaKeysMsg_SessionReady,
318 int /* media_keys_id */,
319 uint32_t /* session_id */)
321 IPC_MESSAGE_ROUTED2(MediaKeysMsg_SessionClosed,
322 int /* media_keys_id */,
323 uint32_t /* session_id */)
325 IPC_MESSAGE_ROUTED4(MediaKeysMsg_SessionError,
326 int /* media_keys_id */,
327 uint32_t /* session_id */,
328 media::MediaKeys::KeyError /* error_code */,
329 int /* system_code */)