Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpjpegdepay.c
index 3159925..14355f3 100644 (file)
@@ -68,16 +68,16 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
 
 #define gst_rtp_jpeg_depay_parent_class parent_class
 G_DEFINE_TYPE (GstRtpJPEGDepay, gst_rtp_jpeg_depay,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+    GST_TYPE_RTP_BASE_DEPAYLOAD);
 
 static void gst_rtp_jpeg_depay_finalize (GObject * object);
 
 static GstStateChangeReturn gst_rtp_jpeg_depay_change_state (GstElement *
     element, GstStateChange transition);
 
-static gboolean gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload,
     GstCaps * caps);
-static GstBuffer *gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload,
     GstBuffer * buf);
 
 static void
@@ -85,11 +85,11 @@ gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * 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_jpeg_depay_finalize;
 
@@ -105,8 +105,8 @@ gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
 
   gstelement_class->change_state = gst_rtp_jpeg_depay_change_state;
 
-  gstbasertpdepayload_class->set_caps = gst_rtp_jpeg_depay_setcaps;
-  gstbasertpdepayload_class->process = gst_rtp_jpeg_depay_process;
+  gstrtpbasedepayload_class->set_caps = gst_rtp_jpeg_depay_setcaps;
+  gstrtpbasedepayload_class->process = gst_rtp_jpeg_depay_process;
 
   GST_DEBUG_CATEGORY_INIT (rtpjpegdepay_debug, "rtpjpegdepay", 0,
       "JPEG Video RTP Depayloader");
@@ -412,7 +412,7 @@ MakeHeaders (guint8 * p, int type, int width, int height, guint8 * qt,
 };
 
 static gboolean
-gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_jpeg_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
 {
   GstRtpJPEGDepay *rtpjpegdepay;
   GstStructure *structure;
@@ -477,7 +477,7 @@ gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
 }
 
 static GstBuffer *
-gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
 {
   GstRtpJPEGDepay *rtpjpegdepay;
   GstBuffer *outbuf;
@@ -488,7 +488,7 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   guint type, width, height;
   guint16 dri, precision, length;
   guint8 *qtable;
-  GstRTPBuffer rtp;
+  GstRTPBuffer rtp = { NULL };
 
   rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
 
@@ -602,8 +602,8 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   }
 
   if (frag_offset == 0) {
+    GstMapInfo map;
     guint size;
-    guint8 *data;
 
     if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
       GstCaps *outcaps;
@@ -645,12 +645,12 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     }
     /* max header length, should be big enough */
     outbuf = gst_buffer_new_and_alloc (1000);
-    data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
-    size = MakeHeaders (data, type, width, height, qtable, precision, dri);
-    gst_buffer_unmap (outbuf, data, size);
+    gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
+    size = MakeHeaders (map.data, type, width, height, qtable, precision, dri);
+    gst_buffer_unmap (outbuf, &map);
+    gst_buffer_resize (outbuf, 0, size);
 
-    GST_DEBUG_OBJECT (rtpjpegdepay,
-        "pushing %" G_GSIZE_FORMAT " bytes of header", size);
+    GST_DEBUG_OBJECT (rtpjpegdepay, "pushing %u bytes of header", size);
 
     gst_adapter_push (rtpjpegdepay->adapter, outbuf);
   }
@@ -664,7 +664,7 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   if (gst_rtp_buffer_get_marker (&rtp)) {
     guint avail;
     guint8 end[2];
-    guint8 *data;
+    GstMapInfo map;
 
     /* last buffer take all data out of the adapter */
     avail = gst_adapter_available (rtpjpegdepay->adapter);
@@ -679,10 +679,10 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
       /* no EOI marker, add one */
       outbuf = gst_buffer_new_and_alloc (2);
-      data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
-      data[0] = 0xff;
-      data[1] = 0xd9;
-      gst_buffer_unmap (outbuf, data, -1);
+      gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
+      map.data[0] = 0xff;
+      map.data[1] = 0xd9;
+      gst_buffer_unmap (outbuf, &map);
 
       gst_adapter_push (rtpjpegdepay->adapter, outbuf);
       avail += 2;