Miam-Player  0.8.0
A nice music player
QtAV::AVDemuxer Class Reference

#include <AVDemuxer.h>

Inheritance diagram for QtAV::AVDemuxer:

Public Types

enum  StreamType { AudioStream, VideoStream, SubtitleStream }
 

Signals

void unloaded ()
 
void userInterrupted ()
 
void loaded ()
 
void started ()
 
void finished ()
 
void error (const QtAV::AVError &e)
 
void mediaStatusChanged (QtAV::MediaStatus status)
 
void seekableChanged ()
 

Public Member Functions

 AVDemuxer (QObject *parent=0)
 
 ~AVDemuxer ()
 
MediaStatus mediaStatus () const
 
bool atEnd () const
 
QString fileName () const
 
QIODevice * ioDevice () const
 
MediaIOmediaIO () const
 not null for QIODevice, custom protocols More...
 
bool setMedia (const QString &fileName)
 setMedia More...
 
bool setMedia (QIODevice *dev)
 
bool setMedia (MediaIO *in)
 
void setFormat (const QString &fmt)
 setFormat Force the input format. More...
 
QString formatForced () const
 
bool load ()
 
bool unload ()
 
bool isLoaded () const
 
bool readFrame ()
 readFrame Read a packet from 1 of the streams. More...
 
Packet packet () const
 packet return the packet read by demuxer. More...
 
int stream () const
 stream Current readFrame() readed stream index. More...
 
bool isSeekable () const
 
void setSeekUnit (SeekUnit unit)
 
SeekUnit seekUnit () const
 
void setSeekType (SeekType target)
 
SeekType seekType () const
 
bool seek (qint64 pos)
 seek seek to a given position. More...
 
bool seek (qreal q)
 seek Percentage seek. More...
 
AVFormatContextformatContext ()
 
QString formatName () const
 
QString formatLongName () const
 
qint64 startTime () const
 
qint64 duration () const
 
qint64 startTimeUs () const
 
qint64 durationUs () const
 
int bitRate () const
 
qreal frameRate () const
 
qint64 frames (int stream=-1) const
 
bool hasAttacedPicture () const
 
bool setStreamIndex (StreamType st, int index)
 setStreamIndex Set stream by index in stream list. More...
 
int currentStream (StreamType st) const
 
QList< int > streams (StreamType st) const
 
int audioStream () const
 
QList< int > audioStreams () const
 
int videoStream () const
 
QList< int > videoStreams () const
 
int subtitleStream () const
 
QList< int > subtitleStreams () const
 
AVCodecContextaudioCodecContext (int stream=-1) const
 
AVCodecContextvideoCodecContext (int stream=-1) const
 
AVCodecContextsubtitleCodecContext (int stream=-1) const
 
qint64 getInterruptTimeout () const
 getInterruptTimeout return the interrupt timeout More...
 
void setInterruptTimeout (qint64 timeout)
 setInterruptTimeout set the interrupt timeout More...
 
bool isInterruptOnTimeout () const
 
void setInterruptOnTimeout (bool value)
 
int getInterruptStatus () const
 getInterruptStatus return the interrupt status. More...
 
void setInterruptStatus (int interrupt)
 setInterruptStatus set the interrupt status More...
 
void setOptions (const QVariantHash &dict)
 setOptions libav's AVDictionary. More...
 
QVariantHash options () const
 

Static Public Member Functions

static const QStringList & supportedFormats ()
 
static const QStringList & supportedExtensions ()
 
static const QStringList & supportedProtocols ()
 Supported ffmpeg/libav input protocols(not complete). A static string list. More...
 

Friends

class InterruptHandler
 

Member Enumeration Documentation

Enumerator
AudioStream 
VideoStream 
SubtitleStream 

Constructor & Destructor Documentation

QtAV::AVDemuxer::AVDemuxer ( QObject *  parent = 0)
QtAV::AVDemuxer::~AVDemuxer ( )

Member Function Documentation

bool QtAV::AVDemuxer::atEnd ( ) const
AVCodecContext* QtAV::AVDemuxer::audioCodecContext ( int  stream = -1) const
int QtAV::AVDemuxer::audioStream ( ) const
QList<int> QtAV::AVDemuxer::audioStreams ( ) const
int QtAV::AVDemuxer::bitRate ( ) const
int QtAV::AVDemuxer::currentStream ( StreamType  st) const
qint64 QtAV::AVDemuxer::duration ( ) const
qint64 QtAV::AVDemuxer::durationUs ( ) const
void QtAV::AVDemuxer::error ( const QtAV::AVError e)
signal
QString QtAV::AVDemuxer::fileName ( ) const
void QtAV::AVDemuxer::finished ( )
signal
AVFormatContext* QtAV::AVDemuxer::formatContext ( )
QString QtAV::AVDemuxer::formatForced ( ) const
QString QtAV::AVDemuxer::formatLongName ( ) const
QString QtAV::AVDemuxer::formatName ( ) const
qreal QtAV::AVDemuxer::frameRate ( ) const
qint64 QtAV::AVDemuxer::frames ( int  stream = -1) const
int QtAV::AVDemuxer::getInterruptStatus ( ) const

getInterruptStatus return the interrupt status.

Returns
-1: interrupted by user 0: not interrupted >0: timeout value of AVError::ErrorCode
qint64 QtAV::AVDemuxer::getInterruptTimeout ( ) const

getInterruptTimeout return the interrupt timeout

bool QtAV::AVDemuxer::hasAttacedPicture ( ) const
QIODevice* QtAV::AVDemuxer::ioDevice ( ) const
bool QtAV::AVDemuxer::isInterruptOnTimeout ( ) const
bool QtAV::AVDemuxer::isLoaded ( ) const
bool QtAV::AVDemuxer::isSeekable ( ) const
bool QtAV::AVDemuxer::load ( )
void QtAV::AVDemuxer::loaded ( )
signal
MediaIO* QtAV::AVDemuxer::mediaIO ( ) const

not null for QIODevice, custom protocols

MediaStatus QtAV::AVDemuxer::mediaStatus ( ) const
void QtAV::AVDemuxer::mediaStatusChanged ( QtAV::MediaStatus  status)
signal
QVariantHash QtAV::AVDemuxer::options ( ) const
Packet QtAV::AVDemuxer::packet ( ) const

packet return the packet read by demuxer.

packet is invalid if readFrame() returns false.

bool QtAV::AVDemuxer::readFrame ( )

readFrame Read a packet from 1 of the streams.

use packet() to get the result packet. packet() returns last valid packet. So do not use packet() if readFrame() failed. Call readFrame() and seek() in the same thread.

Returns
true if no error. false if error occurs, eof reaches, interrupted by user or time out(getInterruptTimeout())
bool QtAV::AVDemuxer::seek ( qint64  pos)

seek seek to a given position.

Only support timestamp seek now. Experiment: if pos is out of range (>duration()), do nothing unless a seekable and variableSize MediaIO is used.

Returns
false if fail
bool QtAV::AVDemuxer::seek ( qreal  q)

seek Percentage seek.

duration() must be >0LL

Parameters
q[0, 1] TODO: what if duration() is not valid but size is known?
void QtAV::AVDemuxer::seekableChanged ( )
signal
SeekType QtAV::AVDemuxer::seekType ( ) const
SeekUnit QtAV::AVDemuxer::seekUnit ( ) const
void QtAV::AVDemuxer::setFormat ( const QString &  fmt)

setFormat Force the input format.

Useful if input stream is a raw video stream(fmt="rawvideo). formatForced() is reset if media changed. So you have to call setFormat() for every media you want to force the format. If AVFormatContext.format_whitelist contains only 1 format, then that format will be forced. For example, setOptions({"format_whitelist": "rawvideo"})

void QtAV::AVDemuxer::setInterruptOnTimeout ( bool  value)
void QtAV::AVDemuxer::setInterruptStatus ( int  interrupt)

setInterruptStatus set the interrupt status

Parameters
interrupt<0: abort current operation like loading and reading packets. 0: no interrupt
void QtAV::AVDemuxer::setInterruptTimeout ( qint64  timeout)

setInterruptTimeout set the interrupt timeout

Parameters
timeoutin ms
bool QtAV::AVDemuxer::setMedia ( const QString &  fileName)

setMedia

Returns
whether the media source is changed
bool QtAV::AVDemuxer::setMedia ( QIODevice *  dev)
bool QtAV::AVDemuxer::setMedia ( MediaIO in)
void QtAV::AVDemuxer::setOptions ( const QVariantHash &  dict)

setOptions libav's AVDictionary.

we can ignore the flags used in av_dict_xxx because we can use hash api. empty value does nothing to current context if it is open, but will change AVDictionary options to null in next open. AVDictionary is used in avformat_open_input() and will not change unless user call setOptions() If an option is not found

void QtAV::AVDemuxer::setSeekType ( SeekType  target)
void QtAV::AVDemuxer::setSeekUnit ( SeekUnit  unit)
bool QtAV::AVDemuxer::setStreamIndex ( StreamType  st,
int  index 
)

setStreamIndex Set stream by index in stream list.

call it after loaded. Stream/index will not change in next load() unless media source changed index < 0 is invalid

void QtAV::AVDemuxer::started ( )
signal
qint64 QtAV::AVDemuxer::startTime ( ) const
qint64 QtAV::AVDemuxer::startTimeUs ( ) const
int QtAV::AVDemuxer::stream ( ) const

stream Current readFrame() readed stream index.

QList<int> QtAV::AVDemuxer::streams ( StreamType  st) const
AVCodecContext* QtAV::AVDemuxer::subtitleCodecContext ( int  stream = -1) const
int QtAV::AVDemuxer::subtitleStream ( ) const
QList<int> QtAV::AVDemuxer::subtitleStreams ( ) const
static const QStringList& QtAV::AVDemuxer::supportedExtensions ( )
static
static const QStringList& QtAV::AVDemuxer::supportedFormats ( )
static
static const QStringList& QtAV::AVDemuxer::supportedProtocols ( )
static

Supported ffmpeg/libav input protocols(not complete). A static string list.

bool QtAV::AVDemuxer::unload ( )
void QtAV::AVDemuxer::unloaded ( )
signal
void QtAV::AVDemuxer::userInterrupted ( )
signal
AVCodecContext* QtAV::AVDemuxer::videoCodecContext ( int  stream = -1) const
int QtAV::AVDemuxer::videoStream ( ) const
QList<int> QtAV::AVDemuxer::videoStreams ( ) const

Friends And Related Function Documentation

friend class InterruptHandler
friend

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