mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
rtsp: only create transport when needed
Only create the StreamTransport when configured.
This commit is contained in:
parent
66a29c7ed9
commit
543aa383e7
5 changed files with 56 additions and 38 deletions
|
@ -537,12 +537,13 @@ unlink_session_transports (GstRTSPClient * client, GstRTSPSession * session,
|
|||
GstRTSPStreamTransport *trans;
|
||||
GstRTSPTransport *tr;
|
||||
|
||||
/* get the stream as configured in the session */
|
||||
trans = gst_rtsp_session_media_get_transport (media, i);
|
||||
/* get the transport, if there is no transport configured, skip this stream */
|
||||
if (!(tr = trans->transport))
|
||||
trans = gst_rtsp_session_media_get_transport (media, i);
|
||||
if (trans == NULL)
|
||||
continue;
|
||||
|
||||
tr = trans->transport;
|
||||
|
||||
if (tr->lower_transport == GST_RTSP_LOWER_TRANS_TCP) {
|
||||
/* for TCP, unlink the stream from the TCP connection of the client */
|
||||
unlink_transport (client, session, trans);
|
||||
|
@ -815,13 +816,13 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
|
|||
gchar *uristr;
|
||||
guint rtptime, seq;
|
||||
|
||||
/* get the stream as configured in the session */
|
||||
trans = gst_rtsp_session_media_get_transport (media, i);
|
||||
/* get the transport, if there is no transport configured, skip this stream */
|
||||
if (!(tr = trans->transport)) {
|
||||
trans = gst_rtsp_session_media_get_transport (media, i);
|
||||
if (trans == NULL) {
|
||||
GST_INFO ("stream %d is not configured", i);
|
||||
continue;
|
||||
}
|
||||
tr = trans->transport;
|
||||
|
||||
if (tr->lower_transport == GST_RTSP_LOWER_TRANS_TCP) {
|
||||
/* for TCP, link the stream to the TCP connection of the client */
|
||||
|
@ -1153,8 +1154,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
|
|||
configure_client_transport (client, state, ct);
|
||||
|
||||
/* set in the session media transport */
|
||||
trans = gst_rtsp_session_media_get_transport (sessmedia, streamid);
|
||||
gst_rtsp_stream_transport_set_transport (trans, ct);
|
||||
trans = gst_rtsp_session_media_set_transport (sessmedia, stream, ct);
|
||||
|
||||
/* configure keepalive for this transport */
|
||||
gst_rtsp_stream_transport_set_keepalive (trans,
|
||||
|
|
|
@ -116,12 +116,42 @@ gst_rtsp_session_media_new (const GstRTSPUrl * url, GstRTSPMedia * media)
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_session_media_set_transport:
|
||||
* @media: a #GstRTSPSessionMedia
|
||||
* @stream: a #GstRTSPStream
|
||||
* @tr: a #GstRTSPTransport
|
||||
*
|
||||
* Configure the transport for @stream to @tr in @media.
|
||||
*
|
||||
* Returns: the new or updated #GstRTSPStreamTransport for @stream.
|
||||
*/
|
||||
GstRTSPStreamTransport *
|
||||
gst_rtsp_session_media_set_transport (GstRTSPSessionMedia * media,
|
||||
GstRTSPStream * stream, GstRTSPTransport * tr)
|
||||
{
|
||||
GstRTSPStreamTransport *result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_RTSP_SESSION_MEDIA (media), NULL);
|
||||
g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), NULL);
|
||||
g_return_val_if_fail (stream->idx < media->transports->len, NULL);
|
||||
|
||||
result = g_ptr_array_index (media->transports, stream->idx);
|
||||
if (result == NULL) {
|
||||
result = gst_rtsp_stream_transport_new (stream, tr);
|
||||
g_ptr_array_index (media->transports, stream->idx) = result;
|
||||
} else {
|
||||
gst_rtsp_stream_transport_set_transport (result, tr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_session_media_get_transport:
|
||||
* @media: a #GstRTSPSessionMedia
|
||||
* @idx: the stream index
|
||||
*
|
||||
* Get a previously created or create a new #GstRTSPStreamTransport at @idx.
|
||||
* Get a previously created #GstRTSPStreamTransport for the stream at @idx.
|
||||
*
|
||||
* Returns: a #GstRTSPStreamTransport that is valid until the session of @media
|
||||
* is unreffed.
|
||||
|
@ -132,30 +162,11 @@ gst_rtsp_session_media_get_transport (GstRTSPSessionMedia * media, guint idx)
|
|||
GstRTSPStreamTransport *result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_RTSP_SESSION_MEDIA (media), NULL);
|
||||
g_return_val_if_fail (media->media != NULL, NULL);
|
||||
|
||||
if (idx >= media->transports->len)
|
||||
return NULL;
|
||||
g_return_val_if_fail (idx < media->transports->len, NULL);
|
||||
|
||||
result = g_ptr_array_index (media->transports, idx);
|
||||
if (result == NULL) {
|
||||
GstRTSPStream *stream;
|
||||
|
||||
stream = gst_rtsp_media_get_stream (media->media, idx);
|
||||
if (stream == NULL)
|
||||
goto no_media;
|
||||
|
||||
result = gst_rtsp_stream_transport_new (stream);
|
||||
|
||||
g_ptr_array_index (media->transports, idx) = result;
|
||||
}
|
||||
return result;
|
||||
|
||||
/* ERRORS */
|
||||
no_media:
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,6 +75,9 @@ gboolean gst_rtsp_session_media_set_state (GstRTSPSessionMe
|
|||
GstState state);
|
||||
|
||||
/* get stream transport config */
|
||||
GstRTSPStreamTransport * gst_rtsp_session_media_set_transport (GstRTSPSessionMedia *media,
|
||||
GstRTSPStream *stream,
|
||||
GstRTSPTransport *tr);
|
||||
GstRTSPStreamTransport * gst_rtsp_session_media_get_transport (GstRTSPSessionMedia *media,
|
||||
guint idx);
|
||||
|
||||
|
|
|
@ -82,21 +82,24 @@ gst_rtsp_stream_transport_finalize (GObject * obj)
|
|||
/**
|
||||
* gst_rtsp_stream_transport_new:
|
||||
* @stream: a #GstRTSPStream
|
||||
* @tr: (transfer full): a GstRTSPTransport
|
||||
*
|
||||
* Create a new #GstRTSPStreamTransport that can be used to manage
|
||||
* @stream.
|
||||
* @stream with transport @tr.
|
||||
*
|
||||
* Returns: a new #GstRTSPStreamTransport
|
||||
*/
|
||||
GstRTSPStreamTransport *
|
||||
gst_rtsp_stream_transport_new (GstRTSPStream * stream)
|
||||
gst_rtsp_stream_transport_new (GstRTSPStream * stream, GstRTSPTransport * tr)
|
||||
{
|
||||
GstRTSPStreamTransport *trans;
|
||||
|
||||
g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), NULL);
|
||||
g_return_val_if_fail (tr != NULL, NULL);
|
||||
|
||||
trans = g_object_new (GST_TYPE_RTSP_STREAM_TRANSPORT, NULL);
|
||||
trans->stream = stream;
|
||||
trans->transport = tr;
|
||||
|
||||
return trans;
|
||||
}
|
||||
|
@ -150,20 +153,20 @@ gst_rtsp_stream_transport_set_keepalive (GstRTSPStreamTransport * trans,
|
|||
/**
|
||||
* gst_rtsp_stream_transport_set_transport:
|
||||
* @trans: a #GstRTSPStreamTransport
|
||||
* @ct: a client #GstRTSPTransport
|
||||
* @tr: (transfer full): a client #GstRTSPTransport
|
||||
*
|
||||
* Set @ct as the client transport. This function takes ownership of
|
||||
* the passed @ct.
|
||||
* the passed @tr.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport * trans,
|
||||
GstRTSPTransport * ct)
|
||||
GstRTSPTransport * tr)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_STREAM_TRANSPORT (trans));
|
||||
g_return_if_fail (ct != NULL);
|
||||
g_return_if_fail (tr != NULL);
|
||||
|
||||
/* keep track of the transports in the stream. */
|
||||
if (trans->transport)
|
||||
gst_rtsp_transport_free (trans->transport);
|
||||
trans->transport = ct;
|
||||
trans->transport = tr;
|
||||
}
|
||||
|
|
|
@ -89,10 +89,11 @@ struct _GstRTSPStreamTransportClass {
|
|||
|
||||
GType gst_rtsp_stream_transport_get_type (void);
|
||||
|
||||
GstRTSPStreamTransport * gst_rtsp_stream_transport_new (GstRTSPStream *stream);
|
||||
GstRTSPStreamTransport * gst_rtsp_stream_transport_new (GstRTSPStream *stream,
|
||||
GstRTSPTransport *tr);
|
||||
|
||||
void gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport *trans,
|
||||
GstRTSPTransport * ct);
|
||||
GstRTSPTransport * tr);
|
||||
|
||||
void gst_rtsp_stream_transport_set_callbacks (GstRTSPStreamTransport *trans,
|
||||
GstRTSPSendFunc send_rtp,
|
||||
|
|
Loading…
Reference in a new issue