rtph264pay: avoid double buffer unmap on error
[platform/upstream/gstreamer.git] / gst / rtp / gstrtpmp4gdepay.c
index 2d55a8f..db472da 100644 (file)
@@ -13,8 +13,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -46,11 +46,10 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("application/x-rtp, "
         "media = (string) { \"video\", \"audio\", \"application\" }, "
-        "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
         "clock-rate = (int) [1, MAX ], "
         "encoding-name = (string) \"MPEG4-GENERIC\", "
         /* required string params */
-        "streamtype = (string) { \"4\", \"5\" }, "      /* 4 = video, 5 = audio */
+        /* "streamtype = (string) { \"4\", \"5\" }, "  Not set by Wowza    4 = video, 5 = audio */
         /* "profile-level-id = (string) [1,MAX], " */
         /* "config = (string) [1,MAX]" */
         "mode = (string) { \"generic\", \"CELP-cbr\", \"CELP-vbr\", \"AAC-lbr\", \"AAC-hbr\" } "
@@ -128,15 +127,15 @@ gst_bs_parse_read (GstBsParse * bs, guint n)
 
 #define gst_rtp_mp4g_depay_parent_class parent_class
 G_DEFINE_TYPE (GstRtpMP4GDepay, gst_rtp_mp4g_depay,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+    GST_TYPE_RTP_BASE_DEPAYLOAD);
 
 static void gst_rtp_mp4g_depay_finalize (GObject * object);
 
-static gboolean gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_mp4g_depay_setcaps (GstRTPBaseDepayload * depayload,
     GstCaps * caps);
-static GstBuffer *gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload,
     GstBuffer * buf);
-static gboolean gst_rtp_mp4g_depay_handle_event (GstBaseRTPDepayload * filter,
+static gboolean gst_rtp_mp4g_depay_handle_event (GstRTPBaseDepayload * filter,
     GstEvent * event);
 
 static GstStateChangeReturn gst_rtp_mp4g_depay_change_state (GstElement *
@@ -148,26 +147,26 @@ gst_rtp_mp4g_depay_class_init (GstRtpMP4GDepayClass * klass)
 {
   GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+  GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
 
   gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+  gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
 
   gobject_class->finalize = gst_rtp_mp4g_depay_finalize;
 
   gstelement_class->change_state = gst_rtp_mp4g_depay_change_state;
 
-  gstbasertpdepayload_class->process = gst_rtp_mp4g_depay_process;
-  gstbasertpdepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
-  gstbasertpdepayload_class->handle_event = gst_rtp_mp4g_depay_handle_event;
+  gstrtpbasedepayload_class->process = gst_rtp_mp4g_depay_process;
+  gstrtpbasedepayload_class->set_caps = gst_rtp_mp4g_depay_setcaps;
+  gstrtpbasedepayload_class->handle_event = gst_rtp_mp4g_depay_handle_event;
 
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_mp4g_depay_src_template));
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_mp4g_depay_sink_template));
 
-  gst_element_class_set_details_simple (gstelement_class,
+  gst_element_class_set_static_metadata (gstelement_class,
       "RTP MPEG4 ES depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts MPEG4 elementary streams from RTP packets (RFC 3640)",
       "Wim Taymans <wim.taymans@gmail.com>");
@@ -215,7 +214,7 @@ gst_rtp_mp4g_depay_parse_int (GstStructure * structure, const gchar * field,
 }
 
 static gboolean
-gst_rtp_mp4g_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_mp4g_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
 {
   GstStructure *structure;
   GstRtpMP4GDepay *rtpmp4gdepay;
@@ -348,7 +347,7 @@ gst_rtp_mp4g_depay_flush_queue (GstRtpMP4GDepay * rtpmp4gdepay)
     }
 
     GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing AU_index %u", AU_index);
-    gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
+    gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
     rtpmp4gdepay->next_AU_index = AU_index + 1;
   }
 }
@@ -368,7 +367,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
 
     /* we received the expected packet, push it and flush as much as we can from
      * the queue */
-    gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay), outbuf);
+    gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay), outbuf);
     rtpmp4gdepay->next_AU_index++;
 
     while ((outbuf = g_queue_peek_head (rtpmp4gdepay->packets))) {
@@ -380,7 +379,7 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
         GST_DEBUG_OBJECT (rtpmp4gdepay, "pushing expected AU_index %u",
             AU_index);
         outbuf = g_queue_pop_head (rtpmp4gdepay->packets);
-        gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpmp4gdepay),
+        gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpmp4gdepay),
             outbuf);
         rtpmp4gdepay->next_AU_index++;
       } else {
@@ -419,12 +418,12 @@ gst_rtp_mp4g_depay_queue (GstRtpMP4GDepay * rtpmp4gdepay, GstBuffer * outbuf)
 }
 
 static GstBuffer *
-gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
 {
   GstRtpMP4GDepay *rtpmp4gdepay;
   GstBuffer *outbuf = NULL;
   GstClockTime timestamp;
-  GstRTPBuffer rtp;
+  GstRTPBuffer rtp = { NULL };
 
   rtpmp4gdepay = GST_RTP_MP4G_DEPAY (depayload);
 
@@ -453,8 +452,6 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     rtptime = gst_rtp_buffer_get_timestamp (&rtp);
     M = gst_rtp_buffer_get_marker (&rtp);
 
-    gst_rtp_buffer_unmap (&rtp);
-
     if (rtpmp4gdepay->sizelength > 0) {
       gint num_AU_headers, AU_headers_bytes, i;
       GstBsParse bs;
@@ -673,7 +670,8 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
            * RTP packet. */
           timestamp = -1;
 
-          GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
+          GST_DEBUG_OBJECT (depayload,
+              "pushing buffer of size %" G_GSIZE_FORMAT,
               gst_buffer_get_size (outbuf));
 
           gst_rtp_mp4g_depay_queue (rtpmp4gdepay, outbuf);
@@ -695,8 +693,8 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
         outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
 
-        GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %d",
-            gst_buffer_get_size (outbuf));
+        GST_DEBUG ("gst_rtp_mp4g_depay_chain: pushing buffer of size %"
+            G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
 
         gst_rtp_buffer_unmap (&rtp);
         return outbuf;
@@ -718,7 +716,7 @@ short_payload:
 }
 
 static gboolean
-gst_rtp_mp4g_depay_handle_event (GstBaseRTPDepayload * filter, GstEvent * event)
+gst_rtp_mp4g_depay_handle_event (GstRTPBaseDepayload * filter, GstEvent * event)
 {
   gboolean ret;
   GstRtpMP4GDepay *rtpmp4gdepay;
@@ -734,7 +732,7 @@ gst_rtp_mp4g_depay_handle_event (GstBaseRTPDepayload * filter, GstEvent * event)
   }
 
   ret =
-      GST_BASE_RTP_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
+      GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
 
   return ret;
 }