Process Alt-Svc headers.
[chromium-blink-merge.git] / content / common / media / media_player_messages_android.h
blob3137011d86b6977743bd898280a8e243d249f151
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/memory/shared_memory.h"
10 #include "base/time/time.h"
11 #include "content/common/content_export.h"
12 #include "content/common/media/media_player_messages_enums_android.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "media/base/android/demuxer_stream_player_params.h"
15 #include "media/base/android/media_player_android.h"
16 #include "ui/gfx/geometry/rect_f.h"
17 #include "url/gurl.h"
19 #undef IPC_MESSAGE_EXPORT
20 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
21 #define IPC_MESSAGE_START MediaPlayerMsgStart
23 IPC_ENUM_TRAITS(media::AudioCodec)
24 IPC_ENUM_TRAITS(media::DemuxerStream::Status)
25 IPC_ENUM_TRAITS(media::DemuxerStream::Type)
26 IPC_ENUM_TRAITS(media::VideoCodec)
28 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerConfigs)
29 IPC_STRUCT_TRAITS_MEMBER(audio_codec)
30 IPC_STRUCT_TRAITS_MEMBER(audio_channels)
31 IPC_STRUCT_TRAITS_MEMBER(audio_sampling_rate)
32 IPC_STRUCT_TRAITS_MEMBER(is_audio_encrypted)
33 IPC_STRUCT_TRAITS_MEMBER(audio_extra_data)
34 IPC_STRUCT_TRAITS_MEMBER(audio_codec_delay_ns)
35 IPC_STRUCT_TRAITS_MEMBER(audio_seek_preroll_ns)
37 IPC_STRUCT_TRAITS_MEMBER(video_codec)
38 IPC_STRUCT_TRAITS_MEMBER(video_size)
39 IPC_STRUCT_TRAITS_MEMBER(is_video_encrypted)
40 IPC_STRUCT_TRAITS_MEMBER(video_extra_data)
42 IPC_STRUCT_TRAITS_MEMBER(duration)
43 IPC_STRUCT_TRAITS_END()
45 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerData)
46 IPC_STRUCT_TRAITS_MEMBER(type)
47 IPC_STRUCT_TRAITS_MEMBER(access_units)
48 IPC_STRUCT_TRAITS_MEMBER(demuxer_configs)
49 IPC_STRUCT_TRAITS_END()
51 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit)
52 IPC_STRUCT_TRAITS_MEMBER(status)
53 IPC_STRUCT_TRAITS_MEMBER(is_end_of_stream)
54 IPC_STRUCT_TRAITS_MEMBER(data)
55 IPC_STRUCT_TRAITS_MEMBER(timestamp)
56 IPC_STRUCT_TRAITS_MEMBER(key_id)
57 IPC_STRUCT_TRAITS_MEMBER(iv)
58 IPC_STRUCT_TRAITS_MEMBER(subsamples)
59 IPC_STRUCT_TRAITS_MEMBER(is_key_frame)
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_MAX_VALUE(MediaPlayerHostMsg_Initialize_Type,
68 MEDIA_PLAYER_TYPE_LAST)
70 // Parameters to describe a media player
71 IPC_STRUCT_BEGIN(MediaPlayerHostMsg_Initialize_Params)
72 IPC_STRUCT_MEMBER(MediaPlayerHostMsg_Initialize_Type, type)
73 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
74 IPC_STRUCT_MEMBER(int, player_id)
75 IPC_STRUCT_MEMBER(int, demuxer_client_id)
76 IPC_STRUCT_MEMBER(GURL, url)
77 IPC_STRUCT_MEMBER(GURL, first_party_for_cookies)
78 IPC_STRUCT_MEMBER(GURL, frame_url)
79 IPC_STRUCT_MEMBER(bool, allow_credentials)
80 IPC_STRUCT_END()
82 // Chrome for Android seek message sequence is:
83 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
84 // This is the beginning of actual seek flow in response to web app requests
85 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
86 // the renderer asks browser to perform actual seek. At most one of these
87 // actual seeks will be in process between this message and renderer's later
88 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
89 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
90 // Once the browser determines the seek is complete, it sends this message to
91 // notify the renderer of seek completion.
93 // Other seek-related IPC messages:
94 // Browser->Renderer MediaPlayerMsg_SeekRequest
95 // Browser requests to begin a seek. All browser-initiated seeks must begin
96 // with this request. Renderer controls actual seek initiation via the normal
97 // seek flow, above, keeping web apps aware of seeks. These requests are
98 // also allowed while another actual seek is in progress.
100 // If the demuxer is located in the renderer, as in media source players, the
101 // browser must ensure the renderer demuxer is appropriately seeked between
102 // receipt of MediaPlayerHostMsg_Seek and transmission of
103 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
104 // messages book-end the renderer-demuxer seek:
105 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
106 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
108 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
109 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
110 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
111 // |is_browser_seek| parameter be true. Regular seek messages must still be
112 // handled even when a hack browser seek is in progress. In this case, the
113 // browser seek request's |time_to_seek| may no longer be buffered and the
114 // demuxer may instead seek to a future buffered time. The resulting
115 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
116 // seeked-to, and is only meaningful for these hack browser seeks.
117 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
118 // keyframe. See http://crbug.com/304234.
120 // Messages for notifying the render process of media playback status -------
122 // Media buffering has updated.
123 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate,
124 int /* player_id */,
125 int /* percent */)
127 // A media playback error has occurred.
128 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError,
129 int /* player_id */,
130 int /* error */)
132 // Playback is completed.
133 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted,
134 int /* player_id */)
136 // Media metadata has changed.
137 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged,
138 int /* player_id */,
139 base::TimeDelta /* duration */,
140 int /* width */,
141 int /* height */,
142 bool /* success */)
144 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
145 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest,
146 int /* player_id */,
147 base::TimeDelta /* time_to_seek_to */)
149 // Media seek is completed.
150 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted,
151 int /* player_id */,
152 base::TimeDelta /* current_time */)
154 // Video size has changed.
155 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged,
156 int /* player_id */,
157 int /* width */,
158 int /* height */)
160 // The current play time has updated.
161 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaTimeUpdate,
162 int /* player_id */,
163 base::TimeDelta /* current_timestamp */,
164 base::TimeTicks /* current_time_ticks */)
166 // A new key is required in order to continue decrypting encrypted content.
167 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_WaitingForDecryptionKey, int /* player_id */)
169 // The player has been released.
170 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased,
171 int /* player_id */)
173 // The player exited fullscreen.
174 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen,
175 int /* player_id */)
177 // The player started playing.
178 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay,
179 int /* player_id */)
181 // The player was paused.
182 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause,
183 int /* player_id */)
185 // Requests renderer demuxer seek.
186 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest,
187 int /* demuxer_client_id */,
188 base::TimeDelta /* time_to_seek */,
189 bool /* is_browser_seek */)
191 // The media source player reads data from demuxer
192 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer,
193 int /* demuxer_client_id */,
194 media::DemuxerStream::Type /* type */)
196 // Clank has connected to the remote device.
197 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice,
198 int /* player_id */,
199 std::string /* remote_playback_message */)
201 // Clank has disconnected from the remote device.
202 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice,
203 int /* player_id */)
205 // The availability of remote devices has changed
206 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_RemoteRouteAvailabilityChanged,
207 int /* player_id */,
208 bool /* routes_available */)
210 // Messages for controlling the media playback in browser process ----------
212 // Destroy the media player object.
213 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer,
214 int /* player_id */)
216 // Initialize a media player object.
217 IPC_MESSAGE_ROUTED1(
218 MediaPlayerHostMsg_Initialize,
219 MediaPlayerHostMsg_Initialize_Params);
221 // Pause the player.
222 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause,
223 int /* player_id */,
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 */)
229 // Perform a seek.
230 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek,
231 int /* player_id */,
232 base::TimeDelta /* time */)
234 // Start the player for playback.
235 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start, int /* player_id */)
237 // Set the volume.
238 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume,
239 int /* player_id */,
240 double /* volume */)
242 // Set the poster image.
243 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster,
244 int /* player_id */,
245 GURL /* poster url */)
247 // Requests the player to enter fullscreen.
248 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen, int /* player_id */)
250 // Play the media on a remote device, if possible.
251 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlayback,
252 int /* demuxer_client_id */)
254 // Control media playing on a remote device.
255 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlaybackControl,
256 int /* demuxer_client_id */)
258 // Requests the player with |player_id| to use the CDM with |cdm_id|.
259 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetCdm,
260 int /* player_id */,
261 int /* cdm_id */);
263 // Sent after the renderer demuxer has seeked.
264 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone,
265 int /* demuxer_client_id */,
266 base::TimeDelta /* actual_browser_seek_time */)
268 // Inform the media source player that the demuxer is ready.
269 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady,
270 int /* demuxer_client_id */,
271 media::DemuxerConfigs)
273 // Sent when the data was read from the ChunkDemuxer.
274 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck,
275 int /* demuxer_client_id */,
276 media::DemuxerData)
278 // Inform the media source player of changed media duration from demuxer.
279 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged,
280 int /* demuxer_client_id */,
281 base::TimeDelta /* duration */)
283 #if defined(VIDEO_HOLE)
284 // Notify the player about the external surface, requesting it if necessary.
285 // |is_request| true if the player is requesting the external surface.
286 // |rect| the boundary rectangle of the video element.
287 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface,
288 int /* player_id */,
289 bool /* is_request */,
290 gfx::RectF /* rect */)
291 #endif // defined(VIDEO_HOLE)