Phonon: play video from a buffer
-
Hello,
Here is the general idea of the projet:
- I read a video stream from a QUdpSocket
- I append the data to a buffer (actually to a QByteArray)
- I wait 10 seconds so that I have enough data in the buffer
- I set the buffer as a Phonon::MediaSource to be played by a Phonon::VideoPlayer
And here is the problem:
I would like to append data continuously to the buffer, and I want these data to be read by the VideoPlayer but the player plays well the first 10 seconds of the video and stops (while data are still added to the buffer from the QUdpSocket).How can I make the VideoPlayer read the continuously ?
Complementary info:
- The video stream is generated by vlc from a local file.
- When I set the local file directlty as a MediaSource (instead of the buffer), the player works correctly.
Some code:
@
datagram = new QByteArray();
bufferCam = new QBuffer(datagram);
...
udpSocket = new QUdpSocket(this);
udpSocket->bind(QHostAddress("10.1.153.126"), mSocket);
connect(udpSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
...
/* wait 10s */
player->mediaObject()->setCurrentSource(Phonon::MediaSource(bufferCam));
player->play();...
void VideoView::readPendingDatagrams() {
while (udpSocket->hasPendingDatagrams()) {
char *data = new char[udpSocket->pendingDatagramSize()];
QHostAddress sender;
quint16 senderPort;int len = udpSocket->readDatagram(data, udpSocket->pendingDatagramSize(), &sender, &senderPort); datagram->append(data, len); /* process data */ }
}
@I hope I gave you enough info so that you can help me. Thanks
excuse me if my english is bad