~ubuntu-branches/ubuntu/feisty/gst-plugins-good0.10/feisty-security

« back to all changes in this revision

Viewing changes to tests/check/elements/id3v2mux.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-15 02:58:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060815025826-h1sa4q0uxwqgzwki
Tags: 0.10.4-0ubuntu1
* Sync with Debian (pkg-gstreamer SVN, rev 470):
  + debian/rules,
    debian/control.in:
    - Add a -dbg package again

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
  return tags;
103
103
}
104
104
 
 
105
static gboolean
 
106
utf8_string_in_buf (GstBuffer * buf, const gchar * s)
 
107
{
 
108
  gint i, len;
 
109
 
 
110
  len = strlen (s);
 
111
  for (i = 0; i < (GST_BUFFER_SIZE (buf) - len); ++i) {
 
112
    if (memcmp (GST_BUFFER_DATA (buf) + i, s, len) == 0) {
 
113
      return TRUE;
 
114
    }
 
115
  }
 
116
 
 
117
  return FALSE;
 
118
}
 
119
 
 
120
static void
 
121
test_taglib_id3mux_check_tag_buffer (GstBuffer * buf, guint32 mask)
 
122
{
 
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));
 
126
  }
 
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));
 
130
  }
 
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));
 
134
  }
 
135
}
 
136
 
105
137
static void
106
138
test_taglib_id3mux_check_tags (GstTagList * tags, guint32 mask)
107
139
{
136
168
    g_date_free (date);
137
169
  }
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);
 
171
    guint num;
 
172
 
 
173
    fail_unless (gst_tag_list_get_uint (tags, GST_TAG_TRACK_NUMBER, &num));
 
174
    fail_unless (num == TEST_TRACK_NUMBER);
141
175
  }
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);
 
177
    guint count;
 
178
 
 
179
    fail_unless (gst_tag_list_get_uint (tags, GST_TAG_TRACK_COUNT, &count));
 
180
    fail_unless (count == TEST_TRACK_COUNT);
145
181
  }
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);
 
183
    guint num;
 
184
 
 
185
    fail_unless (gst_tag_list_get_uint (tags, GST_TAG_ALBUM_VOLUME_NUMBER,
 
186
            &num));
 
187
    fail_unless (num == TEST_VOLUME_NUMBER);
149
188
  }
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);
 
190
    guint count;
 
191
 
 
192
    fail_unless (gst_tag_list_get_uint (tags, GST_TAG_ALBUM_VOLUME_COUNT,
 
193
            &count));
 
194
    fail_unless (count == TEST_VOLUME_COUNT);
153
195
  }
 
196
#if 0
154
197
  if (mask & (1 << 8)) {
 
198
    gdouble gain;
 
199
 
 
200
    fail_unless (gst_tag_list_get_double (tags, GST_TAG_TRACK_GAIN, &gain));
 
201
    fail_unless (gain == TEST_TRACK_GAIN);
155
202
  }
156
203
  if (mask & (1 << 9)) {
 
204
    gdouble gain;
 
205
 
 
206
    fail_unless (gst_tag_list_get_double (tags, GST_TAG_ALBUM_GAIN, &gain));
 
207
    fail_unless (gain == TEST_ALBUM_GAIN);
157
208
  }
 
209
#endif
158
210
  if (mask & (1 << 10)) {
159
211
  }
160
212
  if (mask & (1 << 11)) {
257
309
}
258
310
 
259
311
static void
 
312
identity_cb (GstElement * identity, GstBuffer * buf, GstBuffer ** p_tagbuf)
 
313
{
 
314
  if (*p_tagbuf == NULL) {
 
315
    *p_tagbuf = gst_buffer_ref (buf);
 
316
  }
 
317
}
 
318
 
 
319
static void
260
320
test_taglib_id3mux_with_tags (GstTagList * tags, guint32 mask)
261
321
{
262
322
  GstMessage *msg;
263
323
  GstTagList *tags_read = NULL;
264
 
  GstElement *pipeline, *id3mux, *id3demux, *fakesrc;
 
324
  GstElement *pipeline, *id3mux, *id3demux, *fakesrc, *identity;
265
325
  GstBus *bus;
266
326
  guint64 offset;
267
327
  GstBuffer *outbuf = NULL;
 
328
  GstBuffer *tagbuf = NULL;
268
329
 
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);
277
338
 
 
339
  identity = gst_element_factory_make ("identity", "identity");
 
340
  g_assert (identity != NULL);
 
341
 
278
342
  id3demux = gst_element_factory_make ("id3demux", "id3demux");
279
343
  g_assert (id3demux != NULL);
280
344
 
284
348
 
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);
288
353
 
289
354
  gst_tag_setter_merge_tags (GST_TAG_SETTER (id3mux), tags,
290
355
      GST_TAG_MERGE_APPEND);
291
356
 
292
 
  gst_element_link_many (fakesrc, id3mux, id3demux, NULL);
 
357
  gst_element_link_many (fakesrc, id3mux, identity, id3demux, NULL);
293
358
 
294
359
  /* set up source */
295
360
  g_object_set (fakesrc, "signal-handoffs", TRUE, "can-activate-pull", FALSE,
299
364
  offset = 0;
300
365
  g_signal_connect (fakesrc, "handoff", G_CALLBACK (fill_mp3_buffer), &offset);
301
366
 
 
367
  /* set up identity to catch tag buffer */
 
368
  g_signal_connect (identity, "handoff", G_CALLBACK (identity_cb), &tagbuf);
 
369
 
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);
332
400
 
 
401
  fail_unless (tagbuf != NULL);
 
402
  test_taglib_id3mux_check_tag_buffer (tagbuf, mask);
 
403
  gst_buffer_unref (tagbuf);
 
404
 
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) {