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)
68 IPC_ENUM_TRAITS(MediaKeysHostMsg_CreateSession_Type)
70 // Chrome for Android seek message sequence is:
71 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
72 // This is the beginning of actual seek flow in response to web app requests
73 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
74 // the renderer asks browser to perform actual seek. At most one of these
75 // actual seeks will be in process between this message and renderer's later
76 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
77 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
78 // Once the browser determines the seek is complete, it sends this message to
79 // notify the renderer of seek completion.
81 // Other seek-related IPC messages:
82 // Browser->Renderer MediaPlayerMsg_SeekRequest
83 // Browser requests to begin a seek. All browser-initiated seeks must begin
84 // with this request. Renderer controls actual seek initiation via the normal
85 // seek flow, above, keeping web apps aware of seeks. These requests are
86 // also allowed while another actual seek is in progress.
88 // If the demuxer is located in the renderer, as in media source players, the
89 // browser must ensure the renderer demuxer is appropriately seeked between
90 // receipt of MediaPlayerHostMsg_Seek and transmission of
91 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
92 // messages book-end the renderer-demuxer seek:
93 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
94 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
96 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
97 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
98 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
99 // |is_browser_seek| parameter be true. Regular seek messages must still be
100 // handled even when a hack browser seek is in progress. In this case, the
101 // browser seek request's |time_to_seek| may no longer be buffered and the
102 // demuxer may instead seek to a future buffered time. The resulting
103 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
104 // seeked-to, and is only meaningful for these hack browser seeks.
105 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
106 // keyframe. See http://crbug.com/304234.
108 // Messages for notifying the render process of media playback status -------
110 // Media buffering has updated.
111 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
115 // A media playback error has occurred.
116 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
120 // Playback is completed.
121 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
124 // Media metadata has changed.
125 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
127 base::TimeDelta /* duration */,
132 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
133 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest,
135 base::TimeDelta /* time_to_seek_to */)
137 // Media seek is completed.
138 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted,
140 base::TimeDelta /* current_time */)
142 // Video size has changed.
143 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
148 // The current play time has updated.
149 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaTimeUpdate,
151 base::TimeDelta /* current_time */)
153 // The player has been released.
154 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
157 // The player has entered fullscreen mode.
158 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidEnterFullscreen,
161 // The player exited fullscreen.
162 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
165 // The player started playing.
166 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
169 // The player was paused.
170 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
173 // Requests renderer demuxer seek.
174 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest,
175 int /* demuxer_client_id */,
176 base::TimeDelta /* time_to_seek */,
177 bool /* is_browser_seek */)
179 // The media source player reads data from demuxer
180 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer,
181 int /* demuxer_client_id */,
182 media::DemuxerStream::Type /* type */)
184 // The player needs new config data
185 IPC_MESSAGE_CONTROL1(MediaPlayerMsg_MediaConfigRequest,
186 int /* demuxer_client_id */)
188 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_ConnectedToRemoteDevice,
191 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice,
194 // Instructs the video element to enter fullscreen.
195 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_RequestFullscreen,
198 // Messages for controlling the media playback in browser process ----------
200 // Destroy the media player object.
201 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
204 // Destroy all the players.
205 IPC_MESSAGE_ROUTED0(MediaPlayerHostMsg_DestroyAllMediaPlayers)
207 // Initialize a media player object with the given type and player_id. The other
208 // parameters are used depending on the type of player.
210 // url: the URL to load when initializing a URL player.
212 // first_party_for_cookies: the cookie store to use when loading a URL.
214 // demuxer_client_id: the demuxer associated with this player when initializing
215 // a media source player.
217 MediaPlayerHostMsg_Initialize,
218 MediaPlayerHostMsg_Initialize_Type /* type */,
221 GURL /* first_party_for_cookies */,
222 int /* demuxer_client_id */)
225 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause,
227 bool /* is_media_related_action */)
229 // Release player resources, but keep the object for future usage.
230 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release, int /* player_id */)
233 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek,
235 base::TimeDelta /* time */)
237 // Start the player for playback.
238 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start, int /* player_id */)
241 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume,
245 // Set the poster image.
246 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster,
248 GURL /* poster url */)
250 // Requests the player to enter fullscreen.
251 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen, int /* player_id */)
253 // Requests the player to exit fullscreen.
254 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen, int /* player_id */)
256 // Sent after the renderer demuxer has seeked.
257 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone,
258 int /* demuxer_client_id */,
259 base::TimeDelta /* actual_browser_seek_time */)
261 // Inform the media source player that the demuxer is ready.
262 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady,
263 int /* demuxer_client_id */,
264 media::DemuxerConfigs)
266 // Sent when the data was read from the ChunkDemuxer.
267 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck,
268 int /* demuxer_client_id */,
271 // Inform the media source player of changed media duration from demuxer.
272 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged,
273 int /* demuxer_client_id */,
274 base::TimeDelta /* duration */)
276 #if defined(VIDEO_HOLE)
277 // Notify the player about the external surface, requesting it if necessary.
278 // |is_request| true if the player is requesting the external surface.
279 // |rect| the boundary rectangle of the video element.
280 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface,
282 bool /* is_request */,
283 gfx::RectF /* rect */)
284 #endif // defined(VIDEO_HOLE)
286 // Messages for encrypted media extensions API ------------------------------
287 // TODO(xhwang): Move the following messages to a separate file.
289 IPC_MESSAGE_ROUTED3(MediaKeysHostMsg_InitializeCDM,
290 int /* media_keys_id */,
291 std::vector<uint8> /* uuid */,
292 GURL /* frame url */)
294 IPC_MESSAGE_ROUTED4(MediaKeysHostMsg_CreateSession,
295 int /* media_keys_id */,
296 uint32_t /* session_id */,
297 MediaKeysHostMsg_CreateSession_Type /* type */,
298 std::vector<uint8> /* init_data */)
300 IPC_MESSAGE_ROUTED3(MediaKeysHostMsg_UpdateSession,
301 int /* media_keys_id */,
302 uint32_t /* session_id */,
303 std::vector<uint8> /* response */)
305 IPC_MESSAGE_ROUTED2(MediaKeysHostMsg_ReleaseSession,
306 int /* media_keys_id */,
307 uint32_t /* session_id */)
309 IPC_MESSAGE_ROUTED1(MediaKeysHostMsg_DestroyCdm,
310 int /* media_keys_id */)
312 IPC_MESSAGE_ROUTED3(MediaKeysMsg_SessionCreated,
313 int /* media_keys_id */,
314 uint32_t /* session_id */,
315 std::string /* web_session_id */)
317 IPC_MESSAGE_ROUTED4(MediaKeysMsg_SessionMessage,
318 int /* media_keys_id */,
319 uint32_t /* session_id */,
320 std::vector<uint8> /* message */,
321 GURL /* destination_url */)
323 IPC_MESSAGE_ROUTED2(MediaKeysMsg_SessionReady,
324 int /* media_keys_id */,
325 uint32_t /* session_id */)
327 IPC_MESSAGE_ROUTED2(MediaKeysMsg_SessionClosed,
328 int /* media_keys_id */,
329 uint32_t /* session_id */)
331 IPC_MESSAGE_ROUTED4(MediaKeysMsg_SessionError,
332 int /* media_keys_id */,
333 uint32_t /* session_id */,
334 media::MediaKeys::KeyError /* error_code */,
335 int /* system_code */)