Commit debe2d56 authored by Jonathan Matthew's avatar Jonathan Matthew Committed by Tim-Philipp Müller

id3v2mux: write beats-per-minute tag using TBPM frame

https://bugzilla.gnome.org/show_bug.cgi?id=621520
parent fc00857c
......@@ -626,6 +626,26 @@ add_relative_volume_tag (ID3v2::Tag * id3v2tag, const GstTagList * list,
id3v2tag->addFrame (frame);
}
static void
add_bpm_tag (ID3v2::Tag * id3v2tag, const GstTagList * list,
const gchar * tag, guint num_tags, const gchar * frame_id)
{
gdouble bpm;
if (gst_tag_list_get_double_index (list, tag, 0, &bpm)) {
ID3v2::TextIdentificationFrame * frame;
gchar *tag_str;
tag_str = g_strdup_printf ("%u", (guint)bpm);
GST_DEBUG ("Setting %s to %s", tag, tag_str);
frame = new ID3v2::TextIdentificationFrame ("TBPM", String::UTF8);
id3v2tag->addFrame (frame);
frame->setText (tag_str);
g_free (tag_str);
}
}
/* id3demux produces these for frames it cannot parse */
#define GST_ID3_DEMUX_TAG_ID3V2_FRAME "private-id3v2-frame"
......@@ -669,7 +689,8 @@ static const struct
GST_TAG_TRACK_PEAK, add_relative_volume_tag, ""}, {
GST_TAG_TRACK_GAIN, add_relative_volume_tag, ""}, {
GST_TAG_ALBUM_PEAK, add_relative_volume_tag, ""}, {
GST_TAG_ALBUM_GAIN, add_relative_volume_tag, ""}
GST_TAG_ALBUM_GAIN, add_relative_volume_tag, ""}, {
GST_TAG_BEATS_PER_MINUTE, add_bpm_tag, ""}
};
......
......@@ -37,6 +37,7 @@
#define TEST_ALBUM_GAIN 0.78
#define TEST_TRACK_PEAK 0.83
#define TEST_ALBUM_PEAK 0.18
#define TEST_BPM 113.0
/* for dummy mp3 frame sized MP3_FRAME_SIZE bytes,
* start: ff fb b0 44 00 00 08 00 00 4b 00 00 00 00 00 00 */
......@@ -117,6 +118,8 @@ test_taglib_id3mux_create_tags (guint32 mask)
GST_TAG_ALBUM_PEAK, TEST_ALBUM_PEAK, NULL);
}
if (mask & (1 << 12)) {
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
GST_TAG_BEATS_PER_MINUTE, TEST_BPM, NULL);
}
if (mask & (1 << 13)) {
}
......@@ -239,6 +242,11 @@ test_taglib_id3mux_check_tags (GstTagList * tags, guint32 mask)
fail_unless_sorta_equals_float (peak, TEST_ALBUM_PEAK);
}
if (mask & (1 << 12)) {
gdouble bpm;
fail_unless (gst_tag_list_get_double (tags, GST_TAG_BEATS_PER_MINUTE,
&bpm));
fail_unless_sorta_equals_float (bpm, TEST_BPM);
}
if (mask & (1 << 13)) {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment