Gnash  0.8.11dev
Public Member Functions | Static Public Attributes | List of all members
gnash::media::FLVParser Class Reference

The FLVParser class parses FLV streams. More...

#include <FLVParser.h>

Inheritance diagram for gnash::media::FLVParser:
gnash::media::MediaParser

Public Member Functions

 FLVParser (std::unique_ptr< IOChannel > lt)
 Create an FLV parser reading input from the given IOChannel. More...
 
 ~FLVParser ()
 Kills the parser... More...
 
virtual bool seek (std::uint32_t &)
 Seeks to the closest possible position the given position, and returns the new position. More...
 
virtual bool parseNextChunk ()
 Parse next chunk of input. More...
 
std::uint64_t getBytesLoaded () const
 Return number of bytes parsed so far. More...
 
bool indexingCompleted () const
 Return true of indexing is completed. More...
 
virtual void fetchMetaTags (OrderedMetaTags &tags, std::uint64_t ts)
 Retrieve any parsed metadata tags up to a specified timestamp. More...
 
- Public Member Functions inherited from gnash::media::MediaParser
 MediaParser (std::unique_ptr< IOChannel > stream)
 
virtual ~MediaParser ()
 
DSOEXPORT std::uint64_t getBufferLength () const
 Returns mininum length of available buffers in milliseconds. More...
 
DSOEXPORT bool isBufferEmpty () const
 Return true if both audio and video buffers are empty. More...
 
DSOEXPORT std::uint_fast64_t getBufferTime () const
 Return the time we want the parser thread to maintain in the buffer. More...
 
DSOEXPORT void setBufferTime (std::uint_fast64_t t)
 Set the time we want the parser thread to maintain in the buffer. More...
 
DSOEXPORT bool nextFrameTimestamp (std::uint64_t &ts) const
 Get timestamp of the next frame available, if any. More...
 
DSOEXPORT bool nextVideoFrameTimestamp (std::uint64_t &ts) const
 Get timestamp of the video frame which would be returned on nextVideoFrame. More...
 
DSOEXPORT std::unique_ptr< EncodedVideoFramenextVideoFrame ()
 Returns the next video frame in the parsed buffer, advancing video cursor. More...
 
DSOEXPORT bool nextAudioFrameTimestamp (std::uint64_t &ts) const
 Get timestamp of the audio frame which would be returned on nextAudioFrame. More...
 
DSOEXPORT std::unique_ptr< EncodedAudioFramenextAudioFrame ()
 Returns the next audio frame in the parsed buffer, advancing audio cursor. More...
 
VideoInfogetVideoInfo ()
 Returns a VideoInfo class about the videostream. More...
 
AudioInfogetAudioInfo ()
 Returns a AudioInfo class about the audiostream. More...
 
bool parsingCompleted () const
 Return true of parsing is completed. More...
 
std::uint64_t getBytesTotal () const
 Return total number of bytes in input. More...
 
virtual boost::optional< Id3InfogetId3Info () const
 Get ID3 data from the parsed stream if it exists. More...
 

Static Public Attributes

static const size_t paddingBytes = 8
 The size of padding for all buffers that might be read by FFMPEG. More...
 

Additional Inherited Members

- Public Types inherited from gnash::media::MediaParser
typedef std::multimap< std::uint64_t, std::shared_ptr< SimpleBuffer > > MetaTags
 A container for executable MetaTags contained in media streams. More...
 
typedef std::vector< MetaTags::mapped_type > OrderedMetaTags
 
- Protected Member Functions inherited from gnash::media::MediaParser
void startParserThread ()
 }@ More...
 
void stopParserThread ()
 Stop the parser thread. More...
 
void clearBuffers ()
 Clear the a/v buffers. More...
 
void pushEncodedAudioFrame (std::unique_ptr< EncodedAudioFrame > frame)
 Push an encoded audio frame to buffer. More...
 
void pushEncodedVideoFrame (std::unique_ptr< EncodedVideoFrame > frame)
 Push an encoded video frame to buffer. More...
 
void parserLoop ()
 
bool parserThreadKillRequested () const
 
void waitIfNeeded (std::unique_lock< std::mutex > &qMutexLock)
 
void wakeupParserThread ()
 
bool bufferFull () const
 Method to check if buffer is full w/out locking the _qMutex. More...
 
- Protected Attributes inherited from gnash::media::MediaParser
std::unique_ptr< VideoInfo_videoInfo
 Subclasses must set the following variables: More...
 
std::unique_ptr< AudioInfo_audioInfo
 Info about the audio stream (if any) More...
 
bool _parsingComplete
 Whether the parsing is complete or not. More...
 
std::atomic< std::uint_fast64_t > _bytesLoaded
 Number of bytes loaded. More...
 
std::unique_ptr< IOChannel_stream
 The stream used to access the file. More...
 
std::mutex _streamMutex
 
std::atomic< std::uint_fast64_t > _bufferTime
 
std::thread _parserThread
 
std::atomic< bool > _parserThreadKillRequested
 
std::condition_variable _parserThreadWakeup
 
std::mutex _qMutex
 mutex protecting access to the a/v encoded frames queues More...
 
bool _seekRequest
 

Detailed Description

The FLVParser class parses FLV streams.

Constructor & Destructor Documentation

§ FLVParser()

gnash::media::FLVParser::FLVParser ( std::unique_ptr< IOChannel lt)

Create an FLV parser reading input from the given IOChannel.

Parameters
ltIOChannel to use for input. Ownership transferred.

References gnash::media::MediaParser::startParserThread().

§ ~FLVParser()

gnash::media::FLVParser::~FLVParser ( )

Kills the parser...

References gnash::media::MediaParser::stopParserThread().

Member Function Documentation

§ fetchMetaTags()

void gnash::media::FLVParser::fetchMetaTags ( OrderedMetaTags tags,
std::uint64_t  ts 
)
virtual

Retrieve any parsed metadata tags up to a specified timestamp.

This copies pointers to a SimpleBuffer of AMF data from _metaTags, then removes those pointers from the MetaTags map. Any metadata later than the timestamp is kept until fetchMetaTags is called again (or the dtor is called).

Parameters
tsThe latest timestamp to retrieve metadata for.
tagsThis is filled with shared pointers to metatags in timestamp order. Ownership of the data is shared. It is destroyed automatically along with the last owner.

Reimplemented from gnash::media::MediaParser.

§ getBytesLoaded()

std::uint64_t gnash::media::FLVParser::getBytesLoaded ( ) const
virtual

§ indexingCompleted()

bool gnash::media::FLVParser::indexingCompleted ( ) const
inlinevirtual

Return true of indexing is completed.

If this function returns false, parseNextChunk will be called even when buffers are full. Parsers supporting indexing separated from parsing should override this method and have parseNextChunk figure if they only need to index or to parse based on bufferFull.

Reimplemented from gnash::media::MediaParser.

References ts.

§ parseNextChunk()

bool gnash::media::FLVParser::parseNextChunk ( )
virtual

§ seek()

bool gnash::media::FLVParser::seek ( std::uint32_t &  time)
virtual

Seeks to the closest possible position the given position, and returns the new position.

Parameters
timeinput/output parameter, input requests a time, output return the actual time seeked to.
Returns
true if the seek was valid, false otherwise.

Implements gnash::media::MediaParser.

References gnash::media::MediaParser::_parsingComplete, gnash::media::MediaParser::_seekRequest, gnash::media::MediaParser::_streamMutex, gnash::media::MediaParser::clearBuffers(), and gnash::log_debug().

Member Data Documentation

§ paddingBytes

const size_t gnash::media::FLVParser::paddingBytes = 8
static

The size of padding for all buffers that might be read by FFMPEG.

This possibly also applies to other media handlers (gst). Ideally this would be taken from the current Handler, but we don't know about it here.

Referenced by getBytesLoaded(), and parseNextChunk().


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