Pepper_31_C++_interfaces
media_source_samsung.h
Go to the documentation of this file.
1 // Copyright 2013 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_SOURCE_SAMSUNG_H_
6 #define PPAPI_CPP_SAMSUNG_MEDIA_SOURCE_SAMSUNG_H_
7 
8 #include "ppapi/c/pp_array_output.h"
9 #include "ppapi/c/samsung/pp_media_source_samsung.h"
10 #include "ppapi/cpp/resource.h"
11 #include "ppapi/cpp/var.h"
12 #include "ppapi/cpp/samsung/media_control_samsung.h"
13 
14 namespace pp {
15 
16 class InstanceHandle;
17 
18 /// Interface used by PNaCl appliction to provide chunks of multimedia data
19 /// to the platform. Those chunks will be decoded and played by the platform.
20 ///
21 /// This interface inherits from PPB_MediaControl_Samsung.
22 ///
23 /// API is similar to one defined in JavaScript's Media Source Extensions
25  public:
26  // Creates an is_null() MediaControl object.
28 
29  /// Cretes MediaSource_Samsung resource for given |instance|
30  explicit MediaSource_Samsung(const InstanceHandle& instance);
31 
32  /// Destructor
33  virtual ~MediaSource_Samsung() {}
34 
35  /// PPB_MediaSource_Samsung API
36 
37  /// Binds given MediaSource to vide/audio object of given |id| present on
38  /// HTML page on which given module is embedded.
39  bool BindToHTMLPlayer(const Var& id);
40 
41  /// Adds source for which data are appended using Append method. Added source
42  /// is container of type |type| encoded using codecs on |codecs| list.
43  ///
44  /// Returns status - PP_SourceAddStatus and |id| if status is OK.
45  PP_SourceAddStatus AddSource(const Var& type, const Var& codecs,
46  Var* out_id);
47 
48  /// Checks if given source is active i.e. it contains video, audio or
49  /// text (subtitle) track being played
50  bool IsSourceActive(const Var& id);
51 
52  /// Removes source of given |id| and frees associated resources with it.
53  void RemoveSource(const Var& id);
54 
55  /// Appends data to given buffer (identified by |id|).
56  /// |data| argument must be a handle to PPB_Buffer_Dev_0_4 instance.
57  void Append(const Var& id, const Resource& data);
58 
59  /// Aborts given data source
60  void Abort(const Var& id);
61 
62  /// Sets duration in microseconds of currently played stream
63  /// duration is given in microseconds
64  void SetDuration(PP_MicrosecondsDelta duration);
65 
66  /// Gets duration in microseconds of currently played stream
67  PP_MicrosecondsDelta GetDuration();
68 
69  /// Sets end of stream. |error| argument represents whether it is just end
70  /// of the stream (PP_MEDIAERROR_NO_ERROR) or some kind of error occured.
71  void SetEndOfStream(PP_MediaError error);
72 
73  /// Sets a time offset (in microseconds) to be applied to subsequent
74  /// buffers appended to the given buffer.
75  bool SetTimestampOffset(const Var& id, PP_MicrosecondsDelta offset);
76 
77  /// |output| - An output array which will receive
78  /// <code>PP_TimeRange</code> structures on success.
79  ///
80  /// The browser can not allocate memory on behalf of the plugin becaues
81  /// the plugin and browser may have different allocators.
82  /// A PP_ArrayOutput must be provided so that output will be stored in its
83  /// allocated buffer.
84  bool ReadTimeRanges(const Var& id,
85  PP_ArrayOutput output);
86 
87  /// Gets a current time of media.
88  PP_MicrosecondsDelta GetMediaTime();
89 
90  /// Gets a ReadyState of media.
91  PP_MediaReadyState GetReadyState();
92 
93  /// PPP_MediaSource_Samsung API
94 
95  /// Signals error during processing given data source (e.g. decoding error).
96  virtual void Error(const Var& id, PP_SourceError reason) = 0;
97 
98  /// Signals activation of given data source.
99  virtual void SourceOpen() = 0;
100 
101  /// Called when source is still attached to a media element, but endOfStream()
102  /// has been called.
103  virtual void SourceEnded() = 0;
104 
105  /// Signals unaatached data source to a media elemenet.
106  virtual void SourceClose() = 0;
107 
108  // Signal sucsesfull append data.
109  virtual void AppendEnd(const Var& id) = 0;
110 
111 };
112 
113 } // namespace pp
114 
115 #endif // PPAPI_CPP_SAMSUNG_MEDIA_SOURCE_SAMSUNG_H_
virtual void Error(const Var &id, PP_SourceError reason)=0
PPP_MediaSource_Samsung API.
void Abort(const Var &id)
Aborts given data source.
virtual void SourceClose()=0
Signals unaatached data source to a media elemenet.
virtual void SourceEnded()=0
PP_MicrosecondsDelta GetMediaTime()
Gets a current time of media.
PP_MediaReadyState GetReadyState()
Gets a ReadyState of media.
bool IsSourceActive(const Var &id)
void SetEndOfStream(PP_MediaError error)
virtual void SourceOpen()=0
Signals activation of given data source.
virtual ~MediaSource_Samsung()
Destructor.
bool BindToHTMLPlayer(const Var &id)
PPB_MediaSource_Samsung API.
virtual void AppendEnd(const Var &id)=0
void RemoveSource(const Var &id)
Removes source of given |id| and frees associated resources with it.
PP_MicrosecondsDelta GetDuration()
Gets duration in microseconds of currently played stream.
bool ReadTimeRanges(const Var &id, PP_ArrayOutput output)
bool SetTimestampOffset(const Var &id, PP_MicrosecondsDelta offset)
void SetDuration(PP_MicrosecondsDelta duration)
PP_SourceAddStatus AddSource(const Var &type, const Var &codecs, Var *out_id)
A generic type used for passing data types between the module and the page.
Definition: var.h:20
A reference counted module resource.
Definition: resource.h:18
void Append(const Var &id, const Resource &data)