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_MEMBER(demuxer_configs
)
46 IPC_STRUCT_TRAITS_END()
48 IPC_STRUCT_TRAITS_BEGIN(media::AccessUnit
)
49 IPC_STRUCT_TRAITS_MEMBER(status
)
50 IPC_STRUCT_TRAITS_MEMBER(end_of_stream
)
51 IPC_STRUCT_TRAITS_MEMBER(data
)
52 IPC_STRUCT_TRAITS_MEMBER(timestamp
)
53 IPC_STRUCT_TRAITS_MEMBER(key_id
)
54 IPC_STRUCT_TRAITS_MEMBER(iv
)
55 IPC_STRUCT_TRAITS_MEMBER(subsamples
)
56 IPC_STRUCT_TRAITS_END()
58 IPC_STRUCT_TRAITS_BEGIN(media::SubsampleEntry
)
59 IPC_STRUCT_TRAITS_MEMBER(clear_bytes
)
60 IPC_STRUCT_TRAITS_MEMBER(cypher_bytes
)
61 IPC_STRUCT_TRAITS_END()
63 IPC_ENUM_TRAITS_MAX_VALUE(MediaPlayerHostMsg_Initialize_Type
,
64 MEDIA_PLAYER_TYPE_LAST
)
66 // Parameters to describe a media player
67 IPC_STRUCT_BEGIN(MediaPlayerHostMsg_Initialize_Params
)
68 IPC_STRUCT_MEMBER(MediaPlayerHostMsg_Initialize_Type
, type
)
69 IPC_STRUCT_MEMBER(base::SharedMemoryHandle
, metafile_data_handle
)
70 IPC_STRUCT_MEMBER(int, player_id
)
71 IPC_STRUCT_MEMBER(int, demuxer_client_id
)
72 IPC_STRUCT_MEMBER(GURL
, url
)
73 IPC_STRUCT_MEMBER(GURL
, first_party_for_cookies
)
74 IPC_STRUCT_MEMBER(GURL
, frame_url
)
75 IPC_STRUCT_MEMBER(bool, allow_credentials
)
78 // Chrome for Android seek message sequence is:
79 // 1. Renderer->Browser MediaPlayerHostMsg_Seek
80 // This is the beginning of actual seek flow in response to web app requests
81 // for seeks and browser MediaPlayerMsg_SeekRequests. With this message,
82 // the renderer asks browser to perform actual seek. At most one of these
83 // actual seeks will be in process between this message and renderer's later
84 // receipt of MediaPlayerMsg_SeekCompleted from the browser.
85 // 2. Browser->Renderer MediaPlayerMsg_SeekCompleted
86 // Once the browser determines the seek is complete, it sends this message to
87 // notify the renderer of seek completion.
89 // Other seek-related IPC messages:
90 // Browser->Renderer MediaPlayerMsg_SeekRequest
91 // Browser requests to begin a seek. All browser-initiated seeks must begin
92 // with this request. Renderer controls actual seek initiation via the normal
93 // seek flow, above, keeping web apps aware of seeks. These requests are
94 // also allowed while another actual seek is in progress.
96 // If the demuxer is located in the renderer, as in media source players, the
97 // browser must ensure the renderer demuxer is appropriately seeked between
98 // receipt of MediaPlayerHostMsg_Seek and transmission of
99 // MediaPlayerMsg_SeekCompleted. The following two renderer-demuxer control
100 // messages book-end the renderer-demuxer seek:
101 // 1.1 Browser->Renderer MediaPlayerMsg_DemuxerSeekRequest
102 // 1.2 Renderer->Browser MediaPlayerHostMsg_DemuxerSeekDone
104 // Only in short-term hack to seek to reach I-Frame to feed a newly constructed
105 // video decoder may the above IPC sequence be modified to exclude SeekRequest,
106 // Seek and SeekCompleted, with condition that DemuxerSeekRequest's
107 // |is_browser_seek| parameter be true. Regular seek messages must still be
108 // handled even when a hack browser seek is in progress. In this case, the
109 // browser seek request's |time_to_seek| may no longer be buffered and the
110 // demuxer may instead seek to a future buffered time. The resulting
111 // DemuxerSeekDone message's |actual_browser_seek_time| is the time actually
112 // seeked-to, and is only meaningful for these hack browser seeks.
113 // TODO(wolenetz): Instead of doing browser seek, replay cached data since last
114 // keyframe. See http://crbug.com/304234.
116 // Messages for notifying the render process of media playback status -------
118 // Media buffering has updated.
119 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaBufferingUpdate
,
123 // A media playback error has occurred.
124 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_MediaError
,
128 // Playback is completed.
129 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlaybackCompleted
,
132 // Media metadata has changed.
133 IPC_MESSAGE_ROUTED5(MediaPlayerMsg_MediaMetadataChanged
,
135 base::TimeDelta
/* duration */,
140 // Requests renderer player to ask its client (blink HTMLMediaElement) to seek.
141 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekRequest
,
143 base::TimeDelta
/* time_to_seek_to */)
145 // Media seek is completed.
146 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_SeekCompleted
,
148 base::TimeDelta
/* current_time */)
150 // Video size has changed.
151 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaVideoSizeChanged
,
156 // The current play time has updated.
157 IPC_MESSAGE_ROUTED3(MediaPlayerMsg_MediaTimeUpdate
,
159 base::TimeDelta
/* current_timestamp */,
160 base::TimeTicks
/* current_time_ticks */)
162 // The player has been released.
163 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_MediaPlayerReleased
,
166 // The player exited fullscreen.
167 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidExitFullscreen
,
170 // The player started playing.
171 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPlay
,
174 // The player was paused.
175 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DidMediaPlayerPause
,
178 // Requests renderer demuxer seek.
179 IPC_MESSAGE_CONTROL3(MediaPlayerMsg_DemuxerSeekRequest
,
180 int /* demuxer_client_id */,
181 base::TimeDelta
/* time_to_seek */,
182 bool /* is_browser_seek */)
184 // The media source player reads data from demuxer
185 IPC_MESSAGE_CONTROL2(MediaPlayerMsg_ReadFromDemuxer
,
186 int /* demuxer_client_id */,
187 media::DemuxerStream::Type
/* type */)
189 // Clank has connected to the remote device.
190 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_ConnectedToRemoteDevice
,
192 std::string
/* remote_playback_message */)
194 // Clank has disconnected from the remote device.
195 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_DisconnectedFromRemoteDevice
,
198 // The availability of remote devices has changed
199 IPC_MESSAGE_ROUTED2(MediaPlayerMsg_RemoteRouteAvailabilityChanged
,
201 bool /* routes_available */)
203 // Instructs the video element to enter fullscreen.
204 IPC_MESSAGE_ROUTED1(MediaPlayerMsg_RequestFullscreen
,
207 // Messages for controlling the media playback in browser process ----------
209 // Destroy the media player object.
210 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_DestroyMediaPlayer
,
213 // Initialize a media player object.
215 MediaPlayerHostMsg_Initialize
,
216 MediaPlayerHostMsg_Initialize_Params
);
219 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Pause
,
221 bool /* is_media_related_action */)
223 // Release player resources, but keep the object for future usage.
224 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Release
, int /* player_id */)
227 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_Seek
,
229 base::TimeDelta
/* time */)
231 // Start the player for playback.
232 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_Start
, int /* player_id */)
235 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetVolume
,
239 // Set the poster image.
240 IPC_MESSAGE_ROUTED2(MediaPlayerHostMsg_SetPoster
,
242 GURL
/* poster url */)
244 // Requests the player to enter fullscreen.
245 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_EnterFullscreen
, int /* player_id */)
247 // Requests the player to exit fullscreen.
248 IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_ExitFullscreen
, 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
,
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 */,
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
,
289 bool /* is_request */,
290 gfx::RectF
/* rect */)
291 #endif // defined(VIDEO_HOLE)