rtsp: Allow gst_rtsp_connection_do_tunnel() to just setup decoding context.

If the second connection passed to gst_rtsp_connection_do_tunnel() is NULL
then just setup the base64 decoding context for the first connection.
This commit is contained in:
Peter Kjellerstedt 2009-06-16 19:35:23 +02:00
parent 01d98fdb5d
commit d5b4b5d8af

View file

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