diff --git a/gst-rtsp-server/gst/rtsp-server/rtsp-media.c b/gst-rtsp-server_patch/gst/rtsp-server/rtsp-media.c
index 71dd1d4..b946183 100644
--- a/gst-rtsp-server/gst/rtsp-server/rtsp-media.c
+++ b/gst-rtsp-server_patch/gst/rtsp-server/rtsp-media.c
@@ -1344,10 +1344,11 @@ gst_rtsp_media_prepare (GstRTSPMedia *media)
   }
 
   /* now wait for all pads to be prerolled */
-  ret = gst_element_get_state (media->pipeline, NULL, NULL, -1);
+  ret = gst_element_get_state (media->pipeline, NULL, NULL, 10*GST_SECOND);
   if (ret == GST_STATE_CHANGE_FAILURE)
     goto state_failed;
-
+  if (ret ==  GST_STATE_CHANGE_ASYNC)
+    goto state_not_supported;
   /* collect stats about the media */
   collect_media_stats (media);
 
@@ -1370,6 +1371,14 @@ state_failed:
     gst_element_set_state (media->pipeline, GST_STATE_NULL);
     return FALSE;
   }
+
+state_not_supported:
+  {
+    GST_WARNING ("failed to preroll pipeline: media not supported");
+    unlock_streams (media);
+    gst_element_set_state (media->pipeline, GST_STATE_NULL);
+    return FALSE;
+  }
 is_reused:
   {
     GST_WARNING ("can not reuse media %p", media);
