Rtsp server Deepstream integration

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU): dgpu rtx 4070ti
• DeepStream Version: 6.3
• JetPack Version (valid for Jetson only)
• TensorRT Version: 8.5
Hi @junshengy
SO, I have a scenario where I need to implement 20 deepstream anpr application. I have rtx 4090 server where i intend to deploy it. Now for each application the final osd needs to be restreamed for ui. I have acomplished it and I could see the results at rtsp://127.0.0.1:8554/ds-test .
Now, there are 20 such application and each application has a function that helps to get the job done:

static GstRTSPServer *server;
static gboolean
start_rtsp_streaming (guint rtsp_port_num, guint updsink_port_num,
                      guint64 udp_buffer_size)
{
    GstRTSPMountPoints *mounts;
    GstRTSPMediaFactory *factory;
    char udpsrc_pipeline[512];

    char port_num_Str[64] = { 0 };
    char *encoder_name;

    if (udp_buffer_size == 0)
        udp_buffer_size = 512 * 1024;

    sprintf (udpsrc_pipeline,
             "( udpsrc name=pay0 port=%d buffer-size=%lu caps=\"application/x-rtp, media=video, "
             "clock-rate=90000, encoding-name=H264, payload=96 \" )",
             updsink_port_num, udp_buffer_size);

    sprintf (port_num_Str, "%d", rtsp_port_num);

    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 ();
    gst_rtsp_media_factory_set_launch (factory, udpsrc_pipeline);

    gst_rtsp_mount_points_add_factory (mounts, "/ds-test", factory);

    g_object_unref (mounts);

    gst_rtsp_server_attach (server, NULL);

    g_print
            ("\n *** DeepStream: Launched RTSP Streaming at rtsp://localhost:%d/ds-test ***\n\n",
             rtsp_port_num);

    return TRUE;
}

Which is called as:

start_rtsp_streaming (port/*rtsp_port*/, udp_port, 0);

in the main. Now each time a new server is created as the function states server = gst_rtsp_server_new ();. Is this efficient? How to run an overall gstreamer rtspserver and publish deepstream osd on the same port but with different names like:

rtsp://127.0.0.1:8554/ds-test1
rtsp://127.0.0.1:8554/ds-test2
.
.rtsp://127.0.0.1:8554/ds-test20

Any help is highly appreciated!

This is just a gstreamer problem. Use gst_rtsp_mount_points_add_factory to modify the mount point. Here is a complete example

#include <gst/gst.h>
#include <gst/rtsp-server/rtsp-server.h>

#define NUM_STREAMS 20

int main(int argc, char *argv[]) {
  GMainLoop *loop;
  GstRTSPServer *server;
  GstRTSPMountPoints *mounts;
  GstRTSPMediaFactory *factory;
  gchar *launch_line;
  gchar *mount_point;

  gst_init(&argc, &argv);

  loop = g_main_loop_new(NULL, FALSE);

  server = gst_rtsp_server_new();
  g_object_set(server, "service", "8554", NULL);

  mounts = gst_rtsp_server_get_mount_points(server);

  for (int i = 0; i < NUM_STREAMS; i++) {
    factory = gst_rtsp_media_factory_new();

    launch_line = g_strdup_printf(
        "( videotestsrc pattern=%d ! video/x-raw,width=640,height=480 ! x264enc ! rtph264pay name=pay0 pt=96 )",
        i % 20);
    gst_rtsp_media_factory_set_launch(factory, launch_line);
    g_free(launch_line);

    gst_rtsp_media_factory_set_shared(factory, TRUE);

    mount_point = g_strdup_printf("/stream%d", i);
    gst_rtsp_mount_points_add_factory(mounts, mount_point, factory);
    g_free(mount_point);
  }

  g_object_unref(mounts);

  gst_rtsp_server_attach(server, NULL);

  g_print("RTSP server is running. Streams are available at:\n");
  for (int i = 0; i < NUM_STREAMS; i++) {
    g_print("rtsp://127.0.0.1:8554/stream%d\n", i);
  }

  g_main_loop_run(loop);

  return 0;
}
gcc -o rtsp_server rtsp_server.c `pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0`

Now you can play 20 rtsp streams

rtsp://127.0.0.1:8554/stream0
rtsp://127.0.0.1:8554/stream1
rtsp://127.0.0.1:8554/stream2
rtsp://127.0.0.1:8554/stream3
rtsp://127.0.0.1:8554/stream4
rtsp://127.0.0.1:8554/stream5
rtsp://127.0.0.1:8554/stream6
rtsp://127.0.0.1:8554/stream7
rtsp://127.0.0.1:8554/stream8
rtsp://127.0.0.1:8554/stream9
rtsp://127.0.0.1:8554/stream10
rtsp://127.0.0.1:8554/stream11
rtsp://127.0.0.1:8554/stream12
rtsp://127.0.0.1:8554/stream13
rtsp://127.0.0.1:8554/stream14
rtsp://127.0.0.1:8554/stream15
rtsp://127.0.0.1:8554/stream16
rtsp://127.0.0.1:8554/stream17
rtsp://127.0.0.1:8554/stream18
rtsp://127.0.0.1:8554/stream19

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.