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; gint total_ls;
GstCaps *metadata; GstCaps *metadata;
GstCaps *streaminfo; GstCaps *streaminfo;
GstCaps *caps; GstCaps *caps;
}; };
static void static void
print_caps (GstCaps *caps) print_caps (GstCaps *caps)
{ {
if (caps == NULL) return; char *s;
if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") || s = gst_caps_to_string (caps);
!strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo")) g_print(" %s\n", s);
{ g_free (s);
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");
}
} }
static void static void
print_format (GstCaps *caps) print_format (GstCaps *caps)
{ {
g_print (" format:\n"); char *s;
if (!caps || caps->properties == NULL) { s = gst_caps_to_string (caps);
g_print (" unkown\n"); g_print(" format: %s\n", s);
return; g_free (s);
}
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");
}
} }
static void static void

View file

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

View file

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

View file

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

View file

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

View file

@ -111,24 +111,22 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
GST_PAD_TEMPLATE_FACTORY (id3_tag_src_template_factory, static GstStaticPadTemplate id3_tag_src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
/* FIXME: for spider - GST_PAD_ALWAYS, */ /* FIXME: for spider - GST_PAD_ALWAYS, */
GST_PAD_SOMETIMES, 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", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS ("application/x-id3")
"id3_tag_data_sink", );
"application/x-id3",
NULL
)
)
static void gst_id3_tag_base_init (gpointer g_class); 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_set_details (element_class, &gst_id3_tag_details);
gst_element_class_add_pad_template (element_class, 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_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 static void
gst_id3_tag_class_init (GstID3TagClass *klass) 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->set_property = GST_DEBUG_FUNCPTR (gst_id3_tag_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_id3_tag_get_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_id3_tag_get_property);
} }
static GstCaps * 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)); GstID3Tag *tag = GST_ID3_TAG (gst_pad_get_parent (pad));
if (tag->found_caps) { if (tag->found_caps) {
GstCaps *caps = GST_CAPS_NEW ("gstid3tag", "application/x-gst-tags", NULL); GstCaps *caps;
caps = gst_caps_append (caps, GST_CAPS_NEW ("gstid3tag", "application/x-id3", NULL)); caps = gst_caps_from_string ("application/x-gst-tags; application/x-id3");
caps = gst_caps_append (caps, gst_caps_copy (tag->found_caps)); gst_caps_append (caps, gst_caps_copy (tag->found_caps));
return caps; return caps;
} else { } else {
return GST_CAPS_ANY; return gst_caps_new_any ();
} }
} }
static void static void
gst_id3_tag_add_src_pad (GstID3Tag *tag) gst_id3_tag_add_src_pad (GstID3Tag *tag)
{ {
tag->srcpad = gst_pad_new_from_template( tag->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (
GST_PAD_TEMPLATE_GET (id3_tag_src_template_factory), "src"); &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_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_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)); 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 */ /* create the sink and src pads */
tag->sinkpad = gst_pad_new_from_template( 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_element_add_pad (GST_ELEMENT (tag), tag->sinkpad);
gst_pad_set_chain_function (tag->sinkpad, GST_DEBUG_FUNCPTR (gst_id3_tag_chain)); 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; return NULL;
} }
static void 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; SimpleTypeFind *find = (SimpleTypeFind *) data;
if (probability > find->best_probability) { if (probability > find->best_probability) {
gst_caps_replace (&find->caps, caps); gst_caps_replace (&find->caps, gst_caps_copy (caps));
find->best_probability = probability; 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); gst_id3_tag_add_src_pad (tag);
do { 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) { if (gst_pad_try_set_caps (tag->srcpad, caps) != GST_PAD_LINK_REFUSED) {
tag->parse_mode = GST_ID3_TAG_PARSE_WRITE; tag->parse_mode = GST_ID3_TAG_PARSE_WRITE;
GST_LOG_OBJECT (tag, "normal operation, using application/x-id3 output"); GST_LOG_OBJECT (tag, "normal operation, using application/x-id3 output");
} else { } 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) { if (gst_pad_try_set_caps (tag->srcpad, caps) != GST_PAD_LINK_REFUSED) {
tag->parse_mode = GST_ID3_TAG_PARSE_TAG; tag->parse_mode = GST_ID3_TAG_PARSE_TAG;
GST_LOG_OBJECT (tag, "fast operation, just outputting tags"); 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; tag->parse_mode = GST_ID3_TAG_PARSE_PARSE;
GST_LOG_OBJECT (tag, "parsing operation, extracting tags"); GST_LOG_OBJECT (tag, "parsing operation, extracting tags");
} else { } else {
caps = GST_CAPS_NEW ("id3_tag_data_src", "application/x-id3", NULL); caps = gst_caps_from_string ("application/x-id3; "
caps = gst_caps_append (caps, "application/x-gst-tags");
GST_CAPS_NEW ("id3_tag_tag_src", "application/x-gst-tags", NULL)); gst_caps_append (caps, tag->found_caps);
caps = gst_caps_append (caps, tag->found_caps);
if (gst_pad_recover_caps_error (tag->srcpad, caps)) { if (gst_pad_recover_caps_error (tag->srcpad, caps)) {
tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN; tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN;
continue; continue;
@ -1022,7 +1021,7 @@ gst_id3_tag_change_state (GstElement *element)
tag->buffer = NULL; tag->buffer = NULL;
} }
if (tag->found_caps) { if (tag->found_caps) {
gst_caps_unref (tag->found_caps); gst_caps_free (tag->found_caps);
tag->found_caps = NULL; tag->found_caps = NULL;
} }
tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN; tag->parse_mode = GST_ID3_TAG_PARSE_UNKNOWN;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,12 +1,21 @@
librarydir = $(libdir)/gstreamer-@GST_MAJORMINOR@ librarydir = $(libdir)/gstreamer-@GST_MAJORMINOR@
library_LTLIBRARIES = libgstaudio.la library_LTLIBRARIES = libgstaudio.la libgstaudiofilter.la libgstaudiofilterexample.la
libgstaudio_la_SOURCES = audio.c audioclock.c libgstaudio_la_SOURCES = audio.c audioclock.c
libgstaudioincludedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/audio 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_LIBADD =
libgstaudio_la_CFLAGS = $(GST_CFLAGS) libgstaudio_la_CFLAGS = $(GST_CFLAGS)
libgstaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) 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 width = 0;
int channels = 0; int channels = 0;
GstCaps *caps;
GstCaps *caps = NULL; GstStructure *structure;
/* get caps of pad */ /* get caps of pad */
caps = GST_PAD_CAPS (pad); caps = GST_PAD_CAPS (pad);
if (caps == NULL) if (caps == NULL) {
{
/* ERROR: could not get caps of pad */ /* ERROR: could not get caps of pad */
g_warning ("gstaudio: could not get caps of pad %s:%s\n", g_warning ("gstaudio: could not get caps of pad %s:%s\n",
GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
return 0; return 0;
} }
gst_caps_get_int (caps, "width", &width); structure = gst_caps_get_structure (caps, 0);
gst_caps_get_int (caps, "channels", &channels);
gst_structure_get_int (structure, "width", &width);
gst_structure_get_int (structure, "channels", &channels);
return (width / 8) * channels; return (width / 8) * channels;
} }
@ -83,6 +84,7 @@ gst_audio_frame_rate (GstPad *pad)
{ {
GstCaps *caps = NULL; GstCaps *caps = NULL;
gint rate; gint rate;
GstStructure *structure;
/* get caps of pad */ /* get caps of pad */
caps = GST_PAD_CAPS (pad); caps = GST_PAD_CAPS (pad);
@ -94,7 +96,8 @@ gst_audio_frame_rate (GstPad *pad)
return 0; return 0;
} }
else { else {
gst_caps_get_int (caps, "rate", &rate); structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "rate", &rate);
return rate; return rate;
} }
} }
@ -115,6 +118,7 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
double length; double length;
GstCaps *caps = NULL; GstCaps *caps = NULL;
GstStructure *structure;
g_assert (GST_IS_BUFFER (buf)); g_assert (GST_IS_BUFFER (buf));
/* get caps of pad */ /* get caps of pad */
@ -128,10 +132,11 @@ gst_audio_length (GstPad* pad, GstBuffer* buf)
} }
else else
{ {
structure = gst_caps_get_structure (caps, 0);
bytes = GST_BUFFER_SIZE (buf); bytes = GST_BUFFER_SIZE (buf);
gst_caps_get_int (caps, "width", &width); gst_structure_get_int (structure, "width", &width);
gst_caps_get_int (caps, "channels", &channels); gst_structure_get_int (structure, "channels", &channels);
gst_caps_get_int (caps, "rate", &rate); gst_structure_get_int (structure, "rate", &rate);
g_assert (bytes != 0); g_assert (bytes != 0);
g_assert (width != 0); g_assert (width != 0);
@ -152,6 +157,7 @@ gst_audio_highest_sample_value (GstPad* pad)
gboolean is_signed = FALSE; gboolean is_signed = FALSE;
gint width = 0; gint width = 0;
GstCaps *caps = NULL; GstCaps *caps = NULL;
GstStructure *structure;
caps = GST_PAD_CAPS (pad); caps = GST_PAD_CAPS (pad);
if (caps == NULL) 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_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad));
} }
gst_caps_get_int (caps, "width", &width); structure = gst_caps_get_structure (caps, 0);
gst_caps_get_boolean (caps, "signed", &is_signed); gst_structure_get_int (structure, "width", &width);
gst_structure_get_boolean (structure, "signed", &is_signed);
if (is_signed) --width; if (is_signed) --width;
/* example : 16 bit, signed : samples between -32768 and 32767 */ /* 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_DEF_RATE 44100
#define GST_AUDIO_INT_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \
gst_props_new (\ "audio/x-raw-int, " \
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ "rate = (int) [ 1, MAX ], " \
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\ "channels = (int) [ 1, MAX ], " \
"endianness", GST_PROPS_LIST (\ "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
GST_PROPS_INT (G_LITTLE_ENDIAN),\ "width = (int) { 8, 16, 32 }, " \
GST_PROPS_INT (G_BIG_ENDIAN)\ "depth = (int) [ 1, 32 ], " \
),\ "signed = (boolean) { true, false }, " \
"width", GST_PROPS_LIST (\ "buffer-frames = (int) [ 1, MAX ]"
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)
/* "standard" int audio is native order, 16 bit stereo. */ /* "standard" int audio is native order, 16 bit stereo. */
#define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_CAPS \
gst_props_new (\ "audio/x-raw-int, " \
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ "rate = (int) [ 1, MAX ], " \
"channels", GST_PROPS_INT (2),\ "channels = (int) 2, " \
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\ "endianness = (int) BYTE_ORDER, " \
"width", GST_PROPS_INT (16),\ "width = (int) 16, " \
"depth", GST_PROPS_INT (16),\ "depth = (int) 16, " \
"signed", GST_PROPS_LIST (\ "signed = (boolean) true, " \
GST_PROPS_BOOLEAN (TRUE),\ "buffer-frames = (int) [ 1, MAX]"
GST_PROPS_BOOLEAN (FALSE)\
),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
#define GST_AUDIO_FLOAT_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS \
gst_props_new (\ "audio/x-raw-float, " \
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ "rate = (int) [ 1, MAX ], " \
"channels", GST_PROPS_INT_RANGE (1, G_MAXINT),\ "channels = (int) [ 1, MAX ], " \
"endianness", GST_PROPS_LIST (\ "endianness = (int) { LITTLE_ENDIAN , BIG_ENDIAN }, " \
GST_PROPS_INT (G_LITTLE_ENDIAN),\ "width = (int) { 32, 64 }, " \
GST_PROPS_INT (G_BIG_ENDIAN)\ "buffer-frames = (int) [ 1, MAX]"
),\
"width", GST_PROPS_LIST (\
GST_PROPS_INT (32),\
GST_PROPS_INT (64)\
),\
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
/* "standard" float audio is native order, 32 bit mono. */ /* "standard" float audio is native order, 32 bit mono. */
#define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_PROPS \ #define GST_AUDIO_FLOAT_STANDARD_PAD_TEMPLATE_CAPS \
gst_props_new (\ "audio/x-raw-float, " \
"rate", GST_PROPS_INT_RANGE (1, G_MAXINT),\ "rate = (int) [ 1, MAX ], " \
"channels", GST_PROPS_INT (1),\ "channels = (int) 1, " \
"endianness", GST_PROPS_INT (G_BYTE_ORDER),\ "endianness = (int) BYTE_ORDER, " \
"width", GST_PROPS_INT (32),\ "buffer-frames = (int) [ 1, MAX]"
"buffer-frames", GST_PROPS_INT_RANGE (1, G_MAXINT),\
NULL)
/* /*
* this library defines and implements some helper functions for audio * 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) if (priv->format)
{ {
GMI_DEBUG ("unreffing priv->format, error before this ?\n"); GMI_DEBUG ("unreffing priv->format, error before this ?\n");
gst_caps_unref (priv->format); gst_caps_free (priv->format);
priv->format = NULL; priv->format = NULL;
} }
if (priv->metadata) if (priv->metadata)
{ {
GMI_DEBUG ("unreffing priv->metadata, error before this ?\n"); GMI_DEBUG ("unreffing priv->metadata, error before this ?\n");
gst_caps_unref (priv->metadata); gst_caps_free (priv->metadata);
priv->metadata = NULL; priv->metadata = NULL;
} }
if (priv->stream) if (priv->stream)
@ -193,12 +193,12 @@ gmi_seek_to_track (GstMediaInfo *info, long track)
/* clear structs because of the seek */ /* clear structs because of the seek */
if (priv->metadata) if (priv->metadata)
{ {
gst_caps_unref (priv->metadata); gst_caps_free (priv->metadata);
priv->metadata = NULL; priv->metadata = NULL;
} }
if (priv->streaminfo) if (priv->streaminfo)
{ {
gst_caps_unref (priv->streaminfo); gst_caps_free (priv->streaminfo);
priv->streaminfo = NULL; priv->streaminfo = NULL;
} }
return TRUE; return TRUE;
@ -304,7 +304,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv)
if (priv->type) if (priv->type)
{ {
/* we don't need to unref, this is done inside gsttypefind.c /* 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; priv->type = NULL;
} }
@ -573,14 +573,13 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv)
&format, &value_end); &format, &value_end);
if (res) if (res)
{ {
GstPropsEntry *length;
/* substract to get the length */ /* substract to get the length */
GMI_DEBUG("DEBUG: start %lld, end %lld\n", value_start, value_end); GMI_DEBUG("DEBUG: start %lld, end %lld\n", value_start, value_end);
value_end -= value_start; value_end -= value_start;
/* FIXME: check units; this is in seconds */ /* FIXME: check units; this is in seconds */
length = gst_props_entry_new ("length",
GST_PROPS_INT ((int) (value_end / 1E6))); gst_caps_set_simple (priv->streaminfo,
gst_props_add_entry (gst_caps_get_props (priv->streaminfo), length); "length", G_TYPE_INT, (int) (value_end / 1E6), NULL);
} }
} }
} }

View file

@ -4,56 +4,6 @@
#include <string.h> #include <string.h>
#include "media-info.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 static void
info_print (GstMediaInfoStream *stream) info_print (GstMediaInfoStream *stream)
{ {
@ -77,11 +27,11 @@ info_print (GstMediaInfoStream *stream)
g_print ("- track %d\n", i); g_print ("- track %d\n", i);
track = (GstMediaInfoTrack *) p->data; track = (GstMediaInfoTrack *) p->data;
g_print (" - metadata:\n"); g_print (" - metadata:\n");
caps_print (track->metadata); g_print ("%s\n", gst_caps_to_string (track->metadata));
g_print (" - streaminfo:\n"); g_print (" - streaminfo:\n");
caps_print (track->streaminfo); g_print ("%s\n", gst_caps_to_string (track->streaminfo));
g_print (" - format:\n"); g_print (" - format:\n");
caps_print (track->format); g_print ("%s\n", gst_caps_to_string (track->format));
p = p->next; 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"); GMI_DEBUG("doing find_type_post\n");
gmip_find_type_post (priv); gmip_find_type_post (priv);
GMI_DEBUG("finding out mime type\n"); 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); GMI_DEBUG("found out mime type: %s\n", mime);
decoder = gmi_get_decoder (info, mime); decoder = gmi_get_decoder (info, mime);
if (decoder == NULL) 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; 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); GMI_DEBUG("mime type: %s\n", mime);
/* c) figure out decoder */ /* c) figure out decoder */

View file

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

View file

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

View file

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

View file

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

View file

@ -23,203 +23,175 @@
#include <gst/gst.h> #include <gst/gst.h>
#define R_MASK_32 0xff000000 #define R_MASK_32 "0xff000000"
#define G_MASK_32 0x00ff0000 #define G_MASK_32 "0x00ff0000"
#define B_MASK_32 0x0000ff00 #define B_MASK_32 "0x0000ff00"
#define R_MASK_32_REVERSE 0x000000ff #define R_MASK_32_REVERSE "0x000000ff"
#define G_MASK_32_REVERSE 0x0000ff00 #define G_MASK_32_REVERSE "0x0000ff00"
#define B_MASK_32_REVERSE 0x00ff0000 #define B_MASK_32_REVERSE "0x00ff0000"
#define R_MASK_24 0xff0000 #define R_MASK_24 "0xff0000"
#define G_MASK_24 0x00ff00 #define G_MASK_24 "0x00ff00"
#define B_MASK_24 0x0000ff #define B_MASK_24 "0x0000ff"
#define R_MASK_24_REVERSE 0x0000ff #define R_MASK_24_REVERSE "0x0000ff"
#define G_MASK_24_REVERSE 0x00ff00 #define G_MASK_24_REVERSE "0x00ff00"
#define B_MASK_24_REVERSE 0xff0000 #define B_MASK_24_REVERSE "0xff0000"
#define R_MASK_16 0xf800 #define R_MASK_16 "0xf800"
#define G_MASK_16 0x07e0 #define G_MASK_16 "0x07e0"
#define B_MASK_16 0x001f #define B_MASK_16 "0x001f"
#define R_MASK_15 0x8c00 #define R_MASK_15 "0x7c00"
#define G_MASK_15 0x03e0 #define G_MASK_15 "0x03e0"
#define B_MASK_15 0x001f #define B_MASK_15 "0x001f"
#define SIZE_RANGE GST_PROPS_INT_RANGE (16, 4096) #define R_MASK_32_INT 0xff000000
#define FPS_RANGE GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) #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 */ /* properties for pad templates */
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_LIST ( \ "bpp = (int) { 24, 32 }, " \
GST_PROPS_INT (24), \ "depth = (int) { 24, 32 }, " \
GST_PROPS_INT (32) \ "endianness = (int) BIG_ENDIAN, " \
), \ "red_mask = (int) { " R_MASK_32 ", " R_MASK_24 " }, " \
"depth", GST_PROPS_LIST ( \ "green_mask = (int) { " G_MASK_32 ", " G_MASK_24 " }, " \
GST_PROPS_INT (24), \ "blue_mask = (int) { " B_MASK_32 ", " B_MASK_24 " }, " \
GST_PROPS_INT (32) \ "width = " SIZE_RANGE ", " \
), \ "height = " SIZE_RANGE ", " \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ "framerate = " FPS_RANGE
"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_PROPS_24_32_REVERSE \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32_REVERSE \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_LIST ( \ "bpp = (int) { 24, 32 }, " \
GST_PROPS_INT (24), \ "depth = (int) { 24, 32 }, " \
GST_PROPS_INT (32) \ "endianness = (int) BIG_ENDIAN, " \
), \ "red_mask = (int) { " R_MASK_32_REVERSE ", " R_MASK_24_REVERSE "}, " \
"depth", GST_PROPS_LIST ( \ "green_mask = (int) { " G_MASK_32_REVERSE ", " G_MASK_24_REVERSE "}, " \
GST_PROPS_INT (24), \ "blue_mask = (int) { " B_MASK_32_REVERSE ", " B_MASK_24_REVERSE "}, " \
GST_PROPS_INT (32) \ "width = " SIZE_RANGE ", " \
), \ "height = " SIZE_RANGE ", " \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ "framerate = " FPS_RANGE
"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_PROPS_32 \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32 \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (32), \ "bpp = (int) 32, " \
"depth", GST_PROPS_INT (32), \ "depth = (int) 32, " \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ "endianness = (int) BIG_ENDIAN, " \
"red_mask", GST_PROPS_INT (R_MASK_32), \ "red_mask = (int) " R_MASK_32 ", " \
"green_mask", GST_PROPS_INT (G_MASK_32), \ "green_mask = (int) " G_MASK_32 ", " \
"blue_mask", GST_PROPS_INT (B_MASK_32), \ "blue_mask = (int) " B_MASK_32 ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24 \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24 \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (24), \ "bpp = (int) 24, " \
"depth", GST_PROPS_INT (24), \ "depth = (int) 24, " \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ "endianness = (int) BIG_ENDIAN, " \
"red_mask", GST_PROPS_INT (R_MASK_24), \ "red_mask = (int) " R_MASK_24 ", " \
"green_mask", GST_PROPS_INT (G_MASK_24), \ "green_mask = (int) " G_MASK_24 ", " \
"blue_mask", GST_PROPS_INT (B_MASK_24), \ "blue_mask = (int) " B_MASK_24 ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_32_REVERSE \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32_REVERSE \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (32), \ "bpp = (int) 32, " \
"depth", GST_PROPS_INT (32), \ "depth = (int) 32, " \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ "endianness = (int) BIG_ENDIAN, " \
"red_mask", GST_PROPS_INT (R_MASK_32_REVERSE), \ "red_mask = (int) " R_MASK_32_REVERSE ", " \
"green_mask", GST_PROPS_INT (G_MASK_32_REVERSE), \ "green_mask = (int) " G_MASK_32_REVERSE ", " \
"blue_mask", GST_PROPS_INT (B_MASK_32_REVERSE), \ "blue_mask = (int) " B_MASK_32_REVERSE ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_REVERSE \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_REVERSE \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (24), \ "bpp = (int) 24, " \
"depth", GST_PROPS_INT (24), \ "depth = (int) 24, " \
"endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ "endianness = (int) BIG_ENDIAN, " \
"red_mask", GST_PROPS_INT (R_MASK_24_REVERSE), \ "red_mask = (int) " R_MASK_24_REVERSE ", " \
"green_mask", GST_PROPS_INT (G_MASK_24_REVERSE), \ "green_mask = (int) " G_MASK_24_REVERSE ", " \
"blue_mask", GST_PROPS_INT (B_MASK_24_REVERSE), \ "blue_mask = (int) " B_MASK_24_REVERSE ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16 \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (16), \ "bpp = (int) 16, " \
"depth", GST_PROPS_LIST ( \ "depth = (int) { 15, 16 }, " \
GST_PROPS_INT (15), \ "endianness = (int) BYTE_ORDER, " \
GST_PROPS_INT (16) \ "red_mask = (int) { " R_MASK_15 ", " R_MASK_16 " }, " \
), \ "green_mask = (int) { " G_MASK_15 ", " G_MASK_16 " }, " \
"endianness", GST_PROPS_INT (G_BYTE_ORDER), \ "blue_mask = (int) { " B_MASK_15 ", " B_MASK_16 " }, " \
"red_mask", GST_PROPS_LIST ( \ "width = " SIZE_RANGE ", " \
GST_PROPS_INT (R_MASK_15), \ "height = " SIZE_RANGE ", " \
GST_PROPS_INT (R_MASK_16) \ "framerate = " FPS_RANGE
), \
"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_PROPS_16 \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_16 \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (16), \ "bpp = (int) 16, " \
"depth", GST_PROPS_INT (16), \ "depth = (int) 16, " \
"endianness", GST_PROPS_INT (G_BYTE_ORDER), \ "endianness = (int) BYTE_ORDER, " \
"red_mask", GST_PROPS_INT (R_MASK_16), \ "red_mask = (int) " R_MASK_16 ", " \
"green_mask", GST_PROPS_INT (G_MASK_16), \ "green_mask = (int) " G_MASK_16 ", " \
"blue_mask", GST_PROPS_INT (B_MASK_16), \ "blue_mask = (int) " B_MASK_16 ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15 \ #define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15 \
gst_props_new ( \ "video/x-raw-rgb, " \
"bpp", GST_PROPS_INT (15), \ "bpp = (int) 16, " \
"depth", GST_PROPS_INT (15), \ "depth = (int) 15, " \
"endianness", GST_PROPS_INT (G_BYTE_ORDER), \ "endianness = (int) BYTE_ORDER, " \
"red_mask", GST_PROPS_INT (R_MASK_15), \ "red_mask = (int) " R_MASK_15 ", " \
"green_mask", GST_PROPS_INT (G_MASK_15), \ "green_mask = (int) " G_MASK_15 ", " \
"blue_mask", GST_PROPS_INT (B_MASK_15), \ "blue_mask = (int) " B_MASK_15 ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
#define GST_VIDEO_YUV_PAD_TEMPLATE_PROPS(fourcc) \ #define GST_VIDEO_YUV_PAD_TEMPLATE_CAPS(fourcc) \
gst_props_new (\ "video/x-raw-yuv, " \
"format", fourcc, \ "format = (fourcc) " fourcc ", " \
"width", SIZE_RANGE, \ "width = " SIZE_RANGE ", " \
"height", SIZE_RANGE, \ "height = " SIZE_RANGE ", " \
"framerate", FPS_RANGE, \ "framerate = " FPS_RANGE
NULL)
/* functions */ /* functions */
gfloat gst_video_frame_rate (GstPad *pad); gdouble gst_video_frame_rate (GstPad *pad);
gboolean gst_video_get_size (GstPad *pad, gboolean gst_video_get_size (GstPad *pad,
gint *width, gint *width,
gint *height); gint *height);

View file

@ -92,25 +92,24 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
GST_PAD_TEMPLATE_FACTORY (src_factory, static GstStaticPadTemplate gst_ac3parse_src_template =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ("ac3parse_src", GST_STATIC_CAPS (
"audio/ac3", "audio/ac3, "
"channels", GST_PROPS_INT_RANGE (1, 6), "channels = (int) [ 1, 6 ], "
"rate", GST_PROPS_INT_RANGE (32000, 48000) "rate = (int) [ 32000, 48000 ]"
) )
); );
GST_PAD_TEMPLATE_FACTORY (sink_factory, static GstStaticPadTemplate gst_ac3parse_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ("ac3parse_sink", GST_STATIC_CAPS ("audio/x-ac3")
"audio/x-ac3",
NULL
)
); );
static void gst_ac3parse_class_init (gpointer g_class); static void gst_ac3parse_class_init (gpointer g_class);
@ -167,9 +166,9 @@ gst_ac3parse_class_init (gpointer g_class)
gstelement_class = (GstElementClass*)klass; gstelement_class = (GstElementClass*)klass;
gst_element_class_add_pad_template (gstelement_class, 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_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, gst_element_class_set_details (gstelement_class,
&ac3parse_details); &ac3parse_details);
@ -189,12 +188,12 @@ static void
gst_ac3parse_init (GstAc3Parse *ac3parse) gst_ac3parse_init (GstAc3Parse *ac3parse)
{ {
ac3parse->sinkpad = gst_pad_new_from_template ( 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_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->sinkpad);
gst_pad_set_chain_function (ac3parse->sinkpad, gst_ac3parse_chain); gst_pad_set_chain_function (ac3parse->sinkpad, gst_ac3parse_chain);
ac3parse->srcpad = gst_pad_new_from_template ( 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); gst_element_add_pad (GST_ELEMENT (ac3parse), ac3parse->srcpad);
ac3parse->partialbuf = NULL; ac3parse->partialbuf = NULL;
@ -339,10 +338,9 @@ gst_ac3parse_chain (GstPad *pad, GstData *_data)
} }
if (need_capsnego) { if (need_capsnego) {
GstCaps *newcaps; GstCaps *newcaps;
newcaps = GST_CAPS_NEW ("ac3parse_src", newcaps = gst_caps_new_simple ("audio/x-ac3",
"audio/x-ac3", "channels", G_TYPE_INT, channels,
"channels", GST_PROPS_INT (channels), "rate", G_TYPE_INT, sample_rate, NULL);
"rate", GST_PROPS_INT (sample_rate));
if (gst_pad_try_set_caps (ac3parse->srcpad, newcaps) <= 0) { if (gst_pad_try_set_caps (ac3parse->srcpad, newcaps) <= 0) {
gst_element_error (GST_ELEMENT (ac3parse), gst_element_error (GST_ELEMENT (ac3parse),
"Ac3parse: failed to negotiate format with next element"); "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>", "Owen Fraser-Green <owen@discobabe.net>",
}; };
GST_PAD_TEMPLATE_FACTORY (sink_factory, static GstStaticPadTemplate gst_asf_demux_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ("asf_asf_demux_sink", GST_STATIC_CAPS("video/x-ms-asf")
"video/x-ms-asf",
NULL)
); );
static void gst_asf_demux_base_init (gpointer g_class); 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); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
int i; int i;
GstCaps *audcaps = NULL, *vidcaps = NULL, *temp; GstCaps *audcaps, *vidcaps, *temp;
guint32 vid_list[] = { guint32 vid_list[] = {
GST_MAKE_FOURCC('I','4','2','0'), GST_MAKE_FOURCC('I','4','2','0'),
GST_MAKE_FOURCC('Y','U','Y','2'), GST_MAKE_FOURCC('Y','U','Y','2'),
@ -145,28 +144,31 @@ gst_asf_demux_base_init (gpointer g_class)
-1 /* end */ -1 /* end */
}; };
audcaps = gst_caps_new_empty();
for (i = 0; aud_list[i] != -1; i++) { for (i = 0; aud_list[i] != -1; i++) {
temp = gst_asf_demux_audio_caps (aud_list[i], NULL, NULL); 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", audiosrctempl = gst_pad_template_new ("audio_%02d",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_SOMETIMES, GST_PAD_SOMETIMES,
audcaps, NULL); audcaps);
vidcaps = gst_caps_new_empty();
for (i = 0; vid_list[i] != 0; i++) { for (i = 0; vid_list[i] != 0; i++) {
temp = gst_asf_demux_video_caps (vid_list[i], NULL); 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", videosrctempl = gst_pad_template_new ("video_%02d",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_SOMETIMES, GST_PAD_SOMETIMES,
vidcaps, NULL); vidcaps);
gst_element_class_add_pad_template (element_class, audiosrctempl); 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, videosrctempl);
gst_element_class_add_pad_template (element_class, 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); gst_element_class_set_details (element_class, &gst_asf_demux_details);
} }
@ -193,7 +195,7 @@ gst_asf_demux_init (GstASFDemux *asf_demux)
guint i; guint i;
asf_demux->sinkpad = gst_pad_new_from_template( 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_add_pad (GST_ELEMENT (asf_demux), asf_demux->sinkpad);
gst_element_set_loop_function (GST_ELEMENT (asf_demux), gst_asf_demux_loop); 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, gst_asf_demux_audio_caps (guint16 codec_id,
asf_stream_audio *audio, guint8 *extradata) asf_stream_audio *audio, guint8 *extradata)
{ {
GstCaps *caps = NULL; GstCaps *caps;
gint flags1, flags2; gint flags1, flags2;
flags1 = 0; flags1 = 0;
@ -1256,54 +1258,33 @@ gst_asf_demux_audio_caps (guint16 codec_id,
switch (codec_id) { switch (codec_id) {
case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */ case GST_RIFF_WAVE_FORMAT_MPEGL3: /* mp3 */
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_mp3", caps = gst_caps_from_string ("audio/mpeg, mpegversion = (int) 1, "
"audio/mpeg", "layer = (int) 3");
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (3));
break; break;
case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */ case GST_RIFF_WAVE_FORMAT_MPEGL12: /* mp1 or mp2 */
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_mp12", caps = gst_caps_from_string ("audio/mpeg, mpegversion = (int) 1, "
"audio/mpeg", "layer = (int) 2");
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT (2));
break; break;
case GST_RIFF_WAVE_FORMAT_PCM: /* PCM/wav */ { 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) { if (audio != NULL) {
gint ba = GUINT16_FROM_LE (audio->block_align); gint ba = GUINT16_FROM_LE (audio->block_align);
gint ch = GUINT16_FROM_LE (audio->channels); gint ch = GUINT16_FROM_LE (audio->channels);
gint ws = GUINT16_FROM_LE (audio->word_size); 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", gst_caps_set_simple (caps,
"audio/x-raw-int", "width", G_TYPE_INT, (int)(ba * 8 / ch),
"endianness", "depth", G_TYPE_INT, ws,
GST_PROPS_INT (G_LITTLE_ENDIAN)); "signed", G_TYPE_BOOLEAN, (ws != 8),
gst_props_add_entry (caps->properties, width); NULL);
gst_props_add_entry (caps->properties, depth); }
gst_props_add_entry (caps->properties, signedness);
} }
break; 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_VORBIS1PLUS: /* vorbis mode 1+ */
case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* vorbis mode 2+ */ case GST_RIFF_WAVE_FORMAT_VORBIS2PLUS: /* vorbis mode 2+ */
case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* vorbis mode 3+ */ case GST_RIFF_WAVE_FORMAT_VORBIS3PLUS: /* vorbis mode 3+ */
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_vorbis", caps = gst_caps_from_string("audio/x-vorbis");
"audio/x-vorbis",
NULL);
break; break;
case GST_RIFF_WAVE_FORMAT_A52: case GST_RIFF_WAVE_FORMAT_A52:
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_ac3", caps = gst_caps_from_string("audio/x-ac3");
"audio/x-ac3",
NULL);
break; break;
case GST_RIFF_WAVE_FORMAT_DIVX_WMAV1: 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); flags1 = extradata[0] | (extradata[1] << 8);
flags2 = extradata[2] | (extradata[3] << 8); flags2 = extradata[2] | (extradata[3] << 8);
} }
if (audio != NULL) caps = gst_caps_from_string("audio/x-wma, "
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav1", "wmaversion = (int) 1, "
"audio/x-wma", "flags1 = (int) [ MIN, MAX ], "
"wmaversion", GST_PROPS_INT (1), "flags2 = (int) [ MIN, MAX ], "
"flags1", GST_PROPS_INT (flags1), "block_align = (int) [ 0, MAX ], "
"flags2", GST_PROPS_INT (flags2), "bitrate = (int) [ 0, MAX ]");
"block_align", GST_PROPS_INT (audio->block_align), if (audio != NULL) {
"bitrate", GST_PROPS_INT (audio->byte_rate * 8)); gst_caps_set_simple (caps,
else "flags1", G_TYPE_INT, flags1,
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav1", "flags2", G_TYPE_INT, flags1,
"audio/x-wma", "block_align", G_TYPE_INT, audio->block_align,
"wmaversion", GST_PROPS_INT (1), "bitrate", G_TYPE_INT, audio->byte_rate * 8,
"flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT), NULL);
"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)
);
break; break;
case GST_RIFF_WAVE_FORMAT_DIVX_WMAV2: 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); (extradata[2] << 16) | (extradata[3] << 24);
flags2 = extradata[4] | (extradata[5] << 8); flags2 = extradata[4] | (extradata[5] << 8);
} }
if (audio != NULL) caps = gst_caps_from_string("audio/x-wma, "
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav2", "wmaversion = (int) 2, "
"audio/x-wma", "flags1 = (int) [ MIN, MAX ], "
"wmaversion", GST_PROPS_INT (2), "flags2 = (int) [ MIN, MAX ], "
"flags1", GST_PROPS_INT (flags1), "block_align = (int) [ 0, MAX ], "
"flags2", GST_PROPS_INT (flags2), "bitrate = (int) [ 0, MAX ]");
"block_align", GST_PROPS_INT (audio->block_align), if (audio != NULL) {
"bitrate", GST_PROPS_INT (audio->byte_rate * 8)); gst_caps_set_simple (caps,
else "flags1", G_TYPE_INT, flags1,
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav2", "flags2", G_TYPE_INT, flags1,
"audio/x-wma", "block_align", G_TYPE_INT, audio->block_align,
"wmaversion", GST_PROPS_INT (2), "bitrate", G_TYPE_INT, audio->byte_rate * 8,
"flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT), NULL);
"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)
);
break; break;
case GST_RIFF_WAVE_FORMAT_WMAV9: case GST_RIFF_WAVE_FORMAT_WMAV9:
caps = GST_ASF_AUD_CAPS_NEW ("asf_demux_audio_src_wmav9", caps = gst_caps_from_string("audio/x-wma, "
"audio/x-wma", "wmaversion = (int) 9");
"wmaversion", GST_PROPS_INT (9));
break; break;
default: default:
g_warning ("asfdemux: unkown audio format 0x%04x", g_warning ("asfdemux: unkown audio format 0x%04x",
codec_id); codec_id);
return GST_CAPS_ANY;
break; 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; return caps;
} }
@ -1396,7 +1379,7 @@ gst_asf_demux_add_audio_stream (GstASFDemux *asf_demux,
guint16 id) guint16 id)
{ {
GstPad *src_pad; GstPad *src_pad;
GstCaps *caps; GstCaps *caps;
gchar *name = NULL; gchar *name = NULL;
guint16 size_left = 0; guint16 size_left = 0;
guint8 *extradata=NULL; guint8 *extradata=NULL;
@ -1482,79 +1465,82 @@ gst_asf_demux_video_caps (guint32 codec_fcc,
switch (codec_fcc) { switch (codec_fcc) {
case GST_MAKE_FOURCC('I','4','2','0'): case GST_MAKE_FOURCC('I','4','2','0'):
case GST_MAKE_FOURCC('Y','U','Y','2'): case GST_MAKE_FOURCC('Y','U','Y','2'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_raw", caps = gst_caps_new_simple ("video/x-raw-yuv",
"video/x-raw-yuv", "format", GST_TYPE_FOURCC, codec_fcc, NULL);
"format", GST_PROPS_FOURCC (codec_fcc));
break; break;
case GST_MAKE_FOURCC('M','J','P','G'): case GST_MAKE_FOURCC('M','J','P','G'):
case GST_MAKE_FOURCC('J','P','E','G'): case GST_MAKE_FOURCC('J','P','E','G'):
case GST_MAKE_FOURCC('P','I','X','L'): case GST_MAKE_FOURCC('P','I','X','L'):
case GST_MAKE_FOURCC('V','I','X','L'): case GST_MAKE_FOURCC('V','I','X','L'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_jpeg", caps = gst_caps_new_simple ("video/x-jpeg", NULL);
"video/x-jpeg",
NULL);
break; break;
case GST_MAKE_FOURCC('D','V','S','D'): case GST_MAKE_FOURCC('D','V','S','D'):
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", caps = gst_caps_new_simple ("video/x-dv",
"video/x-dv", "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
"systemstream", GST_PROPS_BOOLEAN (FALSE));
break; break;
case GST_MAKE_FOURCC('W','M','V','1'): case GST_MAKE_FOURCC('W','M','V','1'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_wmv1", caps = gst_caps_new_simple ("video/x-wmv",
"video/x-wmv", "wmvversion", G_TYPE_INT, 1, NULL);
"wmvversion", GST_PROPS_INT (1));
break; break;
case GST_MAKE_FOURCC('W','M','V','2'): case GST_MAKE_FOURCC('W','M','V','2'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_wmv2", caps = gst_caps_new_simple ("video/x-wmv",
"video/x-wmv", "wmvversion", G_TYPE_INT, 2, NULL);
"wmvversion", GST_PROPS_INT (2));
break; break;
case GST_MAKE_FOURCC('M','P','G','4'): case GST_MAKE_FOURCC('M','P','G','4'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_msmpeg41", caps = gst_caps_new_simple ("video/x-msmpeg",
"video/x-msmpeg", "msmpegversion", G_TYPE_INT, 41, NULL);
"msmpegversion", GST_PROPS_INT (41));
break; break;
case GST_MAKE_FOURCC('M','P','4','2'): case GST_MAKE_FOURCC('M','P','4','2'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_msmpeg42", caps = gst_caps_new_simple ("video/x-msmpeg",
"video/x-msmpeg", "msmpegversion", G_TYPE_INT, 42, NULL);
"msmpegversion", GST_PROPS_INT (42));
break; break;
case GST_MAKE_FOURCC('M','P','4','3'): case GST_MAKE_FOURCC('M','P','4','3'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_msmpeg43", caps = gst_caps_new_simple ("video/x-msmpeg",
"video/x-msmpeg", "msmpegversion", G_TYPE_INT, 43, NULL);
"msmpegversion", GST_PROPS_INT (43));
break; break;
case GST_MAKE_FOURCC('D','I','V','3'): case GST_MAKE_FOURCC('D','I','V','3'):
case GST_MAKE_FOURCC('D','I','V','4'): case GST_MAKE_FOURCC('D','I','V','4'):
case GST_MAKE_FOURCC('D','I','V','5'): case GST_MAKE_FOURCC('D','I','V','5'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_div3", caps = gst_caps_new_simple ("video/x-divx",
"video/x-divx", "divxversion", G_TYPE_INT, 3, NULL);
"divxversion", GST_PROPS_INT (3));
break; break;
case GST_MAKE_FOURCC('D','I','V','X'): case GST_MAKE_FOURCC('D','I','V','X'):
case GST_MAKE_FOURCC('d','i','v','x'): case GST_MAKE_FOURCC('d','i','v','x'):
case GST_MAKE_FOURCC('D','X','5','0'): case GST_MAKE_FOURCC('D','X','5','0'):
caps = GST_ASF_VID_CAPS_NEW ("asf_demux_video_src_div5", caps = gst_caps_new_simple ("video/x-divx",
"video/x-divx", "divxversion", G_TYPE_INT, 5, NULL);
"divxversion", GST_PROPS_INT (5));
break; break;
default: default:
g_warning ("asfdemux: unkown video format " GST_FOURCC_FORMAT "(0x%08x)", g_warning ("asfdemux: unkown video format " GST_FOURCC_FORMAT "(0x%08x)",
GST_FOURCC_ARGS(codec_fcc), codec_fcc); GST_FOURCC_ARGS(codec_fcc), codec_fcc);
return NULL;
break; 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; return caps;
} }

View file

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

View file

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

View file

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

View file

@ -56,27 +56,25 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
GST_PAD_TEMPLATE_FACTORY (sink_factory, static GstStaticPadTemplate sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink", "sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS ("video/mpeg, "
"mpeg_parse_sink", "mpegversion = (int) [ 1, 2 ], "
"video/mpeg", "systemstream = (boolean) TRUE"
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (TRUE)
) )
); );
GST_PAD_TEMPLATE_FACTORY (src_factory, static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS ("video/mpeg, "
"mpeg_parse_src", "mpegversion = (int) [ 1, 2 ], "
"video/mpeg", "systemstream = (boolean) TRUE"
"mpegversion", GST_PROPS_INT_RANGE (1, 2),
"systemstream", GST_PROPS_BOOLEAN (TRUE)
) )
); );
@ -136,9 +134,9 @@ gst_mpeg_parse_base_init (GstMPEGParseClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, 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_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); 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_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DISCONT,
g_param_spec_int ("max_discont", "Max Discont", "The maximun allowed SCR discontinuity", g_param_spec_int ("max_discont", "Max Discont", "The maximun allowed SCR discontinuity",
0, G_MAXINT, DEFAULT_MAX_DISCONT, G_PARAM_READWRITE)); 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->get_property = gst_mpeg_parse_get_property;
gobject_class->set_property = gst_mpeg_parse_set_property; gobject_class->set_property = gst_mpeg_parse_set_property;
@ -185,13 +180,13 @@ static void
gst_mpeg_parse_init (GstMPEGParse *mpeg_parse) gst_mpeg_parse_init (GstMPEGParse *mpeg_parse)
{ {
mpeg_parse->sinkpad = gst_pad_new_from_template( 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_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_formats_function (mpeg_parse->sinkpad, gst_mpeg_parse_get_src_formats);
gst_pad_set_convert_function (mpeg_parse->sinkpad, gst_mpeg_parse_convert_src); gst_pad_set_convert_function (mpeg_parse->sinkpad, gst_mpeg_parse_convert_src);
mpeg_parse->srcpad = gst_pad_new_from_template( 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_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_formats_function (mpeg_parse->srcpad, gst_mpeg_parse_get_src_formats);
gst_pad_set_convert_function (mpeg_parse->srcpad, gst_mpeg_parse_convert_src); 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->max_discont = DEFAULT_MAX_DISCONT;
mpeg_parse->provided_clock = gst_mpeg_clock_new ("MPEGParseClock", mpeg_parse->provided_clock = gst_mpeg_clock_new ("MPEGParseClock",
gst_mpeg_parse_get_time, mpeg_parse); gst_mpeg_parse_get_time, mpeg_parse);
mpeg_parse->streaminfo = NULL;
GST_FLAG_SET (mpeg_parse, GST_ELEMENT_EVENT_AWARE); 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); return MPEGTIME_TO_GSTTIME (parse->current_scr);
} }
#if 0
static void static void
gst_mpeg_parse_update_streaminfo (GstMPEGParse *mpeg_parse) 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 (); 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); 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); gst_props_add_entry (props, (GstPropsEntry *) entry);
caps = gst_caps_new ("mpeg_streaminfo", 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); gst_caps_replace_sink (&mpeg_parse->streaminfo, caps);
g_object_notify (G_OBJECT (mpeg_parse), "streaminfo"); g_object_notify (G_OBJECT (mpeg_parse), "streaminfo");
} }
#endif
static void static void
gst_mpeg_parse_send_data (GstMPEGParse *mpeg_parse, GstData *data, GstClockTime time) 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); gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
if (gst_pad_try_set_caps (mpeg_parse->srcpad, if (gst_pad_try_set_caps (mpeg_parse->srcpad,
GST_CAPS_NEW ( gst_caps_new_simple ("video/mpeg",
"mpeg_parse_src", "mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"video/mpeg", "systemstream", G_TYPE_BOOLEAN, TRUE,
"mpegversion", GST_PROPS_INT (mpeg2 ? 2 : 1), "parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0)
"systemstream", GST_PROPS_BOOLEAN (TRUE),
"parsed", GST_PROPS_BOOLEAN (TRUE)
)) < 0)
{ {
gst_element_error (GST_ELEMENT (mpeg_parse), "could no set source caps"); gst_element_error (GST_ELEMENT (mpeg_parse), "could no set source caps");
return; return;
@ -414,7 +407,7 @@ gst_mpeg_parse_parse_packhead (GstMPEGParse *mpeg_parse, GstBuffer *buffer)
if (mpeg_parse->mux_rate != new_rate) { if (mpeg_parse->mux_rate != new_rate) {
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); 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); gboolean mpeg2 = GST_MPEG_PACKETIZE_IS_MPEG2 (mpeg_parse->packetize);
if (gst_pad_try_set_caps (mpeg_parse->sinkpad, if (gst_pad_try_set_caps (mpeg_parse->sinkpad,
GST_CAPS_NEW ( gst_caps_new_simple ("video/mpeg",
"mpeg_parse_src", "mpegversion", G_TYPE_INT, (mpeg2 ? 2 : 1),
"video/mpeg", "systemstream", G_TYPE_BOOLEAN, TRUE,
"mpegversion", GST_PROPS_INT (mpeg2 ? 2 : 1), "parsed", G_TYPE_BOOLEAN, TRUE, NULL)) < 0)
"systemstream", GST_PROPS_BOOLEAN (TRUE),
"parsed", GST_PROPS_BOOLEAN (TRUE)
)) < 0)
{ {
gst_element_error (GST_ELEMENT (mpeg_parse), "could no set sink caps"); gst_element_error (GST_ELEMENT (mpeg_parse), "could no set sink caps");
return; return;
@ -830,7 +820,7 @@ gst_mpeg_parse_change_state (GstElement *element)
gst_mpeg_packetize_destroy (mpeg_parse->packetize); gst_mpeg_packetize_destroy (mpeg_parse->packetize);
mpeg_parse->packetize = NULL; mpeg_parse->packetize = NULL;
} }
gst_caps_replace (&mpeg_parse->streaminfo, NULL); //gst_caps_replace (&mpeg_parse->streaminfo, NULL);
break; break;
default: default:
break; break;
@ -853,9 +843,6 @@ gst_mpeg_parse_get_property (GObject *object, guint prop_id, GValue *value, GPar
case ARG_MAX_DISCONT: case ARG_MAX_DISCONT:
g_value_set_int (value, mpeg_parse->max_discont); g_value_set_int (value, mpeg_parse->max_discont);
break; break;
case ARG_STREAMINFO:
g_value_set_boxed (value, mpeg_parse->streaminfo);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;

View file

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

View file

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

View file

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

View file

@ -23,6 +23,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/video/video.h> #include <gst/video/video.h>
#include <gst/audio/audio.h>
#include "synaescope.h" #include "synaescope.h"
#define GST_TYPE_SYNAESTHESIA (gst_synaesthesia_get_type()) #define GST_TYPE_SYNAESTHESIA (gst_synaesthesia_get_type())
@ -39,7 +40,6 @@ struct _GstSynaesthesia {
/* pads */ /* pads */
GstPad *sinkpad,*srcpad; GstPad *sinkpad,*srcpad;
GstBufferPool *peerpool;
/* the timestamp of the next frame */ /* the timestamp of the next frame */
guint64 next_time; guint64 next_time;
@ -81,41 +81,21 @@ enum {
/* FILL ME */ /* FILL ME */
}; };
GST_PAD_TEMPLATE_FACTORY (src_template, static GstStaticPadTemplate gst_synaesthesia_src_template =
GST_STATIC_PAD_TEMPLATE (
"src", "src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_CAPS_NEW ( GST_STATIC_CAPS (GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_32)
"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_PAD_TEMPLATE_FACTORY (sink_template, static GstStaticPadTemplate gst_synaesthesia_sink_template =
"sink", /* the name of the pads */ GST_STATIC_PAD_TEMPLATE (
GST_PAD_SINK, /* type of the pad */ "sink",
GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */ GST_PAD_SINK,
GST_CAPS_NEW ( GST_PAD_ALWAYS,
"synaesthesiasink", /* the name of the caps */ GST_STATIC_CAPS ( GST_AUDIO_INT_STANDARD_PAD_TEMPLATE_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 void gst_synaesthesia_base_init (gpointer g_class); static void gst_synaesthesia_base_init (gpointer g_class);
@ -133,7 +113,7 @@ static GstElementStateReturn
gst_synaesthesia_change_state (GstElement *element); gst_synaesthesia_change_state (GstElement *element);
static GstPadLinkReturn static GstPadLinkReturn
gst_synaesthesia_sinkconnect (GstPad *pad, GstCaps *caps); gst_synaesthesia_sink_link (GstPad *pad, const GstCaps *caps);
static GstElementClass *parent_class = NULL; 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_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_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template)); 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 static void
gst_synaesthesia_class_init(GstSynaesthesiaClass *klass) gst_synaesthesia_class_init(GstSynaesthesiaClass *klass)
{ {
@ -201,14 +184,14 @@ gst_synaesthesia_init (GstSynaesthesia *synaesthesia)
{ {
/* create the sink and src pads */ /* create the sink and src pads */
synaesthesia->sinkpad = gst_pad_new_from_template ( 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 ( 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->sinkpad);
gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->srcpad); gst_element_add_pad (GST_ELEMENT (synaesthesia), synaesthesia->srcpad);
gst_pad_set_chain_function (synaesthesia->sinkpad, gst_synaesthesia_chain); 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); GST_FLAG_SET (synaesthesia, GST_ELEMENT_EVENT_AWARE);
@ -220,15 +203,11 @@ gst_synaesthesia_init (GstSynaesthesia *synaesthesia)
} }
static GstPadLinkReturn static GstPadLinkReturn
gst_synaesthesia_sinkconnect (GstPad *pad, GstCaps *caps) gst_synaesthesia_sink_link (GstPad *pad, const GstCaps *caps)
{ {
GstSynaesthesia *synaesthesia; GstSynaesthesia *synaesthesia;
synaesthesia = GST_SYNAESTHESIA (gst_pad_get_parent (pad)); synaesthesia = GST_SYNAESTHESIA (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) {
return GST_PAD_LINK_DELAYED;
}
return GST_PAD_LINK_OK; return GST_PAD_LINK_OK;
} }
@ -281,31 +260,8 @@ gst_synaesthesia_chain (GstPad *pad, GstData *_data)
} }
if (synaesthesia->first_buffer) { if (synaesthesia->first_buffer) {
GstCaps *caps;
synaesthesia_init (synaesthesia->width, synaesthesia->height); 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; synaesthesia->first_buffer = FALSE;
} }
@ -383,7 +339,6 @@ gst_synaesthesia_change_state (GstElement *element)
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
synaesthesia->next_time = 0; synaesthesia->next_time = 0;
synaesthesia->peerpool = NULL;
synaesthesia->first_buffer = TRUE; synaesthesia->first_buffer = TRUE;
break; break;
} }