Pepper_37_C++_interfaces
media_player_samsung.h
Go to the documentation of this file.
1 // Copyright 2015 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 #ifndef PPAPI_CPP_SAMSUNG_MEDIA_PLAYER_SAMSUNG_H_
6 #define PPAPI_CPP_SAMSUNG_MEDIA_PLAYER_SAMSUNG_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "ppapi/c/samsung/ppb_media_player_samsung.h"
12 #include "ppapi/cpp/completion_callback.h"
13 #include "ppapi/cpp/resource.h"
14 
15 /// @file
16 /// This file defines the <code>MediaPlayer_Samsung</code> type, which provides
17 /// multimedia streaming and playback control capabilities.
18 ///
19 /// Part of Pepper Media Player interfaces (Samsung's extension).
20 namespace pp {
21 
22 class InstanceHandle;
23 class MediaDataSource_Samsung;
24 
25 /// <code>MediaPlayer_Samsung</code> is type allowing application
26 /// to control playback state, inquire about playback state.
27 /// It's also responsible for assigning data source which will feed player
28 /// with media data.
29 ///
30 /// Assumptions:
31 /// - Video is displayed in area of embed/object element of HTML page
32 /// in which plugin is embedded.
33 /// - Video and graphics from module can be displayed simultaneously.
34 /// (see <code>PPB_Instance.BindGraphics</code>). Application must
35 /// set proper CSS style for embed element with NaCl application
36 /// (mostly transparent background).
37 class MediaPlayer_Samsung : public Resource {
38  public:
40  explicit MediaPlayer_Samsung(const InstanceHandle& instance);
42 
44 
45  virtual ~MediaPlayer_Samsung();
46 
47  /// Attaches given <code>MediaDataSource_Samsung</code> to the player.
48  ///
49  /// You can pass a <code>NULL</code> resource as buffer to detach currently
50  /// attached data source. Reattaching data source will return
51  /// <code>PP_OK</code> and do nothing.
52  ///
53  /// Attaching data source to the player will cause:
54  /// 1. Detaching currently attached data source
55  /// 2. Performing initialization of newly bound data source (this step
56  /// is specific to data source which is being bound).
57  ///
58  /// @param[in] data_source A <code>MediaDataSource_Samsung</code>
59  /// identifying data source to be attached to the player.
60  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
61  /// completion.
62  ///
63  /// @return PP_OK on success, otherwise an error code from
64  /// <code>pp_errors.h</code>.
65  int32_t AttachDataSource(
66  const MediaDataSource_Samsung& data_source,
67  const CompletionCallback& callback);
68 
69  /* Playback control */
70 
71  /// Requests to start playback of media from data source attached to the
72  /// media player.
73  ///
74  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
75  /// completion.
76  ///
77  /// @return PP_OK on success, otherwise an error code from
78  /// <code>pp_errors.h</code>. Meaning of errors:
79  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
80  /// to the media player.
81  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if given operation is not
82  /// supported by attached data source.
83  int32_t Play(const CompletionCallback& callback);
84 
85  /// Requests to pause playback of media from data source attached to the
86  /// media player.
87  ///
88  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
89  /// completion.
90  ///
91  /// @return PP_OK on success, otherwise an error code from
92  /// <code>pp_errors.h</code>. Meaning of errors:
93  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
94  /// to the media player.
95  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if given operation is not
96  /// supported by attached data source.
97  int32_t Pause(const CompletionCallback& callback);
98 
99  /// Requests to stop playback of media from data source attached to the
100  /// media player.
101  ///
102  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
103  /// completion.
104  ///
105  /// @return PP_OK on success, otherwise an error code from
106  /// <code>pp_errors.h</code>. Meaning of errors:
107  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
108  /// to the media player.
109  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if given operation is not
110  /// supported by attached data source.
111  int32_t Stop(const CompletionCallback& callback);
112 
113  /// Requests to seek media from attached data source to the given time stamp.
114  ///
115  /// @param[in] time A time stamp from begging of the clip to from which
116  /// playback should be resumed.
117  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
118  /// completion.
119  ///
120  /// @return PP_OK on success, otherwise an error code from
121  /// <code>pp_errors.h</code>. Meaning of errors:
122  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
123  /// to the media player.
124  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if given operation is not
125  /// supported by attached data source.
126  int32_t Seek(PP_TimeTicks time, const CompletionCallback& callback);
127 
128  /// Sets playback rate, pass:
129  /// |rate| == 1.0 to mark normal playback
130  /// 0.0 < |rate| < 1.0 to mark speeds slower than normal
131  /// |rate| > 1.0 to mark speeds faster than normal
132  ///
133  /// @param[in] rate A rate of the playback.
134  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
135  /// completion.
136  ///
137  /// @return PP_OK on success, otherwise an error code from
138  /// <code>pp_errors.h</code>. Meaning of errors:
139  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
140  /// to the media player.
141  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if given operation is not
142  /// supported by attached data source.
143  int32_t SetPlaybackRate(double rate, const CompletionCallback& callback);
144 
145  /* Playback time info */
146 
147  /// Retrieves duration of the media played from attached data source.
148  ///
149  /// @param[in] callback A <code>CompletionCallbackWitOutput</code>
150  /// to be called upon completion with retrieved duration of the media.
151  ///
152  /// @return PP_OK on success, otherwise an error code from
153  /// <code>pp_errors.h</code>. Meaning of errors:
154  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
155  /// to the media player.
156  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if given operation is not
157  /// supported by attached data source (e.g. live content playback).
158  int32_t GetDuration(
160 
161  /// Retrieves current time/position of the media played from attached
162  /// data source.
163  ///
164  /// This operation can be performed only for media player in
165  /// <code>PP_MEDIAPLAYERSTATE_PLAYING</code> or
166  /// <code>PP_MEDIAPLAYERSTATE_PAUSED</code> states.
167  ///
168  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
169  /// called upon completion with retrieved current time.
170  ///
171  /// @return PP_OK on success, otherwise an error code from
172  /// <code>pp_errors.h</code>. Meaning of errors:
173  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
174  /// to the media player.
175  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if data can't be retrieved
176  /// due to invalid player state.
177  int32_t GetCurrentTime(
179 
180  /* Playback state info */
181 
182  /// Retrieves current state the media player.
183  ///
184  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
185  /// called upon completion with retrieved player state.
186  ///
187  /// @return PP_OK on success, otherwise an error code from
188  /// <code>pp_errors.h</code>.
189  int32_t GetPlayerState(
191 
192  /* Tracks info */
193 
194  /// Retrieves information of current video track from the media played from
195  /// attached data source.
196  ///
197  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
198  /// called upon completion with retrieved video track information.
199  ///
200  /// @return PP_OK on success, otherwise an error code from
201  /// <code>pp_errors.h</code>. Meaning of errors:
202  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
203  /// to the media player.
204  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if no video track is available
205  /// in media played from attached data source.
206  int32_t GetCurrentVideoTrackInfo(
208 
209  typedef std::vector<PP_VideoTrackInfo> VideoTracksList;
210 
211  /// Retrieves information of all video tracks from the media played from
212  /// attached data source.
213  ///
214  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
215  /// called upon completion with list of video tracks available in currently
216  /// attached data source. List will be empty if media played form attached
217  /// data source doesn't have any video tracks.
218  ///
219  /// @return If >= 0, the number of the tracks is returned, otherwise an
220  /// error code from <code>pp_errors.h</code>. Meaning of errors:
221  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
222  /// to the media player.
223  int32_t GetVideoTracksList(
225 
226  /// Retrieves information of current audio track from the media played from
227  /// attached data source.
228  ///
229  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
230  /// called upon completion with retrieved audio track information.
231  ///
232  /// @return PP_OK on success, otherwise an error code from
233  /// <code>pp_errors.h</code>. Meaning of errors:
234  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
235  /// to the media player.
236  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if no video track is available
237  /// in media played from attached data source.
238  int32_t GetCurrentAudioTrackInfo(
240 
241  typedef std::vector<PP_AudioTrackInfo> AudioTracksList;
242 
243  /// Retrieves information of all audio tracks from the media played from
244  /// attached data source.
245  ///
246  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
247  /// called upon completion with list of audio tracks available in currently
248  /// attached data source. List will be empty if media played form attached
249  /// data source doesn't have any audio tracks.
250  ///
251  /// @return If >= 0, the number of the tracks is returned, otherwise an
252  /// error code from <code>pp_errors.h</code>. Meaning of errors:
253  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
254  /// to the media player.
255  int32_t GetAudioTracksList(
257 
258  /// Retrieves information of current text/subtitles track from the media
259  /// played from attached data source.
260  ///
261  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
262  /// called upon completion with retrieved text/subtitles track information.
263  ///
264  /// @return PP_OK on success, otherwise an error code from
265  /// <code>pp_errors.h</code>. Meaning of errors:
266  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
267  /// to the media player.
268  /// - <code>PP_ERROR_NOTSUPPORTED</code> - if no video track is available
269  /// in media played from attached data source.
270  int32_t GetCurrentTextTrackInfo(
272 
273  typedef std::vector<PP_TextTrackInfo> TextTracksList;
274 
275  /// Retrieves information of all text/subtitles tracks from the media played
276  /// from attached data source.
277  ///
278  /// If there are external subtitles tracks attached using
279  /// <code>AddExternalSubtitles</code> they will be added to this list.
280  ///
281  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
282  /// called upon completion with list of text/subtitles tracks available
283  /// in currently attached data source. List will be empty if media played
284  /// form attached data source doesn't have any text/subtitles tracks.
285  ///
286  /// @return If >= 0, the number of the tracks is returned, otherwise an
287  /// error code from <code>pp_errors.h</code>. Meaning of errors:
288  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
289  /// to the media player.
290  int32_t GetTextTracksList(
292 
293  /// Selects track for given stream type to by activated from media played
294  /// from attached data source.
295  ///
296  /// @param[in] track_type A type of the stream for which activate track.
297  /// @param[in] track_index An index of the track which has to be activated.
298  /// Valid track index can be obtained from one of PP_*TrackInfo structures
299  /// returned by corresponding call to Get*TracksInfo.
300  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
301  /// completion.
302  ///
303  /// @return PP_OK on success, otherwise an error code from
304  /// <code>pp_errors.h</code>. Meaning of errors:
305  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
306  /// to the media player or passed |track_type| or |track_index| are
307  /// not valid.
308  int32_t SelectTrack(
309  PP_ElementaryStream_Type_Samsung track_type,
310  uint32_t track_index,
311  const CompletionCallback& callback);
312 
313  /* Subtitles control */
314 
315  /// Sets subtitles (text stream) visibility flag.
316  /// Note - when subtitles are not displayed changing text track (by calling
317  /// <code>SelectTrack</code>) will not automatically toggle this flag.
318  ///
319  /// Passing <code>true</code> will cause that subtitles will be displayed
320  /// and <code>false</code> will hide them.
321  ///
322  /// @param[in] subtitles_visible visibility of the subtitles.
323  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
324  /// completion.
325  ///
326  /// @return PP_OK on success, otherwise an error code from
327  /// <code>pp_errors.h</code>. Meaning of errors:
328  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
329  /// to the media player.
330  int32_t SetSubtitlesVisible(
331  bool visible,
332  const CompletionCallback& callback);
333 
334  /// Returns PP_OK in case of success and writes added text track information
335  /// to |subtitles| param. After that subtitles can be selected by calling
336  /// <code>SelectTrack</code> and passing |track_index| field from |output|
337  /// structure.
338  ///
339  /// Constraints:
340  /// Calling this method before calling <code>Play</code> will set
341  /// <code>subtitles.index</code> to <code>-1</code>. However such subtitles
342  /// will be returned by call to <code>GetTextTrackList</code> after starting
343  /// playback and they will have <code>is_external</code> flag set.
344  ///
345  /// @param[in] file_path A path of the subtitles.
346  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
347  /// called upon completion with added subtitles information.
348  ///
349  /// @return PP_OK on success, otherwise an error code from
350  /// <code>pp_errors.h</code>. Meaning of errors:
351  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
352  /// to the media player.
353  int32_t AddExternalSubtitles(
354  const std::string& file_path,
356 
357  /// Sets subtitles (text stream) display delay regarding to the current
358  /// media time.
359  ///
360  /// @param[in] delay A delay to be set.
361  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
362  /// completion.
363  ///
364  /// @return PP_OK on success, otherwise an error code from
365  /// <code>pp_errors.h</code>. Meaning of errors:
366  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
367  /// to the media player.
368  int32_t SetSubtitlesDelay(
369  PP_TimeDelta delay,
370  const CompletionCallback& callback);
371 
372  /* Other - player control */
373 
374  /// Sets display mode used to scale video to output area if necessary.
375  ///
376  /// @param[in] display_mode A display/scaling mode to be used.
377  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
378  /// completion.
379  ///
380  /// @return PP_OK on success, otherwise an error code from
381  /// <code>pp_errors.h</code>.
382  int32_t SetDisplayMode(
383  PP_MediaPlayerDisplayMode display_mode,
384  const CompletionCallback& callback);
385 
386  /// Sets display region in which video will be displayed. Passed position
387  /// is relative to the embed/object element of WebPage associated with given
388  /// plugin.
389  ///
390  /// @param[in] rect Video region in which video will be displayed.
391  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
392  /// completion.
393  ///
394  /// @return PP_OK on success, otherwise an error code from
395  /// <code>pp_errors.h</code>.
396  int32_t SetDisplayRect(
397  const PP_Rect& rect,
398  const CompletionCallback& callback);
399 
400  /* DRM Related */
401 
402  /// Calls DRM system specific operation.
403  ///
404  /// @param[in] drm_type A DRM system to be used
405  /// @param[in] drm_operation A DRM specific operation to be performed.
406  /// @param[in] drm_data_size A size of data buffer passed to DRM system.
407  /// @param[in] drm_data A data buffer passed to DRM system.
408  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
409  /// completion.
410  ///
411  /// @return PP_OK on success, otherwise an error code from
412  /// <code>pp_errors.h</code>. Meaning of errors:
413  /// - <code>PP_ERROR_BADARGUMENT</code> - if no data source is connected
414  /// to the media player.
415  int32_t SetDRMSpecificData(
416  PP_MediaPlayerDRMType drm_type,
417  PP_MediaPlayerDRMOperation drm_operation,
418  uint32_t drm_data_size,
419  const void* drm_data,
420  const CompletionCallback& callback);
421 };
422 
423 } // namespace pp
424 
425 #endif // PPAPI_CPP_SAMSUNG_MEDIA_PLAYER_SAMSUNG_H_
std::vector< PP_VideoTrackInfo > VideoTracksList
int32_t SelectTrack(PP_ElementaryStream_Type_Samsung track_type, uint32_t track_index, const CompletionCallback &callback)
int32_t GetDuration(const CompletionCallbackWithOutput< PP_TimeDelta > &callback)
int32_t Pause(const CompletionCallback &callback)
int32_t GetCurrentTextTrackInfo(const CompletionCallbackWithOutput< PP_TextTrackInfo > &callback)
int32_t GetCurrentVideoTrackInfo(const CompletionCallbackWithOutput< PP_VideoTrackInfo > &callback)
int32_t SetSubtitlesVisible(bool visible, const CompletionCallback &callback)
MediaPlayer_Samsung & operator=(const MediaPlayer_Samsung &other)
virtual ~MediaPlayer_Samsung()
int32_t GetPlayerState(const CompletionCallbackWithOutput< PP_MediaPlayerState > &callback)
std::vector< PP_AudioTrackInfo > AudioTracksList
int32_t AttachDataSource(const MediaDataSource_Samsung &data_source, const CompletionCallback &callback)
int32_t AddExternalSubtitles(const std::string &file_path, const CompletionCallbackWithOutput< PP_TextTrackInfo > &callback)
int32_t Stop(const CompletionCallback &callback)
int32_t Play(const CompletionCallback &callback)
int32_t GetTextTracksList(const CompletionCallbackWithOutput< TextTracksList > &callback)
int32_t SetDisplayRect(const PP_Rect &rect, const CompletionCallback &callback)
int32_t SetDisplayMode(PP_MediaPlayerDisplayMode display_mode, const CompletionCallback &callback)
std::vector< PP_TextTrackInfo > TextTracksList
int32_t Seek(PP_TimeTicks time, const CompletionCallback &callback)
int32_t SetSubtitlesDelay(PP_TimeDelta delay, const CompletionCallback &callback)
int32_t GetVideoTracksList(const CompletionCallbackWithOutput< VideoTracksList > &callback)
int32_t GetAudioTracksList(const CompletionCallbackWithOutput< AudioTracksList > &callback)
int32_t SetPlaybackRate(double rate, const CompletionCallback &callback)
A reference counted module resource.
Definition: resource.h:20
int32_t GetCurrentAudioTrackInfo(const CompletionCallbackWithOutput< PP_AudioTrackInfo > &callback)
int32_t SetDRMSpecificData(PP_MediaPlayerDRMType drm_type, PP_MediaPlayerDRMOperation drm_operation, uint32_t drm_data_size, const void *drm_data, const CompletionCallback &callback)
int32_t GetCurrentTime(const CompletionCallbackWithOutput< PP_TimeTicks > &callback)