Search code examples
gstreamerrtsp

Gstreamer: How to change RTSP port?


I'm trying to create RTSP server by test-mp4 usage from gst-rtsp-server example. The example works, but I need to change basic 8554 port to another.

I checked the test-record.c example, where we can see:

#define DEFAULT_RTSP_PORT "8554"
static char *port = (char *) DEFAULT_RTSP_PORT;
...
static GOptionEntry entries[] = {
  {"port", 'p', 0, G_OPTION_ARG_STRING, &port,
      "Port to listen on (default: " DEFAULT_RTSP_PORT ")", "PORT"},
  {NULL}
};

optctx = g_option_context_new ("<launch line> - Test RTSP Server, Launch\n\n"
      "Example: \"( decodebin name=depay0 ! autovideosink )\"");

g_option_context_add_main_entries (optctx, entries, NULL);

But finally I can't understand how to change the port in test-mp4 example. I'll be appreciated if you tell me a way for the solution.. Thanks in advance!


Solution

  • Finally I found the solution: It's necessary to add these lines:

    .....
    char *port = (char *) argv[2]; //argv[<X>] is a port - an input argument
    g_object_set (server, "service", port, NULL);
    ....