Phonon  4.7.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Public Member Functions | Protected Attributes | Friends | List of all members
Phonon::StreamInterface Class Referenceabstract

Backend interface to handle media streams (AbstractMediaStream). More...

#include <phonon/StreamInterface>

Public Member Functions

virtual void writeData (const QByteArray &data)=0
 
virtual void endOfData ()=0
 
virtual void setStreamSize (qint64 newSize)=0
 
virtual void setStreamSeekable (bool s)=0
 
void connectToSource (const MediaSource &mediaSource)
 
void needData ()
 
void enoughData ()
 
void seekStream (qint64 seekTo)
 
void reset ()
 

Protected Attributes

StreamInterfacePrivate *const d
 

Friends

class StreamInterfacePrivate
 
class AbstractMediaStreamPrivate
 

Detailed Description

Backend interface to handle media streams (AbstractMediaStream).

All functions relay their calls to the AbstractMediaStream using invokeMethod on the AbstractMediaStream's QMetaObject. This means that every function call will actually be executed in the thread context of the AbstractMediaStream (which usually is a thread Phonon also lives in, could however also be another one). This protectes the AbstractMediaStream against calls from different threads, such as a callback thread. This is very important as most IO implementations are by default not thread-safe.

This protection is only established in one direction though, meaning that a backend implementation of this interface must be made thread-safe at all costs as it can get called from any thread.

Author
Matthias Kretz kretz.nosp@m.@kde.nosp@m..org

Member Function Documentation

void Phonon::StreamInterface::connectToSource ( const MediaSource mediaSource)

Call this function from the constructor of your StreamInterface implementation (or as soon as you get the MediaSource object). This will connect your object to the AbstractMediaStream object. Only after the connection is done will the following functions have an effect.

virtual void Phonon::StreamInterface::endOfData ( )
pure virtual

Called when no more media data is available and writeData will not be called anymore.

void Phonon::StreamInterface::enoughData ( )

Call this function to tell the AbstractMediaStream that you have enough data in your buffer and that it should pause calling writeData if possible.

void Phonon::StreamInterface::needData ( )

Call this function to tell the AbstractMediaStream that you need more data. The data will arrive through writeData. writeData() will not be called from needData() due to the thread protection of the AbstractMediaStream.

Depending on the buffering you need you either treat needData as a replacement for a read call like QIODevice::read, or you start calling needData whenever your buffer reaches a certain lower threshold.

void Phonon::StreamInterface::reset ( )

Resets the AbstractMediaStream. E.g. this can be useful for non-seekable streams to start over again.

void Phonon::StreamInterface::seekStream ( qint64  seekTo)

If the stream is seekable, calling this function will make the next call to writeData pass data that starts at the byte offset seekTo.

virtual void Phonon::StreamInterface::setStreamSeekable ( bool  s)
pure virtual

Tells whether the stream is seekable.

virtual void Phonon::StreamInterface::setStreamSize ( qint64  newSize)
pure virtual

Called at the start of the stream to tell how many bytes will be sent through writeData (if no seeks happen, of course). If this value is negative the stream size cannot be determined (might be a "theoretically infinite" stream - like webradio).

virtual void Phonon::StreamInterface::writeData ( const QByteArray &  data)
pure virtual

Called by the application to send a chunk of (encoded) media data.

It is recommended to keep the QByteArray object until the data is consumed so that no memcopy is needed.


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