PDA

View Full Version : Phonon AbstractMediaStream



kodiak
29th January 2009, 13:55
I am trying to play audio data incoming by QUdpSocket. I use Phonon::AbstractMediaStream with Phonon::MediaSource, but AbstractMediaStream::needData is never called. I do not know what I do wrong.

thanks for advices!

Regards,
Michal

muellerp
29th January 2009, 19:08
Which backend are you using?

Only Xine-backend supports the AbstractMediaStream (AMS) class (as implemented by Matthias Kretz).

The backends DS9, GStreamer and QT were implemented by Qt and the trolls decided to not support AbstractMediaStream - you don't find this class in Qt docu, but in Phonon docu.

Qt told me that they will look into it again with 4.6 version.

All my tests with DS9 and GStreamer confirmed the issue.

In case you are already using Xine backend, please also show the MediaObject call.
Do you call e.g. mymediaobject->play()?

Update:
Your implementation:
- You may be writing to AMS before needData was called. You shouldn't do that.
- NeedData may be called but your buffer maybe empty (here GStreamer has the issue), so you write 0 bytes to AMS. Also bad - Xine can handle it, afaicr. Ensure that you write something or it is the end of the stream.
- You can now use xine-backend without KDE dependencies out of the KDE4.2 phonon release

If you are dependend on GStreamer you can only implement your own QIODevice then for asynchronous datastream (wich I needed to do at the end as proposed by the trolls).
I know: For asynchronous datastreams, AMS is so much easier to handle than implementing your own QIODevice.

kodiak
29th January 2009, 21:40
I use DirectSound9. So AbstractMediaStream is not suitable for me. Thanks for that.

If I understood well, the only solution is to write my own implementation of sequential mode QIOdevice class. Could it work depending on DirectSound9 as well as on Linux native audio interface?

Is there some example of such implementation? Could you provide some link to example or tutorial?

muellerp
30th January 2009, 04:49
Just out of curiosity:
The UDP socket you have is a QIODevice already.
Why don't you use it for the medioobject as source?

You only need to implement your own QIODevice for the case (like me) where you have a custom format.
I assume you have the native media data in your UDP stream that you anyway just want to pass to Phonon.

If this doesn't work:
Qt is cross platform and it should work on all platforms.
The only thing not guaranteed is that some media formats are only supported by some phonon backends. E.g. Xine can really play everything out of the box while for DS9 you may first need to install some codecs and for gstreamer or QT it may not exist. But bread and butter formats are working on all backends.
As an example: Just use the Qt sources as I did (all classes that are derived from qiodevice). I wouldn't say that my code is good enough as an example to look in, but if you want - look for QtVomp in google. The class is iostream.

kodiak
2nd February 2009, 07:32
I have tried to use QUdpSocket as a source. Unfortunately it does not work in my configuration. Phonon::MediaObject get error state.

I will migrate to msvc 2008 and hope it will help. What do you think? Trolltech docs stands that there should be msvs 2008 used to compile phonon. I will write in this thread results of my environment upgrade.

Thanks for your QIODevice implementation. I will try to write my own if upgrade does not help.

muellerp
2nd February 2009, 13:32
I have tried to use QUdpSocket as a source. Unfortunately it does not work in my configuration. Phonon::MediaObject get error state.

I will migrate to msvc 2008 and hope it will help. What do you think? Trolltech docs stands that there should be msvs 2008 used to compile phonon. I will write in this thread results of my environment upgrade.

Thanks for your QIODevice implementation. I will try to write my own if upgrade does not help.

I don't think 2008 instead of 2005 will make a big difference.

Please try if Phonon understands your format:
1) Take the stream and store it "as is" in a file
2) Open the file with the phonon demo or example player
If it plays with one of these players then it is not a Phonon issue.

I assume it is rather the issue with how you are passing the data to phonon. Phonon is state based and asynchronous. So you cannot assume that e.g. once you have called mediaobject->play() it is already playing. It is only playing when stateChanged is called with new state playing.

What states is phonon getting in? Buffering, loading, playing... before it gets into error state?

kodiak
2nd February 2009, 14:28
Phonon understand format very well. If I store incoming datagrams in QByteArray and than pass to phonon through QBuffer => QMediaSource then it plays good, but not streaming. I did some simple implenetation of QIODevice reading directly from file and it also works if ::isSequential method returns false. If ::isSequential returns true, the media object gets ErrorState.

MediaObject::stateChanged is emited only once: LoadingState => ErrorState