Commit ce51f617 authored by David Schleef's avatar David Schleef
Browse files

Merge CAPS branch

Original commit message from CVS:
Merge CAPS branch
parent f43f0a9f
......@@ -12,78 +12,27 @@ struct probe_context {
gint total_ls;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
GstCaps *metadata;
GstCaps *streaminfo;
GstCaps *caps;
};
static void
print_caps (GstCaps *caps)
{
if (caps == NULL) return;
if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") ||
!strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo"))
{
GstProps *props = caps->properties;
GList *walk;
/* ugly hack, but ok for now. If needed, fix by individual strcmp */
g_print (" %s:\n", gst_caps_get_mime (caps) + 18);
if (props == NULL) {
g_print (" none\n");
return;
}
walk = props->properties;
while (walk) {
GstPropsEntry *entry = (GstPropsEntry *) walk->data;
const gchar *name;
const gchar *str_val;
gint int_val;
GstPropsType type;
name = gst_props_entry_get_name (entry);
type = gst_props_entry_get_props_type (entry);
switch (type) {
case GST_PROPS_STRING_TYPE:
gst_props_entry_get_string (entry, &str_val);
g_print (" %s='%s'\n", name, str_val);
break;
case GST_PROPS_INT_TYPE:
gst_props_entry_get_int (entry, &int_val);
g_print (" %s=%d\n", name, int_val);
break;
default:
break;
}
walk = g_list_next (walk);
}
}
else {
g_print (" unkown caps type\n");
}
char *s;
s = gst_caps_to_string (caps);
g_print(" %s\n", s);
g_free (s);
}
static void
print_format (GstCaps *caps)
{
g_print (" format:\n");
if (!caps || caps->properties == NULL) {
g_print (" unkown\n");
return;
}
if (!strcmp (gst_caps_get_mime (caps), "audio/raw")) {
gint channels;
gint rate;
gst_caps_get_int (caps, "channels", &channels);
gst_caps_get_int (caps, "rate", &rate);
g_print (" channels: %d\n", channels);
g_print (" rate: %d\n", rate);
}
else {
g_print (" unkown format\n");
}
char *s;
s = gst_caps_to_string (caps);
g_print(" format: %s\n", s);
g_free (s);
}
static void
......
......@@ -58,17 +58,13 @@ enum {
ARG_FRAME_TIME,
};
GST_PAD_TEMPLATE_FACTORY (sink_template,
static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
gst_caps_new (
"aasink_caps",
"video/x-raw-yuv",
GST_VIDEO_YUV_PAD_TEMPLATE_PROPS (
GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")))
)
)
GST_STATIC_CAPS (GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("I420"))
);
static void gst_aasink_base_init (gpointer g_class);
static void gst_aasink_class_init (GstAASinkClass *klass);
......@@ -177,7 +173,7 @@ gst_aasink_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_template));
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details (element_class, &gst_aasink_details);
}
......@@ -244,17 +240,16 @@ gst_aasink_class_init (GstAASinkClass *klass)
}
static GstPadLinkReturn
gst_aasink_sinkconnect (GstPad *pad, GstCaps *caps)
gst_aasink_sinkconnect (GstPad *pad, const GstCaps *caps)
{
GstAASink *aasink;
GstStructure *structure;
aasink = GST_AASINK (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;
gst_caps_get_int (caps, "width", &aasink->width);
gst_caps_get_int (caps, "height", &aasink->height);
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "width", &aasink->width);
gst_structure_get_int (structure, "height", &aasink->height);
/* FIXME aasink->format is never set */
......@@ -279,7 +274,7 @@ static void
gst_aasink_init (GstAASink *aasink)
{
aasink->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_template), "sink");
gst_element_get_pad_template (GST_ELEMENT (aasink), "sink"), "sink");
gst_element_add_pad (GST_ELEMENT (aasink), aasink->sinkpad);
gst_pad_set_chain_function (aasink->sinkpad, gst_aasink_chain);
gst_pad_set_link_function (aasink->sinkpad, gst_aasink_sinkconnect);
......
......@@ -29,8 +29,11 @@
#define NTSC_HEIGHT 480
#define NTSC_BUFFER 120000
#define NTSC_FRAMERATE 29.997
#define PAL_HEIGHT 576
#define PAL_BUFFER 144000
#define PAL_FRAMERATE 25.0
/* The ElementDetails structure gives a human-readable description
* of the plugin, as well as author and version data.
......@@ -68,91 +71,88 @@ enum {
* can have. They can be quite complex, but for this dvdec plugin
* they are rather simple.
*/
GST_PAD_TEMPLATE_FACTORY (sink_temp,
"sink",
static GstStaticPadTemplate sink_temp =
GST_STATIC_PAD_TEMPLATE
(
"sink" ,
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"dv_dec_sink",
"video/x-dv",
"systemstream", GST_PROPS_BOOLEAN (TRUE)
GST_STATIC_CAPS (
"video/x-dv, systemstream = (boolean) true"
)
)
);
GST_PAD_TEMPLATE_FACTORY (video_src_temp,
static GstStaticPadTemplate video_src_temp =
GST_STATIC_PAD_TEMPLATE
(
"video",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"dv_dec_src",
"video/x-raw-yuv",
"format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y','U','Y','2')),
"width", GST_PROPS_INT (720),
"height", GST_PROPS_LIST (
GST_PROPS_INT (NTSC_HEIGHT),
GST_PROPS_INT (PAL_HEIGHT)
),
"framerate", GST_PROPS_LIST (
GST_PROPS_FLOAT (25.),
GST_PROPS_FLOAT (30/1.001)
)
),
GST_CAPS_NEW (
"dv_dec_src",
"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(0x000000ff),
"green_mask", GST_PROPS_INT(0x0000ff00),
"blue_mask", GST_PROPS_INT(0x00ff0000),
"width", GST_PROPS_INT (720),
"height", GST_PROPS_LIST (
GST_PROPS_INT (NTSC_HEIGHT),
GST_PROPS_INT (PAL_HEIGHT)
),
"framerate", GST_PROPS_LIST (
GST_PROPS_FLOAT (25.),
GST_PROPS_FLOAT (30/1.001)
)
),
GST_CAPS_NEW (
"dv_dec_src",
"video/x-raw-rgb",
"bpp", GST_PROPS_INT(24),
"depth", GST_PROPS_INT(24),
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"red_mask", GST_PROPS_INT(0x0000ff),
"green_mask", GST_PROPS_INT(0x00ff00),
"blue_mask", GST_PROPS_INT(0xff0000),
"width", GST_PROPS_INT (720),
"height", GST_PROPS_LIST (
GST_PROPS_INT (NTSC_HEIGHT),
GST_PROPS_INT (PAL_HEIGHT)
),
"framerate", GST_PROPS_LIST (
GST_PROPS_FLOAT (25.),
GST_PROPS_FLOAT (30/1.001)
)
GST_STATIC_CAPS (
"video/x-raw-yuv, "
"format = (fourcc) YUY2, "
"width = (int) 720, "
"height = (int) { "
G_STRINGIFY(NTSC_HEIGHT) ", "
G_STRINGIFY(PAL_HEIGHT)
" }, "
"framerate = (float) { "
G_STRINGIFY(PAL_FRAMERATE) ", "
G_STRINGIFY(NTSC_FRAMERATE)
" }; "
"video/x-raw-rgb, "
"bpp = (int) 32, "
"depth = (int) 32, "
"endianness = (int) " G_STRINGIFY(G_BIG_ENDIAN) ", "
"red_mask = (int) 0x000000ff, "
"green_mask = (int) 0x0000ff00, "
"blue_mask = (int) 0x00ff0000, "
"width = (int) 720, "
"height = (int) { "
G_STRINGIFY(NTSC_HEIGHT) ", "
G_STRINGIFY(PAL_HEIGHT)
" }, "
"framerate = (float) { "
G_STRINGIFY(PAL_FRAMERATE) ", "
G_STRINGIFY(NTSC_FRAMERATE)
" }; "
"video/x-raw-rgb, "
"bpp = (int) 24, "
"depth = (int) 24, "
"endianness = (int) " G_STRINGIFY(G_BIG_ENDIAN) ", "
"red_mask = (int) 0x000000ff, "
"green_mask = (int) 0x0000ff00, "
"blue_mask = (int) 0x00ff0000, "
"width = (int) 720, "
"height = (int) { "
G_STRINGIFY(NTSC_HEIGHT) ", "
G_STRINGIFY(PAL_HEIGHT)
" }, "
"framerate = (float) { "
G_STRINGIFY(PAL_FRAMERATE) ", "
G_STRINGIFY(NTSC_FRAMERATE)
" }"
)
)
);
GST_PAD_TEMPLATE_FACTORY ( audio_src_temp,
static GstStaticPadTemplate audio_src_temp =
GST_STATIC_PAD_TEMPLATE
(
"audio",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"arts_sample",
"audio/x-raw-int",
"depth", GST_PROPS_INT (16),
"width", GST_PROPS_INT (16),
"signed", GST_PROPS_BOOLEAN (TRUE),
"channels", GST_PROPS_INT (2),
"endianness", GST_PROPS_INT (G_LITTLE_ENDIAN),
"rate", GST_PROPS_INT_RANGE (4000, 48000)
GST_STATIC_CAPS (
"audio/x-raw-int, "
"depth = (int) 16, "
"width = (int) 16, "
"signed = (boolean) TRUE, "
"channels = (int) 2, "
"endianness = (int) " G_STRINGIFY(G_LITTLE_ENDIAN) ", "
"rate = (int) [ 4000, 48000 ]"
)
)
);
#define GST_TYPE_DVDEC_QUALITY (gst_dvdec_quality_get_type())
GType
......@@ -247,9 +247,9 @@ gst_dvdec_base_init (gpointer g_class)
* Note that the generated padtemplates are stored in static global
* variables, for the gst_dvdec_init function to use later on.
*/
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET(sink_temp));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET(video_src_temp));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET(audio_src_temp));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get(&sink_temp));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get(&video_src_temp));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get(&audio_src_temp));
gst_element_class_set_details (element_class, &dvdec_details);
}
......@@ -303,13 +303,13 @@ gst_dvdec_init(GstDVDec *dvdec)
{
gint i;
dvdec->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_temp), "sink");
dvdec->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&sink_temp), "sink");
gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->sinkpad);
gst_pad_set_query_function (dvdec->sinkpad, NULL);
gst_pad_set_convert_function (dvdec->sinkpad, GST_DEBUG_FUNCPTR (gst_dvdec_sink_convert));
gst_pad_set_formats_function (dvdec->sinkpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_formats));
dvdec->videosrcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (video_src_temp), "video");
dvdec->videosrcpad = gst_pad_new_from_template (gst_static_pad_template_get (&video_src_temp), "video");
gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->videosrcpad);
gst_pad_set_query_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_query));
gst_pad_set_query_type_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_src_query_types));
......@@ -318,7 +318,7 @@ gst_dvdec_init(GstDVDec *dvdec)
gst_pad_set_convert_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_convert));
gst_pad_set_formats_function (dvdec->videosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_formats));
dvdec->audiosrcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET(audio_src_temp), "audio");
dvdec->audiosrcpad = gst_pad_new_from_template (gst_static_pad_template_get (&audio_src_temp), "audio");
gst_element_add_pad(GST_ELEMENT(dvdec),dvdec->audiosrcpad);
gst_pad_set_query_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_src_query));
gst_pad_set_query_type_function (dvdec->audiosrcpad, GST_DEBUG_FUNCPTR (gst_dvdec_get_src_query_types));
......@@ -329,7 +329,6 @@ gst_dvdec_init(GstDVDec *dvdec)
gst_element_set_loop_function (GST_ELEMENT (dvdec), gst_dvdec_loop);
dvdec->pool = NULL;
dvdec->length = 0;
dvdec->next_ts = 0LL;
dvdec->end_position = -1LL;
......@@ -706,7 +705,7 @@ gst_dvdec_loop (GstElement *element)
dvdec->PAL = dv_system_50_fields (dvdec->decoder);
dvdec->framerate = (dvdec->PAL ? 2500 : 2997);
fps = (dvdec->PAL ? 25. : 30/1.001);
fps = (dvdec->PAL ? PAL_FRAMERATE : NTSC_FRAMERATE);
dvdec->height = height = (dvdec->PAL ? PAL_HEIGHT : NTSC_HEIGHT);
length = (dvdec->PAL ? PAL_BUFFER : NTSC_BUFFER);
......@@ -724,43 +723,51 @@ gst_dvdec_loop (GstElement *element)
/* if we did not negotiate yet, do it now */
if (!GST_PAD_CAPS (dvdec->videosrcpad)) {
GstCaps *allowed;
GstCaps *trylist;
GstCaps *caps = NULL;
GstCaps *negotiated_caps = NULL;
GstPadTemplate *src_pad_template;
int i;
/* we what we are allowed to do */
allowed = gst_pad_get_allowed_caps (dvdec->videosrcpad);
/* try to fix our height */
trylist = gst_caps_intersect (allowed, gst_caps_append (
GST_CAPS_NEW (
"dvdec_negotiate",
"video/x-raw-yuv",
"height", GST_PROPS_INT (height),
"framerate", GST_PROPS_FLOAT (fps)
), GST_CAPS_NEW (
"dvdec_negotiate",
"video/x-raw-rgb",
"height", GST_PROPS_INT (height),
"framerate", GST_PROPS_FLOAT (fps)
)));
/* prepare for looping */
trylist = gst_caps_normalize (trylist);
src_pad_template = gst_static_pad_template_get (&video_src_temp);
caps = gst_caps_copy(gst_pad_template_get_caps (src_pad_template));
for (i = 0; i < gst_caps_get_size (caps); i++)
{
GstStructure *structure = gst_caps_get_structure (caps, i);
gst_structure_set(structure,
"height", G_TYPE_INT, height,
"framerate", G_TYPE_INT, fps, NULL
);
}
while (trylist) {
GstCaps *to_try = gst_caps_copy_1 (trylist);
for (i=0; i < gst_caps_get_size(caps); i++) {
GstStructure *to_try_struct = gst_caps_get_structure (caps, i);
GstCaps *try_caps = gst_caps_new_full (to_try_struct);
/* try each format */
if (gst_pad_try_set_caps (dvdec->videosrcpad, to_try) > 0) {
guint32 fourcc;
if (gst_pad_try_set_caps (dvdec->videosrcpad, try_caps) > 0) {
negotiated_caps = try_caps;
break;
}
gst_caps_free(try_caps);
}
gst_caps_free (caps);
/* Check if we negotiated caps successfully */
if (negotiated_caps != NULL) {
GstStructure *structure = gst_caps_get_structure (negotiated_caps, 0);
guint32 fourcc;
/* it worked, try to find what it was again */
gst_caps_get_fourcc_int (to_try, "format", &fourcc);
gst_structure_get_fourcc (structure, "format", &fourcc);
if (fourcc == GST_STR_FOURCC ("RGB ")) {
gint bpp;
gst_caps_get_int (to_try, "bpp", &bpp);
gst_structure_get_int (structure, "bpp", &bpp);
if (bpp == 24) {
dvdec->space = e_dv_color_rgb;
dvdec->bpp = 3;
......@@ -774,12 +781,7 @@ gst_dvdec_loop (GstElement *element)
dvdec->space = e_dv_color_yuv;
dvdec->bpp = 2;
}
break;
}
trylist = trylist->next;
}
/* oops list exhausted an nothing was found... */
if (!trylist) {
} else {
gst_element_error (element, "could not negotiate");
return;
}
......@@ -799,15 +801,14 @@ gst_dvdec_loop (GstElement *element)
/* if we did not negotiate yet, do it now */
if (!GST_PAD_CAPS (dvdec->audiosrcpad)) {
gst_pad_try_set_caps (dvdec->audiosrcpad,
GST_CAPS_NEW (
"dvdec_audio_caps",
"audio/x-raw-int",
"rate", GST_PROPS_INT (dvdec->decoder->audio->frequency),
"depth", GST_PROPS_INT (16),
"width", GST_PROPS_INT (16),
"signed", GST_PROPS_BOOLEAN (TRUE),
"channels", GST_PROPS_INT (dvdec->decoder->audio->num_channels),
"endianness", GST_PROPS_INT (G_LITTLE_ENDIAN)
gst_caps_new_simple (
"audio/x-raw-int",
"rate", G_TYPE_INT, dvdec->decoder->audio->frequency,
"depth", G_TYPE_INT, 16,
"width", G_TYPE_INT, 16,
"signed", G_TYPE_BOOLEAN, TRUE,
"channels", G_TYPE_INT, dvdec->decoder->audio->num_channels,
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN
));
}
......@@ -831,23 +832,7 @@ gst_dvdec_loop (GstElement *element)
guint8 *outframe_ptrs[3];
gint outframe_pitches[3];
/* try to grab a pool */
if (!dvdec->pool) {
dvdec->pool = gst_pad_get_bufferpool (dvdec->videosrcpad);
}
outbuf = NULL;
/* try to get a buffer from the pool if we have one */
if (dvdec->pool) {
outbuf = gst_buffer_new_from_pool (dvdec->pool, 0, 0);
}
/* no buffer from pool, allocate one ourselves */
if (!outbuf) {
outbuf = gst_buffer_new ();
GST_BUFFER_SIZE (outbuf) = (720 * height) * dvdec->bpp;
GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
}
outbuf = gst_buffer_new_and_alloc ((720 * height) * dvdec->bpp);
outframe = GST_BUFFER_DATA (outbuf);
......@@ -898,9 +883,6 @@ gst_dvdec_change_state (GstElement *element)
case GST_STATE_PAUSED_TO_PLAYING:
break;
case GST_STATE_PLAYING_TO_PAUSED:
if (dvdec->pool)
gst_buffer_pool_unref (dvdec->pool);
dvdec->pool = NULL;
break;
case GST_STATE_PAUSED_TO_READY:
dv_decoder_free (dvdec->decoder);
......
......@@ -54,7 +54,6 @@ struct _GstDVDec {
gint quality;
GstByteStream *bs;
GstBufferPool *pool;
dv_color_space_t space;
gint bpp;
gboolean PAL;
......
......@@ -52,38 +52,31 @@ enum {
ARG_HOST,
};
GST_PAD_TEMPLATE_FACTORY (src_factory,
"src", /* the name of the pads */
GST_PAD_SRC, /* type of the pad */
GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */
GST_CAPS_NEW (
"esdmon_src", /* the name of the caps */
"audio/x-raw-int", /* the mime type of the caps */
/* Properties follow: */
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)
),
"width", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"depth", GST_PROPS_LIST (
GST_PROPS_INT (8),
GST_PROPS_INT (16)
),
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_LIST (
GST_PROPS_INT (1),
GST_PROPS_INT (2)
)
static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
"signed = (boolean) TRUE, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = [ 8000, 96000 ], "
"channels = [ 1, 2 ]; "
"audio/x-raw-int, "
"signed = (boolean) FALSE, "
"width = (int) 8, "
"depth = (int) 8, "
"rate = [ 8000, 96000 ], "
"channels = [ 1, 2 ]"
)
);
static void gst_esdmon_base_init (gpointer g_class);
static void gst_esdmon_class_init (GstEsdmonClass *klass);
static void gst_esdmon_init (GstEsdmon *esdmon);
static void gst_esdmon_class_init (gpointer g_class, gpointer class_data);
static void gst_esdmon_init (GTypeInstance *instance, gpointer g_class);
static gboolean gst_esdmon_open_audio (GstEsdmon *src);
static void gst_esdmon_close_audio (GstEsdmon *src);
......@@ -143,12 +136,12 @@ gst_esdmon_get_type (void)
sizeof(GstEsdmonClass),
gst_esdmon_base_init,
NULL,
(GClassInitFunc)gst_esdmon_class_init,
gst_esdmon_class_init,
NULL,
NULL,
sizeof(GstEsdmon),
0,
(GInstanceInitFunc)gst_esdmon_init,
gst_esdmon_init,
};
esdmon_type = g_type_register_static(GST_TYPE_ELEMENT, "GstEsdmon", &esdmon_info, 0);
}
......@@ -160,37 +153,35 @@ gst_esdmon_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&src_factory));
gst_element_class_set_details (element_class, &esdmon_details);
}
static void
gst_esdmon_class_init (GstEsdmonClass *klass)
gst_esdmon_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class)