summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavi Kiran K N <ravi.kiran@samsung.com>2014-09-29 14:17:39 +0530
committerTim-Philipp Müller <tim@centricular.com>2015-11-20 20:20:18 +0000
commitdf5725e68331ca50e9d610c5d99d23fbf7c046a0 (patch)
treeaf4bd5433e3e44aea924e66146120e2e9c556a74
parent93a92d7f7065079d601f04b0a50da232ddc58aa3 (diff)
id3v2frames: Handle private frames
Handle PRIV ID3 tag having owner information (string) and binary data, add to tag messages list. https://bugzilla.gnome.org/show_bug.cgi?id=730926
-rw-r--r--gst-libs/gst/tag/gstid3tag.c1
-rw-r--r--gst-libs/gst/tag/id3v2frames.c47
2 files changed, 48 insertions, 0 deletions
diff --git a/gst-libs/gst/tag/gstid3tag.c b/gst-libs/gst/tag/gstid3tag.c
index 95d6df817..383e41187 100644
--- a/gst-libs/gst/tag/gstid3tag.c
+++ b/gst-libs/gst/tag/gstid3tag.c
@@ -113,6 +113,7 @@ static const GstTagEntryMatch tag_matches[] = {
{GST_TAG_PUBLISHER, "TPUB"},
{GST_TAG_INTERPRETED_BY, "TPE4"},
{GST_TAG_MUSICAL_KEY, "TKEY"},
+ {GST_TAG_PRIVATE_DATA, "PRIV"},
{NULL, NULL}
};
diff --git a/gst-libs/gst/tag/id3v2frames.c b/gst-libs/gst/tag/id3v2frames.c
index 47842384a..15b1a274d 100644
--- a/gst-libs/gst/tag/id3v2frames.c
+++ b/gst-libs/gst/tag/id3v2frames.c
@@ -59,6 +59,7 @@ static gboolean
id3v2_genre_fields_to_taglist (ID3TagsWorking * work, const gchar * tag_name,
GArray * tag_fields);
static gboolean parse_picture_frame (ID3TagsWorking * work);
+static gboolean parse_private_frame_data (ID3TagsWorking * work);
#define ID3V2_ENCODING_ISO8859 0x00
#define ID3V2_ENCODING_UTF16 0x01
@@ -201,6 +202,9 @@ id3v2_parse_frame (ID3TagsWorking * work)
} else if (!strcmp (work->frame_id, "UFID")) {
/* Unique file identifier */
tag_str = parse_unique_file_identifier (work, &tag_name);
+ } else if (!strcmp (work->frame_id, "PRIV")) {
+ /* private frame */
+ result = parse_private_frame_data (work);
}
#ifdef HAVE_ZLIB
if (work->frame_flags & ID3V2_FRAME_FORMAT_COMPRESSION) {
@@ -462,6 +466,49 @@ parse_id_string (ID3TagsWorking * work, gchar ** p_str, gint * p_len,
return TRUE;
}
+static gboolean
+parse_private_frame_data (ID3TagsWorking * work)
+{
+ GstBuffer *binary_data = NULL;
+ GstStructure *owner_info = NULL;
+ guint8 *owner_str = NULL;
+ gsize owner_len;
+ GstSample *priv_frame = NULL;
+
+ if (work->parse_size == 0) {
+ /* private frame data not available */
+ return FALSE;
+ }
+
+ owner_str =
+ (guint8 *) memchr ((guint8 *) work->parse_data, 0, work->parse_size);
+
+ if (owner_str == NULL) {
+ GST_WARNING ("Invalid PRIV frame received");
+ return FALSE;
+ }
+
+ owner_len = (gsize) (owner_str - work->parse_data) + 1;
+
+ owner_info =
+ gst_structure_new ("ID3PrivateFrame", "owner", G_TYPE_STRING,
+ work->parse_data, NULL);
+
+ binary_data = gst_buffer_new_and_alloc (work->parse_size - owner_len);
+ gst_buffer_fill (binary_data, 0, work->parse_data + owner_len,
+ work->parse_size - owner_len);
+
+ priv_frame = gst_sample_new (binary_data, NULL, NULL, owner_info);
+
+ gst_tag_list_add (work->tags, GST_TAG_MERGE_APPEND,
+ GST_TAG_PRIVATE_DATA, priv_frame, NULL);
+
+ gst_sample_unref (priv_frame);
+ gst_buffer_unref (binary_data);
+
+ return TRUE;
+}
+
static gchar *
parse_unique_file_identifier (ID3TagsWorking * work, const gchar ** tag_name)
{