rtsp-media: remove transports if media is in error status
authorAleix Conchillo Flaque <aleix@oblong.com>
Wed, 20 Nov 2013 23:51:54 +0000 (15:51 -0800)
committerWim Taymans <wtaymans@redhat.com>
Fri, 22 Nov 2013 10:25:15 +0000 (11:25 +0100)
* gst/rtsp-server/rtsp-media.c (gst_rtsp_media_set_state): if we are
  trying to change to GST_STATE_NULL and media is in error status, we
  remove all transports.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=712776

gst/rtsp-server/rtsp-media.c

index 5767ba9..a41d688 100644 (file)
@@ -2187,6 +2187,8 @@ gst_rtsp_media_set_state (GstRTSPMedia * media, GstState state,
   priv = media->priv;
 
   g_rec_mutex_lock (&priv->state_lock);
+  if (priv->status == GST_RTSP_MEDIA_STATUS_ERROR)
+    goto error_status;
   if (priv->status != GST_RTSP_MEDIA_STATUS_PREPARED)
     goto not_prepared;
 
@@ -2268,6 +2270,26 @@ not_prepared:
     g_rec_mutex_unlock (&priv->state_lock);
     return FALSE;
   }
+error_status:
+  {
+    GST_WARNING ("media %p in error status while changing to state %d",
+        media, state);
+    if (state == GST_STATE_NULL) {
+      for (i = 0; i < transports->len; i++) {
+        GstRTSPStreamTransport *trans;
+
+        /* we need a non-NULL entry in the array */
+        trans = g_ptr_array_index (transports, i);
+        if (trans == NULL)
+          continue;
+
+        gst_rtsp_stream_transport_set_active (trans, FALSE);
+      }
+      priv->n_active = 0;
+    }
+    g_rec_mutex_unlock (&priv->state_lock);
+    return FALSE;
+  }
 }
 
 /* called with state-lock */