Results 1 to 1 of 1

Thread: How to get Video plugged to MY PC via the Network socket

  1. #1
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default How to get Video plugged to MY PC via the Network socket

    I got a camera, plugged to my PC via the network socket. I do not know how to set the source stream!

    this is the code I wrote before to set the source of a file and play video,

    Qt Code:
    1. void PlayVideo::rollOn()
    2. {
    3.  
    4. media = new Phonon::MediaObject(movieLabel);
    5. media->setCurrentSource(Phonon::MediaSource(QString("/home/saman/4.7/phonon_test/sample.mp4")));
    6. //media->setCurrentSource (Phonon::MediaSource());
    7. videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);
    8. videoPlayer->setFixedSize(QSize(400, 300));
    9. videoPlayer->show();
    10.  
    11. connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
    12. videoPlayer->play(media->currentSource());
    13. }
    To copy to clipboard, switch view to plain text mode 

    could anyone tell me how to change the source stream so that I can get video via
    network socket?

    this is the sample code of getting packet via network, i don't know how to buffer the received data
    and send it as a source stream to phonon video.

    Qt Code:
    1. void PlayVideo::rollOn()
    2. {
    3.  
    4. udpSocketin = new QUdpSocket(this);
    5.  
    6. udpSocketin->bind(localPort);
    7.  
    8. connect(udpSocketin, SIGNAL(readyRead()),this, SLOT(readDatagrams()));
    9.  
    10. QDataStream out(&datagramout, QIODevice::WriteOnly);
    11.  
    12. out.setVersion (QDataStream::Qt_4_7);
    13.  
    14. timer2 = new QTimer(this);
    15.  
    16. connect(timer2, SIGNAL(timeout()), this, SLOT(playbuff()));
    17.  
    18. media = new Phonon::MediaObject(movieLabel);
    19.  
    20. media->setCurrentSource(Phonon::MediaSource(QString("/home/saman/4.7/phonon_test/sample.mp4")));
    21.  
    22. //media->setCurrentSource (Phonon::MediaSource());
    23.  
    24. videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, movieLabel);
    25.  
    26. videoPlayer->setFixedSize(QSize(400, 300));
    27.  
    28. videoPlayer->show();
    29.  
    30. connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
    31.  
    32. videoPlayer->play(media->currentSource());
    33. }
    34.  
    35. void PlayVideo::readDatagrams()
    36. {
    37. if(udpSocketin->hasPendingDatagrams ())
    38. {
    39. datagramin.resize (udpSocketin->pendingDatagramSize ());
    40.  
    41. qint64 receiveBytes = udpSocketin->readDatagram (datagramin.data (), datagramin.size ());
    42.  
    43. if(receivedBytes <= 0)
    44. {
    45. qDebug("receivedBytes <= 0");
    46. }
    47. }
    48. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by saman_artorious; 12th August 2012 at 10:45. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 22nd July 2011, 12:22
  2. Replies: 2
    Last Post: 22nd May 2011, 21:31
  3. network client socket without using signals and slots
    By erqsor in forum Qt Programming
    Replies: 7
    Last Post: 24th March 2011, 09:28
  4. Network Socket Programming
    By Walsi in forum Newbie
    Replies: 4
    Last Post: 19th June 2007, 10:04

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.