mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 10:25:33 +00:00
Metadata support
Original commit message from CVS: Metadata support Bugfix and code cleanup
This commit is contained in:
parent
ed6cf23b38
commit
0f08b0e460
3 changed files with 143 additions and 21 deletions
|
@ -42,7 +42,8 @@ enum
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0
|
ARG_0,
|
||||||
|
ARG_METADATA,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_monkeydec_class_init (GstMonkeyDecClass *klass);
|
static void gst_monkeydec_class_init (GstMonkeyDecClass *klass);
|
||||||
|
@ -59,6 +60,12 @@ static const GstFormat*
|
||||||
gst_monkeydec_get_formats (GstPad *pad);
|
gst_monkeydec_get_formats (GstPad *pad);
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
gst_monkeydec_change_state (GstElement *element);
|
gst_monkeydec_change_state (GstElement *element);
|
||||||
|
static void gst_monkeydec_get_property (GObject *object, guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
static void gst_monkeydec_set_property (GObject *object, guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
@ -95,8 +102,14 @@ gst_monkeydec_class_init (GstMonkeyDecClass *klass)
|
||||||
gstelement_class = (GstElementClass *) klass;
|
gstelement_class = (GstElementClass *) klass;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_monkeydec_change_state;
|
gstelement_class->change_state = gst_monkeydec_change_state;
|
||||||
|
gobject_class->get_property = gst_monkeydec_get_property;
|
||||||
|
gobject_class->set_property = gst_monkeydec_set_property;
|
||||||
|
|
||||||
parent_class = GST_ELEMENT_CLASS( g_type_class_ref(GST_TYPE_ELEMENT));
|
parent_class = GST_ELEMENT_CLASS( g_type_class_ref(GST_TYPE_ELEMENT));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, ARG_METADATA,
|
||||||
|
g_param_spec_boxed ("metadata", "Metadata", "(logical) Stream metadata",
|
||||||
|
GST_TYPE_CAPS, G_PARAM_READABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,6 +128,8 @@ gst_monkeydec_init (GstMonkeyDec * monkeydec)
|
||||||
gst_pad_set_query_function (monkeydec->srcpad, gst_monkeydec_src_query);
|
gst_pad_set_query_function (monkeydec->srcpad, gst_monkeydec_src_query);
|
||||||
gst_pad_set_query_type_function (monkeydec->srcpad, (GstPadQueryTypeFunction)(gst_monkeydec_get_query_types));
|
gst_pad_set_query_type_function (monkeydec->srcpad, (GstPadQueryTypeFunction)(gst_monkeydec_get_query_types));
|
||||||
gst_pad_set_formats_function (monkeydec->srcpad, (GstPadFormatsFunction)(gst_monkeydec_get_formats));
|
gst_pad_set_formats_function (monkeydec->srcpad, (GstPadFormatsFunction)(gst_monkeydec_get_formats));
|
||||||
|
|
||||||
|
monkeydec->metadata = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,7 +181,6 @@ gst_monkeydec_src_query (GstPad *pad, GstQueryType type,
|
||||||
*format = GST_FORMAT_TIME;
|
*format = GST_FORMAT_TIME;
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
*value = monkeydec->decomp->GetInfo (APE_DECOMPRESS_LENGTH_MS) * 1000000LL;
|
*value = monkeydec->decomp->GetInfo (APE_DECOMPRESS_LENGTH_MS) * 1000000LL;
|
||||||
g_print ("Song lentgh : %lld\n", *value);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
|
@ -179,7 +193,6 @@ g_print ("Song lentgh : %lld\n", *value);
|
||||||
*format = GST_FORMAT_TIME;
|
*format = GST_FORMAT_TIME;
|
||||||
default:
|
default:
|
||||||
*value = monkeydec->decomp->GetInfo (APE_DECOMPRESS_CURRENT_MS) * 1000000LL;
|
*value = monkeydec->decomp->GetInfo (APE_DECOMPRESS_CURRENT_MS) * 1000000LL;
|
||||||
//g_print ("Song position : %lld\n", *value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -210,10 +223,8 @@ gst_monkeydec_src_event (GstPad *pad, GstEvent *event)
|
||||||
/* shave off the flush flag, we'll need it later */
|
/* shave off the flush flag, we'll need it later */
|
||||||
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
|
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH;
|
||||||
|
|
||||||
monkeydec->seek_to = GST_EVENT_SEEK_OFFSET (event) * monkeydec->frequency / GST_SECOND;
|
monkeydec->seek_to = GST_EVENT_SEEK_OFFSET (event) * monkeydec->frequency / GST_SECOND;
|
||||||
g_print ("Seek to : %lld\n", monkeydec->seek_to);
|
monkeydec->io->need_discont = TRUE;
|
||||||
|
|
||||||
monkeydec->io->need_discont = TRUE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -226,6 +237,64 @@ g_print ("Seek to : %lld\n", monkeydec->seek_to);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_monkeydec_update_metadata (GstMonkeyDec *monkeydec)
|
||||||
|
{
|
||||||
|
GstProps *props = NULL;
|
||||||
|
GstPropsEntry *entry;
|
||||||
|
gchar *name, *value;
|
||||||
|
CAPETagField *field;
|
||||||
|
CAPETag *tag;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
/* clear old one */
|
||||||
|
if (monkeydec->metadata) {
|
||||||
|
gst_caps_unref (monkeydec->metadata);
|
||||||
|
monkeydec->metadata = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_return_val_if_fail (monkeydec, FALSE);
|
||||||
|
|
||||||
|
tag = new CAPETag (monkeydec->io, TRUE);
|
||||||
|
g_return_val_if_fail (tag, FALSE);
|
||||||
|
|
||||||
|
if (!tag->GetHasAPETag ())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
ret = tag->GetNextTagField (TRUE, &field);
|
||||||
|
g_return_val_if_fail (ret, FALSE);
|
||||||
|
|
||||||
|
/* create props to hold the key/value pairs */
|
||||||
|
props = gst_props_empty_new ();
|
||||||
|
|
||||||
|
while (ret)
|
||||||
|
{
|
||||||
|
if (field->GetFieldValueSize() != 0)
|
||||||
|
{
|
||||||
|
name = g_strndup (field->GetFieldName(), field->GetFieldSize());
|
||||||
|
value = g_strndup (field->GetFieldValue(), field->GetFieldValueSize());
|
||||||
|
|
||||||
|
entry = gst_props_entry_new (name, GST_PROPS_STRING_TYPE, value);
|
||||||
|
gst_props_add_entry (props, (GstPropsEntry *) entry);
|
||||||
|
|
||||||
|
g_print ("%s : %s\n", name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = tag->GetNextTagField (FALSE, &field);
|
||||||
|
}
|
||||||
|
|
||||||
|
monkeydec->metadata = gst_caps_new ("monkeydec_metadata", "application/x-gst-metadata",
|
||||||
|
props);
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (monkeydec), "metadata");
|
||||||
|
|
||||||
|
delete tag;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_monkeydec_loop (GstElement *element)
|
gst_monkeydec_loop (GstElement *element)
|
||||||
{
|
{
|
||||||
|
@ -236,6 +305,7 @@ gst_monkeydec_loop (GstElement *element)
|
||||||
gint64 timestamp;
|
gint64 timestamp;
|
||||||
gint retval;
|
gint retval;
|
||||||
|
|
||||||
|
|
||||||
g_return_if_fail (element != NULL);
|
g_return_if_fail (element != NULL);
|
||||||
g_return_if_fail (GST_IS_MONKEYDEC (element));
|
g_return_if_fail (GST_IS_MONKEYDEC (element));
|
||||||
|
|
||||||
|
@ -255,8 +325,23 @@ gst_monkeydec_loop (GstElement *element)
|
||||||
}
|
}
|
||||||
|
|
||||||
monkeydec->io->sinkpad = monkeydec->sinkpad;
|
monkeydec->io->sinkpad = monkeydec->sinkpad;
|
||||||
|
|
||||||
monkeydec->io->Open ("");
|
monkeydec->io->Open ("");
|
||||||
|
|
||||||
|
gst_monkeydec_update_metadata (monkeydec);
|
||||||
|
/*monkeydec->tag = new CAPETag (monkeydec->io, TRUE);
|
||||||
|
if (monkeydec->tag->GetHasAPETag ())
|
||||||
|
g_print ("Yes APE\n");
|
||||||
|
else
|
||||||
|
g_print ("No APE\n");
|
||||||
|
|
||||||
|
if (monkeydec->tag->GetHasID3Tag ())
|
||||||
|
g_print ("Yes Id3\n");
|
||||||
|
else
|
||||||
|
g_print ("No Id3\n");
|
||||||
|
|
||||||
|
if (monkeydec->tag->GetNextTagField(TRUE, &field))
|
||||||
|
g_print ("Champs : %s %.*s\n", field->GetFieldName(), field->GetFieldValueSize(), field->GetFieldValue());
|
||||||
|
*/
|
||||||
monkeydec->decomp = CreateIAPEDecompressEx (monkeydec->io, &retval);
|
monkeydec->decomp = CreateIAPEDecompressEx (monkeydec->io, &retval);
|
||||||
if (monkeydec->decomp == NULL)
|
if (monkeydec->decomp == NULL)
|
||||||
{
|
{
|
||||||
|
@ -285,9 +370,13 @@ gst_monkeydec_loop (GstElement *element)
|
||||||
monkeydec->seek_to = 0;
|
monkeydec->seek_to = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
monkeydec->decomp->GetData((char *) GST_BUFFER_DATA (buffer_out), 1024, &blocks_retrieved);
|
||||||
|
|
||||||
format = GST_FORMAT_TIME;
|
format = GST_FORMAT_TIME;
|
||||||
gst_monkeydec_src_query (monkeydec->srcpad, GST_QUERY_POSITION, &format, ×tamp);
|
gst_monkeydec_src_query (monkeydec->srcpad, GST_QUERY_POSITION, &format, ×tamp);
|
||||||
|
|
||||||
|
GST_BUFFER_SIZE (buffer_out) = blocks_retrieved * monkeydec->decomp->GetInfo(APE_INFO_BLOCK_ALIGN);
|
||||||
|
GST_BUFFER_TIMESTAMP (buffer_out) = timestamp;
|
||||||
|
|
||||||
if (monkeydec->io->need_discont)
|
if (monkeydec->io->need_discont)
|
||||||
{
|
{
|
||||||
|
@ -304,12 +393,6 @@ gst_monkeydec_loop (GstElement *element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
monkeydec->decomp->GetData((char *) GST_BUFFER_DATA (buffer_out), 1024, &blocks_retrieved);
|
|
||||||
|
|
||||||
GST_BUFFER_SIZE (buffer_out) = blocks_retrieved * monkeydec->decomp->GetInfo(APE_INFO_BLOCK_ALIGN);
|
|
||||||
GST_BUFFER_TIMESTAMP (buffer_out) = timestamp;
|
|
||||||
|
|
||||||
|
|
||||||
if (!GST_PAD_CAPS (monkeydec->srcpad)) {
|
if (!GST_PAD_CAPS (monkeydec->srcpad)) {
|
||||||
gst_pad_try_set_caps (monkeydec->srcpad,
|
gst_pad_try_set_caps (monkeydec->srcpad,
|
||||||
GST_CAPS_NEW (
|
GST_CAPS_NEW (
|
||||||
|
@ -368,3 +451,41 @@ gst_monkeydec_change_state (GstElement *element)
|
||||||
|
|
||||||
return GST_STATE_SUCCESS;
|
return GST_STATE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_monkeydec_set_property (GObject *object, guint prop_id,
|
||||||
|
const GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GstMonkeyDec *monkeydec;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_MONKEYDEC (object));
|
||||||
|
|
||||||
|
monkeydec = GST_MONKEYDEC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
default:
|
||||||
|
g_warning ("Unknown property id\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_monkeydec_get_property (GObject *object, guint prop_id,
|
||||||
|
GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GstMonkeyDec *monkeydec;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_MONKEYDEC (object));
|
||||||
|
|
||||||
|
monkeydec = GST_MONKEYDEC (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case ARG_METADATA:
|
||||||
|
g_value_set_boxed (value, monkeydec->metadata);
|
||||||
|
break;
|
||||||
|
/* case ARG_STREAMINFO:
|
||||||
|
g_value_set_boxed (value, monkeydec->streaminfo);
|
||||||
|
break;*/
|
||||||
|
default:
|
||||||
|
g_warning ("Unknown property id\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "libmonkeyaudio/GlobalFunctions.h"
|
#include "libmonkeyaudio/GlobalFunctions.h"
|
||||||
#include "libmonkeyaudio/MACLib.h"
|
#include "libmonkeyaudio/MACLib.h"
|
||||||
#include "libmonkeyaudio/IO.h"
|
#include "libmonkeyaudio/IO.h"
|
||||||
|
#include "libmonkeyaudio/APETag.h"
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ struct _GstMonkeyDec
|
||||||
guint channels;
|
guint channels;
|
||||||
guint frequency;
|
guint frequency;
|
||||||
guint depth;
|
guint depth;
|
||||||
|
GstCaps *metadata;
|
||||||
|
|
||||||
IAPEDecompress *decomp;
|
IAPEDecompress *decomp;
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,7 @@ GstSeekType seek_type;
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (gst_bytestream_seek (bs, (gint64) ABS (nDistance), seek_type))
|
||||||
if (gst_bytestream_seek (bs, nDistance, seek_type))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue