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/demuxer_stream_player_params.h"
14 #include "media/base/android/media_player_android.h"
15 #include "ui/gfx/geometry/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
)
33 IPC_STRUCT_TRAITS_MEMBER(audio_codec_delay_ns
)
34 IPC_STRUCT_TRAITS_MEMBER(audio_seek_preroll_ns
)
36 IPC_STRUCT_TRAITS_MEMBER(video_codec
)
37 IPC_STRUCT_TRAITS_MEMBER(video_size
)
38 IPC_STRUCT_TRAITS_MEMBER(is_video_encrypted
)
39 IPC_STRUCT_TRAITS_MEMBER(video_extra_data
)
41 IPC_STRUCT_TRAITS_MEMBER(duration
)
42 IPC_STRUCT_TRAITS_END()
44 IPC_STRUCT_TRAITS_BEGIN(media::DemuxerData
)
45 IPC_STRUCT_TRAITS_MEMBER(type
)
46 IPC_STRUCT_TRAITS_MEMBER(access_units
)
47 IPC_STRUCT_TRAITS_MEMBER(demuxer_configs
)
48 IPC_STRUCT_TRAITS_END()
50 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit
)
51 IPC_STRUCT_TRAITS_MEMBER(status
)
52 IPC_STRUCT_TRAITS_MEMBER(is_end_of_stream
)
53 IPC_STRUCT_TRAITS_MEMBER(data
)
54 IPC_STRUCT_TRAITS_MEMBER(timestamp
)
55 IPC_STRUCT_TRAITS_MEMBER(key_id
)
56 IPC_STRUCT_TRAITS_MEMBER(iv
)
57 IPC_STRUCT_TRAITS_MEMBER(subsamples
)
58 IPC_STRUCT_TRAITS_MEMBER(is_key_frame
)
59 IPC_STRUCT_TRAITS_END()
61 IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry
)
62 IPC_STRUCT_TRAITS_MEMBER(clear_bytes
)
63 IPC_STRUCT_TRAITS_MEMBER(cypher_bytes
)
64 IPC_STRUCT_TRAITS_END()
66 IPC_ENUM_TRAITS_MAX_VALUE(MediaPlayerHostMsg_Initialize_Type
,
67 MEDIA_PLAYER_TYPE_LAST
)
69 // Parameters to describe a media player
70 IPC_STRUCT_BEGIN(MediaPlayerHostMsg_Initialize_Params
)
71 IPC_STRUCT_MEMBER(MediaPlayerHostMsg_Initialize_Type
, type
)
72 IPC_STRUCT_MEMBER(int, player_id
)
73 IPC_STRUCT_MEMBER(int, demuxer_client_id
)
74 IPC_STRUCT_MEMBER(GURL
, url
)
75 IPC_STRUCT_MEMBER(GURL
, first_party_for_cookies
)
76 IPC_STRUCT_MEMBER(GURL
, frame_url
)
77 IPC_STRUCT_MEMBER(bool, allow_credentials
)
80 // Chrome for Android seek message sequence is:
81 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
82 // This is the beginning of actual seek flow in response to web app requests
83 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
84 // the renderer asks browser to perform actual seek. At most one of these
85 // actual seeks will be in process between this message and renderer's later
86 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
87 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
88 // Once the browser determines the seek is complete, it sends this message to
89 // notify the renderer of seek completion.
91 // Other seek-related IPC messages:
92 // Browser->Renderer MediaPlayerMsg_SeekRequest
93 // Browser requests to begin a seek. All browser-initiated seeks must begin
94 // with this request. Renderer controls actual seek initiation via the normal
95 // seek flow, above, keeping web apps aware of seeks. These requests are
96 // also allowed while another actual seek is in progress.
98 // If the demuxer is located in the renderer, as in media source players, the
99 // browser must ensure the renderer demuxer is appropriately seeked between
100 // receipt of MediaPlayerHostMsg_Seek and transmission of
101 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
102 // messages book-end the renderer-demuxer seek:
103 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
104 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
106 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
107 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
108 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
109 // |is_browser_seek| parameter be true. Regular seek messages must still be
110 // handled even when a hack browser seek is in progress. In this case, the
111 // browser seek request's |time_to_seek| may no longer be buffered and the
112 // demuxer may instead seek to a future buffered time. The resulting
113 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
114 // seeked-to, and is only meaningful for these hack browser seeks.
115 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
116 // keyframe. See http://crbug.com/304234.
118 // Messages for notifying the render process of media playback status -------
120 // Media buffering has updated.
121 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate
,
125 // A media playback error has occurred.
126 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError
,
130 // Playback is completed.
131 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted
,
134 // Media metadata has changed.
135 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged
,
137 base::TimeDelta
/* duration */,
142 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
143 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest
,
145 base::TimeDelta
/* time_to_seek_to */)
147 // Media seek is completed.
148 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted
,
150 base::TimeDelta
/* current_time */)
152 // Video size has changed.
153 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged
,
158 // The current play time has updated.
159 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaTimeUpdate
,
161 base::TimeDelta
/* current_timestamp */,
162 base::TimeTicks
/* current_time_ticks */)
164 // A new key is required in order to continue decrypting encrypted content.
165 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_WaitingForDecryptionKey
, int /* player_id */)
167 // The player has been released.
168 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased
,
171 // The player exited fullscreen.
172 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen
,
175 // The player started playing.
176 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay
,
179 // The player was paused.
180 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause
,
183 // Requests renderer demuxer seek.
184 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest
,
185 int /* demuxer_client_id */,
186 base::TimeDelta
/* time_to_seek */,
187 bool /* is_browser_seek */)
189 // The media source player reads data from demuxer
190 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer
,
191 int /* demuxer_client_id */,
192 media::DemuxerStream::Type
/* type */)
194 // Clank has connected to the remote device.
195 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice
,
197 std::string
/* remote_playback_message */)
199 // Clank has disconnected from the remote device.
200 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice
,
203 // The availability of remote devices has changed
204 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_RemoteRouteAvailabilityChanged
,
206 bool /* routes_available */)
208 // Messages for controlling the media playback in browser process ----------
210 // Destroy the media player object.
211 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer
,
214 // Initialize a media player object.
216 MediaPlayerHostMsg_Initialize
,
217 MediaPlayerHostMsg_Initialize_Params
);
220 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause
,
222 bool /* is_media_related_action */)
224 // Release player resources, but keep the object for future usage.
225 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release
, int /* player_id */)
228 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek
,
230 base::TimeDelta
/* time */)
232 // Start the player for playback.
233 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start
, int /* player_id */)
236 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume
,
240 // Set the poster image.
241 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster
,
243 GURL
/* poster url */)
245 // Requests the player to enter fullscreen.
246 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen
, int /* player_id */)
248 // Play the media on a remote device, if possible.
249 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlayback
,
250 int /* demuxer_client_id */)
252 // Control media playing on a remote device.
253 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlaybackControl
,
254 int /* demuxer_client_id */)
256 // Requests the player with |player_id| to use the CDM with |cdm_id|.
257 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetCdm
,
261 // Sent after the renderer demuxer has seeked.
262 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone
,
263 int /* demuxer_client_id */,
264 base::TimeDelta
/* actual_browser_seek_time */)
266 // Inform the media source player that the demuxer is ready.
267 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady
,
268 int /* demuxer_client_id */,
269 media::DemuxerConfigs
)
271 // Sent when the data was read from the ChunkDemuxer.
272 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck
,
273 int /* demuxer_client_id */,
276 // Inform the media source player of changed media duration from demuxer.
277 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged
,
278 int /* demuxer_client_id */,
279 base::TimeDelta
/* duration */)
281 #if defined(VIDEO_HOLE)
282 // Notify the player about the external surface, requesting it if necessary.
283 // |is_request| true if the player is requesting the external surface.
284 // |rect| the boundary rectangle of the video element.
285 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface
,
287 bool /* is_request */,
288 gfx::RectF
/* rect */)
289 #endif // defined(VIDEO_HOLE)