From cd1832688e660e26054445041d6b79734d1f1089 Mon Sep 17 00:00:00 2001
From: Athanasios Oikonomou <athoik@gmail.com>
Date: Tue, 28 Oct 2014 08:48:20 +0200
Subject: [PATCH] rtmp: fix seeking and potential segfault

Segfault info: https://bugzilla.gnome.org/show_bug.cgi?id=739263
Seeking info: http://forums.openpli.org/topic/32910-mediaplayer-seek-doesnt-work-with-rtmp-streams/

---
 ext/rtmp/gstrtmpsrc.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/ext/rtmp/gstrtmpsrc.c b/ext/rtmp/gstrtmpsrc.c
index 12931a2..52db7f4 100644
--- a/ext/rtmp/gstrtmpsrc.c
+++ b/ext/rtmp/gstrtmpsrc.c
@@ -89,7 +89,6 @@ static void gst_rtmp_src_get_property (GObject * object, guint prop_id,
 static void gst_rtmp_src_finalize (GObject * object);
 
 static gboolean gst_rtmp_src_connect (GstRTMPSrc * src);
-static gboolean gst_rtmp_src_unlock (GstBaseSrc * src);
 static gboolean gst_rtmp_src_stop (GstBaseSrc * src);
 static gboolean gst_rtmp_src_start (GstBaseSrc * src);
 static gboolean gst_rtmp_src_is_seekable (GstBaseSrc * src);
@@ -145,7 +144,6 @@ gst_rtmp_src_class_init (GstRTMPSrcClass * klass)
 
   gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_rtmp_src_start);
   gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_rtmp_src_stop);
-  gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_rtmp_src_unlock);
   gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_rtmp_src_is_seekable);
   gstbasesrc_class->prepare_seek_segment =
       GST_DEBUG_FUNCPTR (gst_rtmp_src_prepare_seek_segment);
@@ -644,23 +642,6 @@ error:
   return FALSE;
 }
 
-static gboolean
-gst_rtmp_src_unlock (GstBaseSrc * basesrc)
-{
-  GstRTMPSrc *rtmpsrc = GST_RTMP_SRC (basesrc);
-
-  GST_DEBUG_OBJECT (rtmpsrc, "unlock");
-
-  /* This closes the socket, which means that any pending socket calls
-   * error out. */
-  if (rtmpsrc->rtmp) {
-    RTMP_Close (rtmpsrc->rtmp);
-  }
-
-  return TRUE;
-}
-
-
 static gboolean
 gst_rtmp_src_stop (GstBaseSrc * basesrc)
 {
@@ -669,6 +650,7 @@ gst_rtmp_src_stop (GstBaseSrc * basesrc)
   src = GST_RTMP_SRC (basesrc);
 
   if (src->rtmp) {
+    RTMP_Close (src->rtmp);
     RTMP_Free (src->rtmp);
     src->rtmp = NULL;
   }