use tags as well

Original commit message from CVS:
use tags as  well
This commit is contained in:
Thomas Vander Stichele 2002-11-09 18:34:48 +00:00
parent 4b83831f48
commit c71c3316cf

View file

@ -59,6 +59,7 @@ struct _VorbisFile {
guint64 offset; guint64 offset;
GstCaps *metadata; GstCaps *metadata;
GstCaps *tags;
}; };
struct _VorbisFileClass { struct _VorbisFileClass {
@ -93,6 +94,7 @@ enum
{ {
ARG_0, ARG_0,
ARG_METADATA, ARG_METADATA,
ARG_TAGS
}; };
static void static void
@ -173,6 +175,9 @@ gst_vorbisfile_class_init (VorbisFileClass * klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (gobject_class, ARG_TAGS,
g_param_spec_boxed ("tags", "Tags", "(logical) Stream tags",
GST_TYPE_CAPS, G_PARAM_READABLE));
g_object_class_install_property (gobject_class, ARG_METADATA, g_object_class_install_property (gobject_class, ARG_METADATA,
g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata", g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata",
GST_TYPE_CAPS, G_PARAM_READABLE)); GST_TYPE_CAPS, G_PARAM_READABLE));
@ -210,6 +215,7 @@ gst_vorbisfile_init (VorbisFile * vorbisfile)
vorbisfile->seek_pending = 0; vorbisfile->seek_pending = 0;
vorbisfile->need_discont = FALSE; vorbisfile->need_discont = FALSE;
vorbisfile->metadata = NULL; vorbisfile->metadata = NULL;
vorbisfile->tags = NULL;
vorbisfile->current_link = -1; vorbisfile->current_link = -1;
} }
@ -345,24 +351,23 @@ ov_callbacks vorbisfile_ov_callbacks =
gst_vorbisfile_tell, gst_vorbisfile_tell,
}; };
/* retrieve the comment field and put tags in metadata GstCaps /* retrieve the comment field (or tags) and put in tags GstCaps
* returns TRUE if caps were still valid or could be set, * returns TRUE if caps could be set,
* FALSE if they couldn't be read somehow */ * FALSE if they couldn't be read somehow */
static gboolean static gboolean
gst_vorbisfile_update_metadata (VorbisFile *vorbisfile, gint link) gst_vorbisfile_update_tags (VorbisFile *vorbisfile, gint link)
{ {
OggVorbis_File *vf = &vorbisfile->vf; OggVorbis_File *vf = &vorbisfile->vf;
gchar **ptr; gchar **ptr;
vorbis_info *vi;
vorbis_comment *vc; vorbis_comment *vc;
GstProps *props = NULL; GstProps *props = NULL;
GstPropsEntry *entry; GstPropsEntry *entry;
gchar *name, *value; gchar *name, *value;
/* clear old one */ /* clear old one */
if (vorbisfile->metadata) { if (vorbisfile->tags) {
gst_caps_unref (vorbisfile->metadata); gst_caps_unref (vorbisfile->tags);
vorbisfile->metadata = NULL; vorbisfile->tags = NULL;
} }
/* create props to hold the key/value pairs */ /* create props to hold the key/value pairs */
@ -380,24 +385,53 @@ gst_vorbisfile_update_metadata (VorbisFile *vorbisfile, gint link)
} }
ptr++; ptr++;
} }
entry = gst_props_entry_new ("vendor", GST_PROPS_STRING_TYPE, vc->vendor); vorbisfile->tags = gst_caps_new ("vorbisfile_tags",
gst_props_add_entry (props, (GstPropsEntry *) entry); "application/x-gst-tags",
props);
g_object_notify (G_OBJECT (vorbisfile), "tags");
return TRUE;
}
/* retrieve logical stream properties and put them in metadata GstCaps
* returns TRUE if caps could be set,
* FALSE if they couldn't be read somehow */
static gboolean
gst_vorbisfile_update_metadata (VorbisFile *vorbisfile, gint link)
{
OggVorbis_File *vf = &vorbisfile->vf;
vorbis_info *vi;
GstProps *props = NULL;
GstPropsEntry *entry;
/* clear old one */
if (vorbisfile->metadata) {
gst_caps_unref (vorbisfile->metadata);
vorbisfile->metadata = NULL;
}
/* create props to hold the key/value pairs */
props = gst_props_empty_new ();
/* grab some more random properties */
vi = ov_info (vf, link); vi = ov_info (vf, link);
entry = gst_props_entry_new ("version", GST_PROPS_INT_TYPE, vi->version); entry = gst_props_entry_new ("version", GST_PROPS_INT_TYPE, vi->version);
gst_props_add_entry (props, (GstPropsEntry *) entry); gst_props_add_entry (props, (GstPropsEntry *) entry);
entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE, vi->bitrate_upper); entry = gst_props_entry_new ("bitrate_upper", GST_PROPS_INT_TYPE,
vi->bitrate_upper);
gst_props_add_entry (props, (GstPropsEntry *) entry); gst_props_add_entry (props, (GstPropsEntry *) entry);
entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE, vi->bitrate_nominal); entry = gst_props_entry_new ("bitrate_nominal", GST_PROPS_INT_TYPE,
vi->bitrate_nominal);
gst_props_add_entry (props, (GstPropsEntry *) entry); gst_props_add_entry (props, (GstPropsEntry *) entry);
entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE, vi->bitrate_lower); entry = gst_props_entry_new ("bitrate_lower", GST_PROPS_INT_TYPE,
vi->bitrate_lower);
gst_props_add_entry (props, (GstPropsEntry *) entry); gst_props_add_entry (props, (GstPropsEntry *) entry);
/* some more properties */ entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE,
entry = gst_props_entry_new ("serial", GST_PROPS_INT_TYPE, ov_serialnumber (vf, link)); ov_serialnumber (vf, link));
gst_props_add_entry (props, (GstPropsEntry *) entry); gst_props_add_entry (props, (GstPropsEntry *) entry);
entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE, ov_bitrate (vf, link)); entry = gst_props_entry_new ("bitrate", GST_PROPS_INT_TYPE,
ov_bitrate (vf, link));
gst_props_add_entry (props, (GstPropsEntry *) entry); gst_props_add_entry (props, (GstPropsEntry *) entry);
vorbisfile->metadata = gst_caps_new ("vorbisfile_metadata", vorbisfile->metadata = gst_caps_new ("vorbisfile_metadata",
@ -418,6 +452,7 @@ gst_vorbisfile_new_link (VorbisFile *vorbisfile, gint link)
vorbisfile->current_link = link; vorbisfile->current_link = link;
gst_vorbisfile_update_metadata (vorbisfile, link); gst_vorbisfile_update_metadata (vorbisfile, link);
gst_vorbisfile_update_tags (vorbisfile, link);
if (gst_pad_try_set_caps (vorbisfile->srcpad, if (gst_pad_try_set_caps (vorbisfile->srcpad,
GST_CAPS_NEW ("vorbisdec_src", GST_CAPS_NEW ("vorbisdec_src",
@ -1013,11 +1048,13 @@ gst_vorbisfile_get_property (GObject *object, guint prop_id,
vorbisfile = GST_VORBISFILE (object); vorbisfile = GST_VORBISFILE (object);
/* FIXME: the reupdate could be expensive */
switch (prop_id) { switch (prop_id) {
case ARG_METADATA: case ARG_METADATA:
g_value_set_boxed (value, vorbisfile->metadata); g_value_set_boxed (value, vorbisfile->metadata);
break; break;
case ARG_TAGS:
g_value_set_boxed (value, vorbisfile->tags);
break;
default: default:
g_warning ("Unknown property id\n"); g_warning ("Unknown property id\n");
} }