Gstreamer:如何更改 RTSP 端口?

Gstreamer: How to change RTSP port?

我正在尝试通过 test-mp4 使用 gst-rtsp-server 示例来创建 RTSP 服务器。 该示例有效,但我需要将基本 8554 端口更改为另一个端口。

我检查了 test-record.c 示例,我们可以在其中看到:

#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);

但最后我无法理解如何更改 test-mp4 示例中的端口。如果您告诉我解决方法,我将不胜感激.. 提前致谢!

最后我找到了解决办法: 有必要添加这些行:

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