Phonon::StreamInterface

Search for usage in LXR

Phonon::StreamInterface Class Referenceabstract

#include <phonon/StreamInterface>

Public Member Functions

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

Protected Attributes

StreamInterfacePrivate *const d
 

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

Definition at line 55 of file streaminterface.h.

Constructor & Destructor Documentation

◆ ~StreamInterface()

Phonon::StreamInterface::~StreamInterface ( )
virtual

Definition at line 40 of file streaminterface.cpp.

◆ StreamInterface()

Phonon::StreamInterface::StreamInterface ( )
protected

Definition at line 34 of file streaminterface.cpp.

Member Function Documentation

◆ connectToSource()

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.

Definition at line 49 of file streaminterface.cpp.

◆ endOfData()

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

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

◆ enoughData()

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.

Definition at line 85 of file streaminterface.cpp.

◆ needData()

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.

Definition at line 78 of file streaminterface.cpp.

◆ reset()

void Phonon::StreamInterface::reset ( )

Resets the AbstractMediaStream.

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

Definition at line 101 of file streaminterface.cpp.

◆ seekStream()

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.

Definition at line 93 of file streaminterface.cpp.

◆ setStreamSeekable()

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

Tells whether the stream is seekable.

◆ setStreamSize()

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).

◆ writeData()

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.

Member Data Documentation

◆ d

StreamInterfacePrivate* const Phonon::StreamInterface::d
protected

Definition at line 128 of file streaminterface.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:53:29 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.