PDA

View Full Version : Video Stream, extending QIODevice



rextr
26th June 2008, 10:07
Hello,

I keep videos in oracle in BFILE (actually a pointer to video). Then I can reach the video binary stream from BFILE, using BFILE's getBinaryStream() function.

What I want to do is play this video in Qt, VideoPlayer. I see that, MediaSource object can get QIODevice as argument, so I think I should extend QIODevice.

Is there any example that I can examine how to subclass QIODevice? First of all, which functions do I have to override? How to implement readData() espacially?

Thanks in advance ...

mcosta
26th June 2008, 10:22
You can convert you binary data in QByteArray then use a QBuffer as source of Phonon::MediaSource

Example


QByteArray bArray(yourData, dataSize);
QBuffer buffer(&bArray);

player->load(MediaSource(&buffer));
player->play();

rextr
26th June 2008, 12:02
Thank you, I had tried that method, but it fails with 400mb vidoes. When I try with a 20 mb video, it plays the sound but there is no display.

Here is the code:


byte[] bytes = bfile.getBytes(1, (int)length);
QBuffer buffer = new QBuffer(new QByteArray(bytes));
source = new MediaSource(buffer);
player.play(source);
Even if this method works, it's still too slow since it needs all the video in memory before starting to play. That's why I need streaming. Thanks again for your interest...

rextr
27th June 2008, 08:55
Is there any way to achieve streaming with/without QIODevice?