summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorEdgard Lima <edgard.lima@indt.org.br>2007-11-01 16:04:29 +0000
committerEdgard Lima <edgard.lima@indt.org.br>2007-11-01 16:04:29 +0000
commit929954f595220293179b7ce22f563f1707934566 (patch)
tree786173419229d5f8f8bbbb28dd201a27d75baeeb /ext
parent5888898c570f0f22c930d8c66fe0949d00a90b93 (diff)
downloadgst-plugins-bad-929954f595220293179b7ce22f563f1707934566.tar.gz
gst-plugins-bad-929954f595220293179b7ce22f563f1707934566.tar.bz2
gst-plugins-bad-929954f595220293179b7ce22f563f1707934566.zip
Some XMP stuff added.
Original commit message from CVS: Some XMP stuff added.
Diffstat (limited to 'ext')
-rw-r--r--ext/metadata/Makefile.am6
-rw-r--r--ext/metadata/metadataparseexif.c10
-rw-r--r--ext/metadata/metadataparseiptc.c21
-rw-r--r--ext/metadata/metadataparsejpeg.c42
-rw-r--r--ext/metadata/metadataparseutil.c64
-rw-r--r--ext/metadata/metadataparseutil.h58
-rw-r--r--ext/metadata/metadataparsexmp.c74
-rw-r--r--ext/metadata/metadataparsexmp.h6
8 files changed, 257 insertions, 24 deletions
diff --git a/ext/metadata/Makefile.am b/ext/metadata/Makefile.am
index fd27b6e4..88596b42 100644
--- a/ext/metadata/Makefile.am
+++ b/ext/metadata/Makefile.am
@@ -6,7 +6,8 @@ libgstmetadata_la_SOURCES = gstmetadata.c \
metadataparsejpeg.c \
metadataparseexif.c \
metadataparseiptc.c \
- metadataparsexmp.c
+ metadataparsexmp.c \
+ metadataparseutil.c
libgstmetadata_la_CFLAGS = $(METADATA_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS)
libgstmetadata_la_LIBADD = $(METADATA_LIBS) -lgsttag-@GST_MAJORMINOR@ $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS)
@@ -17,5 +18,6 @@ noinst_HEADERS = gstmetadataparse.h \
metadataparsejpeg.h \
metadataparseexif.h \
metadataparseiptc.h \
- metadataparsexmp.h
+ metadataparsexmp.h \
+ metadataparseutil.h
diff --git a/ext/metadata/metadataparseexif.c b/ext/metadata/metadataparseexif.c
index 5ed97bba..204319ac 100644
--- a/ext/metadata/metadataparseexif.c
+++ b/ext/metadata/metadataparseexif.c
@@ -42,13 +42,18 @@
*/
#include "metadataparseexif.h"
+#include "metadataparseutil.h"
GST_DEBUG_CATEGORY (gst_metadata_parse_exif_debug);
#define GST_CAT_DEFAULT gst_metadata_parse_exif_debug
+#define GST_TAG_EXIF "exif"
+
void
metadataparse_exif_tags_register (void)
{
+ gst_tag_register (GST_TAG_EXIF, GST_TAG_FLAG_META,
+ GST_TYPE_BUFFER, GST_TAG_EXIF, "exif metadata chunk", NULL);
}
#ifndef HAVE_EXIF
@@ -60,6 +65,8 @@ metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode,
GST_LOG ("EXIF not defined, here I should send just one tag as whole chunk");
+ metadataparse_tag_list_add_chunk (taglist, mode, GST_TAG_EXIF, adapter);
+
}
#else /* ifndef HAVE_EXIF */
@@ -83,6 +90,9 @@ metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode,
goto done;
}
+ /* add chunk tag */
+ metadataparse_tag_list_add_chunk (taglist, mode, GST_TAG_EXIF, adapter);
+
buf = gst_adapter_peek (adapter, size);
exif = exif_data_new_from_data (buf, size);
diff --git a/ext/metadata/metadataparseiptc.c b/ext/metadata/metadataparseiptc.c
index 9c983a70..3f3e5eab 100644
--- a/ext/metadata/metadataparseiptc.c
+++ b/ext/metadata/metadataparseiptc.c
@@ -42,6 +42,7 @@
*/
#include "metadataparseiptc.h"
+#include "metadataparseutil.h"
GST_DEBUG_CATEGORY (gst_metadata_parse_iptc_debug);
#define GST_CAT_DEFAULT gst_metadata_parse_iptc_debug
@@ -55,26 +56,6 @@ metadataparse_iptc_tags_register (void)
GST_TYPE_BUFFER, GST_TAG_IPTC, "iptc metadata chunk", NULL);
}
-void
-metadataparse_tag_list_add_chunk (GstTagList * taglist, GstTagMergeMode mode,
- const gchar * name, GstAdapter * adapter)
-{
- GstBuffer *buf;
- guint size;
-
- if (adapter && (size = gst_adapter_available (adapter))) {
-
- buf = gst_buffer_new_and_alloc (size);
-
- gst_adapter_copy (adapter, GST_BUFFER_DATA (buf), 0, size);
-
- gst_tag_list_add (taglist, mode, name, buf, NULL);
-
- gst_buffer_unref (buf);
- }
-
-}
-
#ifndef HAVE_IPTC
void
diff --git a/ext/metadata/metadataparsejpeg.c b/ext/metadata/metadataparsejpeg.c
index bf453a12..753d436a 100644
--- a/ext/metadata/metadataparsejpeg.c
+++ b/ext/metadata/metadataparsejpeg.c
@@ -66,6 +66,10 @@ metadataparse_jpeg_iptc (JpegData * jpeg_data, guint8 ** buf,
guint32 * bufsize, guint8 ** next_start, guint32 * next_size);
static int
+metadataparse_jpeg_xmp (JpegData * jpeg_data, guint8 ** buf,
+ guint32 * bufsize, guint8 ** next_start, guint32 * next_size);
+
+static int
metadataparse_jpeg_jump (JpegData * jpeg_data, guint8 ** buf,
guint32 * bufsize, guint8 ** next_start, guint32 * next_size);
@@ -80,11 +84,14 @@ metadataparse_jpeg_init (JpegData * jpeg_data, GstAdapter ** adpt_exif,
jpeg_data->adpt_iptc = adpt_iptc;
jpeg_data->adpt_xmp = adpt_xmp;
jpeg_data->read = 0;
+
+ metadataparse_xmp_init ();
}
void
metadataparse_jpeg_dispose (JpegData * jpeg_data)
{
+ metadataparse_xmp_dispose ();
jpeg_data->adpt_exif = NULL;
jpeg_data->adpt_iptc = NULL;
@@ -143,6 +150,11 @@ metadataparse_jpeg_parse (JpegData * jpeg_data, guint8 * buf,
metadataparse_jpeg_iptc (jpeg_data, &buf, bufsize, next_start,
next_size);
break;
+ case JPEG_XMP:
+ ret =
+ metadataparse_jpeg_xmp (jpeg_data, &buf, bufsize, next_start,
+ next_size);
+ break;
case JPEG_DONE:
goto done;
break;
@@ -172,6 +184,7 @@ metadataparse_jpeg_reading (JpegData * jpeg_data, guint8 ** buf,
static const unsigned char ExifHeader[] =
{ 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 };
static const char IptcHeader[] = "Photoshop 3.0";
+ static const char XmpHeader[] = "http://ns.adobe.com/xap/1.0/";
*next_start = *buf;
@@ -204,7 +217,8 @@ metadataparse_jpeg_reading (JpegData * jpeg_data, guint8 ** buf,
chunk_size = READ (*buf, *bufsize) << 8;
chunk_size += READ (*buf, *bufsize);
- if (mark[1] == 0xE1) { /* may be it is Exif */
+ if (mark[1] == 0xE1) { /* may be it is Exif or XMP */
+
if (chunk_size >= 8) { /* size2 'EXIF' 0x00 0x00 */
guint8 ch;
@@ -222,6 +236,22 @@ metadataparse_jpeg_reading (JpegData * jpeg_data, guint8 ** buf,
goto done;
}
}
+ if (chunk_size >= 31) { /* size2 "http://ns.adobe.com/xap/1.0/" */
+ if (*bufsize < 29) {
+ *next_size = (*buf - *next_start) + 29;
+ ret = 1;
+ goto done;
+ }
+
+ if (jpeg_data->adpt_xmp) {
+ if (0 == memcmp (XmpHeader, *buf, 29)) {
+ jpeg_data->read = chunk_size - 2;
+ ret = 0;
+ jpeg_data->state = JPEG_XMP;
+ goto done;
+ }
+ }
+ }
}
} else if (mark[1] == 0xED) { /* may be it is photoshop and may be there is iptc */
if (chunk_size >= 16) { /* size2 "Photoshop 3.0" */
@@ -350,6 +380,16 @@ metadataparse_jpeg_iptc (JpegData * jpeg_data, guint8 ** buf,
}
static int
+metadataparse_jpeg_xmp (JpegData * jpeg_data, guint8 ** buf,
+ guint32 * bufsize, guint8 ** next_start, guint32 * next_size)
+{
+
+ return metadataparse_jpeg_hold_chunk (jpeg_data, buf,
+ bufsize, next_start, next_size, jpeg_data->adpt_xmp);
+
+}
+
+static int
metadataparse_jpeg_jump (JpegData * jpeg_data, guint8 ** buf,
guint32 * bufsize, guint8 ** next_start, guint32 * next_size)
{
diff --git a/ext/metadata/metadataparseutil.c b/ext/metadata/metadataparseutil.c
new file mode 100644
index 00000000..dfab579f
--- /dev/null
+++ b/ext/metadata/metadataparseutil.c
@@ -0,0 +1,64 @@
+/*
+ * GStreamer
+ * Copyright 2007 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
+ * which case the following provisions apply instead of the ones
+ * mentioned above:
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * 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.
+ */
+
+#include "metadataparseutil.h"
+
+void
+metadataparse_tag_list_add_chunk (GstTagList * taglist, GstTagMergeMode mode,
+ const gchar * name, GstAdapter * adapter)
+{
+ GstBuffer *buf;
+ guint size;
+
+ if (adapter && (size = gst_adapter_available (adapter))) {
+
+ buf = gst_buffer_new_and_alloc (size);
+
+ gst_adapter_copy (adapter, GST_BUFFER_DATA (buf), 0, size);
+
+ gst_tag_list_add (taglist, mode, name, buf, NULL);
+
+ gst_buffer_unref (buf);
+ }
+
+}
diff --git a/ext/metadata/metadataparseutil.h b/ext/metadata/metadataparseutil.h
new file mode 100644
index 00000000..75129843
--- /dev/null
+++ b/ext/metadata/metadataparseutil.h
@@ -0,0 +1,58 @@
+/*
+ * GStreamer
+ * Copyright 2007 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Alternatively, the contents of this file may be used under the
+ * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
+ * which case the following provisions apply instead of the ones
+ * mentioned above:
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * 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.
+ */
+
+#ifndef __GST_METADATAPARSE_UTIL_H__
+#define __GST_METADATAPARSE_UTIL_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstadapter.h>
+
+G_BEGIN_DECLS
+
+extern void
+metadataparse_tag_list_add_chunk (GstTagList * taglist, GstTagMergeMode mode,
+ const gchar * name, GstAdapter * adapter);
+
+G_END_DECLS
+
+#endif /* __GST_METADATAPARSE_UTIL_H__ */
diff --git a/ext/metadata/metadataparsexmp.c b/ext/metadata/metadataparsexmp.c
index 5af6bd62..9b583002 100644
--- a/ext/metadata/metadataparsexmp.c
+++ b/ext/metadata/metadataparsexmp.c
@@ -42,13 +42,18 @@
*/
#include "metadataparsexmp.h"
+#include "metadataparseutil.h"
GST_DEBUG_CATEGORY (gst_metadata_parse_xmp_debug);
#define GST_CAT_DEFAULT gst_metadata_parse_xmp_debug
+#define GST_TAG_XMP "xmp"
+
void
metadataparse_xmp_tags_register (void)
{
+ gst_tag_register (GST_TAG_XMP, GST_TAG_FLAG_META,
+ GST_TYPE_BUFFER, GST_TAG_XMP, "xmp metadata chunk", NULL);
}
#ifndef HAVE_XMP
@@ -60,16 +65,83 @@ metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode,
GST_LOG ("XMP not defined, here I should send just one tag as whole chunk");
+ metadataparse_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter);
+
+}
+
+gboolean
+metadataparse_xmp_init (void)
+{
+ return TRUE;
+}
+
+void
+metadataparse_xmp_dispose (void)
+{
+ return;
}
#else /* ifndef HAVE_XMP */
+#include <xmp.h>
+
+gboolean
+metadataparse_xmp_init (void)
+{
+ return xmp_init ();
+}
+
+void
+metadataparse_xmp_dispose (void)
+{
+ xmp_terminate ();
+}
+
void
metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode,
GstAdapter * adapter)
{
+ const guint8 *buf;
+ guint32 size;
+ XmpPtr *xmp = NULL;
+ XmpStringPtr xmp_str = NULL;
+
+ if (adapter == NULL || (size = gst_adapter_available (adapter)) == 0) {
+ goto done;
+ }
+
+ /* add chunk tag */
+ metadataparse_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter);
+
+ buf = gst_adapter_peek (adapter, size);
+
+ buf += 29; /* jump "http://ns.adobe.com/xap/1.0/" */
+ size -= 29;
+
+ xmp = xmp_new (buf, size);
+ if (!xmp)
+ goto done;
+
+ xmp_str = xmp_string_new ();
+ if (!xmp_str)
+ goto done;
+
+ xmp_serialize (xmp, xmp_str, XMP_SERIAL_ENCODEUTF8, 2);
+
+
+ GST_LOG (xmp_string_cstr (xmp_str));
+
+done:
+
+ if (xmp_str) {
+ xmp_string_free (xmp_str);
+ }
+
+ if (xmp) {
+ xmp_free (xmp);
+ }
- GST_LOG ("XMP still not implemented");
+ return;
}
diff --git a/ext/metadata/metadataparsexmp.h b/ext/metadata/metadataparsexmp.h
index a3e0c8c2..07e34a95 100644
--- a/ext/metadata/metadataparsexmp.h
+++ b/ext/metadata/metadataparsexmp.h
@@ -52,6 +52,12 @@ G_BEGIN_DECLS
extern void
metadataparse_xmp_tag_list_add (GstTagList *taglist, GstTagMergeMode mode, GstAdapter * adapter);
+extern gboolean
+metadataparse_xmp_init(void);
+
+extern void
+metadataparse_xmp_dispose(void);
+
extern void
metadataparse_xmp_tags_register (void);