Commit e4ea72cc authored by Wim Taymans's avatar Wim Taymans

stream: use the address managed by the stream

Use the address managed by the stream for multicast. This allows us to have 1
multicast address for each stream.
Because the address is now managed by the stream we don't have to pass it around
anymore.
Set the address pool on the streams.
parent ba21661c
......@@ -974,30 +974,22 @@ handle_blocksize (GstRTSPMedia * media, GstRTSPStream * stream,
static gboolean
configure_client_transport (GstRTSPClient * client, GstRTSPClientState * state,
GstRTSPTransport * ct, GstRTSPAddress ** addr)
GstRTSPTransport * ct)
{
/* we have a valid transport now, set the destination of the client. */
if (ct->lower_transport == GST_RTSP_LOWER_TRANS_UDP_MCAST) {
if (ct->destination == NULL || !client->use_client_settings) {
GstRTSPAddressPool *pool;
GstRTSPAddress *ad;
pool = gst_rtsp_media_get_address_pool (state->media);
if (pool == NULL)
goto no_pool;
GstRTSPAddress *addr;
ad = gst_rtsp_address_pool_acquire_address (pool,
GST_RTSP_ADDRESS_FLAG_EVEN_PORT, 2);
if (ad == NULL)
addr = gst_rtsp_stream_get_address (state->stream);
if (addr == NULL)
goto no_address;
g_free (ct->destination);
ct->destination = g_strdup (ad->address);
ct->port.min = ad->port;
ct->port.max = ad->port + 1;
ct->ttl = ad->ttl;
*addr = ad;
ct->destination = g_strdup (addr->address);
ct->port.min = addr->port;
ct->port.max = addr->port + addr->n_ports - 1;
ct->ttl = addr->ttl;
}
} else {
GstRTSPUrl *url;
......@@ -1017,14 +1009,9 @@ configure_client_transport (GstRTSPClient * client, GstRTSPClientState * state,
return TRUE;
/* ERRORS */
no_pool:
{
GST_ERROR_OBJECT (client, "no address pool specified");
return FALSE;
}
no_address:
{
GST_ERROR_OBJECT (client, "failed to acquire address from pool");
GST_ERROR_OBJECT (client, "failed to acquire address for stream");
return FALSE;
}
}
......@@ -1080,7 +1067,6 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
GstRTSPSessionMedia *sessmedia;
GstRTSPMedia *media;
GstRTSPStream *stream;
GstRTSPAddress *addr;
uri = state->uri;
......@@ -1169,12 +1155,11 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
goto invalid_blocksize;
/* update the client transport */
addr = NULL;
if (!configure_client_transport (client, state, ct, &addr))
if (!configure_client_transport (client, state, ct))
goto unsupported_client_transport;
/* set in the session media transport */
trans = gst_rtsp_session_media_set_transport (sessmedia, stream, ct, addr);
trans = gst_rtsp_session_media_set_transport (sessmedia, stream, ct);
/* configure keepalive for this transport */
gst_rtsp_stream_transport_set_keepalive (trans,
......
......@@ -595,6 +595,8 @@ gst_rtsp_media_set_address_pool (GstRTSPMedia * media,
media->pool = pool ? g_object_ref (pool) : NULL;
else
old = NULL;
g_ptr_array_foreach (media->streams, (GFunc) gst_rtsp_stream_set_address_pool,
pool);
g_mutex_unlock (&media->lock);
if (old)
......
......@@ -123,7 +123,6 @@ gst_rtsp_session_media_new (const GstRTSPUrl * url, GstRTSPMedia * media)
* @media: a #GstRTSPSessionMedia
* @stream: a #GstRTSPStream
* @tr: a #GstRTSPTransport
* @addr: (transfer full) (allow none): an optional #GstRTSPAddress
*
* Configure the transport for @stream to @tr in @media.
*
......@@ -131,7 +130,7 @@ gst_rtsp_session_media_new (const GstRTSPUrl * url, GstRTSPMedia * media)
*/
GstRTSPStreamTransport *
gst_rtsp_session_media_set_transport (GstRTSPSessionMedia * media,
GstRTSPStream * stream, GstRTSPTransport * tr, GstRTSPAddress * addr)
GstRTSPStream * stream, GstRTSPTransport * tr)
{
GstRTSPStreamTransport *result;
......@@ -142,11 +141,11 @@ gst_rtsp_session_media_set_transport (GstRTSPSessionMedia * media,
g_mutex_lock (&media->lock);
result = g_ptr_array_index (media->transports, stream->idx);
if (result == NULL) {
result = gst_rtsp_stream_transport_new (stream, tr, addr);
result = gst_rtsp_stream_transport_new (stream, tr);
g_ptr_array_index (media->transports, stream->idx) = result;
g_mutex_unlock (&media->lock);
} else {
gst_rtsp_stream_transport_set_transport (result, tr, addr);
gst_rtsp_stream_transport_set_transport (result, tr);
g_mutex_unlock (&media->lock);
}
......
......@@ -78,8 +78,7 @@ gboolean gst_rtsp_session_media_set_state (GstRTSPSessionMe
/* get stream transport config */
GstRTSPStreamTransport * gst_rtsp_session_media_set_transport (GstRTSPSessionMedia *media,
GstRTSPStream *stream,
GstRTSPTransport *tr,
GstRTSPAddress *addr);
GstRTSPTransport *tr);
GstRTSPStreamTransport * gst_rtsp_session_media_get_transport (GstRTSPSessionMedia *media,
guint idx);
......
......@@ -70,8 +70,6 @@ gst_rtsp_stream_transport_finalize (GObject * obj)
if (trans->transport)
gst_rtsp_transport_free (trans->transport);
if (trans->addr)
gst_rtsp_address_free (trans->addr);
#if 0
if (trans->rtpsource)
......@@ -85,7 +83,6 @@ gst_rtsp_stream_transport_finalize (GObject * obj)
* gst_rtsp_stream_transport_new:
* @stream: a #GstRTSPStream
* @tr: (transfer full): a GstRTSPTransport
* @addr: (transfer full) (allow none): an optional GstRTSPAddress
*
* Create a new #GstRTSPStreamTransport that can be used to manage
* @stream with transport @tr.
......@@ -93,8 +90,7 @@ gst_rtsp_stream_transport_finalize (GObject * obj)
* Returns: a new #GstRTSPStreamTransport
*/
GstRTSPStreamTransport *
gst_rtsp_stream_transport_new (GstRTSPStream * stream, GstRTSPTransport * tr,
GstRTSPAddress * addr)
gst_rtsp_stream_transport_new (GstRTSPStream * stream, GstRTSPTransport * tr)
{
GstRTSPStreamTransport *trans;
......@@ -104,7 +100,6 @@ gst_rtsp_stream_transport_new (GstRTSPStream * stream, GstRTSPTransport * tr,
trans = g_object_new (GST_TYPE_RTSP_STREAM_TRANSPORT, NULL);
trans->stream = stream;
trans->transport = tr;
trans->addr = addr;
return trans;
}
......@@ -159,14 +154,13 @@ gst_rtsp_stream_transport_set_keepalive (GstRTSPStreamTransport * trans,
* gst_rtsp_stream_transport_set_transport:
* @trans: a #GstRTSPStreamTransport
* @tr: (transfer full): a client #GstRTSPTransport
* @addr: (transfer full) (allow none): a ##GstRTSPAddress
*
* Set @tr and the optional @addr as the client transport. This function
* takes ownership of the passed @tr and @addr.
* Set @tr as the client transport. This function takes ownership of the
* passed @tr.
*/
void
gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport * trans,
GstRTSPTransport * tr, GstRTSPAddress * addr)
GstRTSPTransport * tr)
{
g_return_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans));
g_return_if_fail (tr != NULL);
......@@ -175,9 +169,6 @@ gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport * trans,
if (trans->transport)
gst_rtsp_transport_free (trans->transport);
trans->transport = tr;
if (trans->addr)
gst_rtsp_address_free (trans->addr);
trans->addr = addr;
}
/**
......
......@@ -81,7 +81,6 @@ struct _GstRTSPStreamTransport {
gboolean timeout;
GstRTSPTransport *transport;
GstRTSPAddress *addr;
GObject *rtpsource;
};
......@@ -93,12 +92,10 @@ struct _GstRTSPStreamTransportClass {
GType gst_rtsp_stream_transport_get_type (void);
GstRTSPStreamTransport * gst_rtsp_stream_transport_new (GstRTSPStream *stream,
GstRTSPTransport *tr,
GstRTSPAddress *addr);
GstRTSPTransport *tr);
void gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport *trans,
GstRTSPTransport * tr,
GstRTSPAddress *addr);
GstRTSPTransport * tr);
void gst_rtsp_stream_transport_set_callbacks (GstRTSPStreamTransport *trans,
GstRTSPSendFunc send_rtp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment