ext/jpeg/gstjpegdec.c: Add setcaps() function (for mjpeg).

Original commit message from CVS:
* ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init),
(gst_jpeg_dec_setcaps), (gst_jpeg_dec_chain):
Add setcaps() function (for mjpeg).
This commit is contained in:
Tim-Philipp Müller 2005-08-08 19:09:19 +00:00
parent 71de30e469
commit af16787fec
2 changed files with 32 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2005-08-08 Tim-Philipp Müller <tim at centricular dot net>
* ext/jpeg/gstjpegdec.c: (gst_jpeg_dec_init),
(gst_jpeg_dec_setcaps), (gst_jpeg_dec_chain):
Add setcaps() function (for mjpeg).
2005-08-08 Andy Wingo <wingo@pobox.com>
* ext/esd/esdsink.c (gst_esdsink_getcaps): Seems that wierd

View file

@ -84,6 +84,7 @@ static void gst_jpeg_dec_class_init (GstJpegDecClass * klass);
static void gst_jpeg_dec_init (GstJpegDec * jpegdec);
static GstFlowReturn gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buffer);
static gboolean gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps);
static GstElementStateReturn gst_jpeg_dec_change_state (GstElement * element);
GType
@ -236,6 +237,8 @@ gst_jpeg_dec_init (GstJpegDec * dec)
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_jpeg_dec_sink_pad_template), "sink");
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
gst_pad_set_setcaps_function (dec->sinkpad,
GST_DEBUG_FUNCPTR (gst_jpeg_dec_setcaps));
gst_pad_set_chain_function (dec->sinkpad,
GST_DEBUG_FUNCPTR (gst_jpeg_dec_chain));
@ -595,6 +598,29 @@ guarantee_huff_tables (j_decompress_ptr dinfo)
}
}
static gboolean
gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps)
{
GstStructure *s;
GstJpegDec *dec;
gdouble fps;
gint width, height;
dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad));
s = gst_caps_get_structure (caps, 0);
if (gst_structure_get_double (s, "framerate", &fps))
dec->fps = fps;
if (gst_structure_get_int (s, "width", &width)
&& gst_structure_get_int (s, "height", &height)) {
dec->width = width;
dec->height = height;
}
return TRUE;
}
static GstFlowReturn
gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
{
@ -703,7 +729,6 @@ gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buf)
dec->height = height;
}
/* FIXME: implement upstream nego for framerate? */
caps = gst_caps_new_simple ("video/x-raw-yuv",
"format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
"width", G_TYPE_INT, width,