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.
8 #include "base/basictypes.h"
9 #include "base/time/time.h"
10 #include "content/common/content_export.h"
11 #include "content/common/media/media_player_messages_enums_android.h"
12 #include "ipc/ipc_message_macros.h"
13 #include "media/base/android/media_player_android.h"
14 #include "media/base/android/demuxer_stream_player_params.h"
15 #include "ui/gfx/rect_f.h"
18 #undef IPC_MESSAGE_EXPORT
19 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
20 #define IPC_MESSAGE_START MediaPlayerMsgStart
22 IPC_ENUM_TRAITS(media::AudioCodec)
23 IPC_ENUM_TRAITS(media::DemuxerStream::Status)
24 IPC_ENUM_TRAITS(media::DemuxerStream::Type)
25 IPC_ENUM_TRAITS(media::VideoCodec)
27 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerConfigs)
28 IPC_STRUCT_TRAITS_MEMBER(audio_codec)
29 IPC_STRUCT_TRAITS_MEMBER(audio_channels)
30 IPC_STRUCT_TRAITS_MEMBER(audio_sampling_rate)
31 IPC_STRUCT_TRAITS_MEMBER(is_audio_encrypted)
32 IPC_STRUCT_TRAITS_MEMBER(audio_extra_data)
34 IPC_STRUCT_TRAITS_MEMBER(video_codec)
35 IPC_STRUCT_TRAITS_MEMBER(video_size)
36 IPC_STRUCT_TRAITS_MEMBER(is_video_encrypted)
37 IPC_STRUCT_TRAITS_MEMBER(video_extra_data)
39 IPC_STRUCT_TRAITS_MEMBER(duration)
40 IPC_STRUCT_TRAITS_END()
42 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerData)
43 IPC_STRUCT_TRAITS_MEMBER(type)
44 IPC_STRUCT_TRAITS_MEMBER(access_units)
45 IPC_STRUCT_TRAITS_MEMBER(demuxer_configs)
46 IPC_STRUCT_TRAITS_END()
48 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit)
49 IPC_STRUCT_TRAITS_MEMBER(status)
50 IPC_STRUCT_TRAITS_MEMBER(end_of_stream)
51 IPC_STRUCT_TRAITS_MEMBER(data)
52 IPC_STRUCT_TRAITS_MEMBER(timestamp)
53 IPC_STRUCT_TRAITS_MEMBER(key_id)
54 IPC_STRUCT_TRAITS_MEMBER(iv)
55 IPC_STRUCT_TRAITS_MEMBER(subsamples)
56 IPC_STRUCT_TRAITS_END()
58 IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry)
59 IPC_STRUCT_TRAITS_MEMBER(clear_bytes)
60 IPC_STRUCT_TRAITS_MEMBER(cypher_bytes)
61 IPC_STRUCT_TRAITS_END()
63 IPC_ENUM_TRAITS(MediaPlayerHostMsg_Initialize_Type)
65 // Parameters to describe a media player
66 IPC_STRUCT_BEGIN(MediaPlayerHostMsg_Initialize_Params)
67 IPC_STRUCT_MEMBER(MediaPlayerHostMsg_Initialize_Type, type)
68 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
69 IPC_STRUCT_MEMBER(int, player_id)
70 IPC_STRUCT_MEMBER(int, demuxer_client_id)
71 IPC_STRUCT_MEMBER(GURL, url)
72 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
73 IPC_STRUCT_MEMBER(GURL, frame_url)
74 IPC_STRUCT_MEMBER(bool, allow_credentials)
77 // Chrome for Android seek message sequence is:
78 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
79 // This is the beginning of actual seek flow in response to web app requests
80 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
81 // the renderer asks browser to perform actual seek. At most one of these
82 // actual seeks will be in process between this message and renderer's later
83 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
84 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
85 // Once the browser determines the seek is complete, it sends this message to
86 // notify the renderer of seek completion.
88 // Other seek-related IPC messages:
89 // Browser->Renderer MediaPlayerMsg_SeekRequest
90 // Browser requests to begin a seek. All browser-initiated seeks must begin
91 // with this request. Renderer controls actual seek initiation via the normal
92 // seek flow, above, keeping web apps aware of seeks. These requests are
93 // also allowed while another actual seek is in progress.
95 // If the demuxer is located in the renderer, as in media source players, the
96 // browser must ensure the renderer demuxer is appropriately seeked between
97 // receipt of MediaPlayerHostMsg_Seek and transmission of
98 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
99 // messages book-end the renderer-demuxer seek:
100 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
101 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
103 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
104 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
105 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
106 // |is_browser_seek| parameter be true. Regular seek messages must still be
107 // handled even when a hack browser seek is in progress. In this case, the
108 // browser seek request's |time_to_seek| may no longer be buffered and the
109 // demuxer may instead seek to a future buffered time. The resulting
110 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
111 // seeked-to, and is only meaningful for these hack browser seeks.
112 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
113 // keyframe. See http://crbug.com/304234.
115 // Messages for notifying the render process of media playback status -------
117 // Media buffering has updated.
118 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
122 // A media playback error has occurred.
123 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
127 // Playback is completed.
128 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
131 // Media metadata has changed.
132 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
134 base::TimeDelta /* duration */,
139 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
140 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest,
142 base::TimeDelta /* time_to_seek_to */)
144 // Media seek is completed.
145 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted,
147 base::TimeDelta /* current_time */)
149 // Video size has changed.
150 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
155 // The current play time has updated.
156 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaTimeUpdate,
158 base::TimeDelta /* current_timestamp */,
159 base::TimeTicks /* current_time_ticks */)
161 // The player has been released.
162 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
165 // The player has entered fullscreen mode.
166 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidEnterFullscreen,
169 // The player exited fullscreen.
170 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
173 // The player started playing.
174 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
177 // The player was paused.
178 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
181 // Requests renderer demuxer seek.
182 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest,
183 int /* demuxer_client_id */,
184 base::TimeDelta /* time_to_seek */,
185 bool /* is_browser_seek */)
187 // The media source player reads data from demuxer
188 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer,
189 int /* demuxer_client_id */,
190 media::DemuxerStream::Type /* type */)
192 // Clank has connected to the remote device.
193 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice,
195 std::string /* remote_playback_message */)
197 // Clank has disconnected from the remote device.
198 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice,
201 // The availability of remote devices has changed
202 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_RemoteRouteAvailabilityChanged,
204 bool /* routes_available */)
206 // Instructs the video element to enter fullscreen.
207 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_RequestFullscreen,
210 // Messages for controlling the media playback in browser process ----------
212 // Destroy the media player object.
213 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
216 // Initialize a media player object.
218 MediaPlayerHostMsg_Initialize,
219 MediaPlayerHostMsg_Initialize_Params);
222 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause,
224 bool /* is_media_related_action */)
226 // Release player resources, but keep the object for future usage.
227 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release, int /* player_id */)
230 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek,
232 base::TimeDelta /* time */)
234 // Start the player for playback.
235 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start, int /* player_id */)
238 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume,
242 // Set the poster image.
243 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster,
245 GURL /* poster url */)
247 // Requests the player to enter fullscreen.
248 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen, int /* player_id */)
250 // Requests the player to exit fullscreen.
251 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen, int /* player_id */)
253 // Play the media on a remote device, if possible.
254 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlayback,
255 int /* demuxer_client_id */)
257 // Control media playing on a remote device.
258 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlaybackControl,
259 int /* demuxer_client_id */)
261 // Requests the player with |player_id| to use the CDM with |cdm_id|.
262 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetCdm,
266 // Sent after the renderer demuxer has seeked.
267 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone,
268 int /* demuxer_client_id */,
269 base::TimeDelta /* actual_browser_seek_time */)
271 // Inform the media source player that the demuxer is ready.
272 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady,
273 int /* demuxer_client_id */,
274 media::DemuxerConfigs)
276 // Sent when the data was read from the ChunkDemuxer.
277 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck,
278 int /* demuxer_client_id */,
281 // Inform the media source player of changed media duration from demuxer.
282 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged,
283 int /* demuxer_client_id */,
284 base::TimeDelta /* duration */)
286 #if defined(VIDEO_HOLE)
287 // Notify the player about the external surface, requesting it if necessary.
288 // |is_request| true if the player is requesting the external surface.
289 // |rect| the boundary rectangle of the video element.
290 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface,
292 bool /* is_request */,
293 gfx::RectF /* rect */)
294 #endif // defined(VIDEO_HOLE)