oggdemux: add audio-codec and video-codec tags for streams in more cases

This commit is contained in:
Tim-Philipp Müller 2011-04-11 15:10:01 +01:00
parent e2d0a1835b
commit e045b6fb52
2 changed files with 31 additions and 1 deletions

View file

@ -23,6 +23,7 @@ libgstogg_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS
libgstogg_la_LIBADD = \ libgstogg_la_LIBADD = \
$(top_builddir)/gst-libs/gst/riff/libgstriff-$(GST_API_VERSION).la \ $(top_builddir)/gst-libs/gst/riff/libgstriff-$(GST_API_VERSION).la \
$(top_builddir)/gst-libs/gst/tag/libgsttag-$(GST_API_VERSION).la \ $(top_builddir)/gst-libs/gst/tag/libgsttag-$(GST_API_VERSION).la \
$(top_builddir)/gst-libs/gst/pbutils/libgstpbutils-$(GST_API_VERSION).la \
$(GST_BASE_LIBS) \ $(GST_BASE_LIBS) \
$(GST_LIBS) \ $(GST_LIBS) \
$(OGG_LIBS) $(OGG_LIBS)

View file

@ -27,6 +27,7 @@
#include "vorbis_parse.h" #include "vorbis_parse.h"
#include <gst/riff/riff-media.h> #include <gst/riff/riff-media.h>
#include <gst/pbutils/pbutils.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -499,6 +500,9 @@ extract_tags_theora (GstOggStream * pad, ogg_packet * packet)
if (!pad->taglist) if (!pad->taglist)
pad->taglist = gst_tag_list_new_empty (); pad->taglist = gst_tag_list_new_empty ();
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_VIDEO_CODEC, "Theora", NULL);
if (pad->bitrate) if (pad->bitrate)
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE, gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_BITRATE, (guint) pad->bitrate, NULL); GST_TAG_BITRATE, (guint) pad->bitrate, NULL);
@ -732,6 +736,9 @@ extract_tags_vp8 (GstOggStream * pad, ogg_packet * packet)
if (packet->bytes >= 7 && memcmp (packet->packet, "OVP80\2 ", 7) == 0) { if (packet->bytes >= 7 && memcmp (packet->packet, "OVP80\2 ", 7) == 0) {
tag_list_from_vorbiscomment_packet (packet, tag_list_from_vorbiscomment_packet (packet,
(const guint8 *) "OVP80\2 ", 7, &pad->taglist); (const guint8 *) "OVP80\2 ", 7, &pad->taglist);
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_VIDEO_CODEC, "VP8", NULL);
} }
} }
@ -814,7 +821,8 @@ extract_tags_vorbis (GstOggStream * pad, ogg_packet * packet)
pad->taglist = gst_tag_list_new_empty (); pad->taglist = gst_tag_list_new_empty ();
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE, gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_ENCODER_VERSION, pad->version, NULL); GST_TAG_ENCODER_VERSION, pad->version,
GST_TAG_AUDIO_CODEC, "Vorbis", NULL);
if (pad->bitrate_nominal > 0) if (pad->bitrate_nominal > 0)
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE, gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
@ -904,6 +912,16 @@ extract_tags_count (GstOggStream * pad, ogg_packet * packet)
if (!pad->taglist) if (!pad->taglist)
pad->taglist = gst_tag_list_new_empty (); pad->taglist = gst_tag_list_new_empty ();
if (pad->is_video) {
gst_pb_utils_add_codec_description_to_tag_list (pad->taglist,
GST_TAG_VIDEO_CODEC, pad->caps);
} else if (!pad->is_sparse && !pad->is_ogm_text && !pad->is_ogm) {
gst_pb_utils_add_codec_description_to_tag_list (pad->taglist,
GST_TAG_AUDIO_CODEC, pad->caps);
} else {
GST_FIXME ("not adding codec tag, not sure about codec type");
}
if (pad->bitrate) if (pad->bitrate)
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE, gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_BITRATE, (guint) pad->bitrate, NULL); GST_TAG_BITRATE, (guint) pad->bitrate, NULL);
@ -1025,6 +1043,9 @@ extract_tags_flac (GstOggStream * pad, ogg_packet * packet)
if (packet->bytes > 4 && ((packet->packet[0] & 0x7F) == 0x4)) { if (packet->bytes > 4 && ((packet->packet[0] & 0x7F) == 0x4)) {
tag_list_from_vorbiscomment_packet (packet, tag_list_from_vorbiscomment_packet (packet,
packet->packet, 4, &pad->taglist); packet->packet, 4, &pad->taglist);
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_AUDIO_CODEC, "FLAC", NULL);
} }
} }
@ -1846,6 +1867,11 @@ extract_tags_kate (GstOggStream * pad, ogg_packet * packet)
case 0x81: case 0x81:
tag_list_from_vorbiscomment_packet (packet, tag_list_from_vorbiscomment_packet (packet,
(const guint8 *) "\201kate\0\0\0\0", 9, &list); (const guint8 *) "\201kate\0\0\0\0", 9, &list);
if (list != NULL) {
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
GST_TAG_SUBTITLE_CODEC, "Kate", NULL);
}
break; break;
default: default:
break; break;
@ -1981,6 +2007,9 @@ extract_tags_opus (GstOggStream * pad, ogg_packet * packet)
if (packet->bytes >= 8 && memcmp (packet->packet, "OpusTags", 8) == 0) { if (packet->bytes >= 8 && memcmp (packet->packet, "OpusTags", 8) == 0) {
tag_list_from_vorbiscomment_packet (packet, tag_list_from_vorbiscomment_packet (packet,
(const guint8 *) "OpusTags", 8, &pad->taglist); (const guint8 *) "OpusTags", 8, &pad->taglist);
gst_tag_list_add (pad->taglist, GST_TAG_MERGE_REPLACE,
GST_TAG_AUDIO_CODEC, "Opus", NULL);
} }
} }