client: store TCP ports in transport
authorWim Taymans <wtaymans@redhat.com>
Tue, 20 May 2014 13:57:30 +0000 (15:57 +0200)
committerWim Taymans <wtaymans@redhat.com>
Tue, 20 May 2014 13:57:30 +0000 (15:57 +0200)
Store the TCP ports in the transport when we are doing RTSP over TCP.
This way, we can easily get to the ports from the transport.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=729776

gst/rtsp-server/rtsp-client.c

index d16eee0..fb44a29 100644 (file)
@@ -1394,6 +1394,33 @@ default_configure_client_transport (GstRTSPClient * client,
     ct->destination = g_strdup (url->host);
 
     if (ct->lower_transport & GST_RTSP_LOWER_TRANS_TCP) {
+      GSocket *sock;
+      GSocketAddress *addr;
+
+      sock = gst_rtsp_connection_get_read_socket (priv->connection);
+      if ((addr = g_socket_get_remote_address (sock, NULL))) {
+        /* our read port is the sender port of client */
+        ct->client_port.min =
+            g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
+        g_object_unref (addr);
+      }
+      if ((addr = g_socket_get_local_address (sock, NULL))) {
+        ct->server_port.max =
+            g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
+        g_object_unref (addr);
+      }
+      sock = gst_rtsp_connection_get_write_socket (priv->connection);
+      if ((addr = g_socket_get_remote_address (sock, NULL))) {
+        /* our write port is the receiver port of client */
+        ct->client_port.max =
+            g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
+        g_object_unref (addr);
+      }
+      if ((addr = g_socket_get_local_address (sock, NULL))) {
+        ct->server_port.min =
+            g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
+        g_object_unref (addr);
+      }
       /* check if the client selected channels for TCP */
       if (ct->interleaved.min == -1 || ct->interleaved.max == -1) {
         gst_rtsp_session_media_alloc_channels (ctx->sessmedia,
@@ -1449,6 +1476,8 @@ make_server_transport (GstRTSPClient * client, GstRTSPContext * ctx,
       break;
     case GST_RTSP_LOWER_TRANS_TCP:
       st->interleaved = ct->interleaved;
+      st->client_port = ct->client_port;
+      st->server_port = ct->server_port;
     default:
       break;
   }