I want to stream the video using RTSP, HTTP and UDP
as they are supported by vlc
. I am using Qt5
and as Qt
don't have that much good media libraries so I go for open source and now using libvlc
through VLC-Qt
wrapper.
I am able to receive the stream videos in my program, The source code for receiving the streaming video is given below
void player::on_actionNETWORK_STREAM_triggered()
{
QString url= QInputDialog::getText(this,tr("Open Url"),tr("Enter the URL you want to play"));
if(url.isEmpty())
return;
else
{
m_media=new VlcMedia(url,m_instance);
playlist.append(url);
m_mediaList->addMedia(m_media);
m_player->open(m_media);
}
}
To receive the streaming video I just put the url of that video into the new VlcMedia
instance but don't know how to stream a video.
While reading the documentation of the VLC-QT
wrapper I read that it have one class
named VlcVideoStream
but I am not getting how to use that class to do the streaming. The link of the documentation of this class
is given below
https://vlc-qt.tano.si/reference/1.1/classvlcvideostream
EDIT 1
I searched on the internet more about this thing then I found some discussion of how to use VlcVideoStream
and I have implemented the code for that. The source code is given below
class VideoStreaming : public VlcVideoStream
{
Q_OBJECT
public:
explicit VideoStreaming(QObject *parent = nullptr);
void frameUpdated();
};
void VideoStreaming::frameUpdated()
{
int rows,cols;
std::shared_ptr<const VlcAbstractVideoFrame> frame= renderFrame();
if (!frame)
return; // LCOV_EXCL_LINE
rows = frame->height + frame->height/2;
cols = frame->width;
qDebug()<<"Frame updated gets called";
}
and instantiate it with the following line
m_video_stream= new VideoStreaming(ui->m_video);
m_video_stream->init(m_player);
Now I am able to receive the YUV
frames of the video but don't know how to stream the video till now. Any help is appreciated. Even I am open to the pure libvlc
streaming solution as VLC-QT
wrapper is not that much good wrapper to support video streaming.