summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2018-02-28 21:12:43 +0200
committerSebastian Dröge <sebastian@centricular.com>2018-03-13 16:04:43 +0200
commitefbd933de7d5ceb8c45dd42b0ceb601beb3f241d (patch)
tree4cff4d4afeff559a42353039a26a1c5d28e5837d
parentd67e097c61f3c3ffd2a7dd338441c5b603b418e7 (diff)
rtsp-client: Place netaddress meta on packets received via TCP
This allows us to later map signals from rtpbin/rtpsource back to the corresponding stream transport, and allows to do keep-alive based on RTCP packets in case of TCP media transport. https://bugzilla.gnome.org/show_bug.cgi?id=789646
-rw-r--r--gst/rtsp-server/rtsp-client.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c
index 631add6..5bf3bba 100644
--- a/gst/rtsp-server/rtsp-client.c
+++ b/gst/rtsp-server/rtsp-client.c
@@ -3589,6 +3589,37 @@ handle_data (GstRTSPClient * client, GstRTSPMessage * message)
trans =
g_hash_table_lookup (priv->transports, GINT_TO_POINTER ((gint) channel));
if (trans) {
+ GSocketAddress *addr;
+
+ /* Only create the socket address once for the transport, we don't really
+ * want to do that for every single packet.
+ *
+ * The netaddress meta is later used by the RTP stack to know where
+ * packets came from and allows us to match it again to a stream transport
+ *
+ * In theory we could use the remote socket address of the RTSP connection
+ * here, but this would fail with a custom configure_client_transport()
+ * implementation.
+ */
+ if (!(addr =
+ g_object_get_data (G_OBJECT (trans), "rtsp-client.remote-addr"))) {
+ const GstRTSPTransport *tr;
+ GInetAddress *iaddr;
+
+ tr = gst_rtsp_stream_transport_get_transport (trans);
+ iaddr = g_inet_address_new_from_string (tr->destination);
+ if (iaddr) {
+ addr = g_inet_socket_address_new (iaddr, tr->client_port.min);
+ g_object_unref (iaddr);
+ g_object_set_data_full (G_OBJECT (trans), "rtsp-client.remote-addr",
+ addr, (GDestroyNotify) g_object_unref);
+ }
+ }
+
+ if (addr) {
+ gst_buffer_add_net_address_meta (buffer, addr);
+ }
+
/* dispatch to the stream based on the channel number */
GST_LOG_OBJECT (client, "%u bytes of data on channel %u", size, channel);
gst_rtsp_stream_transport_recv_data (trans, channel, buffer);