Native Player  1.0
StreamDemuxer Class Referenceabstract

An interface for demuxing modules. This interface provides methods used to parse data of media container and perform basic operation on StreamDemuxer. This interface allows to set listeners for data needed by NaCl Player - stream configurations and DRM data. More...

#include <stream_demuxer.h>

Public Types

enum  Type { kUnknown = -1, kAudio = 0, kVideo = 1 }
 
enum  Message {
  kError = -1, kInitialized = 0, kFlushed = 1, kClosed = 2,
  kEndOfStream = 3, kAudioPkt = 4, kVideoPkt = 5
}
 

Public Member Functions

 StreamDemuxer ()
 Constructs an empty StreamDemuxer. More...
 
virtual ~StreamDemuxer ()
 Destroys StreamDemuxer object. More...
 
virtual bool Init (const std::function< void(Message, std::unique_ptr< ElementaryStreamPacket >)> &callback, pp::MessageLoop callback_dispatcher)=0
 
virtual void Flush ()=0
 
virtual void Parse (const std::vector< uint8_t > &data)=0
 
virtual bool SetAudioConfigListener (const std::function< void(const AudioConfig &)> &callback)=0
 
virtual bool SetVideoConfigListener (const std::function< void(const VideoConfig &)> &callback)=0
 
virtual bool SetDRMInitDataListener (const std::function< void(const std::string &type, const std::vector< uint8_t > &init_data)> &callback)=0
 
virtual void SetTimestamp (Samsung::NaClPlayer::TimeTicks)=0
 
virtual void Close ()=0
 

Static Public Member Functions

static std::unique_ptr< StreamDemuxerCreate (const pp::InstanceHandle &instance, Type type)
 

Detailed Description

An interface for demuxing modules. This interface provides methods used to parse data of media container and perform basic operation on StreamDemuxer. This interface allows to set listeners for data needed by NaCl Player - stream configurations and DRM data.

Note
This interface is needed to be implemented by demuxer module to be consistent with other Native Player modules.

Definition at line 144 of file stream_demuxer.h.

Member Enumeration Documentation

Describes message types that StreamDemuxer can post via callback function passed by StreamDemuxer::Init method. This Message can be useful when running demuxer methods asynchronously to signal certain events or completion of actions.

Enumerator
kError 
kInitialized 
kFlushed 
kClosed 
kEndOfStream 
kAudioPkt 
kVideoPkt 

Definition at line 156 of file stream_demuxer.h.

Describes type of demuxer. Each demuxer can be used to parse one type of container: audio or video.

Enumerator
kUnknown 
kAudio 
kVideo 

Definition at line 149 of file stream_demuxer.h.

Constructor & Destructor Documentation

StreamDemuxer::StreamDemuxer ( )
inline

Constructs an empty StreamDemuxer.

Definition at line 177 of file stream_demuxer.h.

virtual StreamDemuxer::~StreamDemuxer ( )
inlinevirtual

Destroys StreamDemuxer object.

Definition at line 180 of file stream_demuxer.h.

Member Function Documentation

virtual void StreamDemuxer::Close ( )
pure virtual

Closes StreamDemuxer. Clear all data, stream configurations. StreamDemuxer::Init should be called, before using it again.

static std::unique_ptr<StreamDemuxer> StreamDemuxer::Create ( const pp::InstanceHandle &  instance,
Type  type 
)
static

Creates StreamDemuxer for given StreamDemuxer::Type.

Parameters
[in]instanceAn InstanceHandle identifying Native Player object.
[in]typeA StreamDemuxer::Type identifying a type of requested to create StreamDemuxer to create.
Returns
StreamDemuxer constructed with given params.
virtual void StreamDemuxer::Flush ( )
pure virtual

Performs flush operation on StreamDemuxer. All demuxed elementary stream packets have to be erased, in order to prepare StreamDemuxer to receive data from container.

virtual bool StreamDemuxer::Init ( const std::function< void(Message, std::unique_ptr< ElementaryStreamPacket >)> &  callback,
pp::MessageLoop  callback_dispatcher 
)
pure virtual

Initialize StreamDemuxer, if finished successfully then data from the requested stream can be parsed.

Parameters
[in]callbackA function which is registered. This function is used to communicate with use of StreamDemuxer::Message. It should be called on callback_dispatcher MessageLoop
In particular is used to pass ElementaryStreamPacket.
[in]callback_dispatcherA pp::MessageLoop on which communication should be performed.
Returns
True on success, false otherwise.
virtual void StreamDemuxer::Parse ( const std::vector< uint8_t > &  data)
pure virtual

Performs parse operation. Passed data should be parsed or added to queue data to be parsed. Parsed data - ElementaryStreamPacket should be passed to the callback function registered in StreamDemuxer::Init. To recognize type of demuxed packet StreamDemuxer::Message::kAudioPkt or StreamDemuxer::Message::kVideoPkt can be used.

Parameters
[in]dataAn byte array which helds data of media container.
virtual bool StreamDemuxer::SetAudioConfigListener ( const std::function< void(const AudioConfig &)> &  callback)
pure virtual

Registers a callback function which is called every time audio configuration has changed and pass new configuration.

Parameters
[in]callbackA function which is registered in StreamDemuxer. It should be called each time AudioConfig had changed or on the first time configuration is available.
Callback should be called on callback_dispatcher MessageLoop registered in StreamDemuxer::Init.
Returns
True on success, false otherwise.
virtual bool StreamDemuxer::SetDRMInitDataListener ( const std::function< void(const std::string &type, const std::vector< uint8_t > &init_data)> &  callback)
pure virtual

Registers a callback function which is called every time DRM init data is discovered by StreamDemuxer and pass DRM init data.

Parameters
[in]callbackA function which is registered in StreamDemuxer. It should be called DRM data is available.
Callback should be called on callback_dispatcher MessageLoop registered in StreamDemuxer::Init.
Returns
True on success, false otherwise.
virtual void StreamDemuxer::SetTimestamp ( Samsung::NaClPlayer::TimeTicks  )
pure virtual

Sets time stamp to demuxed packets. Can be use after performing seek operation on elementary stream to set proper timestamps of packets.

virtual bool StreamDemuxer::SetVideoConfigListener ( const std::function< void(const VideoConfig &)> &  callback)
pure virtual

Registers a callback function which is called every time video configuration has changed and pass new configuration.

Parameters
[in]callbackA function which is registered in StreamDemuxer. It should be called each time VideoConfig had changed or on the first time configuration is available.
Callback should be called on callback_dispatcher MessageLoop registered in StreamDemuxer::Init.
Returns
True on success, false otherwise.

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