NaCl Player API
NaCl Player API Documentation
Samsung::NaClPlayer::ESDataSource Class Reference

#include <es_data_source.h>

Inheritance diagram for Samsung::NaClPlayer::ESDataSource:
Collaboration diagram for Samsung::NaClPlayer::ESDataSource:

Public Member Functions

 ESDataSource (const ESDataSource &other)
 
ESDataSourceoperator= (const ESDataSource &other)
 
template<typename T >
int32_t AddStream (const std::function< void(int32_t, const T &)> &callback, ElementaryStreamListener *listener)
 
template<typename T >
int32_t AddStream (const std::function< void(int32_t, const T &)> &callback, std::shared_ptr< ElementaryStreamListener > listener)
 
template<typename T >
int32_t AddStream (T &stream, ElementaryStreamListener *listener=nullptr)
 
template<typename T >
int32_t AddStream (T &stream, std::shared_ptr< ElementaryStreamListener > listener)
 
int32_t SetDuration (TimeDelta duration, const std::function< void(int32_t)> &callback)
 
int32_t SetDuration (TimeDelta duration)
 
int32_t SetEndOfStream (const std::function< void(int32_t)> &callback)
 
int32_t SetEndOfStream ()
 
- Public Member Functions inherited from Samsung::NaClPlayer::MediaDataSource
 MediaDataSource (const MediaDataSource &other)
 
MediaDataSourceoperator= (const MediaDataSource &other)
 

Protected Member Functions

MediaDataSource::Impl * impl () const
 

Detailed Description

Data source handling appends of Elementary Streams.

It is a container for Elementary Streams (audio/video/...) and there can be at most one stream of given type (see ElementaryStreamType).

Basic usage (playback of clip containing audio and video):

  1. Create ESDataSource object.
  2. Add audio stream using AddStream<T> with argument being callback accepting AudioElementryStream</code.
  3. Configure audio stream, by setting codec, sampling rate, channels and other necessary information.
  4. Call ElementaryStream.InitializeDone to confirm the configuration
  1. Add video stream using AddStream<T> with argument being callback accepting VideoElementryStream</code.
  2. Configure video stream, by setting codec, frame rate, resolution and other necessary information.
  3. Call ElementaryStream.InitializeDone to confirm the configuration.
  4. Attach data source to the player by calling MediaPlayer.AttachMediaSource.
  5. Download and append Elementary Stream audio and video packets by calling ElementaryStream.AppendPacket

Signalize end of stream (clip) by calling SetEndOfStream

  1. Detach data source from the player by calling MediaPlayer.AttachMediaSource with NULL object.

Methods in this class are available in synchronous and asynchronous variant. Both versions perform the same action, the only difference is how results of those actions are reported to the caller. Asynchronous method propagates this result by a provided additional parameter callback function.

Common constraints:

  1. Synchronous methods can't be called from the main thread.
  2. Asynchronous methods must be called from a thread with attached MessageLoop, which is required to report a result via provided callback in the same thread as the call itself.

Definition at line 500 of file es_data_source.h.

Member Function Documentation

◆ AddStream() [1/4]

template<typename T >
int32_t Samsung::NaClPlayer::ESDataSource::AddStream ( const std::function< void(int32_t, const T &)> &  callback,
ElementaryStreamListener listener 
)
inline

Factory method which adds stream of given type to the data source.

Type T must be one of concrete types inherited form ElementaryStream

This data source can handle at most one buffer of given type, so multiple calls of this method with the same buffer type will return the same resource as all previous calls.

Remarks
ElementaryStreamListener methods for a newly added stream will be called on a same thread this method was invoked on.
Parameters
[in]callbackA callback to be called upon completion.
Warning
Listeners added using this method cannot be destroyed before the data source is, because ownership isn't transferred.
Returns
ErrorCodes::Success on success, otherwise an error code from ErrorCodes.

Definition at line 700 of file es_data_source.h.

◆ AddStream() [2/4]

template<typename T >
int32_t Samsung::NaClPlayer::ESDataSource::AddStream ( const std::function< void(int32_t, const T &)> &  callback,
std::shared_ptr< ElementaryStreamListener listener 
)
inline

Deprecated method for backwards compatibility

Deprecated:
In new code, raw pointers should be passed so as to not risk cyclic dependencies in client code.

For detailed description

See also
AddStream(callback, listener).

Definition at line 688 of file es_data_source.h.

◆ AddStream() [3/4]

template<typename T >
int32_t Samsung::NaClPlayer::ESDataSource::AddStream ( T &  stream,
ElementaryStreamListener listener = nullptr 
)
inline

Synchronous factory method which adds stream of given type to the data source.

Warning
This method can't be called from the main thread.
Unlike most synchronous methods, AddStream requires a current thread to have an attached MessageLoop. Methods of a given ElementaryStreamListener will be called on MessageLoop attached to the current thread.

For detailed description

See also
AddStream(callback).

Definition at line 721 of file es_data_source.h.

◆ AddStream() [4/4]

template<typename T >
int32_t Samsung::NaClPlayer::ESDataSource::AddStream ( T &  stream,
std::shared_ptr< ElementaryStreamListener listener 
)
inline

Deprecated method for backwards compatibility

Deprecated:
In new code, raw pointers should be passed so as to not risk cyclic dependencies in client code.

Synchronous factory method which adds stream of given type to the data source.

Warning
This method can't be called from the main thread.
Unlike most synchronous methods, AddStream requires a current thread to have an attached MessageLoop. Methods of a given ElementaryStreamListener will be called on MessageLoop attached to the current thread.

For detailed description

See also
AddStream(callback).

Definition at line 712 of file es_data_source.h.

◆ SetDuration() [1/2]

int32_t Samsung::NaClPlayer::ESDataSource::SetDuration ( TimeDelta  duration,
const std::function< void(int32_t)> &  callback 
)

Sets duration of the whole stream/container/clip.

Parameters
[in]durationA duration of played media.
[in]callbackA callback to be called upon completion.
Returns
ErrorCodes::Success on success, otherwise an error code from ErrorCodes.

◆ SetDuration() [2/2]

int32_t Samsung::NaClPlayer::ESDataSource::SetDuration ( TimeDelta  duration)

Synchronously sets duration of the whole stream/container/clip.

Warning
This method can't be called from the main thread.

For detailed description

See also
SetDuration(..., callback).

◆ SetEndOfStream() [1/2]

int32_t Samsung::NaClPlayer::ESDataSource::SetEndOfStream ( const std::function< void(int32_t)> &  callback)

Signalizes end of the whole stream/container/clip.

Parameters
[in]callbackA callback to be called upon completion.
Returns
ErrorCodes::Success on success, otherwise an error code from ErrorCodes.

◆ SetEndOfStream() [2/2]

int32_t Samsung::NaClPlayer::ESDataSource::SetEndOfStream ( )

Synchronously signalizes end of the whole stream/container/clip.

Warning
This method can't be called from the main thread.

For detailed description

See also
SetEndOfStream(callback).

The documentation for this class was generated from the following file: