Results 1 to 4 of 4

Thread: Video Stream, extending QIODevice

  1. #1
    Join Date
    Apr 2008
    Posts
    4

    Default Video Stream, extending QIODevice

    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 ...

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Video Stream, extending QIODevice

    You can convert you binary data in QByteArray then use a QBuffer as source of Phonon::MediaSource
    Example
    Qt Code:
    1. QByteArray bArray(yourData, dataSize);
    2. QBuffer buffer(&bArray);
    3.  
    4. player->load(MediaSource(&buffer));
    5. player->play();
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Apr 2008
    Posts
    4

    Default Re: Video Stream, extending QIODevice

    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:

    Qt Code:
    1. byte[] bytes = bfile.getBytes(1, (int)length);
    2. QBuffer buffer = new QBuffer(new QByteArray(bytes));
    3. source = new MediaSource(buffer);
    4. player.play(source);
    To copy to clipboard, switch view to plain text mode 
    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...

  4. #4
    Join Date
    Apr 2008
    Posts
    4

    Default Re: Video Stream, extending QIODevice

    Is there any way to achieve streaming with/without QIODevice?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.