[Qt-interest] Using Phonon with a custom data source

Chris chris1.noreply at googlemail.com
Wed Jul 22 21:43:13 CEST 2009


I'm planning to use Phonon to display video from a DVR. Therefore I
need to write a custom interface for feeding the data to phonon. It
seems that there are two ways of doing it:

1. Subclass QIODevice and pass that to the Phonon::MediaSource constructor.
2. Subclass AbstractMediaStream and then do something (not sure what!)

AbstractMediaStream doesn't seem to be well documented, it's not
featured under doc.qtsoftware.com/4.5. I just stumbled across this
recommendation in a post by one of the phonon authors whilst googling
for ideas.

Subclassing QIODevice is giving me a few problems. My IODevice grabs
some video from the server and buffers it. I then tell phonon to play
and see what phonon is asking for. Phonon seems to request the
following from my custom QIODevice:

open - with flags QIODevice::NotOpen and QIODevice::ReadOnly - I return true.

size - I return the bytes of data I have buffered so far - e.g. 57188

isSequential - I return true (I don't want to deal with seeking yet,
just streaming live video)

reset - Why is it calling this?  Doesn't make sense for sequential
devices. Return true anyway.

reset - Again? Return true anyway

isSequential - Again? I return true anyway.

readData - with param maxSize=16384 - I write 16384 bytes to *data and
return 16384.

atEnd - in this case since phonon requested 16384 bytes and I have
57188 buffered, I return false.

After that I get no further requests from phonon.

So I guess my question is; am I right to subclass QIODevice or should
I look into AbstractMediaStream? If the QIODevice route is correct,
any idea what's wrong? If AbstractMediaStream is a better route, is
there any documentation or example code around? There doesn't seem to
be any mention of it on doc.qtsoftware.com and very little on the kde
site.

Thanks in advance, Chris.



More information about the Qt-interest-old mailing list