Phonon::StreamInterface
#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.
Definition at line 55 of file streaminterface.h.
Constructor & Destructor Documentation
◆ ~StreamInterface()
|
virtual |
Definition at line 40 of file streaminterface.cpp.
◆ 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()
|
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()
|
pure virtual |
Tells whether the stream is seekable.
◆ setStreamSize()
|
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()
|
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
|
protected |
Definition at line 128 of file streaminterface.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.