mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
stream: Add functions for checking if stream is receiver or sender
...and replace all checks for RECORD in GstRTSPMedia which are really for "sender-only". This way the code becomes more generic and introducing support for onvif-backchannel later on will require no changes in GstRTSPMedia.
This commit is contained in:
parent
62aae8c7dc
commit
14c511ae62
3 changed files with 78 additions and 5 deletions
|
@ -672,6 +672,25 @@ default_create_rtpbin (GstRTSPMedia * media)
|
||||||
return rtpbin;
|
return rtpbin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
is_receive_only (GstRTSPMedia * media)
|
||||||
|
{
|
||||||
|
GstRTSPMediaPrivate *priv = media->priv;
|
||||||
|
gboolean recive_only = TRUE;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < priv->streams->len; i++) {
|
||||||
|
GstRTSPStream *stream = g_ptr_array_index (priv->streams, i);
|
||||||
|
if (gst_rtsp_stream_is_sender (stream) ||
|
||||||
|
!gst_rtsp_stream_is_receiver (stream)) {
|
||||||
|
recive_only = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return recive_only;
|
||||||
|
}
|
||||||
|
|
||||||
/* must be called with state lock */
|
/* must be called with state lock */
|
||||||
static void
|
static void
|
||||||
check_seekable (GstRTSPMedia * media)
|
check_seekable (GstRTSPMedia * media)
|
||||||
|
@ -680,8 +699,8 @@ check_seekable (GstRTSPMedia * media)
|
||||||
GstRTSPMediaPrivate *priv = media->priv;
|
GstRTSPMediaPrivate *priv = media->priv;
|
||||||
|
|
||||||
/* Update the seekable state of the pipeline in case it changed */
|
/* Update the seekable state of the pipeline in case it changed */
|
||||||
if ((priv->transport_mode & GST_RTSP_TRANSPORT_MODE_RECORD)) {
|
if (is_receive_only (media)) {
|
||||||
/* TODO: Seeking for RECORD? */
|
/* TODO: Seeking for "receive-only"? */
|
||||||
priv->seekable = -1;
|
priv->seekable = -1;
|
||||||
} else {
|
} else {
|
||||||
guint i, n = priv->streams->len;
|
guint i, n = priv->streams->len;
|
||||||
|
@ -2640,8 +2659,8 @@ default_handle_message (GstRTSPMedia * media, GstMessage * message)
|
||||||
GST_DEBUG ("%p: went from %s to %s (pending %s)", media,
|
GST_DEBUG ("%p: went from %s to %s (pending %s)", media,
|
||||||
gst_element_state_get_name (old), gst_element_state_get_name (new),
|
gst_element_state_get_name (old), gst_element_state_get_name (new),
|
||||||
gst_element_state_get_name (pending));
|
gst_element_state_get_name (pending));
|
||||||
if ((priv->transport_mode & GST_RTSP_TRANSPORT_MODE_RECORD)
|
if (priv->no_more_pads_pending == 0 && is_receive_only (media) &&
|
||||||
&& old == GST_STATE_READY && new == GST_STATE_PAUSED) {
|
old == GST_STATE_READY && new == GST_STATE_PAUSED) {
|
||||||
GST_INFO ("%p: went to PAUSED, prepared now", media);
|
GST_INFO ("%p: went to PAUSED, prepared now", media);
|
||||||
collect_media_stats (media);
|
collect_media_stats (media);
|
||||||
|
|
||||||
|
@ -3851,7 +3870,7 @@ default_unsuspend (GstRTSPMedia * media)
|
||||||
|
|
||||||
switch (priv->suspend_mode) {
|
switch (priv->suspend_mode) {
|
||||||
case GST_RTSP_SUSPEND_MODE_NONE:
|
case GST_RTSP_SUSPEND_MODE_NONE:
|
||||||
if ((priv->transport_mode & GST_RTSP_TRANSPORT_MODE_RECORD))
|
if (is_receive_only (media))
|
||||||
break;
|
break;
|
||||||
if (media_streams_blocking (media)) {
|
if (media_streams_blocking (media)) {
|
||||||
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARING);
|
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARING);
|
||||||
|
|
|
@ -4590,3 +4590,51 @@ gst_rtsp_stream_is_complete (GstRTSPStream * stream)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtsp_stream_is_sender:
|
||||||
|
* @stream: a #GstRTSPStream
|
||||||
|
*
|
||||||
|
* Checks whether the stream is a sender.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the stream is a sender and %FALSE otherwise.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtsp_stream_is_sender (GstRTSPStream * stream)
|
||||||
|
{
|
||||||
|
GstRTSPStreamPrivate *priv;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
priv = stream->priv;
|
||||||
|
g_mutex_lock (&priv->lock);
|
||||||
|
ret = (priv->srcpad != NULL);
|
||||||
|
g_mutex_unlock (&priv->lock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtsp_stream_is_receiver:
|
||||||
|
* @stream: a #GstRTSPStream
|
||||||
|
*
|
||||||
|
* Checks whether the stream is a receiver.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the stream is a receiver and %FALSE otherwise.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtsp_stream_is_receiver (GstRTSPStream * stream)
|
||||||
|
{
|
||||||
|
GstRTSPStreamPrivate *priv;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), FALSE);
|
||||||
|
|
||||||
|
priv = stream->priv;
|
||||||
|
g_mutex_lock (&priv->lock);
|
||||||
|
ret = (priv->sinkpad != NULL);
|
||||||
|
g_mutex_unlock (&priv->lock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -293,6 +293,12 @@ gboolean gst_rtsp_stream_complete_stream (GstRTSPStream * stream, const
|
||||||
GST_EXPORT
|
GST_EXPORT
|
||||||
gboolean gst_rtsp_stream_is_complete (GstRTSPStream * stream);
|
gboolean gst_rtsp_stream_is_complete (GstRTSPStream * stream);
|
||||||
|
|
||||||
|
GST_EXPORT
|
||||||
|
gboolean gst_rtsp_stream_is_sender (GstRTSPStream * stream);
|
||||||
|
|
||||||
|
GST_EXPORT
|
||||||
|
gboolean gst_rtsp_stream_is_receiver (GstRTSPStream * stream);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstRTSPStreamTransportFilterFunc:
|
* GstRTSPStreamTransportFilterFunc:
|
||||||
* @stream: a #GstRTSPStream object
|
* @stream: a #GstRTSPStream object
|
||||||
|
|
Loading…
Reference in a new issue