106
utf8_string_in_buf (GstBuffer * buf, const gchar * s)
111
for (i = 0; i < (GST_BUFFER_SIZE (buf) - len); ++i) {
112
if (memcmp (GST_BUFFER_DATA (buf) + i, s, len) == 0) {
121
test_taglib_id3mux_check_tag_buffer (GstBuffer * buf, guint32 mask)
123
/* make sure our UTF-8 string hasn't been put into the tag as ISO-8859-1 */
124
if (mask & (1 << 0)) {
125
fail_unless (utf8_string_in_buf (buf, TEST_ARTIST));
127
/* make sure our UTF-8 string hasn't been put into the tag as ISO-8859-1 */
128
if (mask & (1 << 1)) {
129
fail_unless (utf8_string_in_buf (buf, TEST_TITLE));
131
/* make sure our UTF-8 string hasn't been put into the tag as ISO-8859-1 */
132
if (mask & (1 << 2)) {
133
fail_unless (utf8_string_in_buf (buf, TEST_ALBUM));
106
138
test_taglib_id3mux_check_tags (GstTagList * tags, guint32 mask)
136
168
g_date_free (date);
138
170
if (mask & (1 << 4)) {
139
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
140
GST_TAG_TRACK_NUMBER, TEST_TRACK_NUMBER, NULL);
173
fail_unless (gst_tag_list_get_uint (tags, GST_TAG_TRACK_NUMBER, &num));
174
fail_unless (num == TEST_TRACK_NUMBER);
142
176
if (mask & (1 << 5)) {
143
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
144
GST_TAG_TRACK_COUNT, TEST_TRACK_COUNT, NULL);
179
fail_unless (gst_tag_list_get_uint (tags, GST_TAG_TRACK_COUNT, &count));
180
fail_unless (count == TEST_TRACK_COUNT);
146
182
if (mask & (1 << 6)) {
147
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
148
GST_TAG_ALBUM_VOLUME_NUMBER, TEST_VOLUME_NUMBER, NULL);
185
fail_unless (gst_tag_list_get_uint (tags, GST_TAG_ALBUM_VOLUME_NUMBER,
187
fail_unless (num == TEST_VOLUME_NUMBER);
150
189
if (mask & (1 << 7)) {
151
gst_tag_list_add (tags, GST_TAG_MERGE_KEEP,
152
GST_TAG_ALBUM_VOLUME_COUNT, TEST_VOLUME_COUNT, NULL);
192
fail_unless (gst_tag_list_get_uint (tags, GST_TAG_ALBUM_VOLUME_COUNT,
194
fail_unless (count == TEST_VOLUME_COUNT);
154
197
if (mask & (1 << 8)) {
200
fail_unless (gst_tag_list_get_double (tags, GST_TAG_TRACK_GAIN, &gain));
201
fail_unless (gain == TEST_TRACK_GAIN);
156
203
if (mask & (1 << 9)) {
206
fail_unless (gst_tag_list_get_double (tags, GST_TAG_ALBUM_GAIN, &gain));
207
fail_unless (gain == TEST_ALBUM_GAIN);
158
210
if (mask & (1 << 10)) {
160
212
if (mask & (1 << 11)) {
312
identity_cb (GstElement * identity, GstBuffer * buf, GstBuffer ** p_tagbuf)
314
if (*p_tagbuf == NULL) {
315
*p_tagbuf = gst_buffer_ref (buf);
260
320
test_taglib_id3mux_with_tags (GstTagList * tags, guint32 mask)
263
323
GstTagList *tags_read = NULL;
264
GstElement *pipeline, *id3mux, *id3demux, *fakesrc;
324
GstElement *pipeline, *id3mux, *id3demux, *fakesrc, *identity;
267
327
GstBuffer *outbuf = NULL;
328
GstBuffer *tagbuf = NULL;
269
330
pipeline = gst_pipeline_new ("pipeline");
270
331
g_assert (pipeline != NULL);
275
336
id3mux = gst_element_factory_make ("id3v2mux", "id3v2mux");
276
337
g_assert (id3mux != NULL);
339
identity = gst_element_factory_make ("identity", "identity");
340
g_assert (identity != NULL);
278
342
id3demux = gst_element_factory_make ("id3demux", "id3demux");
279
343
g_assert (id3demux != NULL);
285
349
gst_bin_add (GST_BIN (pipeline), fakesrc);
286
350
gst_bin_add (GST_BIN (pipeline), id3mux);
351
gst_bin_add (GST_BIN (pipeline), identity);
287
352
gst_bin_add (GST_BIN (pipeline), id3demux);
289
354
gst_tag_setter_merge_tags (GST_TAG_SETTER (id3mux), tags,
290
355
GST_TAG_MERGE_APPEND);
292
gst_element_link_many (fakesrc, id3mux, id3demux, NULL);
357
gst_element_link_many (fakesrc, id3mux, identity, id3demux, NULL);
294
359
/* set up source */
295
360
g_object_set (fakesrc, "signal-handoffs", TRUE, "can-activate-pull", FALSE,
300
365
g_signal_connect (fakesrc, "handoff", G_CALLBACK (fill_mp3_buffer), &offset);
367
/* set up identity to catch tag buffer */
368
g_signal_connect (identity, "handoff", G_CALLBACK (identity_cb), &tagbuf);
302
370
gst_element_set_state (pipeline, GST_STATE_PLAYING);
303
371
fail_unless (gst_element_get_state (pipeline, NULL, NULL,
304
372
-1) == GST_STATE_CHANGE_SUCCESS);
330
398
test_taglib_id3mux_check_tags (tags_read, mask);
331
399
gst_tag_list_free (tags_read);
401
fail_unless (tagbuf != NULL);
402
test_taglib_id3mux_check_tag_buffer (tagbuf, mask);
403
gst_buffer_unref (tagbuf);
333
405
GST_LOG ("Waiting for EOS ...");
334
406
msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
335
407
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) {