PDA

View Full Version : QIODevice: How to implement push streams over network like live-tv?



muellerp
24th July 2008, 13:59
Hi,

I'm developing a client for a video server (VDR) with Qt 4.4 using the phonon framework.

Phonon can use different media source types, one is QIODevice. As VDR / Vomp uses a custom network data protocol, I need to reimplement the data stream on my own.

It is quite clear how to derive from QIODevice, if I have a pull-mode:
Phonon-BE requests data, this goes to QIODevice and I implement the readData(...) accordingly which requests data from e.g. a QTcpSocket, in case of e.g. a file is streamed to the client. I call this a pull-stream.

Now I also want live-tv in the application - this is a push stream, the data just comes over the network.
Here I'm stuck how to do it correctly, as QIODevice has some docu what basically needs to be done, but not really any direct support for (AFAIHS so far).
I need to reimplement - when I emit the readyRead-Signal - the waitForReadyRead function - as well as readData(). To start the stream is clear as well as how to end it.

What I understood so far:
Now I need to buffer the data from the live stream, then emit the readyRead signal and afterwards let the IODevice read from my buffer with readData. In between the waitForReadyRead should give a wait condition till some data has arrived.

Am I'm correct so far?

Now the detailed questions from my side:
Is QIODevice the correct class to use as it doesn't have any support build into it directly for the streams?
QBuffer doesn't seem to be correct, as it would just have an increasing buffer and other classes I didn't find.
QTcpSocket I cannot use directly, as the readyRead() would be emitted all the time data arrives, but the protocol also needs to support e.g. "give me the list of channels".

Also on the web and all Qt forums I couldn't get any hint (at least one that fits to Qt 4.4, where QIODevice is in detail different from previous versions).

Also strange is that I found in the quellcode of QIODevice the buffering already implemented, even with a (non-public) ringbuffer class, which is more or less exactly what I need, but there is no way to use it from outside (it is for the internal buffering of the buffered mode).

Do you know any hint or is my assumption what I need to implement correct?

Thanks in advance,

Philipp

muellerp
25th July 2008, 18:54
I'm pushing it up now for the weekend traffic, but I have no hope anymore that someone can help me...:o