summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavi Kiran K N <ravi.kiran@samsung.com>2015-11-27 11:33:07 +0530
committerTim-Philipp Müller <tim@centricular.com>2015-11-27 12:16:57 +0000
commit6b643fdff64a9f0412e7247f343021d92602b3a1 (patch)
tree480e81e8c44d6e2aff7bbfacaaa50a87d04ce03f
parentd387bfd188a15cbb6fcb9e2c3e2893ea3a7d9414 (diff)
id3mux: write private data tag
Handle "PRIV" tag in id3mux. Write owner identifier and private data and add to the id3v2 frame. https://bugzilla.gnome.org/show_bug.cgi?id=758728
-rw-r--r--gst/id3tag/id3tag.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/gst/id3tag/id3tag.c b/gst/id3tag/id3tag.c
index c12a77c59..3a602d1f9 100644
--- a/gst/id3tag/id3tag.c
+++ b/gst/id3tag/id3tag.c
@@ -462,7 +462,58 @@ add_text_tag (GstId3v2Tag * id3v2tag, const GstTagList * list,
g_free (strings);
}
-/* FIXME: id3v2-private frames need to be extracted as samples */
+static void
+add_private_data_tag (GstId3v2Tag * id3v2tag, const GstTagList * list,
+ const gchar * tag, guint num_tags, const gchar * frame_id)
+{
+ gint n;
+
+ for (n = 0; n < num_tags; ++n) {
+ GstId3v2Frame frame;
+ GstSample *sample = NULL;
+ const GstStructure *structure = NULL;
+ GstBuffer *binary = NULL;
+ GstBuffer *priv_frame = NULL;
+ const gchar *owner_str = NULL;
+ guint owner_len = 0;
+ GstMapInfo mapinfo;
+
+ if (!gst_tag_list_get_sample_index (list, tag, n, &sample))
+ continue;
+
+ structure = gst_sample_get_info (sample);
+ if (structure != NULL
+ && !strcmp (gst_structure_get_name (structure), "ID3PrivateFrame")) {
+ owner_str = gst_structure_get_string (structure, "owner");
+
+ if (owner_str != NULL) {
+ owner_len = strlen (owner_str) + 1;
+ priv_frame = gst_buffer_new_and_alloc (owner_len);
+ gst_buffer_fill (priv_frame, 0, owner_str, owner_len);
+
+ binary = gst_buffer_ref (gst_sample_get_buffer (sample));
+ priv_frame = gst_buffer_append (priv_frame, binary);
+
+ id3v2_frame_init (&frame, frame_id, 0);
+
+ if (gst_buffer_map (priv_frame, &mapinfo, GST_MAP_READ)) {
+ id3v2_frame_write_bytes (&frame, mapinfo.data, mapinfo.size);
+ g_array_append_val (id3v2tag->frames, frame);
+ gst_buffer_unmap (priv_frame, &mapinfo);
+ } else {
+ GST_WARNING ("Couldn't map priv frame tag buffer");
+ id3v2_frame_unset (&frame);
+ }
+
+ gst_buffer_unref (priv_frame);
+ gst_sample_unref (sample);
+ }
+ } else {
+ GST_WARNING ("Couldn't find ID3PrivateFrame structure");
+ }
+ }
+}
+
static void
add_id3v2frame_tag (GstId3v2Tag * id3v2tag, const GstTagList * list,
const gchar * tag, guint num_tags, const gchar * unused)
@@ -1095,6 +1146,7 @@ static const struct
GST_TAG_MUSICAL_KEY, add_text_tag, "TKEY"}, {
/* Private frames */
+ GST_TAG_PRIVATE_DATA, add_private_data_tag, "PRIV"}, {
GST_ID3_DEMUX_TAG_ID3V2_FRAME, add_id3v2frame_tag, NULL}, {
/* Track and album numbers */