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(base::SharedMemoryHandle
, metafile_data_handle
)
73 IPC_STRUCT_MEMBER(int, player_id
)
74 IPC_STRUCT_MEMBER(int, demuxer_client_id
)
75 IPC_STRUCT_MEMBER(GURL
, url
)
76 IPC_STRUCT_MEMBER(GURL
, first_party_for_cookies
)
77 IPC_STRUCT_MEMBER(GURL
, frame_url
)
78 IPC_STRUCT_MEMBER(bool, allow_credentials
)
81 // Chrome for Android seek message sequence is:
82 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
83 // This is the beginning of actual seek flow in response to web app requests
84 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
85 // the renderer asks browser to perform actual seek. At most one of these
86 // actual seeks will be in process between this message and renderer's later
87 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
88 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
89 // Once the browser determines the seek is complete, it sends this message to
90 // notify the renderer of seek completion.
92 // Other seek-related IPC messages:
93 // Browser->Renderer MediaPlayerMsg_SeekRequest
94 // Browser requests to begin a seek. All browser-initiated seeks must begin
95 // with this request. Renderer controls actual seek initiation via the normal
96 // seek flow, above, keeping web apps aware of seeks. These requests are
97 // also allowed while another actual seek is in progress.
99 // If the demuxer is located in the renderer, as in media source players, the
100 // browser must ensure the renderer demuxer is appropriately seeked between
101 // receipt of MediaPlayerHostMsg_Seek and transmission of
102 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
103 // messages book-end the renderer-demuxer seek:
104 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
105 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
107 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
108 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
109 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
110 // |is_browser_seek| parameter be true. Regular seek messages must still be
111 // handled even when a hack browser seek is in progress. In this case, the
112 // browser seek request's |time_to_seek| may no longer be buffered and the
113 // demuxer may instead seek to a future buffered time. The resulting
114 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
115 // seeked-to, and is only meaningful for these hack browser seeks.
116 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
117 // keyframe. See http://crbug.com/304234.
119 // Messages for notifying the render process of media playback status -------
121 // Media buffering has updated.
122 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate
,
126 // A media playback error has occurred.
127 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError
,
131 // Playback is completed.
132 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted
,
135 // Media metadata has changed.
136 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged
,
138 base::TimeDelta
/* duration */,
143 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
144 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest
,
146 base::TimeDelta
/* time_to_seek_to */)
148 // Media seek is completed.
149 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted
,
151 base::TimeDelta
/* current_time */)
153 // Video size has changed.
154 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged
,
159 // The current play time has updated.
160 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaTimeUpdate
,
162 base::TimeDelta
/* current_timestamp */,
163 base::TimeTicks
/* current_time_ticks */)
165 // A new key is required in order to continue decrypting encrypted content.
166 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_WaitingForDecryptionKey
, int /* player_id */)
168 // The player has been released.
169 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased
,
172 // The player exited fullscreen.
173 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen
,
176 // The player started playing.
177 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay
,
180 // The player was paused.
181 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause
,
184 // Requests renderer demuxer seek.
185 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest
,
186 int /* demuxer_client_id */,
187 base::TimeDelta
/* time_to_seek */,
188 bool /* is_browser_seek */)
190 // The media source player reads data from demuxer
191 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer
,
192 int /* demuxer_client_id */,
193 media::DemuxerStream::Type
/* type */)
195 // Clank has connected to the remote device.
196 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice
,
198 std::string
/* remote_playback_message */)
200 // Clank has disconnected from the remote device.
201 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice
,
204 // The availability of remote devices has changed
205 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_RemoteRouteAvailabilityChanged
,
207 bool /* routes_available */)
209 // Messages for controlling the media playback in browser process ----------
211 // Destroy the media player object.
212 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer
,
215 // Initialize a media player object.
217 MediaPlayerHostMsg_Initialize
,
218 MediaPlayerHostMsg_Initialize_Params
);
221 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause
,
223 bool /* is_media_related_action */)
225 // Release player resources, but keep the object for future usage.
226 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release
, int /* player_id */)
229 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek
,
231 base::TimeDelta
/* time */)
233 // Start the player for playback.
234 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start
, int /* player_id */)
237 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume
,
241 // Set the poster image.
242 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster
,
244 GURL
/* poster url */)
246 // Requests the player to enter fullscreen.
247 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen
, int /* player_id */)
249 // Play the media on a remote device, if possible.
250 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlayback
,
251 int /* demuxer_client_id */)
253 // Control media playing on a remote device.
254 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlaybackControl
,
255 int /* demuxer_client_id */)
257 // Requests the player with |player_id| to use the CDM with |cdm_id|.
258 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetCdm
,
262 // Sent after the renderer demuxer has seeked.
263 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerSeekDone
,
264 int /* demuxer_client_id */,
265 base::TimeDelta
/* actual_browser_seek_time */)
267 // Inform the media source player that the demuxer is ready.
268 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DemuxerReady
,
269 int /* demuxer_client_id */,
270 media::DemuxerConfigs
)
272 // Sent when the data was read from the ChunkDemuxer.
273 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_ReadFromDemuxerAck
,
274 int /* demuxer_client_id */,
277 // Inform the media source player of changed media duration from demuxer.
278 IPC_MESSAGE_CONTROL2(MediaPlayerHostMsg_DurationChanged
,
279 int /* demuxer_client_id */,
280 base::TimeDelta
/* duration */)
282 #if defined(VIDEO_HOLE)
283 // Notify the player about the external surface, requesting it if necessary.
284 // |is_request| true if the player is requesting the external surface.
285 // |rect| the boundary rectangle of the video element.
286 IPC_MESSAGE_ROUTED3(MediaPlayerHostMsg_NotifyExternalSurface
,
288 bool /* is_request */,
289 gfx::RectF
/* rect */)
290 #endif // defined(VIDEO_HOLE)