Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst-libs / gst / tag / tags.c
index 0236a6d..cb60b54 100644 (file)
@@ -43,6 +43,7 @@
  * </refsect2>
  */
 
+#ifndef GST_DISABLE_GST_DEBUG
 #define GST_CAT_DEFAULT gst_tag_ensure_debug_category()
 
 static GstDebugCategory *
@@ -60,6 +61,7 @@ gst_tag_ensure_debug_category (void)
 
   return (GstDebugCategory *) cat_gonce;
 }
+#endif /* GST_DISABLE_GST_DEBUG */
 
 static gpointer
 gst_tag_register_tags_internal (gpointer unused)
@@ -131,6 +133,10 @@ gst_tag_register_tags_internal (gpointer unused)
       G_TYPE_STRING, _("capturing exposure mode"),
       _("The exposure mode used when capturing an image"), NULL);
 
+  gst_tag_register (GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, GST_TAG_FLAG_META,
+      G_TYPE_DOUBLE, _("capturing exposure compensation"),
+      _("The exposure compensation used when capturing an image"), NULL);
+
   gst_tag_register (GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE, GST_TAG_FLAG_META,
       G_TYPE_STRING, _("capturing scene capture type"),
       _("The scene capture mode used when capturing an image"), NULL);
@@ -153,13 +159,27 @@ gst_tag_register_tags_internal (gpointer unused)
       _("The direction of saturation processing applied when "
           "capturing an image"), NULL);
 
+  gst_tag_register (GST_TAG_CAPTURING_SHARPNESS, GST_TAG_FLAG_META,
+      G_TYPE_STRING, _("capturing sharpness"),
+      _("The direction of sharpness processing applied "
+          "when capturing an image"), NULL);
+
   gst_tag_register (GST_TAG_CAPTURING_FLASH_FIRED, GST_TAG_FLAG_META,
       G_TYPE_BOOLEAN, _("capturing flash fired"),
-      _("If the flash fired while capturing and image"), NULL);
+      _("If the flash fired while capturing an image"), NULL);
 
   gst_tag_register (GST_TAG_CAPTURING_FLASH_MODE, GST_TAG_FLAG_META,
       G_TYPE_STRING, _("capturing flash mode"),
-      _("The selected flash mode while capturing and image"), NULL);
+      _("The selected flash mode while capturing an image"), NULL);
+
+  gst_tag_register (GST_TAG_CAPTURING_METERING_MODE, GST_TAG_FLAG_META,
+      G_TYPE_STRING, _("capturing metering mode"),
+      _("The metering mode used while determining exposure for capturing an"
+          " image"), NULL);
+
+  gst_tag_register (GST_TAG_CAPTURING_SOURCE, GST_TAG_FLAG_META,
+      G_TYPE_STRING, _("capturing source"),
+      _("The source or type of device used for the capture"), NULL);
 
   gst_tag_register (GST_TAG_IMAGE_HORIZONTAL_PPI, GST_TAG_FLAG_META,
       G_TYPE_DOUBLE, _("image horizontal ppi"),
@@ -537,10 +557,9 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
     guint image_data_len, GstTagImageType image_type)
 {
   const gchar *name;
-
   GstBuffer *image;
-
   GstCaps *caps;
+  guint8 *data;
 
   g_return_val_if_fail (image_data != NULL, NULL);
   g_return_val_if_fail (image_data_len > 0, NULL);
@@ -549,14 +568,14 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
   GST_DEBUG ("image data len: %u bytes", image_data_len);
 
   /* allocate space for a NUL terminator for an uri too */
-  image = gst_buffer_try_new_and_alloc (image_data_len + 1);
-  if (image == NULL) {
-    GST_WARNING ("failed to allocate buffer of %d for image", image_data_len);
-    return NULL;
-  }
+  image = gst_buffer_new_and_alloc (image_data_len + 1);
+  if (image == NULL)
+    goto alloc_failed;
 
-  memcpy (GST_BUFFER_DATA (image), image_data, image_data_len);
-  GST_BUFFER_DATA (image)[image_data_len] = '\0';
+  data = gst_buffer_map (image, NULL, NULL, GST_MAP_WRITE);
+  memcpy (data, image_data, image_data_len);
+  data[image_data_len] = '\0';
+  gst_buffer_unmap (image, data, image_data_len + 1);
 
   /* Find GStreamer media type, can't trust declared type */
   caps = gst_type_find_helper_for_buffer (NULL, image, NULL);
@@ -580,7 +599,7 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data,
    * to keep the original size of the image
    */
   if (!g_str_equal (name, "text/uri-list"))
-    GST_BUFFER_SIZE (image) = image_data_len;
+    gst_buffer_set_size (image, image_data_len);
 
   if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
     GST_LOG ("Setting image type: %d", image_type);
@@ -607,4 +626,11 @@ error:
       gst_caps_unref (caps);
     return NULL;
   }
+alloc_failed:
+  {
+    GST_WARNING ("failed to allocate buffer of %d for image", image_data_len);
+    gst_buffer_unref (image);
+    return NULL;
+  }
+
 }