Skip to content

Commit

Permalink
Add rtsp server patch
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Jan 17, 2025
1 parent 4610a71 commit 1e8fccd
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
70 changes: 70 additions & 0 deletions scripts/gst-rtsp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
diff --git a/examples/test-video.c b/examples/test-video.c
index 087da08..ec4d550 100644
--- a/examples/test-video.c
+++ b/examples/test-video.c
@@ -17,6 +17,7 @@
* Boston, MA 02110-1301, USA.
*/

+#include <stdio.h>
#include <gst/gst.h>

#include <gst/rtsp-server/rtsp-server.h>
@@ -61,9 +62,18 @@ main (int argc, char *argv[])
GTlsCertificate *cert;
GError *error = NULL;
#endif
+ int mode;
+ char buf[2048];

gst_init (&argc, &argv);
+
+ if(argc != 2 || (strcmp(argv[1], "h264") != 0 && strcmp(argv[1], "h265") != 0))
+ {
+ fprintf(stderr, "Usage: %s (h264 | h265)\n", argv[0]);
+ exit(1);
+ }

+ mode = atoi(argv[1] + 1);
loop = g_main_loop_new (NULL, FALSE);

/* create a server instance */
@@ -127,11 +137,12 @@ main (int argc, char *argv[])
* any launch line works as long as it contains elements named pay%d. Each
* element with pay%d names will be a stream */
factory = gst_rtsp_media_factory_new ();
- gst_rtsp_media_factory_set_launch (factory, "( "
- "videotestsrc ! video/x-raw,width=352,height=288,framerate=15/1 ! "
- "x264enc ! rtph264pay name=pay0 pt=96 "
- "audiotestsrc ! audio/x-raw,rate=8000 ! "
- "alawenc ! rtppcmapay name=pay1 pt=97 " ")");
+ snprintf(buf, sizeof(buf), "( "
+ "udpsrc port=5600 ! application/x-rtp,media=video,clock-rate=90000,encoding-name=H%d ! rtph%ddepay ! rtph%dpay name=pay0 pt=96 "
+ ")", mode, mode, mode);
+ gst_rtsp_media_factory_set_launch (factory, buf);
+
+ gst_rtsp_media_factory_set_shared (factory, TRUE);
#ifdef WITH_AUTH
/* add permissions for the user media role */
permissions = gst_rtsp_permissions_new ();
@@ -146,7 +157,7 @@ main (int argc, char *argv[])
#endif

/* attach the test factory to the /test url */
- gst_rtsp_mount_points_add_factory (mounts, "/test", factory);
+ gst_rtsp_mount_points_add_factory (mounts, "/wfb", factory);

/* don't need the ref to the mapper anymore */
g_object_unref (mounts);
@@ -160,9 +171,9 @@ main (int argc, char *argv[])

/* start serving, this never stops */
#ifdef WITH_TLS
- g_print ("stream ready at rtsps://127.0.0.1:8554/test\n");
+ g_print ("H%d stream ready at rtsps://127.0.0.1:8554/wfb\n", mode);
#else
- g_print ("stream ready at rtsp://127.0.0.1:8554/test\n");
+ g_print ("H%d stream ready at rtsp://127.0.0.1:8554/wfb\n", mode);
#endif
g_main_loop_run (loop);

14 changes: 14 additions & 0 deletions scripts/systemd/rtsp@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=WFB-ng %i RTSP server
After=network-online.target

[Service]
ExecStart=/usr/bin/wfb-rtsp-server %i
Type=simple
Restart=always
RestartSec=1s
TimeoutStopSec=10s
KillMode=control-group

[Install]
WantedBy=multi-user.target

0 comments on commit 1e8fccd

Please sign in to comment.