GNOME Bugzilla – Bug 763313
gst-rtsp-server: matching of media fails when using different IPs/hostnames
Last modified: 2018-11-03 15:39:51 UTC
I forward the local port 8554 to port 3000 on my gateway. I can access the stream via LAN at: rtsp://192.168.0.1:8554/stream and I can access the stream via the internet at: rtsp://myurl:3000/stream I cannot access both streams at the same time. If the first client is attached on the LAN, I can only access the LAN stream and vice-versa. test case 1: LAN client and Internet client 0:00:06.711999431 10608 0x14167b0 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<rpicamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:06.713950395 10608 0x1416780 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<appsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:06.912338832 10608 0x13d2690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:07.046474422 10608 0x13d2690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:07.047287408 10608 0x13d2690 WARN rtspmedia rtsp-media.c:3451:gst_rtsp_media_suspend: media 0x13ff138 was not prepared 0:00:12.645305854 10608 0x13d2690 WARN rtspmedia rtsp-media.c:3712:gst_rtsp_media_set_state: media 0x13ff138 was not prepared 0:00:13.441799548 10608 0x1476af0 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<rpicamsrc1:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:13.443320520 10608 0x1476ac0 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<appsrc1:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:13.629415178 10608 0x129dd20 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:13.773946582 10608 0x129dd20 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:13.774754567 10608 0x129dd20 WARN rtspmedia rtsp-media.c:3451:gst_rtsp_media_suspend: media 0x13ff278 was not prepared >>> here attaches the second client from a different network <<< 0:00:23.922597300 10608 0x143d580 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<rpicamsrc2:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:23.924215271 10608 0x143d490 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<appsrc2:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id mmal: mmal_vc_component_enable: failed to enable component: ENOSPC 0:00:23.951330784 10608 0x143d580 ERROR rpicamsrc RaspiCapture.c:1241:raspi_capture_set_format_and_start: camera component couldn't be enabled 0:00:23.957637671 10608 0x143d580 WARN basesrc gstbasesrc.c:2948:gst_base_src_loop:<rpicamsrc2> error: Internal data flow error. 0:00:23.958480656 10608 0x143d580 WARN basesrc gstbasesrc.c:2948:gst_base_src_loop:<rpicamsrc2> error: streaming task paused, reason error (-5) 0:00:23.960889613 10608 0x145f690 WARN rtspmedia rtsp-media.c:2278:default_handle_message: 0x13ff3b8: got error Internal data flow error. (gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:bin2/GstRpiCamSrc:rpicamsrc2: streaming task paused, reason error (-5)) 0:00:23.963292570 10608 0x129dd20 WARN rtspmedia rtsp-media.c:2573:wait_preroll: failed to preroll pipeline 0:00:23.964245552 10608 0x129dd20 WARN rtspmedia rtsp-media.c:2877:gst_rtsp_media_prepare: failed to preroll pipeline 0:00:24.007065783 10608 0x129dd20 ERROR rtspclient rtsp-client.c:763:find_media: client 0x1312c60: can't prepare media 0:00:24.011692700 10608 0x129dd20 ERROR rtspclient rtsp-client.c:2286:handle_describe_request: client 0x1312c60: no media test case 2: 2 LAN clients 0:00:06.180315159 10665 0x2107b0 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<rpicamsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:06.182136126 10665 0x210780 FIXME default gstutils.c:3764:gst_pad_create_stream_id_internal:<appsrc0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:06.377422624 10665 0x1cc690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:06.383724511 10665 0x1cc690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:06.384523497 10665 0x1cc690 WARN rtspmedia rtsp-media.c:3451:gst_rtsp_media_suspend: media 0x1f9138 was not prepared >>> here it comes the second client from the same network <<< 0:00:10.797286359 10665 0x1cc690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:10.803551247 10665 0x1cc690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:17.166038147 10665 0x1cc690 FIXME rtspmedia rtsp-media.c:3425:gst_rtsp_media_suspend: suspend for dynamic pipelines needs fixing 0:00:17.242016784 10665 0x1cc690 WARN rtspmedia rtsp-media.c:3712:gst_rtsp_media_set_state: media 0x1f9138 was not prepared
You haven't set your pipeline as shared, so the second client triggers an attempt to open the camera a second time, which fails. Use gst_rtsp_media_factory_set_shared (factory, TRUE); in your server app.
Hello Jan! From my server app: /* share media with more than one client */ gst_rtsp_media_factory_set_shared (factory, TRUE); and it works! I can access with a second, third, fourth client but only from the same network of the first one accessing the stream. I'm afraid this is not the problem in this issue.
The problem is probably matching the URI/path when a new client connects. It probably looks at the hostname part too, and then doesn't find a media for it.
It looks like that the problematic part is the service port. If I keep '8554' on both sides of the tunnel, I can access the stream locally and remotely.
gst-rtsp-server/gst/rtsp-server/rtsp-media-factory.c +1278 static gchar * default_gen_key (GstRTSPMediaFactory * factory, const GstRTSPUrl * url) { gchar *result; const gchar *pre_query; const gchar *query; guint16 port; pre_query = url->query ? "?" : ""; query = url->query ? url->query : ""; gst_rtsp_url_get_port (url, &port); result = g_strdup_printf ("%u%s%s%s", port, url->abspath, pre_query, query); return result; } Why result is composed using the port? This actually causes the problem. result = g_strdup_printf ("%s%s%s", url->abspath, pre_query, query); Fixes it. Is it safe?
Created attachment 344792 [details] [review] Proposed patch
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/issues/21.