rtpvrawpay: Add missing break
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpvrawdepay.c
index 1d49cd1..7674122 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
@@ -43,7 +43,6 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("application/x-rtp, "
         "media = (string) \"video\", "
-        "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
         "clock-rate = (int) 90000, " "encoding-name = (string) \"RAW\"")
     );
 
@@ -82,7 +81,7 @@ gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_vraw_depay_sink_template));
 
-  gst_element_class_set_details_simple (gstelement_class,
+  gst_element_class_set_static_metadata (gstelement_class,
       "RTP Raw Video depayloader", "Codec/Depayloader/Network/RTP",
       "Extracts raw video from RTP packets (RFC 4175)",
       "Wim Taymans <wim.taymans@gmail.com>");
@@ -94,7 +93,6 @@ gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
 static void
 gst_rtp_vraw_depay_init (GstRtpVRawDepay * rtpvrawdepay)
 {
-  /* needed because of GST_BOILERPLATE */
 }
 
 static void
@@ -149,7 +147,7 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
 
   config = gst_buffer_pool_get_config (pool);
   gst_buffer_pool_config_set_params (config, caps, size, min, max);
-  if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) {
+  if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
     /* just set the metadata, if the pool can support it we will transparently use
      * it through the video info API. We could also see if the pool support this
      * metadata and only activate it then. */
@@ -173,7 +171,7 @@ gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
   GstRtpVRawDepay *rtpvrawdepay;
   gint clock_rate;
   const gchar *str;
-  gint format, width, height, pgroup, xinc, yinc;
+  gint format, width, height, depth, pgroup, xinc, yinc;
   GstCaps *srccaps;
   gboolean res;
   GstFlowReturn ret;
@@ -196,6 +194,10 @@ gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
     goto no_height;
   height = atoi (str);
 
+  if (!(str = gst_structure_get_string (structure, "depth")))
+    goto no_depth;
+  depth = atoi (str);
+
   /* optional interlace value but we don't handle interlaced
    * formats yet */
   if (gst_structure_get_string (structure, "interlace"))
@@ -220,8 +222,14 @@ gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
     format = GST_VIDEO_FORMAT_AYUV;
     pgroup = 3;
   } else if (!strcmp (str, "YCbCr-4:2:2")) {
-    format = GST_VIDEO_FORMAT_UYVY;
-    pgroup = 4;
+    if (depth == 8) {
+      format = GST_VIDEO_FORMAT_UYVY;
+      pgroup = 4;
+    } else if (depth == 10) {
+      format = GST_VIDEO_FORMAT_UYVP;
+      pgroup = 5;
+    } else
+      goto unknown_format;
     xinc = 2;
   } else if (!strcmp (str, "YCbCr-4:2:0")) {
     format = GST_VIDEO_FORMAT_I420;
@@ -253,7 +261,7 @@ gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
       xinc, yinc, pgroup);
 
   /* negotiate a bufferpool */
-  if ((ret = gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, caps,
+  if ((ret = gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, srccaps,
               &rtpvrawdepay->vinfo)) != GST_FLOW_OK)
     goto no_bufferpool;
 
@@ -270,6 +278,11 @@ no_height:
     GST_ERROR_OBJECT (depayload, "no height specified");
     return FALSE;
   }
+no_depth:
+  {
+    GST_ERROR_OBJECT (depayload, "no depth specified");
+    return FALSE;
+  }
 interlaced:
   {
     GST_ERROR_OBJECT (depayload, "interlaced formats not supported yet");
@@ -302,6 +315,8 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
   gint width, height, xinc, yinc;
   GstRTPBuffer rtp = { NULL };
   GstVideoFrame frame;
+  gboolean marker;
+  GstBuffer *outbuf = NULL;
 
   rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
 
@@ -434,6 +449,7 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
       case GST_VIDEO_FORMAT_BGR:
       case GST_VIDEO_FORMAT_BGRA:
       case GST_VIDEO_FORMAT_UYVY:
+      case GST_VIDEO_FORMAT_UYVP:
         /* samples are packed just like gstreamer packs them */
         offs /= xinc;
         datap = yp + (line * ystride) + (offs * pgroup);
@@ -524,17 +540,16 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
   }
 
   gst_video_frame_unmap (&frame);
+  marker = gst_rtp_buffer_get_marker (&rtp);
   gst_rtp_buffer_unmap (&rtp);
 
-  if (gst_rtp_buffer_get_marker (&rtp)) {
+  if (marker) {
     GST_LOG_OBJECT (depayload, "marker, flushing frame");
-    if (rtpvrawdepay->outbuf) {
-      gst_rtp_base_depayload_push (depayload, rtpvrawdepay->outbuf);
-      rtpvrawdepay->outbuf = NULL;
-    }
+    outbuf = rtpvrawdepay->outbuf;
+    rtpvrawdepay->outbuf = NULL;
     rtpvrawdepay->timestamp = -1;
   }
-  return NULL;
+  return outbuf;
 
   /* ERRORS */
 unknown_sampling: