Merge CAPS branch

Original commit message from CVS:
Merge CAPS branch
This commit is contained in:
David Schleef 2003-12-22 01:47:08 +00:00
parent aca4c1865c
commit 200089a2ba
37 changed files with 1829 additions and 1865 deletions

View file

@ -12,78 +12,27 @@ struct probe_context {
gint total_ls;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
};
static void
print_caps (GstCaps *caps)
{
if (caps == NULL) return;
if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") ||
!strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo"))
{
GstProps *props = caps->properties;
GList *walk;
/* ugly hack, but ok for now. If needed, fix by individual strcmp */
g_print (" %s:\n", gst_caps_get_mime (caps) + 18);
if (props == NULL) {
g_print (" none\n");
return;
}
walk = props->properties;
while (walk) {
GstPropsEntry *entry = (GstPropsEntry *) walk->data;
const gchar *name;
const gchar *str_val;
gint int_val;
GstPropsType type;
name = gst_props_entry_get_name (entry);
type = gst_props_entry_get_props_type (entry);
switch (type) {
case GST_PROPS_STRING_TYPE:
gst_props_entry_get_string (entry, &str_val);
g_print (" %s='%s'\n", name, str_val);
break;
case GST_PROPS_INT_TYPE:
gst_props_entry_get_int (entry, &int_val);
g_print (" %s=%d\n", name, int_val);
break;
default:
break;
}
walk = g_list_next (walk);
}
}
else {
g_print (" unkown caps type\n");
}
char *s;
s = gst_caps_to_string (caps);
g_print(" %s\n", s);
g_free (s);
}
static void
print_format (GstCaps *caps)
{
g_print (" format:\n");
if (!caps || caps->properties == NULL) {
g_print (" unkown\n");
return;
}
if (!strcmp (gst_caps_get_mime (caps), "audio/raw")) {
gint channels;
gint rate;
gst_caps_get_int (caps, "channels", &channels);
gst_caps_get_int (caps, "rate", &rate);
g_print (" channels: %d\n", channels);
g_print (" rate: %d\n", rate);
}
else {
g_print (" unkown format\n");
}
char *s;
s = gst_caps_to_string (caps);
g_print(" format: %s\n", s);
g_free (s);
}
static void

View file

@ -67,37 +67,32 @@ enum
{
ARG_0,
ARG_DRC,
ARG_STREAMINFO
};
/*
* "audio/a52" and "audio/ac3" are the same format. The name
* "ac3" is now deprecated and should not be used in new code.
*/
GST_PAD_TEMPLATE_FACTORY (sink_factory,
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"a52dec_sink",
"audio/x-ac3",
NULL
)
GST_STATIC_CAPS ("audio/x-ac3")
);
GST_PAD_TEMPLATE_FACTORY (src_factory,
static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"a52dec_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (4000, 48000),
"channels", GST_PROPS_INT_RANGE (1, 6)
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 4000, 48000 ], "
"channels = (int) [ 1, 6 ]"
)
);
@ -145,9 +140,9 @@ gst_a52dec_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_factory));
gst_static_pad_template_get (&sink_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_factory));
gst_static_pad_template_get (&src_factory));
gst_element_class_set_details (element_class, &gst_a52dec_details);
}
@ -165,9 +160,6 @@ gst_a52dec_class_init (GstA52DecClass * klass)
g_param_spec_boolean ("drc", "Dynamic Range Compression",
"Use Dynamic Range Compression", FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_STREAMINFO,
g_param_spec_boxed ("streaminfo", "Streaminfo", "Streaminfo",
GST_TYPE_CAPS, G_PARAM_READABLE));
gobject_class->set_property = gst_a52dec_set_property;
gobject_class->get_property = gst_a52dec_get_property;
@ -179,15 +171,16 @@ static void
gst_a52dec_init (GstA52Dec * a52dec)
{
/* create the sink and src pads */
a52dec->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink");
a52dec->sinkpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (a52dec), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->sinkpad);
gst_element_set_loop_function ((GstElement *) a52dec, gst_a52dec_loop);
a52dec->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src");
a52dec->srcpad = gst_pad_new_from_template (
gst_element_get_pad_template (GST_ELEMENT (a52dec), "src"), "src");
gst_element_add_pad (GST_ELEMENT (a52dec), a52dec->srcpad);
a52dec->dynamic_range_compression = FALSE;
a52dec->streaminfo = NULL;
}
/* BEGIN modified a52dec conversion code */
@ -373,15 +366,14 @@ gst_a52dec_reneg (GstPad * pad, int channels, int rate)
GST_INFO ( "a52dec: reneg channels:%d rate:%d\n", channels, rate);
if (gst_pad_try_set_caps (pad,
GST_CAPS_NEW ("a52dec_src_caps",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"channels", GST_PROPS_INT (channels),
"rate", GST_PROPS_INT (rate))
) <= 0) {
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, rate,
NULL)) <= 0) {
gst_element_error (GST_PAD_PARENT (pad), "could not set caps on source pad, aborting...");
}
}
@ -408,6 +400,7 @@ gst_a52dec_handle_event (GstA52Dec *a52dec)
}
}
#if 0
static void
gst_a52dec_update_streaminfo (GstA52Dec *a52dec)
{
@ -426,6 +419,7 @@ gst_a52dec_update_streaminfo (GstA52Dec *a52dec)
props);
g_object_notify (G_OBJECT (a52dec), "streaminfo");
}
#endif
static void
gst_a52dec_loop (GstElement *element)
@ -471,7 +465,6 @@ gst_a52dec_loop (GstElement *element)
if (bit_rate != a52dec->bit_rate) {
a52dec->bit_rate = bit_rate;
gst_a52dec_update_streaminfo (a52dec);
}
/* read the header + rest of frame */
@ -568,7 +561,6 @@ gst_a52dec_change_state (GstElement * element)
a52dec->samples = NULL;
a52_free (a52dec->state);
a52dec->state = NULL;
gst_caps_unref (a52dec->streaminfo);
break;
case GST_STATE_READY_TO_NULL:
break;
@ -614,9 +606,6 @@ gst_a52dec_get_property (GObject * object, guint prop_id, GValue * value, GParam
case ARG_DRC:
g_value_set_boolean (value, src->dynamic_range_compression);
break;
case ARG_STREAMINFO:
g_value_set_boxed (value, src->streaminfo);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -62,8 +62,6 @@ struct _GstA52Dec {
GstClockTime last_ts;
GstClockTime current_ts;
GstCaps *streaminfo;
};
struct _GstA52DecClass {

View file

@ -51,7 +51,7 @@ struct _DVDNavSrc {
GstElement element;
/* pads */
GstPad *srcpad;
GstPad *srcpad;
GstCaps *streaminfo;
/* location */
@ -59,7 +59,6 @@ struct _DVDNavSrc {
gboolean did_seek;
gboolean need_flush;
GstBufferPool *bufferpool;
int title, chapter, angle;
dvdnav_t *dvdnav;
@ -293,8 +292,6 @@ dvdnavsrc_init (DVDNavSrc *src)
gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
src->bufferpool = gst_buffer_pool_get_default (DVD_VIDEO_LB_LEN, 2);
src->location = g_strdup("/dev/dvd");
src->did_seek = FALSE;
src->need_flush = FALSE;
@ -305,17 +302,6 @@ dvdnavsrc_init (DVDNavSrc *src)
src->buttoninfo = NULL;
}
/* FIXME: this code is not being used */
#ifdef PLEASEFIXTHISCODE
static void
dvdnavsrc_destroy (DVDNavSrc *dvdnavsrc)
{
/* FIXME */
g_print("FIXME\n");
gst_buffer_pool_destroy (dvdnavsrc->bufferpool);
}
#endif
static gboolean
dvdnavsrc_is_open (DVDNavSrc *src)
{
@ -518,49 +504,36 @@ static void
dvdnavsrc_update_streaminfo (DVDNavSrc *src)
{
GstCaps *caps;
GstProps *props;
GstPropsEntry *entry;
GstStructure *structure;
gint64 value;
props = gst_props_empty_new ();
/*
entry = gst_props_entry_new ("title_string", GST_PROPS_STRING (""));
gst_props_add_entry (props, entry);
*/
caps = gst_caps_new_empty();
structure = gst_structure_empty_new ("application/x-gst-streaminfo");
gst_caps_append_structure (caps, structure);
if (dvdnavsrc_query(src->srcpad, GST_QUERY_TOTAL, &title_format, &value)) {
entry = gst_props_entry_new ("titles", GST_PROPS_INT (value));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, "titles", G_TYPE_INT, value, NULL);
}
if (dvdnavsrc_query(src->srcpad, GST_QUERY_POSITION, &title_format, &value)) {
entry = gst_props_entry_new ("title", GST_PROPS_INT (value));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, "title", G_TYPE_INT, value, NULL);
}
if (dvdnavsrc_query(src->srcpad, GST_QUERY_TOTAL, &chapter_format, &value)) {
entry = gst_props_entry_new ("chapters", GST_PROPS_INT (value));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, "chapters", G_TYPE_INT, value, NULL);
}
if (dvdnavsrc_query(src->srcpad, GST_QUERY_POSITION, &chapter_format, &value)) {
entry = gst_props_entry_new ("chapter", GST_PROPS_INT (value));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, "chapter", G_TYPE_INT, value, NULL);
}
if (dvdnavsrc_query(src->srcpad, GST_QUERY_TOTAL, &angle_format, &value)) {
entry = gst_props_entry_new ("angles", GST_PROPS_INT (value));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, "angles", G_TYPE_INT, value, NULL);
}
if (dvdnavsrc_query(src->srcpad, GST_QUERY_POSITION, &angle_format, &value)) {
entry = gst_props_entry_new ("angle", GST_PROPS_INT (value));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, "angle", G_TYPE_INT, value, NULL);
}
caps = gst_caps_new ("dvdnavsrc_streaminfo",
"application/x-gst-streaminfo",
props);
if (src->streaminfo) {
gst_caps_unref (src->streaminfo);
gst_caps_free (src->streaminfo);
}
src->streaminfo = caps;
g_object_notify (G_OBJECT (src), "streaminfo");
@ -570,23 +543,16 @@ static void
dvdnavsrc_update_buttoninfo (DVDNavSrc *src)
{
GstCaps *caps;
GstProps *props;
GstPropsEntry *entry;
pci_t *pci;
pci = dvdnav_get_current_nav_pci(src->dvdnav);
fprintf(stderr, "update button info total:%d\n", pci->hli.hl_gi.btn_ns);
props = gst_props_empty_new ();
entry = gst_props_entry_new ("total", GST_PROPS_INT (pci->hli.hl_gi.btn_ns));
gst_props_add_entry (props, entry);
caps = gst_caps_new ("dvdnavsrc_buttoninfo",
caps = gst_caps_new_simple ("dvdnavsrc_buttoninfo",
"application/x-gst-dvdnavsrc-buttoninfo",
props);
"total", G_TYPE_INT, pci->hli.hl_gi.btn_ns, NULL);
if (src->buttoninfo) {
gst_caps_unref (src->buttoninfo);
gst_caps_free (src->buttoninfo);
}
src->buttoninfo = caps;
g_object_notify (G_OBJECT (src), "buttoninfo");
@ -870,9 +836,7 @@ dvdnavsrc_get (GstPad *pad)
/* loop processing blocks until data is pushed */
have_buf = FALSE;
while (!have_buf) {
/* allocate a pool for the buffer data */
/* FIXME: mem leak on non BLOCK_OK events */
buf = gst_buffer_new_from_pool (src->bufferpool, DVD_VIDEO_LB_LEN, 0);
buf = gst_buffer_new_and_alloc (DVD_VIDEO_LB_LEN);
if (!buf) {
gst_element_error (GST_ELEMENT (src), "Failed to create a new GstBuffer");
return NULL;

View file

@ -32,55 +32,35 @@ static GstElementDetails gst_lame_details =
"Erik Walthinsen <omega@cse.ogi.edu>",
};
GST_PAD_TEMPLATE_FACTORY (gst_lame_sink_factory,
static GstStaticPadTemplate gst_lame_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"gstlame_sink",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_LIST (
GST_PROPS_INT (8000),
GST_PROPS_INT (11025),
GST_PROPS_INT (12000),
GST_PROPS_INT (16000),
GST_PROPS_INT (22050),
GST_PROPS_INT (24000),
GST_PROPS_INT (32000),
GST_PROPS_INT (44100),
GST_PROPS_INT (48000)
),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]"
)
)
);
GST_PAD_TEMPLATE_FACTORY (gst_lame_src_factory,
static GstStaticPadTemplate gst_lame_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"gstlame_src",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (3),
"rate", GST_PROPS_LIST (
GST_PROPS_INT (8000),
GST_PROPS_INT (11025),
GST_PROPS_INT (12000),
GST_PROPS_INT (16000),
GST_PROPS_INT (22050),
GST_PROPS_INT (24000),
GST_PROPS_INT (32000),
GST_PROPS_INT (44100),
GST_PROPS_INT (48000)
),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS (
"audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) 3, "
"rate = (int) { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]"
)
)
);
/********** Define useful types for non-programmatic interfaces **********/
#define GST_TYPE_LAME_MODE (gst_lame_mode_get_type())
@ -235,8 +215,10 @@ gst_lame_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_lame_src_factory));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_lame_sink_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_lame_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_lame_sink_template));
gst_element_class_set_details (element_class, &gst_lame_details);
}
@ -358,21 +340,18 @@ gst_lame_class_init (GstLameClass *klass)
}
static GstPadLinkReturn
gst_lame_sinkconnect (GstPad *pad, GstCaps *caps)
gst_lame_sink_link (GstPad *pad, const GstCaps *caps)
{
GstLame *lame;
gint out_samplerate;
GstStructure *structure;
GstCaps *othercaps;
lame = GST_LAME (gst_pad_get_parent (pad));
structure = gst_caps_get_structure (caps, 0);
if (!GST_CAPS_IS_FIXED (caps)) {
GST_DEBUG ("caps on lame pad %s:%s not fixed, delayed",
GST_DEBUG_PAD_NAME (pad));
return GST_PAD_LINK_DELAYED;
}
gst_caps_get_int (caps, "rate", &lame->samplerate);
gst_caps_get_int (caps, "channels", &lame->num_channels);
gst_structure_get_int (structure, "rate", &lame->samplerate);
gst_structure_get_int (structure, "channels", &lame->num_channels);
if (!gst_lame_setup (lame)) {
gst_element_error (GST_ELEMENT (lame),
@ -381,14 +360,17 @@ gst_lame_sinkconnect (GstPad *pad, GstCaps *caps)
}
out_samplerate = lame_get_out_samplerate (lame->lgf);
caps = GST_CAPS_NEW ("lame_src_caps",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (3),
"channels", GST_PROPS_INT (lame->num_channels),
"rate", GST_PROPS_INT (out_samplerate));
othercaps =
gst_caps_new_simple (
"audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 3,
"channels", G_TYPE_INT, lame->num_channels,
"rate", G_TYPE_INT, out_samplerate,
NULL
);
return gst_pad_try_set_caps (lame->srcpad, caps);
return gst_pad_try_set_caps (lame->srcpad, othercaps);
}
static void
@ -396,12 +378,14 @@ gst_lame_init (GstLame *lame)
{
GST_DEBUG_OBJECT (lame, "starting initialization");
lame->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (gst_lame_sink_factory), "sink");
lame->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_lame_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (lame), lame->sinkpad);
gst_pad_set_chain_function (lame->sinkpad, gst_lame_chain);
gst_pad_set_link_function (lame->sinkpad, gst_lame_sinkconnect);
gst_pad_set_link_function (lame->sinkpad, gst_lame_sink_link);
lame->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (gst_lame_src_factory), "src");
lame->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_lame_src_template), "src");
gst_element_add_pad (GST_ELEMENT (lame), lame->srcpad);
GST_FLAG_SET (lame, GST_ELEMENT_EVENT_AWARE);

View file

@ -111,24 +111,22 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (id3_tag_src_template_factory,
static GstStaticPadTemplate id3_tag_src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
/* FIXME: for spider - GST_PAD_ALWAYS, */
GST_PAD_SOMETIMES,
NULL
)
GST_STATIC_CAPS ("application/x-id3; application/x-gst-tags")
);
GST_PAD_TEMPLATE_FACTORY (id3_tag_sink_template_factory,
static GstStaticPadTemplate id3_tag_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"id3_tag_data_sink",
"application/x-id3",
NULL
)
)
GST_STATIC_CAPS ("application/x-id3")
);
static void gst_id3_tag_base_init (gpointer g_class);
@ -200,9 +198,9 @@ gst_id3_tag_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &gst_id3_tag_details);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (id3_tag_sink_template_factory));
gst_static_pad_template_get (&id3_tag_sink_template_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (id3_tag_src_template_factory));
gst_static_pad_template_get (&id3_tag_src_template_factory));
}
static void
gst_id3_tag_class_init (GstID3TagClass *klass)
@ -230,25 +228,27 @@ gst_id3_tag_class_init (GstID3TagClass *klass)
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_id3_tag_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_id3_tag_get_property);
}
static GstCaps *
gst_id3_tag_get_caps (GstPad *pad, GstCaps *unused)
gst_id3_tag_get_caps (GstPad *pad)
{
GstID3Tag *tag = GST_ID3_TAG (gst_pad_get_parent (pad));
if (tag->found_caps) {
GstCaps *caps = GST_CAPS_NEW ("gstid3tag", "application/x-gst-tags", NULL);
caps = gst_caps_append (caps, GST_CAPS_NEW ("gstid3tag", "application/x-id3", NULL));
caps = gst_caps_append (caps, gst_caps_copy (tag->found_caps));
GstCaps *caps;
caps = gst_caps_from_string ("application/x-gst-tags; application/x-id3");
gst_caps_append (caps, gst_caps_copy (tag->found_caps));
return caps;
} else {
return GST_CAPS_ANY;
return gst_caps_new_any ();
}
}
static void
gst_id3_tag_add_src_pad (GstID3Tag *tag)
{
tag->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (id3_tag_src_template_factory), "src");
tag->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (
&id3_tag_src_template_factory), "src");
gst_pad_set_event_function (tag->srcpad, GST_DEBUG_FUNCPTR (gst_id3_tag_src_event));
gst_pad_set_event_mask_function (tag->srcpad, GST_DEBUG_FUNCPTR (gst_id3_tag_get_event_masks));
gst_pad_set_query_function (tag->srcpad, GST_DEBUG_FUNCPTR (gst_id3_tag_src_query));
@ -261,7 +261,7 @@ gst_id3_tag_init (GstID3Tag *tag)
{
/* create the sink and src pads */
tag->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (id3_tag_sink_template_factory), "sink");
gst_static_pad_template_get (&id3_tag_sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (tag), tag->sinkpad);
gst_pad_set_chain_function (tag->sinkpad, GST_DEBUG_FUNCPTR (gst_id3_tag_chain));
@ -695,12 +695,12 @@ simple_find_peek (gpointer data, gint64 offset, guint size)
return NULL;
}
static void
simple_find_suggest (gpointer data, guint probability, GstCaps *caps)
simple_find_suggest (gpointer data, guint probability, const GstCaps *caps)
{
SimpleTypeFind *find = (SimpleTypeFind *) data;
if (probability > find->best_probability) {
gst_caps_replace (&find->caps, caps);
gst_caps_replace (&find->caps, gst_caps_copy (caps));
find->best_probability = probability;
}
}
@ -756,12 +756,12 @@ gst_id3_tag_do_caps_nego (GstID3Tag *tag, GstBuffer *buffer)
gst_id3_tag_add_src_pad (tag);
do {
caps = GST_CAPS_NEW ("id3_tag_data_src", "application/x-id3", NULL);
caps = gst_caps_new_simple ("application/x-id3", NULL);
if (gst_pad_try_set_caps (tag->srcpad, caps) != GST_PAD_LINK_REFUSED) {
tag->parse_mode = GST_ID3_TAG_PARSE_WRITE;
GST_LOG_OBJECT (tag, "normal operation, using application/x-id3 output");
} else {
caps = GST_CAPS_NEW ("id3_tag_tag_src", "application/x-gst-tags", NULL);
caps = gst_caps_new_simple ("application/x-gst-tags", NULL);
if (gst_pad_try_set_caps (tag->srcpad, caps) != GST_PAD_LINK_REFUSED) {
tag->parse_mode = GST_ID3_TAG_PARSE_TAG;
GST_LOG_OBJECT (tag, "fast operation, just outputting tags");
@ -771,10 +771,9 @@ gst_id3_tag_do_caps_nego (GstID3Tag *tag, GstBuffer *buffer)
tag->parse_mode = GST_ID3_TAG_PARSE_PARSE;
GST_LOG_OBJECT (tag, "parsing operation, extracting tags");
} else {
caps = GST_CAPS_NEW ("id3_tag_data_src", "application/x-id3", NULL);
caps = gst_caps_append (caps,
GST_CAPS_NEW ("id3_tag_tag_src", "application/x-gst-tags", NULL));
caps = gst_caps_append (caps, tag->found_caps);
caps = gst_caps_from_string ("application/x-id3; "
"application/x-gst-tags");
gst_caps_append (caps, tag->found_caps);
if (gst_pad_recover_caps_error (tag->srcpad, caps)) {
tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN;
continue;
@ -1022,7 +1021,7 @@ gst_id3_tag_change_state (GstElement *element)
tag->buffer = NULL;
}
if (tag->found_caps) {
gst_caps_unref (tag->found_caps);
gst_caps_free (tag->found_caps);
tag->found_caps = NULL;
}
tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN;

View file

@ -107,34 +107,31 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (mad_src_template_factory,
static GstStaticPadTemplate mad_src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mad_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (11025, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
"signed = (boolean) true, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 11025, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
)
);
GST_PAD_TEMPLATE_FACTORY (mad_sink_template_factory,
static GstStaticPadTemplate mad_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mad_sink",
"audio/mpeg",
/* we don't need channel/rate ... */
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT_RANGE (1, 3)
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) [ 1, 3 ]"
)
)
);
static void gst_mad_base_init (gpointer g_class);
static void gst_mad_class_init (GstMadClass *klass);
@ -256,9 +253,9 @@ gst_mad_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (mad_sink_template_factory));
gst_static_pad_template_get (&mad_sink_template_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (mad_src_template_factory));
gst_static_pad_template_get (&mad_src_template_factory));
gst_element_class_set_details (element_class, &gst_mad_details);
}
static void
@ -297,14 +294,14 @@ gst_mad_init (GstMad *mad)
{
/* create the sink and src pads */
mad->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (mad_sink_template_factory), "sink");
gst_static_pad_template_get (&mad_sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (mad), mad->sinkpad);
gst_pad_set_chain_function (mad->sinkpad, GST_DEBUG_FUNCPTR (gst_mad_chain));
gst_pad_set_convert_function (mad->sinkpad, GST_DEBUG_FUNCPTR (gst_mad_convert_sink));
gst_pad_set_formats_function (mad->sinkpad, GST_DEBUG_FUNCPTR (gst_mad_get_formats));
mad->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (mad_src_template_factory), "src");
gst_static_pad_template_get (&mad_src_template_factory), "src");
gst_element_add_pad (GST_ELEMENT (mad), mad->srcpad);
gst_pad_set_event_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_src_event));
gst_pad_set_event_mask_function (mad->srcpad, GST_DEBUG_FUNCPTR (gst_mad_get_event_masks));
@ -1066,17 +1063,14 @@ gst_mad_chain (GstPad *pad, GstData *_data)
/* we set the caps even when the pad is not connected so they
* can be gotten for streaminfo */
if (gst_pad_try_set_caps (mad->srcpad,
gst_caps_new (
"mad_src",
"audio/x-raw-int",
gst_props_new (
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT (rate),
"channels", GST_PROPS_INT (nchannels),
NULL))) <= 0)
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, nchannels,
NULL)) <= 0)
{
if (!gst_pad_recover_caps_error (mad->srcpad, NULL)) {
gst_buffer_unref (buffer);

View file

@ -54,59 +54,40 @@ enum {
enum {
ARG_0,
ARG_STREAMINFO,
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (src_template_factory,
static GstStaticPadTemplate src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mpeg2dec_src",
"video/x-raw-yuv",
"format", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','V','1','2')),
GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0'))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"pixel_width", GST_PROPS_INT_RANGE (1, 255),
"pixel_height", GST_PROPS_INT_RANGE (1, 255),
"framerate", GST_PROPS_LIST (
GST_PROPS_FLOAT (24/1.001),
GST_PROPS_FLOAT (24.),
GST_PROPS_FLOAT (25.),
GST_PROPS_FLOAT (30/1.001),
GST_PROPS_FLOAT (30.),
GST_PROPS_FLOAT (50.),
GST_PROPS_FLOAT (60/1.001),
GST_PROPS_FLOAT (60.)
)
)
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) { YV12, I420 }, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"pixel_width = (int) [ 1, 255 ], "
"pixel_height = (int) [ 1, 255 ], "
"framerate = (double) { 23.976024, 24.0, "
"25.0, 29.970030, 30.0, 50.0, 59.940060, 60.0 }")
);
GST_PAD_TEMPLATE_FACTORY (user_data_template_factory,
static GstStaticPadTemplate user_data_template_factory =
GST_STATIC_PAD_TEMPLATE (
"user_data",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mpeg2dec_user_data",
"application/octet-stream",
NULL
)
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (sink_template_factory,
static GstStaticPadTemplate sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mpeg2dec_sink",
"video/mpeg",
/* width/height/framerate not needed */
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], "
"systemstream = (boolean) false"
)
);
@ -175,9 +156,9 @@ gst_mpeg2dec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template_factory));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template_factory));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (user_data_template_factory));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_template_factory));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_template_factory));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&user_data_template_factory));
gst_element_class_set_details (element_class, &gst_mpeg2dec_details);
}
@ -193,10 +174,6 @@ gst_mpeg2dec_class_init(GstMpeg2decClass *klass)
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
g_object_class_install_property (gobject_class, ARG_STREAMINFO,
g_param_spec_boxed ("streaminfo", "Streaminfo", "Streaminfo",
GST_TYPE_CAPS, G_PARAM_READABLE));
gobject_class->set_property = gst_mpeg2dec_set_property;
gobject_class->get_property = gst_mpeg2dec_get_property;
gobject_class->dispose = gst_mpeg2dec_dispose;
@ -211,14 +188,14 @@ gst_mpeg2dec_init (GstMpeg2dec *mpeg2dec)
{
/* create the sink and src pads */
mpeg2dec->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_template_factory), "sink");
gst_static_pad_template_get (&sink_template_factory), "sink");
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->sinkpad);
gst_pad_set_chain_function (mpeg2dec->sinkpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_chain));
gst_pad_set_formats_function (mpeg2dec->sinkpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_sink_formats));
gst_pad_set_convert_function (mpeg2dec->sinkpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_convert_sink));
mpeg2dec->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_template_factory), "src");
gst_static_pad_template_get (&src_template_factory), "src");
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->srcpad);
gst_pad_set_formats_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_formats));
gst_pad_set_event_mask_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_get_src_event_masks));
@ -228,7 +205,7 @@ gst_mpeg2dec_init (GstMpeg2dec *mpeg2dec)
gst_pad_set_convert_function (mpeg2dec->srcpad, GST_DEBUG_FUNCPTR (gst_mpeg2dec_convert_src));
mpeg2dec->userdatapad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (user_data_template_factory), "user_data");
gst_static_pad_template_get (&user_data_template_factory), "user_data");
gst_element_add_pad (GST_ELEMENT (mpeg2dec), mpeg2dec->userdatapad);
/* initialize the mpeg2dec acceleration */
@ -294,12 +271,7 @@ gst_mpeg2dec_alloc_buffer (GstMpeg2dec *mpeg2dec, const mpeg2_info_t *info, gint
guint8 *buf[3], *out;
const mpeg2_picture_t *picture;
if (mpeg2dec->peerpool) {
outbuf = gst_buffer_new_from_pool (mpeg2dec->peerpool, 0, 0);
}
if (!outbuf) {
outbuf = gst_buffer_new_and_alloc ((size * 3) / 2);
}
outbuf = gst_buffer_new_and_alloc ((size * 3) / 2);
out = GST_BUFFER_DATA (outbuf);
@ -335,7 +307,9 @@ static gboolean
gst_mpeg2dec_negotiate_format (GstMpeg2dec *mpeg2dec)
{
GstCaps *allowed;
GstCaps *intersect, *trylist, *head, *to_intersect;
GstCaps *caps;
guint32 fourcc;
GstPadLinkReturn ret;
if (!GST_PAD_IS_LINKED (mpeg2dec->srcpad)) {
mpeg2dec->format = MPEG2DEC_FORMAT_I420;
@ -344,64 +318,34 @@ gst_mpeg2dec_negotiate_format (GstMpeg2dec *mpeg2dec)
/* we what we are allowed to do */
allowed = gst_pad_get_allowed_caps (mpeg2dec->srcpad);
/* we could not get allowed caps */
if (!allowed) {
allowed = GST_CAPS_NEW (
"mpeg2dec_negotiate",
"video/x-raw-yuv",
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))
);
}
caps = gst_caps_copy_1 (allowed);
to_intersect = GST_CAPS_NEW (
"mpeg2dec_negotiate",
"video/x-raw-yuv",
"width", GST_PROPS_INT (mpeg2dec->width),
"height", GST_PROPS_INT (mpeg2dec->height),
"pixel_width", GST_PROPS_INT (mpeg2dec->pixel_width),
"pixel_height", GST_PROPS_INT (mpeg2dec->pixel_height),
"framerate", GST_PROPS_FLOAT (1. * GST_SECOND / mpeg2dec->frame_period)
);
gst_caps_set_simple (caps,
"width", G_TYPE_INT, mpeg2dec->width,
"height", G_TYPE_INT, mpeg2dec->height,
"pixel_width", G_TYPE_INT, mpeg2dec->pixel_width,
"pixel_height", G_TYPE_INT, mpeg2dec->pixel_height,
"framerate", G_TYPE_DOUBLE, 1. * GST_SECOND / mpeg2dec->frame_period,
NULL);
/* try to fix our height */
intersect = gst_caps_intersect (allowed, to_intersect);
gst_caps_unref (allowed);
gst_caps_unref (to_intersect);
ret = gst_pad_try_set_caps (mpeg2dec->srcpad, caps);
if (ret != GST_PAD_LINK_OK) return FALSE;
/* prepare for looping */
head = trylist = gst_caps_normalize (intersect);
gst_caps_unref (intersect);
while (trylist) {
GstCaps *to_try = gst_caps_copy_1 (trylist);
/* try each format */
if (gst_pad_try_set_caps (mpeg2dec->srcpad, to_try) > 0) {
guint32 fourcc;
/* it worked, try to find what it was again */
gst_caps_get_fourcc_int (to_try, "format", &fourcc);
/* it worked, try to find what it was again */
gst_structure_get_fourcc (gst_caps_get_structure (caps,0),
"format", &fourcc);
if (fourcc == GST_STR_FOURCC ("I420")) {
mpeg2dec->format = MPEG2DEC_FORMAT_I420;
}
else {
mpeg2dec->format = MPEG2DEC_FORMAT_YV12;
}
break;
}
trylist = trylist->next;
if (fourcc == GST_STR_FOURCC ("I420")) {
mpeg2dec->format = MPEG2DEC_FORMAT_I420;
} else {
mpeg2dec->format = MPEG2DEC_FORMAT_YV12;
}
gst_caps_unref (head);
/* oops list exhausted and nothing was found... */
if (!trylist) {
return FALSE;
}
gst_caps_free (caps);
return TRUE;
}
#if 0
static void
update_streaminfo (GstMpeg2dec *mpeg2dec)
{
@ -414,9 +358,9 @@ update_streaminfo (GstMpeg2dec *mpeg2dec)
props = gst_props_empty_new ();
entry = gst_props_entry_new ("framerate", GST_PROPS_FLOAT (GST_SECOND/(float)mpeg2dec->frame_period));
entry = gst_props_entry_new ("framerate", G_TYPE_DOUBLE (GST_SECOND/(float)mpeg2dec->frame_period));
gst_props_add_entry (props, entry);
entry = gst_props_entry_new ("bitrate", GST_PROPS_INT (info->sequence->byte_rate * 8));
entry = gst_props_entry_new ("bitrate", G_TYPE_INT (info->sequence->byte_rate * 8));
gst_props_add_entry (props, entry);
caps = gst_caps_new ("mpeg2dec_streaminfo",
@ -426,6 +370,7 @@ update_streaminfo (GstMpeg2dec *mpeg2dec)
gst_caps_replace_sink (&mpeg2dec->streaminfo, caps);
g_object_notify (G_OBJECT (mpeg2dec), "streaminfo");
}
#endif
static void
gst_mpeg2dec_flush_decoder (GstMpeg2dec *mpeg2dec)
@ -533,13 +478,6 @@ gst_mpeg2dec_chain (GstPad *pad, GstData *_data)
goto exit;
}
/* now that we've negotiated, try to get a bufferpool */
mpeg2dec->peerpool = gst_pad_get_bufferpool (mpeg2dec->srcpad);
if (mpeg2dec->peerpool)
GST_INFO ( "got pool %p", mpeg2dec->peerpool);
update_streaminfo (mpeg2dec);
if (!mpeg2dec->have_fbuf) {
/* alloc 3 buffers */
gst_mpeg2dec_alloc_buffer (mpeg2dec, info, GST_BUFFER_OFFSET (buf));
@ -1087,7 +1025,6 @@ gst_mpeg2dec_change_state (GstElement *element)
case GST_STATE_READY_TO_PAUSED:
{
mpeg2dec->next_time = 0;
mpeg2dec->peerpool = NULL;
/* reset the initial video state */
mpeg2dec->format = MPEG2DEC_FORMAT_NONE;
@ -1097,29 +1034,16 @@ gst_mpeg2dec_change_state (GstElement *element)
mpeg2dec->segment_end = -1;
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
mpeg2dec->frame_period = 0;
mpeg2dec->streaminfo = NULL;
gst_mpeg2dec_open_decoder (mpeg2dec);
mpeg2dec->need_sequence = TRUE;
break;
}
case GST_STATE_PAUSED_TO_PLAYING:
/* if we've negotiated caps, try to get a bufferpool */
if (mpeg2dec->peerpool == NULL && mpeg2dec->width > 0) {
mpeg2dec->peerpool = gst_pad_get_bufferpool (mpeg2dec->srcpad);
if (mpeg2dec->peerpool)
GST_INFO ( "got pool %p", mpeg2dec->peerpool);
}
break;
case GST_STATE_PLAYING_TO_PAUSED:
/* need to clear things we get from other plugins, since we could be reconnected */
if (mpeg2dec->peerpool) {
gst_buffer_pool_unref (mpeg2dec->peerpool);
mpeg2dec->peerpool = NULL;
}
break;
case GST_STATE_PAUSED_TO_READY:
gst_mpeg2dec_close_decoder (mpeg2dec);
gst_caps_replace (&mpeg2dec->streaminfo, NULL);
break;
case GST_STATE_READY_TO_NULL:
break;
@ -1155,9 +1079,6 @@ gst_mpeg2dec_get_property (GObject *object, guint prop_id, GValue *value, GParam
mpeg2dec = GST_MPEG2DEC (object);
switch (prop_id) {
case ARG_STREAMINFO:
g_value_set_boxed (value, mpeg2dec->streaminfo);
break;
default:
break;
}

View file

@ -65,7 +65,6 @@ struct _GstMpeg2dec {
GstPad *sinkpad,
*srcpad,
*userdatapad;
GstBufferPool *peerpool;
mpeg2dec_t *decoder;
gboolean closed;
@ -88,7 +87,6 @@ struct _GstMpeg2dec {
gint64 frame_period;
gboolean need_sequence;
GstCaps *streaminfo;
GstEvent *pending_event;
GstIndex *index;

View file

@ -49,41 +49,28 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (sink_templ,
static GstStaticPadTemplate sink_templ =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"siddecoder_sink",
"audio/x-sid",
NULL
)
)
GST_STATIC_CAPS ("audio/x-sid")
);
GST_PAD_TEMPLATE_FACTORY (src_templ,
static GstStaticPadTemplate src_templ =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"src_audio",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)
),
"width", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"depth", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"rate", GST_PROPS_INT_RANGE (8000, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 8000, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
)
);
enum {
SID_STATE_NEED_TUNE = 1,
@ -181,9 +168,9 @@ gst_siddec_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &gst_siddec_details);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_templ));
gst_static_pad_template_get (&src_templ));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_templ));
gst_static_pad_template_get (&sink_templ));
}
@ -234,13 +221,13 @@ static void
gst_siddec_init (GstSidDec *siddec)
{
siddec->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_templ), "sink");
gst_static_pad_template_get (&sink_templ), "sink");
gst_element_add_pad (GST_ELEMENT (siddec), siddec->sinkpad);
gst_pad_set_query_function (siddec->sinkpad, NULL);
gst_pad_set_convert_function (siddec->sinkpad, NULL);
siddec->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_templ), "src");
gst_static_pad_template_get (&src_templ), "src");
gst_pad_set_event_function (siddec->srcpad, NULL);
gst_pad_set_convert_function (siddec->srcpad, gst_siddec_src_convert);
gst_pad_set_query_function (siddec->srcpad, gst_siddec_src_query);
@ -282,6 +269,7 @@ gst_siddec_init (GstSidDec *siddec)
siddec->blocksize = DEFAULT_BLOCKSIZE;
}
#if 0
static void
update_metadata (GstSidDec *siddec)
{
@ -293,15 +281,15 @@ update_metadata (GstSidDec *siddec)
props = gst_props_empty_new ();
if (info.nameString) {
entry = gst_props_entry_new ("Title", GST_PROPS_STRING (info.nameString));
entry = gst_props_entry_new ("Title", G_TYPE_STRING (info.nameString));
gst_props_add_entry (props, entry);
}
if (info.authorString) {
entry = gst_props_entry_new ("Composer", GST_PROPS_STRING (info.authorString));
entry = gst_props_entry_new ("Composer", G_TYPE_STRING (info.authorString));
gst_props_add_entry (props, entry);
}
if (info.copyrightString) {
entry = gst_props_entry_new ("Copyright", GST_PROPS_STRING (info.copyrightString));
entry = gst_props_entry_new ("Copyright", G_TYPE_STRING (info.copyrightString));
gst_props_add_entry (props, entry);
}
@ -312,16 +300,17 @@ update_metadata (GstSidDec *siddec)
g_object_notify (G_OBJECT (siddec), "metadata");
}
}
#endif
#define GET_FIXED_INT(caps, name, dest) \
G_STMT_START { \
if (gst_caps_has_fixed_property (caps, name)) \
gst_caps_get_int (caps, name, (gint*)dest); \
gst_structure_get_int (structure, name, (gint*)dest); \
} G_STMT_END
#define GET_FIXED_BOOLEAN(caps, name, dest) \
G_STMT_START { \
if (gst_caps_has_fixed_property (caps, name)) \
gst_caps_get_boolean (caps, name, dest); \
gst_structure_get_boolean (structure, name, dest); \
} G_STMT_END
static gboolean
@ -330,13 +319,18 @@ siddec_negotiate (GstSidDec *siddec)
GstCaps *allowed;
gboolean sign = TRUE;
gint width = 0, depth = 0;
GstStructure *structure;
int rate;
int channels;
allowed = gst_pad_get_allowed_caps (siddec->srcpad);
if (!allowed)
return FALSE;
GET_FIXED_INT (allowed, "width", &width);
GET_FIXED_INT (allowed, "depth", &depth);
structure = gst_caps_get_structure (allowed, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "depth", &depth);
if (width && depth && width != depth) {
return FALSE;
@ -347,24 +341,24 @@ siddec_negotiate (GstSidDec *siddec)
siddec->config->bitsPerSample = width;
}
GET_FIXED_BOOLEAN (allowed, "signed", &sign);
GET_FIXED_INT (allowed, "rate", &siddec->config->frequency);
GET_FIXED_INT (allowed, "channels", &siddec->config->channels);
gst_structure_get_boolean (structure, "signed", &sign);
gst_structure_get_int (structure, "rate", &rate);
siddec->config->frequency = rate;
gst_structure_get_int (structure, "channels", &channels);
siddec->config->channels = channels;
siddec->config->sampleFormat = (sign ? SIDEMU_SIGNED_PCM : SIDEMU_UNSIGNED_PCM);
if (!GST_PAD_CAPS (siddec->srcpad)) {
if (!gst_pad_try_set_caps (siddec->srcpad,
GST_CAPS_NEW (
"siddec_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (sign),
"width", GST_PROPS_INT (siddec->config->bitsPerSample),
"depth", GST_PROPS_INT (siddec->config->bitsPerSample),
"rate", GST_PROPS_INT (siddec->config->frequency),
"channels", GST_PROPS_INT (siddec->config->channels)
)))
gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, sign,
"width", G_TYPE_INT, siddec->config->bitsPerSample,
"depth", G_TYPE_INT, siddec->config->bitsPerSample,
"rate", G_TYPE_INT, siddec->config->frequency,
"channels", G_TYPE_INT, siddec->config->channels,
NULL)))
{
return FALSE;
}
@ -420,7 +414,7 @@ gst_siddec_loop (GstElement *element)
return;
}
update_metadata (siddec);
//update_metadata (siddec);
if (!siddec_negotiate (siddec)) {
gst_element_error (GST_ELEMENT (siddec), "could not negotiate format");

View file

@ -62,7 +62,7 @@ struct _GstSidDec {
gulong blocksize;
GstCaps *metadata;
GstCaps *metadata;
};
struct _GstSidDecClass {

View file

@ -1,12 +1,21 @@
librarydir = $(libdir)/gstreamer-@GST_MAJORMINOR@
library_LTLIBRARIES = libgstaudio.la
library_LTLIBRARIES = libgstaudio.la libgstaudiofilter.la libgstaudiofilterexample.la
libgstaudio_la_SOURCES = audio.c audioclock.c
libgstaudioincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/audio
libgstaudioinclude_HEADERS = audio.h audioclock.h
libgstaudioinclude_HEADERS = audio.h audioclock.h gstaudiofilter.h
libgstaudio_la_LIBADD =
libgstaudio_la_CFLAGS = $(GST_CFLAGS)
libgstaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstaudiofilter_la_SOURCES = gstaudiofilter.c gstaudiofilter.h
libgstaudiofilter_la_CFLAGS = $(GST_CFLAGS)
libgstaudiofilter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstaudiofilterexample_la_SOURCES = gstaudiofilterexample.c
libgstaudiofilterexample_la_CFLAGS = $(GST_CFLAGS)
libgstaudiofilterexample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)

View file

@ -35,22 +35,23 @@ gst_audio_frame_byte_size (GstPad* pad)
int width = 0;
int channels = 0;
GstCaps *caps = NULL;
GstCaps *caps;
GstStructure *structure;
/* get caps of pad */
caps = GST_PAD_CAPS (pad);
if (caps == NULL)
{
if (caps == NULL) {
/* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0;
}
gst_caps_get_int (caps, "width", &width);
gst_caps_get_int (caps, "channels", &channels);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
return (width / 8) * channels;
}
@ -83,6 +84,7 @@ gst_audio_frame_rate (GstPad *pad)
{
GstCaps *caps = NULL;
gint rate;
GstStructure *structure;
/* get caps of pad */
caps = GST_PAD_CAPS (pad);
@ -94,7 +96,8 @@ gst_audio_frame_rate (GstPad *pad)
return 0;
}
else {
gst_caps_get_int (caps, "rate", &rate);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &rate);
return rate;
}
}
@ -115,6 +118,7 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
double length;
GstCaps *caps = NULL;
GstStructure *structure;
g_assert (GST_IS_BUFFER (buf));
/* get caps of pad */
@ -128,10 +132,11 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
}
else
{
structure = gst_caps_get_structure (caps, 0);
bytes = GST_BUFFER_SIZE (buf);
gst_caps_get_int (caps, "width", &width);
gst_caps_get_int (caps, "channels", &channels);
gst_caps_get_int (caps, "rate", &rate);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
gst_structure_get_int (structure, "rate", &rate);
g_assert (bytes != 0);
g_assert (width != 0);
@ -152,6 +157,7 @@ gst_audio_highest_sample_value (GstPad* pad)
gboolean is_signed = FALSE;
gint width = 0;
GstCaps *caps = NULL;
GstStructure *structure;
caps = GST_PAD_CAPS (pad);
if (caps == NULL)
@ -160,8 +166,9 @@ gst_audio_highest_sample_value (GstPad* pad)
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
}
gst_caps_get_int (caps, "width", &width);
gst_caps_get_boolean (caps, "signed", &is_signed);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_boolean (structure, "signed", &is_signed);
if (is_signed) --width;
/* example : 16 bit, signed : samples between -32768 and 32767 */

View file

@ -50,66 +50,43 @@ G_BEGIN_DECLS
#define GST_AUDIO_DEF_RATE 44100
#define GST_AUDIO_INT_PAD_TEMPLATE_PROPS \
gst_props_new (\
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"endianness", GST_PROPS_LIST (\
GST_PROPS_INT (G_LITTLE_ENDIAN),\
GST_PROPS_INT (G_BIG_ENDIAN)\
),\
"width", GST_PROPS_LIST (\
GST_PROPS_INT (8),\
GST_PROPS_INT (16),\
GST_PROPS_INT (32)\
),\
"depth", GST_PROPS_INT_RANGE (1, 32),\
"signed", GST_PROPS_LIST (\
GST_PROPS_BOOLEAN (TRUE),\
GST_PROPS_BOOLEAN (FALSE)\
),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
#define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, MAX ], " \
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
"width = (int) { 8, 16, 32 }, " \
"depth = (int) [ 1, 32 ], " \
"signed = (boolean) { true, false }, " \
"buffer-frames = (int) [ 1, MAX ]"
/* "standard" int audio is native order, 16 bit stereo. */
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_PROPS \
gst_props_new (\
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT (2),\
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\
"width", GST_PROPS_INT (16),\
"depth", GST_PROPS_INT (16),\
"signed", GST_PROPS_LIST (\
GST_PROPS_BOOLEAN (TRUE),\
GST_PROPS_BOOLEAN (FALSE)\
),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-int, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) 2, " \
"endianness = (int) BYTE_ORDER, " \
"width = (int) 16, " \
"depth = (int) 16, " \
"signed = (boolean) true, " \
"buffer-frames = (int) [ 1, MAX]"
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS \
gst_props_new (\
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"endianness", GST_PROPS_LIST (\
GST_PROPS_INT (G_LITTLE_ENDIAN),\
GST_PROPS_INT (G_BIG_ENDIAN)\
),\
"width", GST_PROPS_LIST (\
GST_PROPS_INT (32),\
GST_PROPS_INT (64)\
),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) [ 1, MAX ], " \
"endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
"width = (int) { 32, 64 }, " \
"buffer-frames = (int) [ 1, MAX]"
/* "standard" float audio is native order, 32 bit mono. */
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS \
gst_props_new (\
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\
"channels", GST_PROPS_INT (1),\
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\
"width", GST_PROPS_INT (32),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
"audio/x-raw-float, " \
"rate = (int) [ 1, MAX ], " \
"channels = (int) 1, " \
"endianness = (int) BYTE_ORDER, " \
"buffer-frames = (int) [ 1, MAX]"
/*
* this library defines and implements some helper functions for audio

View file

@ -0,0 +1,322 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/*#define DEBUG_ENABLED */
#include <gstaudiofilter.h>
#include <string.h>
/* GstAudiofilter signals and args */
enum {
/* FILL ME */
LAST_SIGNAL
};
enum {
ARG_0,
ARG_METHOD,
/* FILL ME */
};
static void gst_audiofilter_base_init (gpointer g_class);
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_init (GTypeInstance *instance, gpointer g_class);
static void gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_audiofilter_chain (GstPad *pad, GstData *_data);
GstCaps * gst_audiofilter_class_get_capslist(GstAudiofilterClass *klass);
static GstElementClass *parent_class = NULL;
GType
gst_audiofilter_get_type (void)
{
static GType audiofilter_type = 0;
if (!audiofilter_type) {
static const GTypeInfo audiofilter_info = {
sizeof(GstAudiofilterClass),
gst_audiofilter_base_init,
NULL,
gst_audiofilter_class_init,
NULL,
NULL,
sizeof(GstAudiofilter),
0,
gst_audiofilter_init,
};
audiofilter_type = g_type_register_static(GST_TYPE_ELEMENT,
"GstAudiofilter", &audiofilter_info, G_TYPE_FLAG_ABSTRACT);
}
return audiofilter_type;
}
static void gst_audiofilter_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_details = {
"Audio filter base class",
"Filter/Effect/Audio",
"Filters audio",
"David Schleef <ds@schleef.org>"
};
GstAudiofilterClass *klass = (GstAudiofilterClass *) g_class;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_details (element_class, &audiofilter_details);
}
static void gst_audiofilter_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstAudiofilterClass *klass;
klass = (GstAudiofilterClass *)g_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
gobject_class->set_property = gst_audiofilter_set_property;
gobject_class->get_property = gst_audiofilter_get_property;
}
static GstCaps *
gst_audiofilter_getcaps (GstPad *pad)
{
GstAudiofilter *audiofilter;
GstCaps *othercaps;
GstAudiofilterClass *audiofilter_class;
GST_DEBUG("gst_audiofilter_sink_getcaps");
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
if (pad == audiofilter->srcpad) {
othercaps = gst_pad_get_allowed_caps (audiofilter->sinkpad);
} else {
othercaps = gst_pad_get_allowed_caps (audiofilter->srcpad);
}
return gst_caps_intersect (othercaps, audiofilter_class->caps);
}
static GstPadLinkReturn
gst_audiofilter_link (GstPad *pad, const GstCaps *caps)
{
GstAudiofilter *audiofilter;
GstPadLinkReturn ret;
GstPadLinkReturn link_ret;
GstStructure *structure;
GstAudiofilterClass *audiofilter_class;
GST_DEBUG("gst_audiofilter_link");
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
if (pad == audiofilter->srcpad) {
link_ret = gst_pad_try_set_caps (audiofilter->sinkpad, caps);
} else {
link_ret = gst_pad_try_set_caps (audiofilter->srcpad, caps);
}
if (link_ret != GST_PAD_LINK_OK) return link_ret;
structure = gst_caps_get_structure (caps, 0);
if (strcmp (gst_structure_get_name (structure), "audio/x-raw-int") == 0) {
ret = gst_structure_get_int (structure, "depth", &audiofilter->depth);
ret &= gst_structure_get_int (structure, "width", &audiofilter->width);
ret &= gst_structure_get_int (structure, "channels", &audiofilter->channels);
} else if (strcmp (gst_structure_get_name (structure), "audio/x-raw-float")
== 0) {
} else {
g_assert_not_reached();
}
ret &= gst_structure_get_int (structure, "rate", &audiofilter->rate);
if (audiofilter_class->setup) (audiofilter_class->setup) (audiofilter);
return GST_PAD_LINK_OK;
}
static void
gst_audiofilter_init (GTypeInstance *instance, gpointer g_class)
{
GstAudiofilter *audiofilter = GST_AUDIOFILTER (instance);
GstPadTemplate *pad_template;
GST_DEBUG("gst_audiofilter_init");
pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"sink");
g_return_if_fail(pad_template != NULL);
audiofilter->sinkpad = gst_pad_new_from_template(pad_template, "sink");
gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->sinkpad);
gst_pad_set_chain_function(audiofilter->sinkpad,gst_audiofilter_chain);
gst_pad_set_link_function(audiofilter->sinkpad,gst_audiofilter_link);
gst_pad_set_getcaps_function(audiofilter->sinkpad,gst_audiofilter_getcaps);
pad_template = gst_element_class_get_pad_template(GST_ELEMENT_CLASS(g_class),
"src");
g_return_if_fail(pad_template != NULL);
audiofilter->srcpad = gst_pad_new_from_template(pad_template, "src");
gst_element_add_pad(GST_ELEMENT(audiofilter),audiofilter->srcpad);
gst_pad_set_link_function(audiofilter->srcpad,gst_audiofilter_link);
gst_pad_set_getcaps_function(audiofilter->srcpad,gst_audiofilter_getcaps);
audiofilter->inited = FALSE;
}
static void
gst_audiofilter_chain (GstPad *pad, GstData *data)
{
GstBuffer *inbuf = GST_BUFFER (data);
GstAudiofilter *audiofilter;
GstBuffer *outbuf;
GstAudiofilterClass *audiofilter_class;
GST_DEBUG ("gst_audiofilter_chain");
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (inbuf != NULL);
audiofilter = GST_AUDIOFILTER (gst_pad_get_parent (pad));
//g_return_if_fail (audiofilter->inited);
audiofilter_class = GST_AUDIOFILTER_CLASS (
G_OBJECT_GET_CLASS (audiofilter));
GST_DEBUG ("gst_audiofilter_chain: got buffer of %d bytes in '%s'",
GST_BUFFER_SIZE(inbuf), GST_OBJECT_NAME (audiofilter));
if(audiofilter->passthru){
gst_pad_push(audiofilter->srcpad, data);
return;
}
if (gst_data_is_writable(data)) {
if (audiofilter_class->filter_inplace) {
(audiofilter_class->filter_inplace) (audiofilter, inbuf);
outbuf = inbuf;
} else {
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf));
GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf);
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf);
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
gst_buffer_unref(inbuf);
}
} else {
outbuf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE(inbuf));
GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(inbuf);
GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(inbuf);
if (audiofilter_class->filter) {
(audiofilter_class->filter) (audiofilter, outbuf, inbuf);
} else {
memcpy(GST_BUFFER_DATA(outbuf), GST_BUFFER_DATA(inbuf),
GST_BUFFER_SIZE(inbuf));
(audiofilter_class->filter_inplace) (audiofilter, outbuf);
}
gst_buffer_unref(inbuf);
}
gst_pad_push(audiofilter->srcpad, GST_DATA (outbuf));
}
static void
gst_audiofilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstAudiofilter *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER(object));
src = GST_AUDIOFILTER(object);
GST_DEBUG("gst_audiofilter_set_property");
switch (prop_id) {
default:
break;
}
}
static void
gst_audiofilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GstAudiofilter *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER(object));
src = GST_AUDIOFILTER(object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
void gst_audiofilter_class_add_pad_templates (
GstAudiofilterClass *audiofilter_class, const GstCaps *caps)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (audiofilter_class);
audiofilter_class->caps = gst_caps_copy(caps);
gst_element_class_add_pad_template (element_class,
gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS,
gst_caps_copy(caps)));
gst_element_class_add_pad_template (element_class,
gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
gst_caps_copy(caps)));
}
static gboolean
plugin_init (GstPlugin *plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter",
"Audio filter parent class",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)

View file

@ -0,0 +1,84 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_AUDIOFILTER_H__
#define __GST_AUDIOFILTER_H__
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstAudiofilter GstAudiofilter;
typedef struct _GstAudiofilterClass GstAudiofilterClass;
typedef void (*GstAudiofilterFilterFunc)(GstAudiofilter *filter,
GstBuffer *outbuf, GstBuffer *inbuf);
typedef void (*GstAudiofilterInplaceFilterFunc)(GstAudiofilter *filter,
GstBuffer *buffer);
typedef void (*GstAudiofilterSetupFunc) (GstAudiofilter *filter);
#define GST_TYPE_AUDIOFILTER \
(gst_audiofilter_get_type())
#define GST_AUDIOFILTER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIOFILTER,GstAudiofilter))
#define GST_AUDIOFILTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIOFILTER,GstAudiofilterClass))
#define GST_IS_AUDIOFILTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIOFILTER))
#define GST_IS_AUDIOFILTER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER))
struct _GstAudiofilter {
GstElement element;
GstPad *sinkpad,*srcpad;
/* audio state */
gboolean inited;
int rate;
int width;
int channels;
int depth;
gboolean passthru;
};
struct _GstAudiofilterClass {
GstElementClass parent_class;
GstCaps *caps;
GstAudiofilterSetupFunc setup;
GstAudiofilterInplaceFilterFunc filter_inplace;
GstAudiofilterFilterFunc filter;
};
GType gst_audiofilter_get_type(void);
void gst_audiofilter_class_add_pad_templates (GstAudiofilterClass *audiofilterclass, const GstCaps *caps);
G_END_DECLS
#endif /* __GST_AUDIOFILTER_H__ */

View file

@ -0,0 +1,170 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2003> David Schleef <ds@schleef.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
#include <gst/audio/gstaudiofilter.h>
typedef struct _GstAudiofilterExample GstAudiofilterExample;
typedef struct _GstAudiofilterExampleClass GstAudiofilterExampleClass;
#define GST_TYPE_AUDIOFILTER_EXAMPLE \
(gst_audiofilter_example_get_type())
#define GST_AUDIOFILTER_EXAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIOFILTER_EXAMPLE,GstAudiofilterExample))
#define GST_AUDIOFILTER_EXAMPLE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIOFILTER_EXAMPLE,GstAudiofilterExampleClass))
#define GST_IS_AUDIOFILTER_EXAMPLE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIOFILTER_EXAMPLE))
#define GST_IS_AUDIOFILTER_EXAMPLE_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOFILTER_EXAMPLE))
struct _GstAudiofilterExample {
GstAudiofilter audiofilter;
};
struct _GstAudiofilterExampleClass {
GstAudiofilterClass parent_class;
};
/* GstAudiofilterExample signals and args */
enum {
/* FILL ME */
LAST_SIGNAL
};
enum {
ARG_0,
ARG_METHOD,
/* FILL ME */
};
static void gst_audiofilter_example_base_init (gpointer g_class);
static void gst_audiofilter_example_class_init (gpointer g_class, gpointer class_data);
static void gst_audiofilter_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_audiofilter_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
GType
gst_audiofilter_example_get_type (void)
{
static GType audiofilter_example_type = 0;
if (!audiofilter_example_type) {
static const GTypeInfo audiofilter_example_info = {
sizeof(GstAudiofilterExampleClass),
gst_audiofilter_example_base_init,
NULL,
gst_audiofilter_example_class_init,
NULL,
NULL,
sizeof(GstAudiofilterExample),
0,
NULL,
};
audiofilter_example_type = g_type_register_static(GST_TYPE_AUDIOFILTER,
"GstAudiofilterExample", &audiofilter_example_info, 0);
}
return audiofilter_example_type;
}
static void gst_audiofilter_example_base_init (gpointer g_class)
{
static GstElementDetails audiofilter_example_details = {
"Audio filter example",
"Filter/Effect/Audio",
"Filters audio",
"David Schleef <ds@schleef.org>"
};
GstAudiofilterExampleClass *klass = (GstAudiofilterExampleClass *) g_class;
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_details (element_class, &audiofilter_example_details);
}
static void gst_audiofilter_example_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstAudiofilterExampleClass *klass;
klass = (GstAudiofilterExampleClass *)g_class;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
gobject_class->set_property = gst_audiofilter_example_set_property;
gobject_class->get_property = gst_audiofilter_example_get_property;
}
static void
gst_audiofilter_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GstAudiofilterExample *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER_EXAMPLE(object));
src = GST_AUDIOFILTER_EXAMPLE(object);
GST_DEBUG("gst_audiofilter_example_set_property");
switch (prop_id) {
default:
break;
}
}
static void
gst_audiofilter_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GstAudiofilterExample *src;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail(GST_IS_AUDIOFILTER_EXAMPLE(object));
src = GST_AUDIOFILTER_EXAMPLE(object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
plugin_init (GstPlugin *plugin)
{
return TRUE;
}
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstaudiofilter_example",
"Audio filter example",
plugin_init,
VERSION,
"LGPL",
GST_PACKAGE,
GST_ORIGIN
)

View file

@ -136,13 +136,13 @@ gmi_reset (GstMediaInfo *info)
if (priv->format)
{
GMI_DEBUG ("unreffing priv->format, error before this ?\n");
gst_caps_unref (priv->format);
gst_caps_free (priv->format);
priv->format = NULL;
}
if (priv->metadata)
{
GMI_DEBUG ("unreffing priv->metadata, error before this ?\n");
gst_caps_unref (priv->metadata);
gst_caps_free (priv->metadata);
priv->metadata = NULL;
}
if (priv->stream)
@ -193,12 +193,12 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
/* clear structs because of the seek */
if (priv->metadata)
{
gst_caps_unref (priv->metadata);
gst_caps_free (priv->metadata);
priv->metadata = NULL;
}
if (priv->streaminfo)
{
gst_caps_unref (priv->streaminfo);
gst_caps_free (priv->streaminfo);
priv->streaminfo = NULL;
}
return TRUE;
@ -304,7 +304,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv)
if (priv->type)
{
/* we don't need to unref, this is done inside gsttypefind.c
gst_caps_unref (priv->type);
gst_caps_free (priv->type);
*/
priv->type = NULL;
}
@ -573,14 +573,13 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
&format, &value_end);
if (res)
{
GstPropsEntry *length;
/* substract to get the length */
GMI_DEBUG("DEBUG: start %lld, end %lld\n", value_start, value_end);
value_end -= value_start;
/* FIXME: check units; this is in seconds */
length = gst_props_entry_new ("length",
GST_PROPS_INT ((int) (value_end / 1E6)));
gst_props_add_entry (gst_caps_get_props (priv->streaminfo), length);
gst_caps_set_simple (priv->streaminfo,
"length", G_TYPE_INT, (int) (value_end / 1E6), NULL);
}
}
}

View file

@ -4,56 +4,6 @@
#include <string.h>
#include "media-info.h"
static void
caps_print (GstCaps *caps)
{
if (caps == NULL) return;
/*
if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") ||
!strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo"))
*/
if (TRUE)
{
GstProps *props = caps->properties;
GList *walk;
if (props == NULL)
{
g_print (" none\n");
return;
}
walk = props->properties;
while (walk) {
GstPropsEntry *entry = (GstPropsEntry *) walk->data;
const gchar *name;
const gchar *str_val;
gint int_val;
GstPropsType type;
name = gst_props_entry_get_name (entry);
type = gst_props_entry_get_props_type (entry);
switch (type) {
case GST_PROPS_STRING_TYPE:
gst_props_entry_get_string (entry, &str_val);
g_print (" %s='%s'\n", name, str_val);
break;
case GST_PROPS_INT_TYPE:
gst_props_entry_get_int (entry, &int_val);
g_print (" %s=%d\n", name, int_val);
break;
default:
break;
}
walk = g_list_next (walk);
}
}
else {
g_print (" unkown caps type\n");
}
}
static void
info_print (GstMediaInfoStream *stream)
{
@ -77,11 +27,11 @@ info_print (GstMediaInfoStream *stream)
g_print ("- track %d\n", i);
track = (GstMediaInfoTrack *) p->data;
g_print (" - metadata:\n");
caps_print (track->metadata);
g_print ("%s\n", gst_caps_to_string (track->metadata));
g_print (" - streaminfo:\n");
caps_print (track->streaminfo);
g_print ("%s\n", gst_caps_to_string (track->streaminfo));
g_print (" - format:\n");
caps_print (track->format);
g_print ("%s\n", gst_caps_to_string (track->format));
p = p->next;
}
}

View file

@ -294,7 +294,8 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp)
GMI_DEBUG("doing find_type_post\n");
gmip_find_type_post (priv);
GMI_DEBUG("finding out mime type\n");
mime = g_strdup (gst_caps_get_mime (priv->type));
mime = g_strdup (gst_structure_get_name (
gst_caps_get_structure(priv->type, 0)));
GMI_DEBUG("found out mime type: %s\n", mime);
decoder = gmi_get_decoder (info, mime);
if (decoder == NULL)
@ -443,7 +444,8 @@ gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags)
if (!gmip_find_type (priv)) return NULL;
mime = g_strdup (gst_caps_get_mime (priv->type));
mime = g_strdup (gst_structure_get_name (
gst_caps_get_structure(priv->type, 0)));
GMI_DEBUG("mime type: %s\n", mime);
/* c) figure out decoder */

View file

@ -20,6 +20,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "gstplay.h"
@ -919,40 +920,41 @@ gst_play_get_sink_element (GstPlay *play,
}
else {
/* If not a src pad checking caps */
GstCaps *caps;
caps = gst_pad_get_caps (GST_PAD (pads->data));
while (caps) {
gboolean has_video_cap = FALSE, has_audio_cap = FALSE;
if (g_ascii_strcasecmp (gst_caps_get_mime (caps),
"audio/x-raw-int") == 0) {
has_audio_cap = TRUE;
}
if ((g_ascii_strcasecmp (gst_caps_get_mime (caps),
"video/x-raw-yuv") == 0) ||
(g_ascii_strcasecmp (gst_caps_get_mime (caps),
"video/x-raw-rgb") == 0)) {
has_video_cap = TRUE;
}
const GstCaps *caps;
GstStructure *structure;
gboolean has_video_cap = FALSE;
gboolean has_audio_cap = FALSE;
switch (sink_type) {
case GST_PLAY_SINK_TYPE_AUDIO:
if (has_audio_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_VIDEO:
if (has_video_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_ANY:
if ((has_video_cap) || (has_audio_cap))
has_correct_type = TRUE;
break;;
default:
has_correct_type = FALSE;
}
caps = caps->next;
caps = gst_pad_get_caps (GST_PAD (pads->data));
structure = gst_caps_get_structure (caps, 0);
if (strcmp (gst_structure_get_name (structure),
"audio/x-raw-int") == 0) {
has_audio_cap = TRUE;
}
if (strcmp (gst_structure_get_name (structure),
"video/x-raw-yuv") == 0 ||
strcmp (gst_structure_get_name (structure),
"video/x-raw-rgb") == 0) {
has_video_cap = TRUE;
}
switch (sink_type) {
case GST_PLAY_SINK_TYPE_AUDIO:
if (has_audio_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_VIDEO:
if (has_video_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_ANY:
if ((has_video_cap) || (has_audio_cap))
has_correct_type = TRUE;
break;;
default:
has_correct_type = FALSE;
}
}

View file

@ -20,6 +20,7 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "gstplay.h"
@ -919,40 +920,41 @@ gst_play_get_sink_element (GstPlay *play,
}
else {
/* If not a src pad checking caps */
GstCaps *caps;
caps = gst_pad_get_caps (GST_PAD (pads->data));
while (caps) {
gboolean has_video_cap = FALSE, has_audio_cap = FALSE;
if (g_ascii_strcasecmp (gst_caps_get_mime (caps),
"audio/x-raw-int") == 0) {
has_audio_cap = TRUE;
}
if ((g_ascii_strcasecmp (gst_caps_get_mime (caps),
"video/x-raw-yuv") == 0) ||
(g_ascii_strcasecmp (gst_caps_get_mime (caps),
"video/x-raw-rgb") == 0)) {
has_video_cap = TRUE;
}
const GstCaps *caps;
GstStructure *structure;
gboolean has_video_cap = FALSE;
gboolean has_audio_cap = FALSE;
switch (sink_type) {
case GST_PLAY_SINK_TYPE_AUDIO:
if (has_audio_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_VIDEO:
if (has_video_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_ANY:
if ((has_video_cap) || (has_audio_cap))
has_correct_type = TRUE;
break;;
default:
has_correct_type = FALSE;
}
caps = caps->next;
caps = gst_pad_get_caps (GST_PAD (pads->data));
structure = gst_caps_get_structure (caps, 0);
if (strcmp (gst_structure_get_name (structure),
"audio/x-raw-int") == 0) {
has_audio_cap = TRUE;
}
if (strcmp (gst_structure_get_name (structure),
"video/x-raw-yuv") == 0 ||
strcmp (gst_structure_get_name (structure),
"video/x-raw-rgb") == 0) {
has_video_cap = TRUE;
}
switch (sink_type) {
case GST_PLAY_SINK_TYPE_AUDIO:
if (has_audio_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_VIDEO:
if (has_video_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_ANY:
if ((has_video_cap) || (has_audio_cap))
has_correct_type = TRUE;
break;;
default:
has_correct_type = FALSE;
}
}

View file

@ -26,6 +26,7 @@
#include "config.h"
#endif
#include <string.h>
#include "play.h"
enum
@ -906,43 +907,38 @@ gst_play_get_sink_element (GstPlay * play,
else
{
/* If not a src pad checking caps */
GstCaps *caps;
caps = gst_pad_get_caps (GST_PAD (pads->data));
while (caps)
{
gboolean has_video_cap = FALSE, has_audio_cap = FALSE;
if (g_ascii_strcasecmp (gst_caps_get_mime (caps),
"audio/x-raw-int") == 0)
{
has_audio_cap = TRUE;
}
if ((g_ascii_strcasecmp (gst_caps_get_mime (caps),
"video/x-raw-yuv") == 0) ||
(g_ascii_strcasecmp (gst_caps_get_mime (caps),
"video/x-raw-rgb") == 0))
{
has_video_cap = TRUE;
}
gboolean has_video_cap = FALSE, has_audio_cap = FALSE;
const char *media_type;
switch (sink_type)
{
case GST_PLAY_SINK_TYPE_AUDIO:
if (has_audio_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_VIDEO:
if (has_video_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_ANY:
if ((has_video_cap) || (has_audio_cap))
has_correct_type = TRUE;
break;;
default:
has_correct_type = FALSE;
}
caps = caps->next;
media_type = gst_structure_get_name (gst_caps_get_structure (
gst_pad_get_caps (GST_PAD (pads->data)), 0));
if (strcmp (media_type, "audio/x-raw-int") == 0)
{
has_audio_cap = TRUE;
}
if ((strcmp (media_type, "video/x-raw-yuv") == 0) ||
(strcmp (media_type, "video/x-raw-rgb") == 0))
{
has_video_cap = TRUE;
}
switch (sink_type)
{
case GST_PLAY_SINK_TYPE_AUDIO:
if (has_audio_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_VIDEO:
if (has_video_cap)
has_correct_type = TRUE;
break;;
case GST_PLAY_SINK_TYPE_ANY:
if ((has_video_cap) || (has_audio_cap))
has_correct_type = TRUE;
break;;
default:
has_correct_type = FALSE;
}
}
pads = g_list_next (pads);

View file

@ -36,40 +36,28 @@ gst_riff_create_video_caps (guint32 codec_fcc,
switch (codec_fcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
case GST_MAKE_FOURCC('Y','U','Y','2'):
caps = GST_CAPS_NEW (
"riff_video_raw",
"video/x-raw-yuv",
"format", GST_PROPS_FOURCC (codec_fcc)
);
caps = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, codec_fcc,
NULL);
break;
case GST_MAKE_FOURCC('M','J','P','G'): /* YUY2 MJPEG */
case GST_MAKE_FOURCC('J','P','E','G'): /* generic (mostly RGB) MJPEG */
case GST_MAKE_FOURCC('P','I','X','L'): /* Miro/Pinnacle fourccs */
case GST_MAKE_FOURCC('V','I','X','L'): /* Miro/Pinnacle fourccs */
caps = GST_CAPS_NEW (
"riff_video_jpeg",
"video/x-jpeg",
NULL
);
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
break;
case GST_MAKE_FOURCC('H','F','Y','U'):
caps = GST_CAPS_NEW (
"riff_video_hfyu",
"video/x-huffyuv",
NULL
);
caps = gst_caps_new_simple ( "video/x-huffyuv", NULL);
break;
case GST_MAKE_FOURCC('M','P','E','G'):
case GST_MAKE_FOURCC('M','P','G','I'):
caps = GST_CAPS_NEW (
"riff_video_mpeg1",
"video/mpeg",
"systemstream", GST_PROPS_BOOLEAN (FALSE),
"mpegversion", GST_PROPS_BOOLEAN (1)
);
caps = gst_caps_new_simple ("video/mpeg",
"systemstream", G_TYPE_BOOLEAN, FALSE,
"mpegversion", G_TYPE_BOOLEAN, 1,
NULL);
break;
case GST_MAKE_FOURCC('H','2','6','3'):
@ -79,138 +67,98 @@ gst_riff_create_video_caps (guint32 codec_fcc,
case GST_MAKE_FOURCC('V','D','O','W'):
case GST_MAKE_FOURCC('V','I','V','O'):
case GST_MAKE_FOURCC('x','2','6','3'):
caps = GST_CAPS_NEW (
"riff_video_h263",
"video/x-h263",
NULL
);
caps = gst_caps_new_simple ("video/x-h263", NULL);
break;
case GST_MAKE_FOURCC('D','I','V','3'):
case GST_MAKE_FOURCC('D','I','V','4'):
case GST_MAKE_FOURCC('D','I','V','5'):
caps = GST_CAPS_NEW (
"riff_video_divx3",
"video/x-divx",
"divxversion", GST_PROPS_INT(3)
);
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 3,
NULL);
break;
case GST_MAKE_FOURCC('d','i','v','x'):
case GST_MAKE_FOURCC('D','I','V','X'):
case GST_MAKE_FOURCC('D','X','5','0'):
caps = GST_CAPS_NEW (
"riff_video_divx45",
"video/x-divx",
"divxversion", GST_PROPS_INT(5)
);
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 5,
NULL);
break;
case GST_MAKE_FOURCC('X','V','I','D'):
case GST_MAKE_FOURCC('x','v','i','d'):
caps = GST_CAPS_NEW (
"riff_video_xvid",
"video/x-xvid",
NULL
);
caps = gst_caps_new_simple ("video/x-xvid", NULL);
break;
case GST_MAKE_FOURCC('M','P','G','4'):
caps = GST_CAPS_NEW (
"riff_video_msmpeg41",
"video/x-msmpeg",
"msmpegversion", GST_PROPS_INT (41)
);
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 41,
NULL);
break;
case GST_MAKE_FOURCC('M','P','4','2'):
caps = GST_CAPS_NEW (
"riff_video_msmpeg42",
"video/x-msmpeg",
"msmpegversion", GST_PROPS_INT (42)
);
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 42,
NULL);
break;
case GST_MAKE_FOURCC('M','P','4','3'):
caps = GST_CAPS_NEW (
"riff_video_msmpeg43",
"video/x-msmpeg",
"msmpegversion", GST_PROPS_INT (43)
);
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 43,
NULL);
break;
case GST_MAKE_FOURCC('3','I','V','1'):
case GST_MAKE_FOURCC('3','I','V','2'):
caps = GST_CAPS_NEW (
"riff_video_3ivx",
"video/x-3ivx",
NULL
);
caps = gst_caps_new_simple ( "video/x-3ivx", NULL);
break;
case GST_MAKE_FOURCC('D','V','S','D'):
case GST_MAKE_FOURCC('d','v','s','d'):
caps = GST_CAPS_NEW (
"riff_video_dv",
"video/x-dv",
"systemstream", GST_PROPS_BOOLEAN (FALSE)
);
caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, FALSE,
NULL);
break;
case GST_MAKE_FOURCC('W','M','V','1'):
caps = GST_CAPS_NEW (
"riff_video_wmv1",
"video/x-wmv",
"wmvversion", GST_PROPS_INT (1)
);
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 1,
NULL);
break;
case GST_MAKE_FOURCC('W','M','V','2'):
caps = GST_CAPS_NEW (
"riff_video_wmv2",
"video/x-wmv",
"wmvversion", GST_PROPS_INT (2)
);
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 2,
NULL);
break;
default:
GST_WARNING ("Unkown video fourcc " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (codec_fcc));
break;
return NULL;
}
/* add general properties */
if (caps != NULL) {
GstPropsEntry *framerate, *width, *height;
if (strh != NULL) {
gfloat fps = 1. * strh->rate / strh->scale;
if (strh != NULL) {
gfloat fps = 1. * strh->rate / strh->scale;
gst_caps_set_simple (caps, "framerate", G_TYPE_DOUBLE, fps, NULL);
} else {
gst_caps_set_simple (caps,
"framerate", GST_TYPE_DOUBLE_RANGE, 0., G_MAXDOUBLE,
NULL);
}
framerate = gst_props_entry_new ("framerate",
GST_PROPS_FLOAT (fps));
} else {
framerate = gst_props_entry_new ("framerate",
GST_PROPS_FLOAT_RANGE (0., G_MAXFLOAT));
}
if (strf != NULL) {
width = gst_props_entry_new ("width",
GST_PROPS_INT (strf->width));
height = gst_props_entry_new ("height",
GST_PROPS_INT (strf->height));
} else {
width = gst_props_entry_new ("width",
GST_PROPS_INT_RANGE (16, 4096));
height = gst_props_entry_new ("height",
GST_PROPS_INT_RANGE (16, 4096));
}
if (!caps->properties)
caps->properties = gst_props_empty_new ();
gst_props_add_entry (caps->properties, width);
gst_props_add_entry (caps->properties, height);
gst_props_add_entry (caps->properties, framerate);
if (strf != NULL) {
gst_caps_set_simple (caps,
"width", G_TYPE_INT, strf->width,
"height", G_TYPE_INT, strf->height,
NULL);
} else {
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, 16, 4096,
"height", GST_TYPE_INT_RANGE, 16, 4096,
NULL);
}
return caps;
@ -225,57 +173,38 @@ gst_riff_create_audio_caps (guint16 codec_id,
switch (codec_id) {
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
caps = GST_CAPS_NEW ("riff_audio_mp1l3",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (3));
caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 3,
NULL);
break;
case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
caps = GST_CAPS_NEW ("riff_audio_mp1l12",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (2));
caps = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, 2,
NULL);
break;
case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */ {
GstPropsEntry *width = NULL, *depth = NULL, *signedness = NULL;
case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */
if (strf != NULL) {
gint ba = GUINT16_FROM_LE (strf->blockalign);
gint ch = GUINT16_FROM_LE (strf->channels);
gint ws = GUINT16_FROM_LE (strf->size);
width = gst_props_entry_new ("width",
GST_PROPS_INT (ba * 8 / ch));
depth = gst_props_entry_new ("depth",
GST_PROPS_INT (ws));
signedness = gst_props_entry_new ("signed",
GST_PROPS_BOOLEAN (ws != 8));
caps = gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
"width", G_TYPE_INT, (int)(ba * 8 / ch),
"depth", G_TYPE_INT, ws,
"signed", G_TYPE_BOOLEAN, ws != 8,
NULL);
} else {
signedness = gst_props_entry_new ("signed",
GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)));
width = gst_props_entry_new ("width",
GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)));
depth = gst_props_entry_new ("depth",
GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)));
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"height = (int) { 8, 16 }");
}
caps = GST_CAPS_NEW ("riff_audio_pcm",
"audio/x-raw-int",
"endianness",
GST_PROPS_INT (G_LITTLE_ENDIAN));
gst_props_add_entry (caps->properties, width);
gst_props_add_entry (caps->properties, depth);
gst_props_add_entry (caps->properties, signedness);
}
break;
case GST_RIFF_WAVE_FORMAT_MULAW:
@ -283,9 +212,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
GST_WARNING ("invalid depth (%d) of mulaw audio, overwriting.",
strf->size);
}
caps = GST_CAPS_NEW ("riff_audio_mulaw",
"audio/x-mulaw",
NULL);
caps = gst_caps_new_simple ("audio/x-mulaw", NULL);
break;
case GST_RIFF_WAVE_FORMAT_ALAW:
@ -293,9 +220,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
GST_WARNING ("invalid depth (%d) of alaw audio, overwriting.",
strf->size);
}
caps = GST_CAPS_NEW ("riff_audio_alaw",
"audio/x-alaw",
NULL);
caps = gst_caps_new_simple ("audio/x-alaw", NULL);
break;
case GST_RIFF_WAVE_FORMAT_VORBIS1: /* ogg/vorbis mode 1 */
@ -304,15 +229,11 @@ gst_riff_create_audio_caps (guint16 codec_id,
case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* ogg/vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* ogg/vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* ogg/vorbis mode 3+ */
caps = GST_CAPS_NEW ("riff_audio_vorbis",
"audio/x-vorbis",
NULL);
caps = gst_caps_new_simple ("audio/x-vorbis", NULL);
break;
case GST_RIFF_WAVE_FORMAT_A52:
caps = GST_CAPS_NEW ("riff_audio_ac3",
"audio/x-ac3",
NULL);
caps = gst_caps_new_simple ("audio/x-ac3", NULL);
break;
default:
@ -321,26 +242,16 @@ gst_riff_create_audio_caps (guint16 codec_id,
break;
}
if (caps != NULL) {
GstPropsEntry *samplerate, *channels;
if (strf != NULL) {
samplerate = gst_props_entry_new ("rate",
GST_PROPS_INT (strf->rate));
channels = gst_props_entry_new ("channels",
GST_PROPS_INT (strf->channels));
} else {
samplerate = gst_props_entry_new ("rate",
GST_PROPS_INT_RANGE (8000, 96000));
channels = gst_props_entry_new ("channels",
GST_PROPS_INT_RANGE (1, 2));
}
if (!caps->properties)
caps->properties = gst_props_empty_new ();
gst_props_add_entry (caps->properties, samplerate);
gst_props_add_entry (caps->properties, channels);
if (strf != NULL) {
gst_caps_set_simple (caps,
"rate", G_TYPE_INT, strf->rate,
"channels", G_TYPE_INT, strf->channels,
NULL);
} else {
gst_caps_set_simple (caps,
"rate", GST_TYPE_INT_RANGE, 8000, 96000,
"channels", GST_TYPE_INT_RANGE, 1, 2,
NULL);
}
return caps;
@ -357,14 +268,13 @@ gst_riff_create_iavs_caps (guint32 codec_fcc,
/* is this correct? */
case GST_MAKE_FOURCC ('D','V','S','D'):
case GST_MAKE_FOURCC ('d','v','s','d'):
caps = GST_CAPS_NEW ("riff_iavs_dv",
"video/x-dv",
"systemstream", GST_PROPS_BOOLEAN (TRUE));
caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
default:
GST_WARNING ("Unkown IAVS fourcc " GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (codec_fcc));
break;
return NULL;
}
return caps;
@ -398,12 +308,13 @@ gst_riff_create_video_template_caps (void)
0
};
guint i;
GstCaps *caps = NULL, *one;
GstCaps *caps, *one;
caps = gst_caps_new_empty ();
for (i = 0; tags[i] != 0; i++) {
one = gst_riff_create_video_caps (tags[i], NULL, NULL);
if (one)
caps = gst_caps_append (caps, one);
gst_caps_append (caps, one);
}
return caps;
@ -424,12 +335,13 @@ gst_riff_create_audio_template_caps (void)
0
};
guint i;
GstCaps *caps = NULL, *one;
GstCaps *caps, *one;
caps = gst_caps_new_empty ();
for (i = 0; tags[i] != 0; i++) {
one = gst_riff_create_audio_caps (tags[i], NULL, NULL);
if (one)
caps = gst_caps_append (caps, one);
gst_caps_append (caps, one);
}
return caps;
@ -444,13 +356,15 @@ gst_riff_create_iavs_template_caps (void)
0
};
guint i;
GstCaps *caps = NULL, *one;
GstCaps *caps, *one;
caps = gst_caps_new_empty ();
for (i = 0; tags[i] != 0; i++) {
one = gst_riff_create_iavs_caps (tags[i], NULL, NULL);
if (one)
caps = gst_caps_append (caps, one);
gst_caps_append (caps, one);
}
return caps;
}

View file

@ -714,7 +714,7 @@ gst_riff_read_info (GstRiffRead *riff)
GstRiffLevel *level;
GList *last;
gchar *name, *type;
GstProps *props;
GstCaps *caps;
/* What we're doing here is ugly (oh no!); we look
* at our LIST tag size and assure that we do not
@ -726,11 +726,10 @@ gst_riff_read_info (GstRiffRead *riff)
end = level->start + level->length;
g_free (level);
props = gst_props_empty_new ();
caps = gst_caps_new_simple ("application/x-gst-metadata", NULL);
while (gst_bytestream_tell (riff->bs) < end) {
if (!gst_riff_peek_head (riff, &tag, NULL, NULL)) {
gst_props_unref (props);
return FALSE;
}
@ -813,26 +812,18 @@ gst_riff_read_info (GstRiffRead *riff)
}
if (type) {
GstPropsEntry *entry;
if (!gst_riff_read_ascii (riff, &tag, &name)) {
gst_props_unref (props);
return FALSE;
}
entry = gst_props_entry_new (type, GST_PROPS_STRING (name));
gst_props_add_entry (props, entry);
gst_caps_set_simple (caps, type, G_TYPE_STRING, name, NULL);
} else {
gst_riff_read_skip (riff);
}
}
/* let the world know about this wonderful thing */
gst_props_debug (props);
gst_caps_replace_sink (&riff->metadata,
gst_caps_new ("riff_metadata",
"application/x-gst-metadata",
props));
gst_caps_replace (&riff->metadata, caps);
g_object_notify (G_OBJECT (riff), "metadata");
return TRUE;

View file

@ -26,11 +26,12 @@
/* This is simply a convenience function, nothing more or less */
gfloat
gdouble
gst_video_frame_rate (GstPad *pad)
{
gfloat fps = 0.;
gdouble fps = 0.;
GstCaps *caps;
GstStructure *structure;
/* get pad caps */
caps = GST_PAD_CAPS (pad);
@ -41,16 +42,14 @@ gst_video_frame_rate (GstPad *pad)
return 0.;
}
if (!gst_caps_has_property_typed (caps, "framerate",
GST_PROPS_FLOAT_TYPE)) {
structure = gst_caps_get_structure (caps, 0);
if (!gst_structure_get_double (structure, "framerate", &fps)){
g_warning ("gstvideo: failed to get framerate property of pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME (pad));
return 0.;
}
gst_caps_get_float (caps, "framerate", &fps);
GST_DEBUG ("Framerate request on pad %s:%s: %f",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME(pad), fps);
@ -64,8 +63,12 @@ gst_video_get_size (GstPad *pad,
gint *height)
{
GstCaps *caps;
GstStructure *structure;
gboolean ret;
g_return_val_if_fail (pad != NULL, FALSE);
g_return_val_if_fail (width != NULL, FALSE);
g_return_val_if_fail (height != NULL, FALSE);
caps = GST_PAD_CAPS (pad);
@ -76,21 +79,17 @@ gst_video_get_size (GstPad *pad,
return FALSE;
}
if (!gst_caps_has_property_typed (caps, "width",
GST_PROPS_INT_TYPE) ||
!gst_caps_has_property_typed (caps, "height",
GST_PROPS_FLOAT_TYPE)) {
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", width);
ret &= gst_structure_get_int (structure, "height", height);
if (!ret) {
g_warning ("gstvideo: failed to get size properties on pad %s:%s",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME(pad));
return FALSE;
}
if (width)
gst_caps_get_int (caps, "width", width);
if (height)
gst_caps_get_int (caps, "height", height);
GST_DEBUG ("size request on pad %s:%s: %dx%d",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)),
GST_PAD_NAME (pad),

View file

@ -23,203 +23,175 @@
#include <gst/gst.h>
#define R_MASK_32 0xff000000
#define G_MASK_32 0x00ff0000
#define B_MASK_32 0x0000ff00
#define R_MASK_32 "0xff000000"
#define G_MASK_32 "0x00ff0000"
#define B_MASK_32 "0x0000ff00"
#define R_MASK_32_REVERSE 0x000000ff
#define G_MASK_32_REVERSE 0x0000ff00
#define B_MASK_32_REVERSE 0x00ff0000
#define R_MASK_32_REVERSE "0x000000ff"
#define G_MASK_32_REVERSE "0x0000ff00"
#define B_MASK_32_REVERSE "0x00ff0000"
#define R_MASK_24 0xff0000
#define G_MASK_24 0x00ff00
#define B_MASK_24 0x0000ff
#define R_MASK_24 "0xff0000"
#define G_MASK_24 "0x00ff00"
#define B_MASK_24 "0x0000ff"
#define R_MASK_24_REVERSE 0x0000ff
#define G_MASK_24_REVERSE 0x00ff00
#define B_MASK_24_REVERSE 0xff0000
#define R_MASK_24_REVERSE "0x0000ff"
#define G_MASK_24_REVERSE "0x00ff00"
#define B_MASK_24_REVERSE "0xff0000"
#define R_MASK_16 0xf800
#define G_MASK_16 0x07e0
#define B_MASK_16 0x001f
#define R_MASK_16 "0xf800"
#define G_MASK_16 "0x07e0"
#define B_MASK_16 "0x001f"
#define R_MASK_15 0x8c00
#define G_MASK_15 0x03e0
#define B_MASK_15 0x001f
#define R_MASK_15 "0x7c00"
#define G_MASK_15 "0x03e0"
#define B_MASK_15 "0x001f"
#define SIZE_RANGE GST_PROPS_INT_RANGE (16, 4096)
#define FPS_RANGE GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
#define R_MASK_32_INT 0xff000000
#define G_MASK_32_INT 0x00ff0000
#define B_MASK_32_INT 0x0000ff00
#define R_MASK_32_REVERSE_INT 0x000000ff
#define G_MASK_32_REVERSE_INT 0x0000ff00
#define B_MASK_32_REVERSE_INT 0x00ff0000
#define R_MASK_24_INT 0xff0000
#define G_MASK_24_INT 0x00ff00
#define B_MASK_24_INT 0x0000ff
#define R_MASK_24_REVERSE_INT 0x0000ff
#define G_MASK_24_REVERSE_INT 0x00ff00
#define B_MASK_24_REVERSE_INT 0xff0000
#define R_MASK_16_INT 0xf800
#define G_MASK_16_INT 0x07e0
#define B_MASK_16_INT 0x001f
#define R_MASK_15_INT 0x7c00
#define G_MASK_15_INT 0x03e0
#define B_MASK_15_INT 0x001f
#define SIZE_RANGE "(int) [ 16, 4096 ]"
#define FPS_RANGE "(double) [ 0, max ]"
/* properties for pad templates */
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 \
gst_props_new ( \
"bpp", GST_PROPS_LIST ( \
GST_PROPS_INT (24), \
GST_PROPS_INT (32) \
), \
"depth", GST_PROPS_LIST ( \
GST_PROPS_INT (24), \
GST_PROPS_INT (32) \
), \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \
"red_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (R_MASK_32), \
GST_PROPS_INT (R_MASK_24) \
), \
"green_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (G_MASK_32), \
GST_PROPS_INT (G_MASK_24) \
), \
"blue_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (B_MASK_32), \
GST_PROPS_INT (B_MASK_24) \
), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 \
"video/x-raw-rgb, " \
"bpp = (int) { 24, 32 }, " \
"depth = (int) { 24, 32 }, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) { " R_MASK_32 ", " R_MASK_24 " }, " \
"green_mask = (int) { " G_MASK_32 ", " G_MASK_24 " }, " \
"blue_mask = (int) { " B_MASK_32 ", " B_MASK_24 " }, " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32_REVERSE \
gst_props_new ( \
"bpp", GST_PROPS_LIST ( \
GST_PROPS_INT (24), \
GST_PROPS_INT (32) \
), \
"depth", GST_PROPS_LIST ( \
GST_PROPS_INT (24), \
GST_PROPS_INT (32) \
), \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \
"red_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (R_MASK_32_REVERSE), \
GST_PROPS_INT (R_MASK_24_REVERSE) \
), \
"green_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (G_MASK_32_REVERSE), \
GST_PROPS_INT (G_MASK_24_REVERSE) \
), \
"blue_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (B_MASK_32_REVERSE), \
GST_PROPS_INT (B_MASK_24_REVERSE) \
), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32_REVERSE \
"video/x-raw-rgb, " \
"bpp = (int) { 24, 32 }, " \
"depth = (int) { 24, 32 }, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) { " R_MASK_32_REVERSE ", " R_MASK_24_REVERSE "}, " \
"green_mask = (int) { " G_MASK_32_REVERSE ", " G_MASK_24_REVERSE "}, " \
"blue_mask = (int) { " B_MASK_32_REVERSE ", " B_MASK_24_REVERSE "}, " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_32 \
gst_props_new ( \
"bpp", GST_PROPS_INT (32), \
"depth", GST_PROPS_INT (32), \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \
"red_mask", GST_PROPS_INT (R_MASK_32), \
"green_mask", GST_PROPS_INT (G_MASK_32), \
"blue_mask", GST_PROPS_INT (B_MASK_32), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32 \
"video/x-raw-rgb, " \
"bpp = (int) 32, " \
"depth = (int) 32, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " R_MASK_32 ", " \
"green_mask = (int) " G_MASK_32 ", " \
"blue_mask = (int) " B_MASK_32 ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24 \
gst_props_new ( \
"bpp", GST_PROPS_INT (24), \
"depth", GST_PROPS_INT (24), \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \
"red_mask", GST_PROPS_INT (R_MASK_24), \
"green_mask", GST_PROPS_INT (G_MASK_24), \
"blue_mask", GST_PROPS_INT (B_MASK_24), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24 \
"video/x-raw-rgb, " \
"bpp = (int) 24, " \
"depth = (int) 24, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " R_MASK_24 ", " \
"green_mask = (int) " G_MASK_24 ", " \
"blue_mask = (int) " B_MASK_24 ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_32_REVERSE \
gst_props_new ( \
"bpp", GST_PROPS_INT (32), \
"depth", GST_PROPS_INT (32), \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \
"red_mask", GST_PROPS_INT (R_MASK_32_REVERSE), \
"green_mask", GST_PROPS_INT (G_MASK_32_REVERSE), \
"blue_mask", GST_PROPS_INT (B_MASK_32_REVERSE), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32_REVERSE \
"video/x-raw-rgb, " \
"bpp = (int) 32, " \
"depth = (int) 32, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " R_MASK_32_REVERSE ", " \
"green_mask = (int) " G_MASK_32_REVERSE ", " \
"blue_mask = (int) " B_MASK_32_REVERSE ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_REVERSE \
gst_props_new ( \
"bpp", GST_PROPS_INT (24), \
"depth", GST_PROPS_INT (24), \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \
"red_mask", GST_PROPS_INT (R_MASK_24_REVERSE), \
"green_mask", GST_PROPS_INT (G_MASK_24_REVERSE), \
"blue_mask", GST_PROPS_INT (B_MASK_24_REVERSE), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_REVERSE \
"video/x-raw-rgb, " \
"bpp = (int) 24, " \
"depth = (int) 24, " \
"endianness = (int) BIG_ENDIAN, " \
"red_mask = (int) " R_MASK_24_REVERSE ", " \
"green_mask = (int) " G_MASK_24_REVERSE ", " \
"blue_mask = (int) " B_MASK_24_REVERSE ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 \
gst_props_new ( \
"bpp", GST_PROPS_INT (16), \
"depth", GST_PROPS_LIST ( \
GST_PROPS_INT (15), \
GST_PROPS_INT (16) \
), \
"endianness", GST_PROPS_INT (G_BYTE_ORDER), \
"red_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (R_MASK_15), \
GST_PROPS_INT (R_MASK_16) \
), \
"green_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (G_MASK_15), \
GST_PROPS_INT (G_MASK_16) \
), \
"blue_mask", GST_PROPS_LIST ( \
GST_PROPS_INT (B_MASK_15), \
GST_PROPS_INT (B_MASK_16) \
), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16 \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
"depth = (int) { 15, 16 }, " \
"endianness = (int) BYTE_ORDER, " \
"red_mask = (int) { " R_MASK_15 ", " R_MASK_16 " }, " \
"green_mask = (int) { " G_MASK_15 ", " G_MASK_16 " }, " \
"blue_mask = (int) { " B_MASK_15 ", " B_MASK_16 " }, " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_16 \
gst_props_new ( \
"bpp", GST_PROPS_INT (16), \
"depth", GST_PROPS_INT (16), \
"endianness", GST_PROPS_INT (G_BYTE_ORDER), \
"red_mask", GST_PROPS_INT (R_MASK_16), \
"green_mask", GST_PROPS_INT (G_MASK_16), \
"blue_mask", GST_PROPS_INT (B_MASK_16), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_16 \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
"depth = (int) 16, " \
"endianness = (int) BYTE_ORDER, " \
"red_mask = (int) " R_MASK_16 ", " \
"green_mask = (int) " G_MASK_16 ", " \
"blue_mask = (int) " B_MASK_16 ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15 \
gst_props_new ( \
"bpp", GST_PROPS_INT (15), \
"depth", GST_PROPS_INT (15), \
"endianness", GST_PROPS_INT (G_BYTE_ORDER), \
"red_mask", GST_PROPS_INT (R_MASK_15), \
"green_mask", GST_PROPS_INT (G_MASK_15), \
"blue_mask", GST_PROPS_INT (B_MASK_15), \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15 \
"video/x-raw-rgb, " \
"bpp = (int) 16, " \
"depth = (int) 15, " \
"endianness = (int) BYTE_ORDER, " \
"red_mask = (int) " R_MASK_15 ", " \
"green_mask = (int) " G_MASK_15 ", " \
"blue_mask = (int) " B_MASK_15 ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
#define GST_VIDEO_YUV_PAD_TEMPLATE_PROPS(fourcc) \
gst_props_new (\
"format", fourcc, \
"width", SIZE_RANGE, \
"height", SIZE_RANGE, \
"framerate", FPS_RANGE, \
NULL)
#define GST_VIDEO_YUV_PAD_TEMPLATE_CAPS(fourcc) \
"video/x-raw-yuv, " \
"format = (fourcc) " fourcc ", " \
"width = " SIZE_RANGE ", " \
"height = " SIZE_RANGE ", " \
"framerate = " FPS_RANGE
/* functions */
gfloat gst_video_frame_rate (GstPad *pad);
gdouble gst_video_frame_rate (GstPad *pad);
gboolean gst_video_get_size (GstPad *pad,
gint *width,
gint *height);

View file

@ -92,25 +92,24 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (src_factory,
static GstStaticPadTemplate gst_ac3parse_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW ("ac3parse_src",
"audio/ac3",
"channels", GST_PROPS_INT_RANGE (1, 6),
"rate", GST_PROPS_INT_RANGE (32000, 48000)
)
GST_STATIC_CAPS (
"audio/ac3, "
"channels = (int) [ 1, 6 ], "
"rate = (int) [ 32000, 48000 ]"
)
);
GST_PAD_TEMPLATE_FACTORY (sink_factory,
static GstStaticPadTemplate gst_ac3parse_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW ("ac3parse_sink",
"audio/x-ac3",
NULL
)
GST_STATIC_CAPS ("audio/x-ac3")
);
static void gst_ac3parse_class_init (gpointer g_class);
@ -167,9 +166,9 @@ gst_ac3parse_class_init (gpointer g_class)
gstelement_class = (GstElementClass*)klass;
gst_element_class_add_pad_template (gstelement_class,
GST_PAD_TEMPLATE_GET(src_factory));
gst_static_pad_template_get (&gst_ac3parse_src_template));
gst_element_class_add_pad_template (gstelement_class,
GST_PAD_TEMPLATE_GET(sink_factory));
gst_static_pad_template_get (&gst_ac3parse_sink_template));
gst_element_class_set_details (gstelement_class,
&ac3parse_details);
@ -189,12 +188,12 @@ static void
gst_ac3parse_init (GstAc3Parse *ac3parse)
{
ac3parse->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET(sink_factory), "sink");
gst_static_pad_template_get (&gst_ac3parse_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->sinkpad);
gst_pad_set_chain_function (ac3parse->sinkpad, gst_ac3parse_chain);
ac3parse->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET(src_factory), "src");
gst_static_pad_template_get (&gst_ac3parse_src_template), "src");
gst_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->srcpad);
ac3parse->partialbuf = NULL;
@ -339,10 +338,9 @@ gst_ac3parse_chain (GstPad *pad, GstData *_data)
}
if (need_capsnego) {
GstCaps *newcaps;
newcaps = GST_CAPS_NEW ("ac3parse_src",
"audio/x-ac3",
"channels", GST_PROPS_INT (channels),
"rate", GST_PROPS_INT (sample_rate));
newcaps = gst_caps_new_simple ("audio/x-ac3",
"channels", G_TYPE_INT, channels,
"rate", G_TYPE_INT, sample_rate, NULL);
if (gst_pad_try_set_caps (ac3parse->srcpad, newcaps) <= 0) {
gst_element_error (GST_ELEMENT (ac3parse),
"Ac3parse: failed to negotiate format with next element");

View file

@ -34,13 +34,12 @@ static GstElementDetails gst_asf_demux_details = {
"Owen Fraser-Green <owen@discobabe.net>",
};
GST_PAD_TEMPLATE_FACTORY (sink_factory,
static GstStaticPadTemplate gst_asf_demux_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW ("asf_asf_demux_sink",
"video/x-ms-asf",
NULL)
GST_STATIC_CAPS("video/x-ms-asf")
);
static void gst_asf_demux_base_init (gpointer g_class);
@ -118,7 +117,7 @@ gst_asf_demux_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
int i;
GstCaps *audcaps = NULL, *vidcaps = NULL, *temp;
GstCaps *audcaps, *vidcaps, *temp;
guint32 vid_list[] = {
GST_MAKE_FOURCC('I','4','2','0'),
GST_MAKE_FOURCC('Y','U','Y','2'),
@ -145,28 +144,31 @@ gst_asf_demux_base_init (gpointer g_class)
-1 /* end */
};
audcaps = gst_caps_new_empty();
for (i = 0; aud_list[i] != -1; i++) {
temp = gst_asf_demux_audio_caps (aud_list[i], NULL, NULL);
audcaps = gst_caps_append (audcaps, temp);
gst_caps_append (audcaps, temp);
}
audiosrctempl = gst_pad_template_new ("audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
audcaps, NULL);
audcaps);
vidcaps = gst_caps_new_empty();
for (i = 0; vid_list[i] != 0; i++) {
temp = gst_asf_demux_video_caps (vid_list[i], NULL);
vidcaps = gst_caps_append (vidcaps, temp);
gst_caps_append (vidcaps, temp);
}
videosrctempl = gst_pad_template_new ("video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
vidcaps, NULL);
vidcaps);
gst_element_class_add_pad_template (element_class, audiosrctempl);
gst_element_class_add_pad_template (element_class, videosrctempl);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_factory));
gst_static_pad_template_get (&gst_asf_demux_sink_template));
gst_element_class_set_details (element_class, &gst_asf_demux_details);
}
@ -193,7 +195,7 @@ gst_asf_demux_init (GstASFDemux *asf_demux)
guint i;
asf_demux->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_static_pad_template_get (&gst_asf_demux_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (asf_demux), asf_demux->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (asf_demux), gst_asf_demux_loop);
@ -1248,7 +1250,7 @@ static GstCaps *
gst_asf_demux_audio_caps (guint16 codec_id,
asf_stream_audio *audio, guint8 *extradata)
{
GstCaps *caps = NULL;
GstCaps *caps;
gint flags1, flags2;
flags1 = 0;
@ -1256,54 +1258,33 @@ gst_asf_demux_audio_caps (guint16 codec_id,
switch (codec_id) {
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_mp3",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (3));
caps = gst_caps_from_string ("audio/mpeg, mpegversion = (int) 1, "
"layer = (int) 3");
break;
case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_mp12",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (2));
caps = gst_caps_from_string ("audio/mpeg, mpegversion = (int) 1, "
"layer = (int) 2");
break;
case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */ {
GstPropsEntry *width, *depth, *signedness;
caps = gst_caps_from_string ("audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN,"
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }");
if (audio != NULL) {
gint ba = GUINT16_FROM_LE (audio->block_align);
gint ch = GUINT16_FROM_LE (audio->channels);
gint ws = GUINT16_FROM_LE (audio->word_size);
width = gst_props_entry_new ("width",
GST_PROPS_INT (ba * 8 / ch));
depth = gst_props_entry_new ("depth",
GST_PROPS_INT (ws));
signedness = gst_props_entry_new ("signedness",
GST_PROPS_BOOLEAN (ws != 8));
} else {
signedness = gst_props_entry_new ("signed",
GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)));
width = gst_props_entry_new ("width",
GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)));
depth = gst_props_entry_new ("depth",
GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)));
}
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_pcm",
"audio/x-raw-int",
"endianness",
GST_PROPS_INT (G_LITTLE_ENDIAN));
gst_props_add_entry (caps->properties, width);
gst_props_add_entry (caps->properties, depth);
gst_props_add_entry (caps->properties, signedness);
gst_caps_set_simple (caps,
"width", G_TYPE_INT, (int)(ba * 8 / ch),
"depth", G_TYPE_INT, ws,
"signed", G_TYPE_BOOLEAN, (ws != 8),
NULL);
}
}
break;
@ -1313,15 +1294,11 @@ gst_asf_demux_audio_caps (guint16 codec_id,
case GST_RIFF_WAVE_FORMAT_VORBIS1PLUS: /* vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* vorbis mode 3+ */
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_vorbis",
"audio/x-vorbis",
NULL);
caps = gst_caps_from_string("audio/x-vorbis");
break;
case GST_RIFF_WAVE_FORMAT_A52:
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_ac3",
"audio/x-ac3",
NULL);
caps = gst_caps_from_string("audio/x-ac3");
break;
case GST_RIFF_WAVE_FORMAT_DIVX_WMAV1:
@ -1330,23 +1307,20 @@ gst_asf_demux_audio_caps (guint16 codec_id,
flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8);
}
if (audio != NULL)
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav1",
"audio/x-wma",
"wmaversion", GST_PROPS_INT (1),
"flags1", GST_PROPS_INT (flags1),
"flags2", GST_PROPS_INT (flags2),
"block_align", GST_PROPS_INT (audio->block_align),
"bitrate", GST_PROPS_INT (audio->byte_rate * 8));
else
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav1",
"audio/x-wma",
"wmaversion", GST_PROPS_INT (1),
"flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
"flags2", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
"block_align", GST_PROPS_INT_RANGE (0, G_MAXINT),
"bitrate", GST_PROPS_INT_RANGE (0, G_MAXINT)
);
caps = gst_caps_from_string("audio/x-wma, "
"wmaversion = (int) 1, "
"flags1 = (int) [ MIN, MAX ], "
"flags2 = (int) [ MIN, MAX ], "
"block_align = (int) [ 0, MAX ], "
"bitrate = (int) [ 0, MAX ]");
if (audio != NULL) {
gst_caps_set_simple (caps,
"flags1", G_TYPE_INT, flags1,
"flags2", G_TYPE_INT, flags1,
"block_align", G_TYPE_INT, audio->block_align,
"bitrate", G_TYPE_INT, audio->byte_rate * 8,
NULL);
}
break;
case GST_RIFF_WAVE_FORMAT_DIVX_WMAV2:
@ -1356,37 +1330,46 @@ gst_asf_demux_audio_caps (guint16 codec_id,
(extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8);
}
if (audio != NULL)
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav2",
"audio/x-wma",
"wmaversion", GST_PROPS_INT (2),
"flags1", GST_PROPS_INT (flags1),
"flags2", GST_PROPS_INT (flags2),
"block_align", GST_PROPS_INT (audio->block_align),
"bitrate", GST_PROPS_INT (audio->byte_rate * 8));
else
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav2",
"audio/x-wma",
"wmaversion", GST_PROPS_INT (2),
"flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
"flags2", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
"block_align", GST_PROPS_INT_RANGE (0, G_MAXINT),
"bitrate", GST_PROPS_INT_RANGE (0, G_MAXINT)
);
caps = gst_caps_from_string("audio/x-wma, "
"wmaversion = (int) 2, "
"flags1 = (int) [ MIN, MAX ], "
"flags2 = (int) [ MIN, MAX ], "
"block_align = (int) [ 0, MAX ], "
"bitrate = (int) [ 0, MAX ]");
if (audio != NULL) {
gst_caps_set_simple (caps,
"flags1", G_TYPE_INT, flags1,
"flags2", G_TYPE_INT, flags1,
"block_align", G_TYPE_INT, audio->block_align,
"bitrate", G_TYPE_INT, audio->byte_rate * 8,
NULL);
}
break;
case GST_RIFF_WAVE_FORMAT_WMAV9:
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav9",
"audio/x-wma",
"wmaversion", GST_PROPS_INT (9));
caps = gst_caps_from_string("audio/x-wma, "
"wmaversion = (int) 9");
break;
default:
g_warning ("asfdemux: unkown audio format 0x%04x",
codec_id);
return GST_CAPS_ANY;
break;
}
if (audio != NULL) {
gst_caps_set_simple (caps,
"rate", G_TYPE_INT, GUINT32_FROM_LE (audio->sample_rate),
"channels", G_TYPE_INT, GUINT16_FROM_LE (audio->channels),
NULL);
}else{
gst_caps_set_simple (caps,
"rate", GST_TYPE_INT_RANGE, 8000, 96000,
"channels", GST_TYPE_INT_RANGE, 1, 2,
NULL);
}
return caps;
}
@ -1396,7 +1379,7 @@ gst_asf_demux_add_audio_stream (GstASFDemux *asf_demux,
guint16 id)
{
GstPad *src_pad;
GstCaps *caps;
GstCaps *caps;
gchar *name = NULL;
guint16 size_left = 0;
guint8 *extradata=NULL;
@ -1482,79 +1465,82 @@ gst_asf_demux_video_caps (guint32 codec_fcc,
switch (codec_fcc) {
case GST_MAKE_FOURCC('I','4','2','0'):
case GST_MAKE_FOURCC('Y','U','Y','2'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_raw",
"video/x-raw-yuv",
"format", GST_PROPS_FOURCC (codec_fcc));
caps = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, codec_fcc, NULL);
break;
case GST_MAKE_FOURCC('M','J','P','G'):
case GST_MAKE_FOURCC('J','P','E','G'):
case GST_MAKE_FOURCC('P','I','X','L'):
case GST_MAKE_FOURCC('V','I','X','L'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_jpeg",
"video/x-jpeg",
NULL);
caps = gst_caps_new_simple ("video/x-jpeg", NULL);
break;
case GST_MAKE_FOURCC('D','V','S','D'):
case GST_MAKE_FOURCC('d','v','s','d'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_dv",
"video/x-dv",
"systemstream", GST_PROPS_BOOLEAN (FALSE));
caps = gst_caps_new_simple ("video/x-dv",
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
break;
case GST_MAKE_FOURCC('W','M','V','1'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_wmv1",
"video/x-wmv",
"wmvversion", GST_PROPS_INT (1));
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 1, NULL);
break;
case GST_MAKE_FOURCC('W','M','V','2'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_wmv2",
"video/x-wmv",
"wmvversion", GST_PROPS_INT (2));
caps = gst_caps_new_simple ("video/x-wmv",
"wmvversion", G_TYPE_INT, 2, NULL);
break;
case GST_MAKE_FOURCC('M','P','G','4'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_msmpeg41",
"video/x-msmpeg",
"msmpegversion", GST_PROPS_INT (41));
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 41, NULL);
break;
case GST_MAKE_FOURCC('M','P','4','2'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_msmpeg42",
"video/x-msmpeg",
"msmpegversion", GST_PROPS_INT (42));
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 42, NULL);
break;
case GST_MAKE_FOURCC('M','P','4','3'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_msmpeg43",
"video/x-msmpeg",
"msmpegversion", GST_PROPS_INT (43));
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 43, NULL);
break;
case GST_MAKE_FOURCC('D','I','V','3'):
case GST_MAKE_FOURCC('D','I','V','4'):
case GST_MAKE_FOURCC('D','I','V','5'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_div3",
"video/x-divx",
"divxversion", GST_PROPS_INT (3));
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 3, NULL);
break;
case GST_MAKE_FOURCC('D','I','V','X'):
case GST_MAKE_FOURCC('d','i','v','x'):
case GST_MAKE_FOURCC('D','X','5','0'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_div5",
"video/x-divx",
"divxversion", GST_PROPS_INT (5));
caps = gst_caps_new_simple ("video/x-divx",
"divxversion", G_TYPE_INT, 5, NULL);
break;
default:
g_warning ("asfdemux: unkown video format " GST_FOURCC_FORMAT "(0x%08x)",
GST_FOURCC_ARGS(codec_fcc), codec_fcc);
return NULL;
break;
}
if (video != NULL) {
gst_caps_set_simple (caps,
"width", G_TYPE_INT, GUINT32_FROM_LE (video->width),
"height", G_TYPE_INT, GUINT32_FROM_LE (video->height),
"framerate", G_TYPE_DOUBLE, 0, NULL);
} else {
gst_caps_set_simple (caps,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE,
NULL);
}
return caps;
}

View file

@ -68,137 +68,83 @@ enum {
ARG_0,
};
GST_PAD_TEMPLATE_FACTORY (src_factory,
static GstStaticPadTemplate gst_asfmux_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"asfmux_src_video",
"video/x-ms-asf",
NULL
)
GST_STATIC_CAPS ("video/x-ms-asf")
);
GST_PAD_TEMPLATE_FACTORY (video_sink_factory,
static GstStaticPadTemplate gst_asfmux_videosink_template =
GST_STATIC_PAD_TEMPLATE (
"video_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_NEW (
"asfmux_sink_video_yuv",
"video/x-raw-yuv",
"format", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_MAKE_FOURCC('Y','U','Y','2')),
GST_PROPS_FOURCC (GST_MAKE_FOURCC('I','4','2','0'))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"asfmux_sink_video_jpeg",
"video/x-jpeg",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"asfmux_sink_video_divx",
"video/x-divx",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"divxversion", GST_PROPS_INT_RANGE (3, 5)
),
GST_CAPS_NEW (
"asfmux_sink_video_xvid",
"video/x-xvid",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"asfmux_sink_video_3ivx",
"video/x-3ivx",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"asfmux_sink_video_msmpeg",
"video/x-msmpeg",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"msmpegversion", GST_PROPS_INT_RANGE (41, 43)
),
GST_CAPS_NEW (
"asfmux_sink_video_mpeg",
"video/mpeg",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
),
GST_CAPS_NEW (
"asfmux_sink_video_h263",
"video/x-h263",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"asfmux_sink_video_dv",
"video/x-dv",
"width", GST_PROPS_INT (720),
"height", GST_PROPS_LIST (
GST_PROPS_INT (576),
GST_PROPS_INT (480)
),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
),
GST_CAPS_NEW (
"asfmux_sink_video_hfyu",
"video/x-huffyuv",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
GST_STATIC_CAPS (
"video/x-raw-yuv, "
"format = (fourcc) { YUY2, I420 }, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-jpeg, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-divx, "
"divxversion = (int) [ 3, 5 ], "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-xvid, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-3ivx, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-msmpeg, "
"msmpegversion = (int) [ 41, 43 ], "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/mpeg, "
"mpegversion = (int) 1,"
"systemstream = (boolean) false,"
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-h263, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]; "
"video/x-dv, "
"systemstream = (boolean) false,"
"width = (int) 720,"
"height = (int) { 576, 480 };"
"video/x-huffyuv, "
"width = (int) [ 1, MAX], "
"height = (int) [ 1, MAX]"
)
);
GST_PAD_TEMPLATE_FACTORY (audio_sink_factory,
static GstStaticPadTemplate gst_asfmux_audiosink_template =
GST_STATIC_PAD_TEMPLATE (
"audio_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_NEW (
"asfmux_sink_audio_raw",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_LITTLE_ENDIAN),
"signed", GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)
),
"width", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"depth", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"asfmux_sink_audio_mpeg",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT_RANGE (1, 3),
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"asfmux_sink_audio_vorbis",
"audio/x-vorbis",
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"asfmux_sink_audio_ac3",
"audio/x-ac3",
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 6)
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { true, false }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) { 1, 3 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/x-vorbis, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]; "
"audio/x-ac3, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2]"
)
);
@ -251,11 +197,11 @@ gst_asfmux_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_factory));
gst_static_pad_template_get (&gst_asfmux_src_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (audio_sink_factory));
gst_static_pad_template_get (&gst_asfmux_videosink_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (video_sink_factory));
gst_static_pad_template_get (&gst_asfmux_audiosink_template));
gst_element_class_set_details (element_class, &gst_asfmux_details);
}
@ -287,10 +233,9 @@ static void
gst_asfmux_init (GstAsfMux *asfmux)
{
gint n;
GstElementClass *klass = GST_ELEMENT_GET_CLASS (asfmux);
asfmux->srcpad = gst_pad_new_from_template (
gst_element_class_get_pad_template (klass, "src"), "src");
gst_static_pad_template_get (&gst_asfmux_src_template), "src");
gst_element_add_pad (GST_ELEMENT (asfmux), asfmux->srcpad);
GST_FLAG_SET (GST_ELEMENT (asfmux), GST_ELEMENT_EVENT_AWARE);
@ -310,12 +255,15 @@ gst_asfmux_init (GstAsfMux *asfmux)
}
static GstPadLinkReturn
gst_asfmux_vidsinkconnect (GstPad *pad, GstCaps *vscaps)
gst_asfmux_vidsink_link (GstPad *pad, const GstCaps *caps)
{
GstAsfMux *asfmux;
GstCaps *caps;
GstAsfMuxStream *stream = NULL;
GstStructure *structure;
gint n;
const gchar* mimetype;
gint w, h;
gboolean ret;
asfmux = GST_ASFMUX (gst_pad_get_parent (pad));
@ -329,101 +277,98 @@ gst_asfmux_vidsinkconnect (GstPad *pad, GstCaps *vscaps)
g_assert (stream != NULL);
g_assert (stream->type == ASF_STREAM_VIDEO);
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED (vscaps))
return GST_PAD_LINK_DELAYED;
GST_DEBUG ("asfmux: video sinkconnect triggered on %s",
gst_pad_get_name (pad));
for (caps = vscaps; caps != NULL; caps = caps->next) {
const gchar* mimetype = gst_caps_get_mime(caps);
gint w, h;
structure = gst_caps_get_structure (caps, 0);
/* global */
gst_caps_get (caps, "width", &w,
"height", &h,
NULL);
/* global */
ret = gst_structure_get_int (structure, "width", &w);
ret &= gst_structure_get_int (structure, "height", &h);
stream->header.video.stream.width = w;
stream->header.video.stream.height = h;
stream->header.video.stream.unknown = 2;
stream->header.video.stream.size = 40;
stream->bitrate = 0; /* TODO */
if(!ret) return GST_PAD_LINK_REFUSED;
if (!strcmp (mimetype, "video/x-raw-yuv")) {
guint32 format;
stream->header.video.stream.width = w;
stream->header.video.stream.height = h;
stream->header.video.stream.unknown = 2;
stream->header.video.stream.size = 40;
stream->bitrate = 0; /* TODO */
gst_caps_get_fourcc_int (caps, "format", &format);
stream->header.video.format.tag = format;
switch (format) {
case GST_MAKE_FOURCC ('Y','U','Y','2'):
stream->header.video.format.depth = 16;
stream->header.video.format.planes = 1;
break;
case GST_MAKE_FOURCC ('I','4','2','0'):
stream->header.video.format.depth = 12;
stream->header.video.format.planes = 3;
break;
}
mimetype = gst_structure_get_name (structure);
if (!strcmp (mimetype, "video/x-raw-yuv")) {
guint32 format;
goto done;
} else {
stream->header.video.format.depth = 24;
stream->header.video.format.planes = 1;
stream->header.video.format.tag = 0;
ret = gst_structure_get_fourcc (structure, "format", &format);
if(!ret) return GST_PAD_LINK_REFUSED;
/* find format */
if (!strcmp (mimetype, "video/x-huffyuv")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('H','F','Y','U');
} else if (!strcmp (mimetype, "video/x-jpeg")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','J','P','G');
} else if (!strcmp (mimetype, "video/x-divx")) {
gint divxversion;
gst_caps_get_int (caps, "divxversion", &divxversion);
switch (divxversion) {
case 3:
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','I','V','3');
break;
case 4:
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','I','V','X');
break;
case 5:
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','X','5','0');
break;
}
} else if (!strcmp (mimetype, "video/x-xvid")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('X','V','I','D');
} else if (!strcmp (mimetype, "video/x-3ivx")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('3','I','V','2');
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
gint msmpegversion;
gst_caps_get_int (caps, "msmpegversion", &msmpegversion);
switch (msmpegversion) {
case 41:
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','G','4');
break;
case 42:
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','4','2');
break;
case 43:
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','4','3');
break;
}
} else if (!strcmp (mimetype, "video/x-dv")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','V','S','D');
} else if (!strcmp (mimetype, "video/x-h263")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('H','2','6','3');
} else if (!strcmp (mimetype, "video/mpeg")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','E','G');
}
if (!stream->header.video.format.tag) {
continue;
}
goto done;
stream->header.video.format.tag = format;
switch (format) {
case GST_MAKE_FOURCC ('Y','U','Y','2'):
stream->header.video.format.depth = 16;
stream->header.video.format.planes = 1;
break;
case GST_MAKE_FOURCC ('I','4','2','0'):
stream->header.video.format.depth = 12;
stream->header.video.format.planes = 3;
break;
}
goto done;
} else {
stream->header.video.format.depth = 24;
stream->header.video.format.planes = 1;
stream->header.video.format.tag = 0;
/* find format */
if (!strcmp (mimetype, "video/x-huffyuv")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('H','F','Y','U');
} else if (!strcmp (mimetype, "video/x-jpeg")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','J','P','G');
} else if (!strcmp (mimetype, "video/x-divx")) {
gint divxversion;
gst_structure_get_int (structure, "divxversion", &divxversion);
switch (divxversion) {
case 3:
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','I','V','3');
break;
case 4:
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','I','V','X');
break;
case 5:
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','X','5','0');
break;
}
} else if (!strcmp (mimetype, "video/x-xvid")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('X','V','I','D');
} else if (!strcmp (mimetype, "video/x-3ivx")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('3','I','V','2');
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
gint msmpegversion;
gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
switch (msmpegversion) {
case 41:
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','G','4');
break;
case 42:
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','4','2');
break;
case 43:
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','4','3');
break;
}
} else if (!strcmp (mimetype, "video/x-dv")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('D','V','S','D');
} else if (!strcmp (mimetype, "video/x-h263")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('H','2','6','3');
} else if (!strcmp (mimetype, "video/mpeg")) {
stream->header.video.format.tag = GST_MAKE_FOURCC ('M','P','E','G');
}
if (!stream->header.video.format.tag) {
return GST_PAD_LINK_REFUSED;
}
goto done;
}
return GST_PAD_LINK_REFUSED;
@ -443,12 +388,15 @@ done:
}
static GstPadLinkReturn
gst_asfmux_audsinkconnect (GstPad *pad, GstCaps *vscaps)
gst_asfmux_audsink_link (GstPad *pad, const GstCaps *caps)
{
GstAsfMux *asfmux;
GstCaps *caps;
GstAsfMuxStream *stream = NULL;
gint n;
const gchar* mimetype;
gint rate, channels;
gboolean ret;
GstStructure *structure;
asfmux = GST_ASFMUX (gst_pad_get_parent (pad));
@ -462,75 +410,69 @@ gst_asfmux_audsinkconnect (GstPad *pad, GstCaps *vscaps)
g_assert (stream != NULL);
g_assert (stream->type == ASF_STREAM_AUDIO);
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED (vscaps))
return GST_PAD_LINK_DELAYED;
GST_DEBUG ("asfmux: audio sinkconnect triggered on %s",
GST_DEBUG ("asfmux: audio sink_link triggered on %s",
gst_pad_get_name (pad));
for (caps = vscaps; caps != NULL; caps = caps->next) {
const gchar* mimetype = gst_caps_get_mime(caps);
gint rate, channels;
structure = gst_caps_get_structure (caps, 0);
/* we want these for all */
gst_caps_get (caps, "channels", &channels,
"rate", &rate,
NULL);
/* we want these for all */
ret = gst_structure_get_int (structure, "channels", &channels);
ret &= gst_structure_get_int (structure, "rate", &rate);
stream->header.audio.sample_rate = rate;
stream->header.audio.channels = channels;
if (!ret) return GST_PAD_LINK_REFUSED;
if (!strcmp (mimetype, "audio/x-raw-int")) {
gint block, size;
stream->header.audio.sample_rate = rate;
stream->header.audio.channels = channels;
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_PCM;
mimetype = gst_structure_get_name (structure);
if (!strcmp (mimetype, "audio/x-raw-int")) {
gint block, size;
gst_caps_get (caps, "width", &block,
"depth", &size,
NULL);
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_PCM;
stream->header.audio.block_align = block;
stream->header.audio.word_size = size;
stream->header.audio.size = 0;
gst_structure_get_int (structure, "width", &block);
gst_structure_get_int (structure, "depth", &size);
/* set some more info straight */
stream->header.audio.block_align /= 8;
stream->header.audio.block_align *= stream->header.audio.channels;
stream->header.audio.byte_rate = stream->header.audio.block_align *
stream->header.audio.sample_rate;
goto done;
} else {
stream->header.audio.codec_tag = 0;
stream->header.audio.block_align = block;
stream->header.audio.word_size = size;
stream->header.audio.size = 0;
if (!strcmp (mimetype, "audio/mpeg")) {
gint layer = 3;
gst_caps_get_int(caps, "layer", &layer);
switch (layer) {
case 3:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL3;
break;
case 1: case 2:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL12;
break;
}
} else if (!strcmp (mimetype, "audio/x-vorbis")) {
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_VORBIS3;
} else if (!strcmp (mimetype, "audio/x-ac3")) {
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_A52;
/* set some more info straight */
stream->header.audio.block_align /= 8;
stream->header.audio.block_align *= stream->header.audio.channels;
stream->header.audio.byte_rate = stream->header.audio.block_align *
stream->header.audio.sample_rate;
goto done;
} else {
stream->header.audio.codec_tag = 0;
if (!strcmp (mimetype, "audio/mpeg")) {
gint layer = 3;
gst_structure_get_int(structure, "layer", &layer);
switch (layer) {
case 3:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL3;
break;
case 1: case 2:
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_MPEGL12;
break;
}
stream->header.audio.block_align = 1;
stream->header.audio.byte_rate = 8 * 1024;
stream->header.audio.word_size = 16;
stream->header.audio.size = 0;
if (!stream->header.audio.codec_tag) {
continue;
}
goto done;
} else if (!strcmp (mimetype, "audio/x-vorbis")) {
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_VORBIS3;
} else if (!strcmp (mimetype, "audio/x-ac3")) {
stream->header.audio.codec_tag = GST_RIFF_WAVE_FORMAT_A52;
}
stream->header.audio.block_align = 1;
stream->header.audio.byte_rate = 8 * 1024;
stream->header.audio.word_size = 16;
stream->header.audio.size = 0;
if (!stream->header.audio.codec_tag) {
return GST_PAD_LINK_REFUSED;
}
goto done;
}
return GST_PAD_LINK_REFUSED;
@ -615,11 +557,11 @@ gst_asfmux_request_new_pad (GstElement *element,
if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
padname = g_strdup_printf ("audio_%02d", asfmux->num_audio++);
stream->type = ASF_STREAM_AUDIO;
linkfunc = gst_asfmux_audsinkconnect;
linkfunc = gst_asfmux_audsink_link;
} else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
padname = g_strdup_printf ("video_%02d", asfmux->num_video++);
stream->type = ASF_STREAM_VIDEO;
linkfunc = gst_asfmux_vidsinkconnect;
linkfunc = gst_asfmux_vidsink_link;
} else {
g_warning ("asfmux: this is not our template!\n");
return NULL;

View file

@ -32,42 +32,27 @@ static GstElementDetails mp3parse_details = {
"Erik Walthinsen <omega@cse.ogi.edu>"
};
static GstPadTemplate*
mp3_src_factory (void)
{
return
gst_pad_template_new (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
gst_caps_new (
"mp3parse_src",
"audio/mpeg",
gst_props_new (
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT_RANGE (1, 3),
"rate", GST_PROPS_INT_RANGE (8000, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2),
NULL)),
NULL);
}
static GstStaticPadTemplate mp3_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) [ 1, 3 ], "
"rate = (int) [ 8000, 48000], "
"channels = (int) [ 1, 2 ]")
);
static GstPadTemplate*
mp3_sink_factory (void)
{
return
gst_pad_template_new (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mp3parse_sink",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1)
),
NULL
);
};
static GstStaticPadTemplate mp3_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1"
)
);
/* GstMPEGAudioParse signals and args */
enum {
@ -82,7 +67,6 @@ enum {
/* FILL ME */
};
static GstPadTemplate *sink_temp, *src_temp;
static void gst_mp3parse_class_init (GstMPEGAudioParseClass *klass);
static void gst_mp3parse_base_init (GstMPEGAudioParseClass *klass);
@ -248,13 +232,11 @@ mp3_caps_create (guint layer, guint channels,
g_assert (bitrate);
g_assert (channels);
new = GST_CAPS_NEW ("mp3_type_find",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (layer),
/*"bitrate", GST_PROPS_INT (bitrate),*/
"rate", GST_PROPS_INT (samplerate),
"channels", GST_PROPS_INT (channels));
new = gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"layer", G_TYPE_INT, layer,
"rate", G_TYPE_INT, samplerate,
"channels", G_TYPE_INT, channels, NULL);
return new;
}
@ -264,8 +246,10 @@ gst_mp3parse_base_init (GstMPEGAudioParseClass *klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, sink_temp);
gst_element_class_add_pad_template (element_class, src_temp);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&mp3_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&mp3_src_template));
gst_element_class_set_details (element_class, &mp3parse_details);
}
@ -296,13 +280,15 @@ gst_mp3parse_class_init (GstMPEGAudioParseClass *klass)
static void
gst_mp3parse_init (GstMPEGAudioParse *mp3parse)
{
mp3parse->sinkpad = gst_pad_new_from_template(sink_temp, "sink");
mp3parse->sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&mp3_sink_template), "sink");
gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->sinkpad);
gst_pad_set_chain_function(mp3parse->sinkpad,gst_mp3parse_chain);
gst_element_set_loop_function (GST_ELEMENT(mp3parse),NULL);
mp3parse->srcpad = gst_pad_new_from_template(src_temp, "src");
mp3parse->srcpad = gst_pad_new_from_template(
gst_static_pad_template_get (&mp3_src_template), "src");
gst_element_add_pad(GST_ELEMENT(mp3parse),mp3parse->srcpad);
/*gst_pad_set_type_id(mp3parse->srcpad, mp3frametype); */
@ -587,9 +573,6 @@ gst_mp3parse_change_state (GstElement *element)
static gboolean
plugin_init (GstPlugin *plugin)
{
sink_temp = mp3_sink_factory ();
src_temp = mp3_src_factory ();
return gst_element_register (plugin, "mp3parse",
GST_RANK_NONE, GST_TYPE_MP3PARSE);
}

View file

@ -48,106 +48,76 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (sink_factory,
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mpeg_demux_sink",
"video/mpeg",
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (TRUE)
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2], "
"systemstream = (boolean) TRUE"
)
);
GST_PAD_TEMPLATE_FACTORY (audio_factory,
static GstStaticPadTemplate audio_factory =
GST_STATIC_PAD_TEMPLATE (
"audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_NEW (
"mpeg_demux_audio",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1)
GST_STATIC_CAPS ( "audio/mpeg, "
"mpegversion = (int) 1"
)
);
GST_PAD_TEMPLATE_FACTORY (video_src_factory,
static GstStaticPadTemplate video_src_factory =
GST_STATIC_PAD_TEMPLATE (
"video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_NEW (
"mpeg_demux_video_mpeg1",
"video/mpeg",
"mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
),
GST_CAPS_NEW (
"mpeg_demux_video_mpeg2",
"video/mpeg",
"mpegversion", GST_PROPS_INT (2),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
GST_STATIC_CAPS (
"video/mpeg, "
"mpegversion = (int) { 1, 2 }, "
"systemstream = (boolean) FALSE"
)
);
GST_PAD_TEMPLATE_FACTORY (private1_factory,
static GstStaticPadTemplate private1_factory =
GST_STATIC_PAD_TEMPLATE (
"private_stream_1_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_NEW (
"mpeg_demux_private1",
"audio/x-ac3",
NULL
)
GST_STATIC_CAPS ("audio/x-ac3")
);
GST_PAD_TEMPLATE_FACTORY (private2_factory,
static GstStaticPadTemplate private2_factory =
GST_STATIC_PAD_TEMPLATE (
"private_stream_2",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_NEW (
"mpeg_demux_private_2",
"unknown/unknown",
NULL
)
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (pcm_factory,
static GstStaticPadTemplate pcm_factory =
GST_STATIC_PAD_TEMPLATE (
"pcm_stream_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_NEW (
"mpeg_demux_pcm",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_LIST (
GST_PROPS_INT (16),
GST_PROPS_INT (20),
GST_PROPS_INT (24)
),
"depth", GST_PROPS_LIST (
GST_PROPS_INT (16),
GST_PROPS_INT (20),
GST_PROPS_INT (24)
),
"rate", GST_PROPS_LIST (
GST_PROPS_INT (48000),
GST_PROPS_INT (96000)
),
"channels", GST_PROPS_INT_RANGE (1, 8)
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BIG_ENDIAN, "
"signed = (boolean) TRUE, "
"width = (int) { 16, 20, 24 }, "
"depth = (int) { 16, 20, 24 }, "
"rate = (int) { 48000, 96000 }, "
"channels = (int) [ 1, 8 ]"
)
);
GST_PAD_TEMPLATE_FACTORY (subtitle_factory,
static GstStaticPadTemplate subtitle_factory =
GST_STATIC_PAD_TEMPLATE (
"subtitle_stream_%d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
GST_CAPS_NEW (
"mpeg_demux_subtitle",
"unknown/unknown",
NULL
)
GST_STATIC_CAPS_ANY
);
static void gst_mpeg_demux_class_init (GstMPEGDemuxClass *klass);
@ -205,19 +175,19 @@ gst_mpeg_demux_base_init (GstMPEGDemuxClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_factory));
gst_static_pad_template_get (&sink_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (video_src_factory));
gst_static_pad_template_get (&video_src_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (private1_factory));
gst_static_pad_template_get (&private1_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (private2_factory));
gst_static_pad_template_get (&private2_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (pcm_factory));
gst_static_pad_template_get (&pcm_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (subtitle_factory));
gst_static_pad_template_get (&subtitle_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (audio_factory));
gst_static_pad_template_get (&audio_factory));
gst_element_class_set_details (element_class, &mpeg_demux_details);
}
@ -254,7 +224,7 @@ gst_mpeg_demux_init (GstMPEGDemux *mpeg_demux)
gst_element_remove_pad (GST_ELEMENT (mpeg_parse), mpeg_parse->sinkpad);
mpeg_parse->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_static_pad_template_get (&sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (mpeg_parse), mpeg_parse->sinkpad);
gst_element_remove_pad (GST_ELEMENT (mpeg_parse), mpeg_parse->srcpad);
@ -448,32 +418,25 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
/* private_stream_2 */
name = g_strdup_printf ("private_stream_2");
outstream = &mpeg_demux->private_2_stream;
newtemp = GST_PAD_TEMPLATE_GET (private2_factory);
newtemp = gst_static_pad_template_get (&private2_factory);
} else if (stream_id >= 0xC0 && stream_id < 0xE0) {
/* Audio */
name = g_strdup_printf ("audio_%02d", stream_id & 0x1F);
outstream = &mpeg_demux->audio_stream[stream_id & 0x1F];
newtemp = GST_PAD_TEMPLATE_GET (audio_factory);
newtemp = gst_static_pad_template_get (&audio_factory);
} else if (stream_id >= 0xE0 && stream_id < 0xF0) {
/* Video */
name = g_strdup_printf ("video_%02d", stream_id & 0x0F);
outstream = &mpeg_demux->video_stream[stream_id & 0x0F];
newtemp = GST_PAD_TEMPLATE_GET (video_src_factory);
newtemp = gst_static_pad_template_get (&video_src_factory);
if (!GST_MPEG_PARSE_IS_MPEG2 (mpeg_demux)) {
caps = GST_CAPS_NEW (
"mpeg_demux_video_mpeg1",
"video/mpeg",
"mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
);
}
else {
caps = GST_CAPS_NEW (
"mpeg_demux_video_mpeg2",
"video/mpeg",
"mpegversion", GST_PROPS_INT (2),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
);
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
} else {
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
} else {
GST_DEBUG ("unkown stream id %d", stream_id);
@ -496,11 +459,8 @@ gst_mpeg_demux_parse_syshead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
*outpad = gst_pad_new_from_template (newtemp, name);
if (!caps) {
caps = gst_pad_template_get_caps (newtemp);
gst_pad_try_set_caps (*outpad, caps);
gst_caps_unref(caps);
}
else {
gst_pad_try_set_caps (*outpad, gst_pad_template_get_caps (newtemp));
} else {
gst_pad_try_set_caps (*outpad, caps);
}
@ -903,46 +863,40 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
gst_mpeg_demux_dvd_audio_clear (mpeg_demux, ps_id_code - 0x80);
name = g_strdup_printf ("private_stream_1_%d",ps_id_code - 0x80);
newtemp = GST_PAD_TEMPLATE_GET (private1_factory);
newtemp = gst_static_pad_template_get (&private1_factory);
} else if (ps_id_code >= 0xA0 && ps_id_code <= 0xA7) {
/* Erase any DVD audio pads. */
gst_mpeg_demux_dvd_audio_clear (mpeg_demux, ps_id_code - 0xA0);
name = g_strdup_printf ("pcm_stream_%d", ps_id_code - 0xA0);
newtemp = GST_PAD_TEMPLATE_GET (pcm_factory);
newtemp = gst_static_pad_template_get (&pcm_factory);
} else if (ps_id_code >= 0x20 && ps_id_code <= 0x2F) {
name = g_strdup_printf ("subtitle_stream_%d",ps_id_code - 0x20);
newtemp = GST_PAD_TEMPLATE_GET (subtitle_factory);
newtemp = gst_static_pad_template_get (&subtitle_factory);
} else {
name = g_strdup_printf ("unknown_stream_%d",ps_id_code);
}
} else if (id == 0xBF) {
/* private_stream_2 */
name = g_strdup ("private_stream_2");
newtemp = GST_PAD_TEMPLATE_GET (private2_factory);
newtemp = gst_static_pad_template_get (&private2_factory);
} else if (id >= 0xC0 && id <= 0xDF) {
/* audio */
name = g_strdup_printf ("audio_%02d", id - 0xC0);
newtemp = GST_PAD_TEMPLATE_GET (audio_factory);
newtemp = gst_static_pad_template_get (&audio_factory);
} else if (id >= 0xE0 && id <= 0xEF) {
/* video */
name = g_strdup_printf ("video_%02d", id - 0xE0);
newtemp = GST_PAD_TEMPLATE_GET (video_src_factory);
newtemp = gst_static_pad_template_get (&video_src_factory);
if (!GST_MPEG_PARSE_IS_MPEG2 (mpeg_demux)) {
caps = GST_CAPS_NEW (
"mpeg_demux_video_mpeg1",
"video/mpeg",
"mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
);
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
else {
caps = GST_CAPS_NEW (
"mpeg_demux_video_mpeg2",
"video/mpeg",
"mpegversion", GST_PROPS_INT (2),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
);
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
} else {
/* unkown */
@ -958,11 +912,8 @@ gst_mpeg_demux_parse_pes (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
*outpad = gst_pad_new_from_template (newtemp, name);
if (ps_id_code < 0xA0 || ps_id_code > 0xA7) {
if (!caps) {
caps = gst_pad_template_get_caps (newtemp);
gst_pad_try_set_caps (*outpad, caps);
gst_caps_unref(caps);
}
else {
gst_pad_try_set_caps (*outpad, gst_pad_template_get_caps (newtemp));
} else {
gst_pad_try_set_caps (*outpad, caps);
}
}
@ -1058,24 +1009,20 @@ gst_mpeg_demux_lpcm_set_caps (GstPad *pad, guint8 sample_info)
/* Determine the rate. */
if (sample_info & 0x10) {
rate = 96000;
}
else {
} else {
rate = 48000;
}
/* Determine the number of channels. */
channels = (sample_info & 0x7) + 1;
caps = GST_CAPS_NEW (
"mpeg_demux_pcm",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (width),
"depth", GST_PROPS_INT (width),
"rate", GST_PROPS_INT (rate),
"channels", GST_PROPS_INT (channels)
);
caps = gst_caps_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"signed", G_TYPE_BOOLEAN, TRUE,
"width", G_TYPE_INT, width,
"depth", G_TYPE_INT, width,
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, channels, NULL);
gst_pad_try_set_caps (pad, caps);
}

View file

@ -56,27 +56,25 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (sink_factory,
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mpeg_parse_sink",
"video/mpeg",
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (TRUE)
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], "
"systemstream = (boolean) TRUE"
)
);
GST_PAD_TEMPLATE_FACTORY (src_factory,
static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"mpeg_parse_src",
"video/mpeg",
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (TRUE)
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], "
"systemstream = (boolean) TRUE"
)
);
@ -136,9 +134,9 @@ gst_mpeg_parse_base_init (GstMPEGParseClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_factory));
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_factory));
gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &mpeg_parse_details);
}
@ -159,9 +157,6 @@ gst_mpeg_parse_class_init (GstMPEGParseClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DISCONT,
g_param_spec_int ("max_discont", "Max Discont", "The maximun allowed SCR discontinuity",
0, G_MAXINT, DEFAULT_MAX_DISCONT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_STREAMINFO,
g_param_spec_boxed ("streaminfo", "Streaminfo", "Streaminfo",
GST_TYPE_CAPS, G_PARAM_READABLE));
gobject_class->get_property = gst_mpeg_parse_get_property;
gobject_class->set_property = gst_mpeg_parse_set_property;
@ -185,13 +180,13 @@ static void
gst_mpeg_parse_init (GstMPEGParse *mpeg_parse)
{
mpeg_parse->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_static_pad_template_get (&sink_factory), "sink");
gst_element_add_pad(GST_ELEMENT(mpeg_parse),mpeg_parse->sinkpad);
gst_pad_set_formats_function (mpeg_parse->sinkpad, gst_mpeg_parse_get_src_formats);
gst_pad_set_convert_function (mpeg_parse->sinkpad, gst_mpeg_parse_convert_src);
mpeg_parse->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (src_factory), "src");
gst_static_pad_template_get (&src_factory), "src");
gst_element_add_pad(GST_ELEMENT(mpeg_parse),mpeg_parse->srcpad);
gst_pad_set_formats_function (mpeg_parse->srcpad, gst_mpeg_parse_get_src_formats);
gst_pad_set_convert_function (mpeg_parse->srcpad, gst_mpeg_parse_convert_src);
@ -208,7 +203,6 @@ gst_mpeg_parse_init (GstMPEGParse *mpeg_parse)
mpeg_parse->max_discont = DEFAULT_MAX_DISCONT;
mpeg_parse->provided_clock = gst_mpeg_clock_new ("MPEGParseClock",
gst_mpeg_parse_get_time, mpeg_parse);
mpeg_parse->streaminfo = NULL;
GST_FLAG_SET (mpeg_parse, GST_ELEMENT_EVENT_AWARE);
}
@ -238,6 +232,7 @@ gst_mpeg_parse_get_time (GstClock *clock, gpointer data)
return MPEGTIME_TO_GSTTIME (parse->current_scr);
}
#if 0
static void
gst_mpeg_parse_update_streaminfo (GstMPEGParse *mpeg_parse)
{
@ -248,10 +243,10 @@ gst_mpeg_parse_update_streaminfo (GstMPEGParse *mpeg_parse)
props = gst_props_empty_new ();
entry = gst_props_entry_new ("mpegversion", GST_PROPS_INT (mpeg2 ? 2 : 1));
entry = gst_props_entry_new ("mpegversion", G_TYPE_INT (mpeg2 ? 2 : 1));
gst_props_add_entry (props, (GstPropsEntry *) entry);
entry = gst_props_entry_new ("bitrate", GST_PROPS_INT (mpeg_parse->mux_rate * 400));
entry = gst_props_entry_new ("bitrate", G_TYPE_INT (mpeg_parse->mux_rate * 400));
gst_props_add_entry (props, (GstPropsEntry *) entry);
caps = gst_caps_new ("mpeg_streaminfo",
@ -261,6 +256,7 @@ gst_mpeg_parse_update_streaminfo (GstMPEGParse *mpeg_parse)
gst_caps_replace_sink (&mpeg_parse->streaminfo, caps);
g_object_notify (G_OBJECT (mpeg_parse), "streaminfo");
}
#endif
static void
gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime time)
@ -279,13 +275,10 @@ gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
if (gst_pad_try_set_caps (mpeg_parse->srcpad,
GST_CAPS_NEW (
"mpeg_parse_src",
"video/mpeg",
"mpegversion", GST_PROPS_INT (mpeg2 ? 2 : 1),
"systemstream", GST_PROPS_BOOLEAN (TRUE),
"parsed", GST_PROPS_BOOLEAN (TRUE)
)) < 0)
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0)
{
gst_element_error (GST_ELEMENT (mpeg_parse), "could no set source caps");
return;
@ -414,7 +407,7 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
if (mpeg_parse->mux_rate != new_rate) {
mpeg_parse->mux_rate = new_rate;
gst_mpeg_parse_update_streaminfo (mpeg_parse);
//gst_mpeg_parse_update_streaminfo (mpeg_parse);
GST_DEBUG ("stream is %1.3fMbs", (mpeg_parse->mux_rate * 400) / 1000000.0);
}
@ -524,13 +517,10 @@ gst_mpeg_parse_loop (GstElement *element)
gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
if (gst_pad_try_set_caps (mpeg_parse->sinkpad,
GST_CAPS_NEW (
"mpeg_parse_src",
"video/mpeg",
"mpegversion", GST_PROPS_INT (mpeg2 ? 2 : 1),
"systemstream", GST_PROPS_BOOLEAN (TRUE),
"parsed", GST_PROPS_BOOLEAN (TRUE)
)) < 0)
gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"systemstream", G_TYPE_BOOLEAN, TRUE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0)
{
gst_element_error (GST_ELEMENT (mpeg_parse), "could no set sink caps");
return;
@ -830,7 +820,7 @@ gst_mpeg_parse_change_state (GstElement *element)
gst_mpeg_packetize_destroy (mpeg_parse->packetize);
mpeg_parse->packetize = NULL;
}
gst_caps_replace (&mpeg_parse->streaminfo, NULL);
//gst_caps_replace (&mpeg_parse->streaminfo, NULL);
break;
default:
break;
@ -853,9 +843,6 @@ gst_mpeg_parse_get_property (GObject *object, guint prop_id, GValue *value, GPar
case ARG_MAX_DISCONT:
g_value_set_int (value, mpeg_parse->max_discont);
break;
case ARG_STREAMINFO:
g_value_set_boxed (value, mpeg_parse->streaminfo);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;

View file

@ -78,8 +78,6 @@ struct _GstMPEGParse {
GstIndex *index;
gint index_id;
GstCaps *streaminfo;
};
struct _GstMPEGParseClass {

View file

@ -47,27 +47,25 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (sink_factory,
static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"rfc2250_enc_sink",
"video/mpeg",
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], "
"systemstream = (boolean) FALSE"
)
);
GST_PAD_TEMPLATE_FACTORY (src_factory,
static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"rfc2250_enc_src",
"video/mpeg",
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
GST_STATIC_CAPS ("video/mpeg, "
"mpegversion = (int) [ 1, 2 ], "
"systemstream = (boolean) FALSE"
)
);
@ -113,9 +111,9 @@ gst_rfc2250_enc_base_init (GstRFC2250EncClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_factory));
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_factory));
gst_static_pad_template_get (&sink_factory));
gst_element_class_set_details (element_class, &rfc2250_enc_details);
}
@ -146,11 +144,11 @@ static void
gst_rfc2250_enc_init (GstRFC2250Enc *rfc2250_enc)
{
rfc2250_enc->sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (sink_factory), "sink");
gst_static_pad_template_get (&sink_factory), "sink");
gst_element_add_pad(GST_ELEMENT(rfc2250_enc),rfc2250_enc->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (rfc2250_enc), gst_rfc2250_enc_loop);
rfc2250_enc->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET (src_factory), "src");
gst_static_pad_template_get (&src_factory), "src");
gst_element_add_pad(GST_ELEMENT(rfc2250_enc),rfc2250_enc->srcpad);
/* initialize parser state */

View file

@ -92,30 +92,29 @@ enum {
ARG_0
};
GST_PAD_TEMPLATE_FACTORY (sink_templ,
static GstStaticPadTemplate gst_rmdemux_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"rmdemux_sink",
"video/x-pn-realvideo",
NULL
)
)
GST_STATIC_CAPS ("video/x-pn-realvideo")
);
GST_PAD_TEMPLATE_FACTORY (src_video_templ,
static GstStaticPadTemplate gst_rmdemux_videosrc_template =
GST_STATIC_PAD_TEMPLATE (
"video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
NULL
)
GST_STATIC_CAPS_ANY
);
GST_PAD_TEMPLATE_FACTORY (src_audio_templ,
static GstStaticPadTemplate gst_rmdemux_audiosrc_template =
GST_STATIC_PAD_TEMPLATE (
"audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
NULL
)
GST_STATIC_CAPS_ANY
);
static GstElementClass *parent_class = NULL;
@ -168,11 +167,11 @@ static void gst_rmdemux_base_init (GstRMDemuxClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_templ));
gst_static_pad_template_get (&gst_rmdemux_sink_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_video_templ));
gst_static_pad_template_get (&gst_rmdemux_videosrc_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_audio_templ));
gst_static_pad_template_get (&gst_rmdemux_audiosrc_template));
gst_element_class_set_details (element_class, &gst_rmdemux_details);
}
@ -192,7 +191,8 @@ static void gst_rmdemux_class_init (GstRMDemuxClass *klass)
static void
gst_rmdemux_init (GstRMDemux *rmdemux)
{
rmdemux->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_templ), "sink");
rmdemux->sinkpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_rmdemux_sink_template), "sink");
gst_element_set_loop_function (GST_ELEMENT (rmdemux), gst_rmdemux_loop);
gst_element_add_pad (GST_ELEMENT (rmdemux), rmdemux->sinkpad);
}
@ -462,11 +462,10 @@ static void gst_rmdemux_loop (GstElement *element)
}
static GstCaps *gst_rmdemux_src_getcaps(GstPad *pad, GstCaps *caps)
static GstCaps *gst_rmdemux_src_getcaps(GstPad *pad)
{
GstRMDemux *rmdemux;
GstRMDemuxStream *stream;
int i;
GST_DEBUG ("gst_rmdemux_src_getcaps");
@ -474,22 +473,14 @@ static GstCaps *gst_rmdemux_src_getcaps(GstPad *pad, GstCaps *caps)
g_return_val_if_fail(GST_IS_RMDEMUX(rmdemux), NULL);
GST_DEBUG ("looking for pad %p in rmdemux %p", pad, rmdemux);
GST_DEBUG ("n_streams is %d", rmdemux->n_streams);
for(i=0;i<rmdemux->n_streams;i++){
stream = rmdemux->streams[i];
if(stream->pad == pad){
return stream->caps;
}
}
GST_DEBUG ("Couldn't find stream cooresponding to pad\n");
return NULL;
stream = GST_PAD_ELEMENT_PRIVATE (pad);
return gst_caps_copy(stream->caps);
}
#ifdef unused
/* This function is not useful currently */
static GstPadLinkReturn
gst_rmdemux_src_link(GstPad *pad, GstCaps *caps)
gst_rmdemux_src_link(GstPad *pad, static GstCaps *caps)
{
GstRMDemux *rmdemux;
GstRMDemuxStream *stream;
@ -503,18 +494,14 @@ gst_rmdemux_src_link(GstPad *pad, GstCaps *caps)
g_return_val_if_fail(GST_IS_RMDEMUX(rmdemux), GST_PAD_LINK_REFUSED);
GST_DEBUG ("n_streams is %d\n", rmdemux->n_streams);
for(i=0;i<rmdemux->n_streams;i++){
stream = rmdemux->streams[i];
GST_DEBUG ("pad[%d] is %p\n", i, stream->pad);
if(stream->pad == pad){
return GST_PAD_LINK_OK;
}
}
stream = GST_PAD_ELEMENT_PRIVATE (pad);
return GST_PAD_LINK_OK;
GST_DEBUG ("Couldn't find stream cooresponding to pad\n");
return GST_PAD_LINK_REFUSED;
}
#endif
static GstRMDemuxStream *gst_rmdemux_get_stream_by_id(GstRMDemux *rmdemux,
int id)
@ -536,48 +523,45 @@ void gst_rmdemux_add_stream(GstRMDemux *rmdemux, GstRMDemuxStream *stream)
{
if(stream->subtype == GST_RMDEMUX_STREAM_VIDEO){
stream->pad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_video_templ), g_strdup_printf ("video_%02d",
rmdemux->n_video_streams));
if(stream->caps){
gst_caps_set(stream->caps,"width",GST_PROPS_INT(stream->width));
gst_caps_set(stream->caps,"height",GST_PROPS_INT(stream->height));
gst_static_pad_template_get (&gst_rmdemux_videosrc_template),
g_strdup_printf ("video_%02d", rmdemux->n_video_streams));
if(stream->caps) {
gst_caps_set_simple (stream->caps,
"width", G_TYPE_INT, stream->width,
"height", G_TYPE_INT, stream->height, NULL);
}
rmdemux->n_video_streams++;
}else
if(stream->subtype == GST_RMDEMUX_STREAM_AUDIO){
stream->pad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_audio_templ), g_strdup_printf ("audio_%02d",
rmdemux->n_audio_streams));
stream->caps = GST_CAPS_NEW("audio_caps","audio/a52",NULL);
gst_caps_ref(stream->caps);
gst_caps_sink(stream->caps);
if(stream->caps){
if(gst_caps_has_property(stream->caps,"rate")){
gst_caps_set(stream->caps,"rate",GST_PROPS_INT((int)stream->rate));
}
if(gst_caps_has_property(stream->caps,"channels")){
gst_caps_set(stream->caps,"channels",GST_PROPS_INT(stream->n_channels));
}
}
gst_static_pad_template_get (&gst_rmdemux_audiosrc_template),
g_strdup_printf ("audio_%02d", rmdemux->n_audio_streams));
stream->caps = gst_caps_new_simple("audio/a52",NULL);
gst_caps_set_simple (stream->caps,
"rate", G_TYPE_INT, (int)stream->rate,
"channels", G_TYPE_INT, stream->n_channels, NULL);
rmdemux->n_audio_streams++;
}else{
g_print("not adding stream of type %d\n",stream->subtype);
}
GST_PAD_ELEMENT_PRIVATE (stream->pad) = stream;
rmdemux->streams[rmdemux->n_streams] = stream;
rmdemux->n_streams++;
g_print("n_streams is now %d\n", rmdemux->n_streams);
if(stream->pad){
gst_pad_set_getcaps_function(stream->pad, gst_rmdemux_src_getcaps);
#ifdef unused
gst_pad_set_link_function(stream->pad, gst_rmdemux_src_link);
#endif
g_print("adding pad %p to rmdemux %p\n", stream->pad, rmdemux);
gst_element_add_pad(GST_ELEMENT (rmdemux), stream->pad);
/* Note: we need to have everything set up before calling try_set_caps */
if(stream->caps){
g_print("setting caps to %s\n",gst_caps_to_string(stream->caps));
GST_DEBUG_CAPS("setting caps",stream->caps);
gst_pad_try_set_caps(stream->pad, stream->caps);
}

View file

@ -23,6 +23,7 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/audio/audio.h>
#include "synaescope.h"
#define GST_TYPE_SYNAESTHESIA (gst_synaesthesia_get_type())
@ -39,7 +40,6 @@ struct _GstSynaesthesia {
/* pads */
GstPad *sinkpad,*srcpad;
GstBufferPool *peerpool;
/* the timestamp of the next frame */
guint64 next_time;
@ -81,41 +81,21 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (src_template,
static GstStaticPadTemplate gst_synaesthesia_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"synaesthesiasrc",
"video/x-raw-rgb",
"bpp", GST_PROPS_INT (32),
"depth", GST_PROPS_INT (32),
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"red_mask", GST_PROPS_INT (R_MASK_32),
"green_mask", GST_PROPS_INT (G_MASK_32),
"blue_mask", GST_PROPS_INT (B_MASK_32),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)
)
)
GST_STATIC_CAPS (GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32)
);
GST_PAD_TEMPLATE_FACTORY (sink_template,
"sink", /* the name of the pads */
GST_PAD_SINK, /* type of the pad */
GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */
GST_CAPS_NEW (
"synaesthesiasink", /* the name of the caps */
"audio/x-raw-int", /* the mime type of the caps */
/* Properties follow: */
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (TRUE),
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_INT (2)
)
)
static GstStaticPadTemplate gst_synaesthesia_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ( GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS )
);
static void gst_synaesthesia_base_init (gpointer g_class);
@ -133,7 +113,7 @@ static GstElementStateReturn
gst_synaesthesia_change_state (GstElement *element);
static GstPadLinkReturn
gst_synaesthesia_sinkconnect (GstPad *pad, GstCaps *caps);
gst_synaesthesia_sink_link (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL;
@ -166,9 +146,12 @@ gst_synaesthesia_base_init (gpointer g_class)
gst_element_class_set_details (element_class, &gst_synaesthesia_details);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_template));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get(&gst_synaesthesia_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get(&gst_synaesthesia_sink_template));
}
static void
gst_synaesthesia_class_init(GstSynaesthesiaClass *klass)
{
@ -201,14 +184,14 @@ gst_synaesthesia_init (GstSynaesthesia *synaesthesia)
{
/* create the sink and src pads */
synaesthesia->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_template ), "sink");
gst_static_pad_template_get(&gst_synaesthesia_sink_template), "sink");
synaesthesia->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_template ), "src");
gst_static_pad_template_get(&gst_synaesthesia_src_template), "src");
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->sinkpad);
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->srcpad);
gst_pad_set_chain_function (synaesthesia->sinkpad, gst_synaesthesia_chain);
gst_pad_set_link_function (synaesthesia->sinkpad, gst_synaesthesia_sinkconnect);
gst_pad_set_link_function (synaesthesia->sinkpad, gst_synaesthesia_sink_link);
GST_FLAG_SET (synaesthesia, GST_ELEMENT_EVENT_AWARE);
@ -220,15 +203,11 @@ gst_synaesthesia_init (GstSynaesthesia *synaesthesia)
}
static GstPadLinkReturn
gst_synaesthesia_sinkconnect (GstPad *pad, GstCaps *caps)
gst_synaesthesia_sink_link (GstPad *pad, const GstCaps *caps)
{
GstSynaesthesia *synaesthesia;
synaesthesia = GST_SYNAESTHESIA (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) {
return GST_PAD_LINK_DELAYED;
}
return GST_PAD_LINK_OK;
}
@ -281,31 +260,8 @@ gst_synaesthesia_chain (GstPad *pad, GstData *_data)
}
if (synaesthesia->first_buffer) {
GstCaps *caps;
synaesthesia_init (synaesthesia->width, synaesthesia->height);
GST_DEBUG ("making new pad");
caps = GST_CAPS_NEW (
"synaesthesiasrc",
"video/x-raw-rgb",
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
"bpp", GST_PROPS_INT (32),
"depth", GST_PROPS_INT (32),
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"red_mask", GST_PROPS_INT (R_MASK_32),
"green_mask", GST_PROPS_INT (G_MASK_32),
"blue_mask", GST_PROPS_INT (B_MASK_32),
"width", GST_PROPS_INT (synaesthesia->width),
"height", GST_PROPS_INT (synaesthesia->height),
"framerate", GST_PROPS_FLOAT (synaesthesia->fps)
);
if (gst_pad_try_set_caps (synaesthesia->srcpad, caps) <= 0) {
gst_element_error (GST_ELEMENT (synaesthesia), "could not set caps");
return;
}
synaesthesia->first_buffer = FALSE;
}
@ -383,7 +339,6 @@ gst_synaesthesia_change_state (GstElement *element)
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED:
synaesthesia->next_time = 0;
synaesthesia->peerpool = NULL;
synaesthesia->first_buffer = TRUE;
break;
}