396 GDate *date = g_date_new_dmy (1, 1, year); |
396 GDate *date = g_date_new_dmy (1, 1, year); |
397 |
397 |
398 gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_DATE, date, NULL); |
398 gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_DATE, date, NULL); |
399 g_date_free (date); |
399 g_date_free (date); |
400 } |
400 } |
401 if (data[125] == 0 && data[126] != 0) { |
401 if (data[125] == 0) { |
402 gst_tag_extract_id3v1_string (list, GST_TAG_COMMENT, (gchar *) & data[97], |
402 gst_tag_extract_id3v1_string (list, GST_TAG_COMMENT, (gchar *) & data[97], |
403 28); |
403 28); |
404 gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_TRACK_NUMBER, |
404 gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_TRACK_NUMBER, |
405 (guint) data[126], NULL); |
405 (guint) data[126], NULL); |
406 } else { |
406 } else { |
407 gst_tag_extract_id3v1_string (list, GST_TAG_COMMENT, (gchar *) & data[97], |
407 gst_tag_extract_id3v1_string (list, GST_TAG_COMMENT, (gchar *) & data[97], |
408 30); |
408 30); |
409 } |
409 } |
410 if (data[127] < gst_tag_id3_genre_count () && !gst_tag_list_is_empty (list)) { |
410 if (data[127] < gst_tag_id3_genre_count ()) { |
411 gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE, |
411 gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE, |
412 gst_tag_id3_genre_get (data[127]), NULL); |
412 gst_tag_id3_genre_get (data[127]), NULL); |
413 } |
413 } |
414 |
414 |
415 return list; |
415 return list; |
450 { |
450 { |
451 if (id >= G_N_ELEMENTS (genres)) |
451 if (id >= G_N_ELEMENTS (genres)) |
452 return NULL; |
452 return NULL; |
453 return genres[id]; |
453 return genres[id]; |
454 } |
454 } |
455 |
|
456 /** |
|
457 * gst_tag_list_add_id3_image: |
|
458 * @tag_list: a tag list |
|
459 * @image_data: the (encoded) image |
|
460 * @image_data_len: the length of the encoded image data at @image_data |
|
461 * @id3_picture_type: picture type as per the ID3 (v2.4.0) specification for |
|
462 * the APIC frame (0 = unknown/other) |
|
463 * |
|
464 * Adds an image from an ID3 APIC frame (or similar, such as used in FLAC) |
|
465 * to the given tag list. Also see gst_tag_image_data_to_image_buffer() for |
|
466 * more information on image tags in GStreamer. |
|
467 * |
|
468 * Returns: %TRUE if the image was processed, otherwise %FALSE |
|
469 * |
|
470 * Since: 0.10.20 |
|
471 */ |
|
472 #ifdef __SYMBIAN32__ |
|
473 EXPORT_C |
|
474 #endif |
|
475 |
|
476 gboolean |
|
477 gst_tag_list_add_id3_image (GstTagList * tag_list, const guint8 * image_data, |
|
478 guint image_data_len, guint id3_picture_type) |
|
479 { |
|
480 GstTagImageType tag_image_type; |
|
481 const gchar *tag_name; |
|
482 GstBuffer *image; |
|
483 |
|
484 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), FALSE); |
|
485 g_return_val_if_fail (image_data != NULL, FALSE); |
|
486 g_return_val_if_fail (image_data_len > 0, FALSE); |
|
487 |
|
488 if (id3_picture_type == 0x01 || id3_picture_type == 0x02) { |
|
489 /* file icon for preview. Don't add image-type to caps, since there |
|
490 * is only supposed to be one of these, and the type is already indicated |
|
491 * via the special tag */ |
|
492 tag_name = GST_TAG_PREVIEW_IMAGE; |
|
493 tag_image_type = GST_TAG_IMAGE_TYPE_NONE; |
|
494 } else { |
|
495 tag_name = GST_TAG_IMAGE; |
|
496 |
|
497 /* Remap the ID3v2 APIC type our ImageType enum */ |
|
498 if (id3_picture_type >= 0x3 && id3_picture_type <= 0x14) |
|
499 tag_image_type = (GstTagImageType) (id3_picture_type - 2); |
|
500 else |
|
501 tag_image_type = GST_TAG_IMAGE_TYPE_UNDEFINED; |
|
502 } |
|
503 |
|
504 image = gst_tag_image_data_to_image_buffer (image_data, image_data_len, |
|
505 tag_image_type); |
|
506 |
|
507 if (image == NULL) |
|
508 return FALSE; |
|
509 |
|
510 gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, image, NULL); |
|
511 gst_buffer_unref (image); |
|
512 return TRUE; |
|
513 } |
|