ext/jpeg/gstsmokeenc.*: Implement getcaps function.
Original commit message from CVS: * ext/jpeg/gstsmokeenc.c: (gst_smokeenc_init), (gst_smokeenc_getcaps), (gst_smokeenc_setcaps), (gst_smokeenc_chain), (gst_smokeenc_change_state): * ext/jpeg/gstsmokeenc.h: Implement getcaps function. Set caps on the pad and on all outgoing buffers. Fixes #565441.
This commit is contained in:
parent
211bda0966
commit
2f1c50ef38
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2008-12-23 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* ext/jpeg/gstsmokeenc.c: (gst_smokeenc_init),
|
||||||
|
(gst_smokeenc_getcaps), (gst_smokeenc_setcaps),
|
||||||
|
(gst_smokeenc_chain), (gst_smokeenc_change_state):
|
||||||
|
* ext/jpeg/gstsmokeenc.h:
|
||||||
|
Implement getcaps function.
|
||||||
|
Set caps on the pad and on all outgoing buffers.
|
||||||
|
Fixes #565441.
|
||||||
|
|
||||||
2008-12-19 Stefan Kost <ensonic@users.sf.net>
|
2008-12-19 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* ext/pulse/pulsemixerctrl.c:
|
* ext/pulse/pulsemixerctrl.c:
|
||||||
|
@ -69,6 +69,7 @@ static GstStateChangeReturn
|
|||||||
gst_smokeenc_change_state (GstElement * element, GstStateChange transition);
|
gst_smokeenc_change_state (GstElement * element, GstStateChange transition);
|
||||||
|
|
||||||
static GstFlowReturn gst_smokeenc_chain (GstPad * pad, GstBuffer * buf);
|
static GstFlowReturn gst_smokeenc_chain (GstPad * pad, GstBuffer * buf);
|
||||||
|
static GstCaps *gst_smokeenc_getcaps (GstPad * pad);
|
||||||
static gboolean gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps);
|
||||||
|
|
||||||
static gboolean gst_smokeenc_resync (GstSmokeEnc * smokeenc);
|
static gboolean gst_smokeenc_resync (GstSmokeEnc * smokeenc);
|
||||||
@ -176,11 +177,13 @@ gst_smokeenc_init (GstSmokeEnc * smokeenc)
|
|||||||
gst_pad_new_from_static_template (&gst_smokeenc_sink_pad_template,
|
gst_pad_new_from_static_template (&gst_smokeenc_sink_pad_template,
|
||||||
"sink");
|
"sink");
|
||||||
gst_pad_set_chain_function (smokeenc->sinkpad, gst_smokeenc_chain);
|
gst_pad_set_chain_function (smokeenc->sinkpad, gst_smokeenc_chain);
|
||||||
|
gst_pad_set_getcaps_function (smokeenc->sinkpad, gst_smokeenc_getcaps);
|
||||||
gst_pad_set_setcaps_function (smokeenc->sinkpad, gst_smokeenc_setcaps);
|
gst_pad_set_setcaps_function (smokeenc->sinkpad, gst_smokeenc_setcaps);
|
||||||
gst_element_add_pad (GST_ELEMENT (smokeenc), smokeenc->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (smokeenc), smokeenc->sinkpad);
|
||||||
|
|
||||||
smokeenc->srcpad =
|
smokeenc->srcpad =
|
||||||
gst_pad_new_from_static_template (&gst_smokeenc_src_pad_template, "src");
|
gst_pad_new_from_static_template (&gst_smokeenc_src_pad_template, "src");
|
||||||
|
gst_pad_set_getcaps_function (smokeenc->srcpad, gst_smokeenc_getcaps);
|
||||||
gst_pad_use_fixed_caps (smokeenc->srcpad);
|
gst_pad_use_fixed_caps (smokeenc->srcpad);
|
||||||
gst_element_add_pad (GST_ELEMENT (smokeenc), smokeenc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (smokeenc), smokeenc->srcpad);
|
||||||
|
|
||||||
@ -201,6 +204,60 @@ gst_smokeenc_finalize (GObject * object)
|
|||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_smokeenc_getcaps (GstPad * pad)
|
||||||
|
{
|
||||||
|
GstSmokeEnc *smokeenc = GST_SMOKEENC (gst_pad_get_parent (pad));
|
||||||
|
GstPad *otherpad;
|
||||||
|
GstCaps *result, *caps;
|
||||||
|
const GstCaps *tcaps;
|
||||||
|
const char *name;
|
||||||
|
int i;
|
||||||
|
GstStructure *structure = NULL;
|
||||||
|
|
||||||
|
/* we want to proxy properties like width, height and framerate from the
|
||||||
|
other end of the element */
|
||||||
|
otherpad = (pad == smokeenc->srcpad) ? smokeenc->sinkpad : smokeenc->srcpad;
|
||||||
|
|
||||||
|
/* get template caps, we always need this to fiter the peer caps */
|
||||||
|
tcaps = gst_pad_get_pad_template_caps (otherpad);
|
||||||
|
|
||||||
|
/* get any constraints on the peer pad */
|
||||||
|
caps = gst_pad_peer_get_caps (otherpad);
|
||||||
|
|
||||||
|
if (caps == NULL)
|
||||||
|
caps = gst_caps_copy (tcaps);
|
||||||
|
else
|
||||||
|
caps = gst_caps_make_writable (caps);
|
||||||
|
|
||||||
|
/* intersect with the template */
|
||||||
|
result = gst_caps_intersect (caps, tcaps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
|
if (pad == smokeenc->srcpad) {
|
||||||
|
name = "video/x-smoke";
|
||||||
|
} else {
|
||||||
|
name = "video/x-raw-yuv";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we can only copy width, height, framerate from one side to the other */
|
||||||
|
for (i = 0; i < gst_caps_get_size (result); i++) {
|
||||||
|
structure = gst_caps_get_structure (result, i);
|
||||||
|
|
||||||
|
gst_structure_set_name (structure, name);
|
||||||
|
gst_structure_remove_field (structure, "format");
|
||||||
|
/* ... but for the sink pad, we only do I420 anyway, so add that */
|
||||||
|
if (pad == smokeenc->sinkpad) {
|
||||||
|
gst_structure_set (structure, "format", GST_TYPE_FOURCC,
|
||||||
|
GST_STR_FOURCC ("I420"), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_object_unref (smokeenc);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps)
|
gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
@ -208,6 +265,7 @@ gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps)
|
|||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
const GValue *framerate;
|
const GValue *framerate;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
GstCaps *srccaps;
|
||||||
|
|
||||||
smokeenc = GST_SMOKEENC (gst_pad_get_parent (pad));
|
smokeenc = GST_SMOKEENC (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
@ -227,16 +285,17 @@ gst_smokeenc_setcaps (GstPad * pad, GstCaps * caps)
|
|||||||
if ((smokeenc->width & 0x0f) != 0 || (smokeenc->height & 0x0f) != 0)
|
if ((smokeenc->width & 0x0f) != 0 || (smokeenc->height & 0x0f) != 0)
|
||||||
goto width_or_height_notx16;
|
goto width_or_height_notx16;
|
||||||
|
|
||||||
if (smokeenc->srccaps)
|
if (!gst_smokeenc_resync (smokeenc))
|
||||||
gst_caps_unref (smokeenc->srccaps);
|
goto init_failed;
|
||||||
|
|
||||||
smokeenc->srccaps = gst_caps_new_simple ("video/x-smoke",
|
srccaps = gst_caps_new_simple ("video/x-smoke",
|
||||||
"width", G_TYPE_INT, smokeenc->width,
|
"width", G_TYPE_INT, smokeenc->width,
|
||||||
"height", G_TYPE_INT, smokeenc->height,
|
"height", G_TYPE_INT, smokeenc->height,
|
||||||
"framerate", GST_TYPE_FRACTION, smokeenc->fps_num, smokeenc->fps_denom,
|
"framerate", GST_TYPE_FRACTION, smokeenc->fps_num, smokeenc->fps_denom,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
ret = gst_smokeenc_resync (smokeenc);
|
ret = gst_pad_set_caps (smokeenc->srcpad, srccaps);
|
||||||
|
gst_caps_unref (srccaps);
|
||||||
|
|
||||||
gst_object_unref (smokeenc);
|
gst_object_unref (smokeenc);
|
||||||
|
|
||||||
@ -249,6 +308,12 @@ width_or_height_notx16:
|
|||||||
gst_object_unref (smokeenc);
|
gst_object_unref (smokeenc);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
init_failed:
|
||||||
|
{
|
||||||
|
GST_WARNING_OBJECT (smokeenc, "could not init decoder");
|
||||||
|
gst_object_unref (smokeenc);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -328,7 +393,7 @@ gst_smokeenc_chain (GstPad * pad, GstBuffer * buf)
|
|||||||
GST_BUFFER_DURATION (outbuf) =
|
GST_BUFFER_DURATION (outbuf) =
|
||||||
gst_util_uint64_scale_int (GST_SECOND, smokeenc->fps_denom,
|
gst_util_uint64_scale_int (GST_SECOND, smokeenc->fps_denom,
|
||||||
smokeenc->fps_num);
|
smokeenc->fps_num);
|
||||||
gst_buffer_set_caps (outbuf, smokeenc->srccaps);
|
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (smokeenc->srcpad));
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
if ((smokeenc->frame % smokeenc->keyframe) == 0) {
|
if ((smokeenc->frame % smokeenc->keyframe) == 0) {
|
||||||
@ -433,10 +498,6 @@ gst_smokeenc_change_state (GstElement * element, GstStateChange transition)
|
|||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
if (enc->srccaps) {
|
|
||||||
gst_caps_unref (enc->srccaps);
|
|
||||||
enc->srccaps = NULL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -55,8 +55,6 @@ struct _GstSmokeEnc {
|
|||||||
gint keyframe;
|
gint keyframe;
|
||||||
gint fps_num, fps_denom;
|
gint fps_num, fps_denom;
|
||||||
|
|
||||||
GstCaps *srccaps;
|
|
||||||
|
|
||||||
SmokeCodecInfo *info;
|
SmokeCodecInfo *info;
|
||||||
|
|
||||||
gint threshold;
|
gint threshold;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user