Setting up rtsp server using gstreamer?
krombopulus
ajaygajju96 at gmail.com
Fri Jul 3 08:31:28 UTC 2020
Hi, I've been trying to setup an rtsp server where I send images to this
server, here is my code,
#include <iostream>
#include <gst/rtsp-server/rtsp-server.h>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
using namespace std;
using namespace cv;
int main()
{
GstRTSPServer *server;
GstRTSPMountPoints *mounts;
GstRTSPMediaFactory *factory;
char port_num_Str[64] = { 0 };
char udpsrc_pipeline[512];
sprintf (port_num_Str, "%d", 8554);
server = gst_rtsp_server_new ();
g_object_set (server, "service", port_num_Str, NULL);
mounts = gst_rtsp_server_get_mount_points (server);
factory = gst_rtsp_media_factory_new ();
sprintf (udpsrc_pipeline,
"( udpsrc name=pay0 port=%d caps=\"application/x-rtp, media=video, "
"clock-rate=90000, encoding-name=JPEG, payload=26 \" )",
5000);
// gst-launch-1.0 -v udpsrc port=5000 \
// ! application/x-rtp, media=video, clock-rate=90000,
encoding-name=JPEG, payload=26 \
// ! rtpjpegdepay \
// ! jpegdec \
// ! xvimagesink sync=0
gst_rtsp_media_factory_set_launch (factory, udpsrc_pipeline);
gst_rtsp_mount_points_add_factory (mounts, "/test", factory);
g_object_unref (mounts);
gst_rtsp_server_attach (server, NULL);
VideoCapture cap("videotestsrc !
video/x-raw,format=BGR,width=640,height=480,framerate=30/1 !
appsink",CAP_GSTREAMER);
VideoWriter out("appsrc ! videoconvert !
video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! jpegenc !
rtpjpegpay ! udpsink host=127.0.0.1
port=5000",CAP_GSTREAMER,0,30,Size(640,480),true);
if(!cap.isOpened() || !out.isOpened())
{
cout<<"VideoCapture or VideoWriter not opened"<<endl;
exit(-1);
}
Mat frame;
while(true) {
cap.read(frame);
if(frame.empty())
break;
out.write(frame);
}
destroyWindow("Sender");
}
When I launch a pipeline which is in comments then I can see the port
receiving my frames but however when I try to attach this pipeline to the
server I don't see any frames from the server. Any help would be
appreciated. Thanks. I've looked at the sample code for setting up rtsp
server from github, it did not work.
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list