rtsp: allocate channels in TCP mode
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 27 Jul 2009 17:42:44 +0000 (19:42 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 27 Jul 2009 17:42:44 +0000 (19:42 +0200)
When the client does not provide us with channels in TCP mode, allocate channels
ourselves.

gst/rtsp-server/rtsp-client.c
gst/rtsp-server/rtsp-session.c
gst/rtsp-server/rtsp-session.h

index 65217b9..c2986d4 100644 (file)
@@ -797,6 +797,14 @@ handle_setup_request (GstRTSPClient * client, GstRTSPUrl * uri,
   if (media == NULL)
     goto not_found;
 
+  /* fix the transports */
+  if (ct->lower_transport & GST_RTSP_LOWER_TRANS_TCP) {
+    /* check if the client selected channels for TCP */
+    if (ct->interleaved.min == -1 || ct->interleaved.max == -1) {
+      gst_rtsp_session_media_alloc_channels (media, &ct->interleaved);
+    }
+  }
+
   /* get a handle to the stream in the media */
   if (!(stream = gst_rtsp_session_media_get_stream (media, streamid)))
     goto no_stream;
@@ -1307,9 +1315,11 @@ message_received (GstRTSPWatch * watch, GstRTSPMessage * message,
 static GstRTSPResult
 message_sent (GstRTSPWatch * watch, guint cseq, gpointer user_data)
 {
-  GstRTSPClient *client = GST_RTSP_CLIENT (user_data);
+  GstRTSPClient *client;
+  
+  client = GST_RTSP_CLIENT (user_data);
 
-  g_message ("client %p: sent a message with cseq %d", client, cseq);
+  /* g_message ("client %p: sent a message with cseq %d", client, cseq); */
 
   return GST_RTSP_OK;
 }
index 3afd788..7525036 100644 (file)
@@ -323,6 +323,15 @@ no_media:
   }
 }
 
+gboolean
+gst_rtsp_session_media_alloc_channels (GstRTSPSessionMedia *media, GstRTSPRange *range)
+{
+  range->min = media->counter++;
+  range->max = media->counter++;
+
+  return TRUE;
+}
+
 /**
  * gst_rtsp_session_new:
  *
@@ -481,8 +490,7 @@ gst_rtsp_session_stream_set_transport (GstRTSPSessionStream *stream,
   st->lower_transport = ct->lower_transport;
   st->client_port = ct->client_port;
   st->interleaved = ct->interleaved;
-  st->server_port.min = stream->media_stream->server_port.min;
-  st->server_port.max = stream->media_stream->server_port.max;
+  st->server_port = stream->media_stream->server_port;
 
   /* keep track of the transports in the stream. */
   if (stream->trans.transport)
index 0074b55..5681667 100644 (file)
@@ -75,6 +75,9 @@ struct _GstRTSPSessionMedia
   /* the server state */
   GstRTSPState  state;
 
+  /* counter for channels */
+  guint         counter;
+
   /* configuration for the different streams */
   GArray       *streams;
 };
@@ -138,6 +141,9 @@ gboolean               gst_rtsp_session_media_set_state      (GstRTSPSessionMedi
 GstRTSPSessionStream * gst_rtsp_session_media_get_stream     (GstRTSPSessionMedia *media,
                                                               guint idx);
 
+gboolean               gst_rtsp_session_media_alloc_channels (GstRTSPSessionMedia *media,
+                                                              GstRTSPRange *range);
+
 /* configure transport */
 GstRTSPTransport *     gst_rtsp_session_stream_set_transport (GstRTSPSessionStream *stream,
                                                               GstRTSPTransport *ct);