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_END()
47 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit)
48 IPC_STRUCT_TRAITS_MEMBER(status)
49 IPC_STRUCT_TRAITS_MEMBER(end_of_stream)
50 IPC_STRUCT_TRAITS_MEMBER(data)
51 IPC_STRUCT_TRAITS_MEMBER(timestamp)
52 IPC_STRUCT_TRAITS_MEMBER(key_id)
53 IPC_STRUCT_TRAITS_MEMBER(iv)
54 IPC_STRUCT_TRAITS_MEMBER(subsamples)
55 IPC_STRUCT_TRAITS_END()
57 IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry)
58 IPC_STRUCT_TRAITS_MEMBER(clear_bytes)
59 IPC_STRUCT_TRAITS_MEMBER(cypher_bytes)
60 IPC_STRUCT_TRAITS_END()
62 IPC_ENUM_TRAITS(MediaPlayerHostMsg_Initialize_Type)
64 // Chrome for Android seek message sequence is:
65 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
66 // This is the beginning of actual seek flow in response to web app requests
67 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
68 // the renderer asks browser to perform actual seek. At most one of these
69 // actual seeks will be in process between this message and renderer's later
70 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
71 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
72 // Once the browser determines the seek is complete, it sends this message to
73 // notify the renderer of seek completion.
75 // Other seek-related IPC messages:
76 // Browser->Renderer MediaPlayerMsg_SeekRequest
77 // Browser requests to begin a seek. All browser-initiated seeks must begin
78 // with this request. Renderer controls actual seek initiation via the normal
79 // seek flow, above, keeping web apps aware of seeks. These requests are
80 // also allowed while another actual seek is in progress.
82 // If the demuxer is located in the renderer, as in media source players, the
83 // browser must ensure the renderer demuxer is appropriately seeked between
84 // receipt of MediaPlayerHostMsg_Seek and transmission of
85 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
86 // messages book-end the renderer-demuxer seek:
87 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
88 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
90 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
91 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
92 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
93 // |is_browser_seek| parameter be true. Regular seek messages must still be
94 // handled even when a hack browser seek is in progress. In this case, the
95 // browser seek request's |time_to_seek| may no longer be buffered and the
96 // demuxer may instead seek to a future buffered time. The resulting
97 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
98 // seeked-to, and is only meaningful for these hack browser seeks.
99 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
100 // keyframe. See http://crbug.com/304234.
102 // Messages for notifying the render process of media playback status -------
104 // Media buffering has updated.
105 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
109 // A media playback error has occurred.
110 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
114 // Playback is completed.
115 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
118 // Media metadata has changed.
119 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
121 base::TimeDelta /* duration */,
126 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
127 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest,
129 base::TimeDelta /* time_to_seek_to */)
131 // Media seek is completed.
132 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted,
134 base::TimeDelta /* current_time */)
136 // Video size has changed.
137 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
142 // The current play time has updated.
143 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaTimeUpdate,
145 base::TimeDelta /* current_time */)
147 // The player has been released.
148 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
151 // The player has entered fullscreen mode.
152 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidEnterFullscreen,
155 // The player exited fullscreen.
156 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
159 // The player started playing.
160 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
163 // The player was paused.
164 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
167 // Requests renderer demuxer seek.
168 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest,
169 int /* demuxer_client_id */,
170 base::TimeDelta /* time_to_seek */,
171 bool /* is_browser_seek */)
173 // The media source player reads data from demuxer
174 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer,
175 int /* demuxer_client_id */,
176 media::DemuxerStream::Type /* type */)
178 // The player needs new config data
179 IPC_MESSAGE_CONTROL1(MediaPlayerMsg_MediaConfigRequest,
180 int /* demuxer_client_id */)
182 // Clank has connected to the remote device.
183 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice,
185 std::string /* remote_playback_message */)
187 // Clank has disconnected from the remote device.
188 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice,
191 // Instructs the video element to enter fullscreen.
192 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_RequestFullscreen,
195 // Messages for controlling the media playback in browser process ----------
197 // Destroy the media player object.
198 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
201 // Destroy all the players.
202 IPC_MESSAGE_ROUTED0(MediaPlayerHostMsg_DestroyAllMediaPlayers)
204 // Initialize a media player object with the given type and player_id. The other
205 // parameters are used depending on the type of player.
207 // url: the URL to load when initializing a URL player.
209 // first_party_for_cookies: the cookie store to use when loading a URL.
211 // demuxer_client_id: the demuxer associated with this player when initializing
212 // a media source player.
214 MediaPlayerHostMsg_Initialize,
215 MediaPlayerHostMsg_Initialize_Type /* type */,
218 GURL /* first_party_for_cookies */,
219 int /* demuxer_client_id */)
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 // Requests the player with |player_id| to use the CDM with |cdm_id|.
254 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetCdm,
258 // Sent after the renderer demuxer has seeked.
259 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone,
260 int /* demuxer_client_id */,
261 base::TimeDelta /* actual_browser_seek_time */)
263 // Inform the media source player that the demuxer is ready.
264 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady,
265 int /* demuxer_client_id */,
266 media::DemuxerConfigs)
268 // Sent when the data was read from the ChunkDemuxer.
269 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck,
270 int /* demuxer_client_id */,
273 // Inform the media source player of changed media duration from demuxer.
274 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged,
275 int /* demuxer_client_id */,
276 base::TimeDelta /* duration */)
278 #if defined(VIDEO_HOLE)
279 // Notify the player about the external surface, requesting it if necessary.
280 // |is_request| true if the player is requesting the external surface.
281 // |rect| the boundary rectangle of the video element.
282 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface,
284 bool /* is_request */,
285 gfx::RectF /* rect */)
286 #endif // defined(VIDEO_HOLE)