rtsp: Allow gst_rtsp_connection_do_tunnel() to just setup decoding context.
authorPeter Kjellerstedt <pkj@axis.com>
Tue, 16 Jun 2009 17:35:23 +0000 (19:35 +0200)
committerPeter Kjellerstedt <pkj@axis.com>
Mon, 24 Aug 2009 11:19:46 +0000 (13:19 +0200)
If the second connection passed to gst_rtsp_connection_do_tunnel() is NULL
then just setup the base64 decoding context for the first connection.

gst-libs/gst/rtsp/gstrtspconnection.c

index eee292d..e5eba85 100644 (file)
@@ -2858,7 +2858,7 @@ gst_rtsp_connection_get_tunnelid (const GstRTSPConnection * conn)
 /**
  * gst_rtsp_connection_do_tunnel:
  * @conn: a #GstRTSPConnection
- * @conn2: a #GstRTSPConnection
+ * @conn2: a #GstRTSPConnection or %NULL
  *
  * If @conn received the first tunnel connection and @conn2 received
  * the second tunnel connection, link the two connections together so that
@@ -2867,6 +2867,9 @@ gst_rtsp_connection_get_tunnelid (const GstRTSPConnection * conn)
  * After this call, @conn2 cannot be used anymore and must be freed with
  * gst_rtsp_connection_free().
  *
+ * If @conn2 is %NULL then only the base64 decoding context will be setup for
+ * @conn.
+ *
  * Returns: return GST_RTSP_OK on success.
  *
  * Since: 0.10.23
@@ -2876,26 +2879,28 @@ gst_rtsp_connection_do_tunnel (GstRTSPConnection * conn,
     GstRTSPConnection * conn2)
 {
   g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
-  g_return_val_if_fail (conn2 != NULL, GST_RTSP_EINVAL);
-  g_return_val_if_fail (conn->tstate == TUNNEL_STATE_GET, GST_RTSP_EINVAL);
-  g_return_val_if_fail (conn2->tstate == TUNNEL_STATE_POST, GST_RTSP_EINVAL);
-  g_return_val_if_fail (!memcmp (conn2->tunnelid, conn->tunnelid, TUNNELID_LEN),
-      GST_RTSP_EINVAL);
-
-  /* both connections have fd0 as the read/write socket. start by taking the
-   * socket from conn2 and set it as the socket in conn */
-  conn->fd1 = conn2->fd0;
-
-  /* clean up some of the state of conn2 */
-  gst_poll_remove_fd (conn2->fdset, &conn2->fd0);
-  conn2->fd0.fd = -1;
-  conn2->readfd = conn2->writefd = NULL;
-
-  /* We make fd0 the write socket and fd1 the read socket. */
-  conn->writefd = &conn->fd0;
-  conn->readfd = &conn->fd1;
 
-  conn->tstate = TUNNEL_STATE_COMPLETE;
+  if (conn2 != NULL) {
+    g_return_val_if_fail (conn->tstate == TUNNEL_STATE_GET, GST_RTSP_EINVAL);
+    g_return_val_if_fail (conn2->tstate == TUNNEL_STATE_POST, GST_RTSP_EINVAL);
+    g_return_val_if_fail (!memcmp (conn2->tunnelid, conn->tunnelid,
+            TUNNELID_LEN), GST_RTSP_EINVAL);
+
+    /* both connections have fd0 as the read/write socket. start by taking the
+     * socket from conn2 and set it as the socket in conn */
+    conn->fd1 = conn2->fd0;
+
+    /* clean up some of the state of conn2 */
+    gst_poll_remove_fd (conn2->fdset, &conn2->fd0);
+    conn2->fd0.fd = -1;
+    conn2->readfd = conn2->writefd = NULL;
+
+    /* We make fd0 the write socket and fd1 the read socket. */
+    conn->writefd = &conn->fd0;
+    conn->readfd = &conn->fd1;
+
+    conn->tstate = TUNNEL_STATE_COMPLETE;
+  }
 
   /* we need base64 decoding for the readfd */
   conn->ctx.state = 0;