Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / common / media / media_player_messages_android.h
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 "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"
16 #include "url/gurl.h"
17
18 #undef IPC_MESSAGE_EXPORT
19 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
20 #define IPC_MESSAGE_START MediaPlayerMsgStart
21
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)
26
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)
33
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)
38
39   IPC_STRUCT_TRAITS_MEMBER(duration)
40 IPC_STRUCT_TRAITS_END()
41
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()
46
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()
56
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()
61
62 IPC_ENUM_TRAITS(MediaPlayerHostMsg_Initialize_Type)
63
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.
74 //
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.
81 //
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
89
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.
101
102 // Messages for notifying the render process of media playback status -------
103
104 // Media buffering has updated.
105 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
106                     int /* player_id */,
107                     int /* percent */)
108
109 // A media playback error has occurred.
110 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
111                     int /* player_id */,
112                     int /* error */)
113
114 // Playback is completed.
115 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
116                     int /* player_id */)
117
118 // Media metadata has changed.
119 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
120                     int /* player_id */,
121                     base::TimeDelta /* duration */,
122                     int /* width */,
123                     int /* height */,
124                     bool /* success */)
125
126 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
127 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest,
128                     int /* player_id */,
129                     base::TimeDelta /* time_to_seek_to */)
130
131 // Media seek is completed.
132 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted,
133                     int /* player_id */,
134                     base::TimeDelta /* current_time */)
135
136 // Video size has changed.
137 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
138                     int /* player_id */,
139                     int /* width */,
140                     int /* height */)
141
142 // The current play time has updated.
143 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaTimeUpdate,
144                     int /* player_id */,
145                     base::TimeDelta /* current_time */)
146
147 // The player has been released.
148 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
149                     int /* player_id */)
150
151 // The player has entered fullscreen mode.
152 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidEnterFullscreen,
153                     int /* player_id */)
154
155 // The player exited fullscreen.
156 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
157                     int /* player_id */)
158
159 // The player started playing.
160 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
161                     int /* player_id */)
162
163 // The player was paused.
164 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
165                     int /* player_id */)
166
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 */)
172
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 */)
177
178 // The player needs new config data
179 IPC_MESSAGE_CONTROL1(MediaPlayerMsg_MediaConfigRequest,
180                      int /* demuxer_client_id */)
181
182 // Clank has connected to the remote device.
183 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice,
184                     int /* player_id */,
185                     std::string /* remote_playback_message */)
186
187 // Clank has disconnected from the remote device.
188 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice,
189                     int /* player_id */)
190
191 // Instructs the video element to enter fullscreen.
192 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_RequestFullscreen,
193                     int /*player_id */)
194
195 // Messages for controlling the media playback in browser process ----------
196
197 // Destroy the media player object.
198 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
199                     int /* player_id */)
200
201 // Destroy all the players.
202 IPC_MESSAGE_ROUTED0(MediaPlayerHostMsg_DestroyAllMediaPlayers)
203
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.
206 //
207 // url: the URL to load when initializing a URL player.
208 //
209 // first_party_for_cookies: the cookie store to use when loading a URL.
210 //
211 // demuxer_client_id: the demuxer associated with this player when initializing
212 // a media source player.
213 IPC_MESSAGE_ROUTED5(
214     MediaPlayerHostMsg_Initialize,
215     MediaPlayerHostMsg_Initialize_Type /* type */,
216     int /* player_id */,
217     GURL /* url */,
218     GURL /* first_party_for_cookies */,
219     int /* demuxer_client_id */)
220
221 // Pause the player.
222 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause,
223                     int /* player_id */,
224                     bool /* is_media_related_action */)
225
226 // Release player resources, but keep the object for future usage.
227 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release, int /* player_id */)
228
229 // Perform a seek.
230 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek,
231                     int /* player_id */,
232                     base::TimeDelta /* time */)
233
234 // Start the player for playback.
235 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start, int /* player_id */)
236
237 // Set the volume.
238 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume,
239                     int /* player_id */,
240                     double /* volume */)
241
242 // Set the poster image.
243 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster,
244                     int /* player_id */,
245                     GURL /* poster url */)
246
247 // Requests the player to enter fullscreen.
248 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen, int /* player_id */)
249
250 // Requests the player to exit fullscreen.
251 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen, int /* player_id */)
252
253 // Requests the player with |player_id| to use the CDM with |cdm_id|.
254 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetCdm,
255                     int /* player_id */,
256                     int /* cdm_id */);
257
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 */)
262
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)
267
268 // Sent when the data was read from the ChunkDemuxer.
269 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck,
270                      int /* demuxer_client_id */,
271                      media::DemuxerData)
272
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 */)
277
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,
283                     int /* player_id */,
284                     bool /* is_request */,
285                     gfx::RectF /* rect */)
286 #endif  // defined(VIDEO_HOLE)