mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
jpegenc: more generic sink getcaps
This commit is contained in:
parent
cec48383b1
commit
c5614dbb40
1 changed files with 24 additions and 16 deletions
|
@ -314,30 +314,38 @@ static GstCaps *
|
||||||
gst_jpegenc_getcaps (GstPad * pad)
|
gst_jpegenc_getcaps (GstPad * pad)
|
||||||
{
|
{
|
||||||
GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
|
GstJpegEnc *jpegenc = GST_JPEGENC (gst_pad_get_parent (pad));
|
||||||
GstCaps *caps;
|
GstCaps *caps, *othercaps;
|
||||||
int i;
|
const GstCaps *templ;
|
||||||
|
gint i, j;
|
||||||
GstStructure *structure = NULL;
|
GstStructure *structure = NULL;
|
||||||
|
|
||||||
/* we want to proxy properties like width, height and framerate from the
|
/* we want to proxy properties like width, height and framerate from the
|
||||||
other end of the element */
|
other end of the element */
|
||||||
|
|
||||||
caps = gst_pad_get_allowed_caps (jpegenc->srcpad);
|
othercaps = gst_pad_get_allowed_caps (jpegenc->srcpad);
|
||||||
|
if (othercaps == NULL ||
|
||||||
|
gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
|
||||||
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
|
|
||||||
if (caps == NULL) {
|
caps = gst_caps_new_empty ();
|
||||||
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
templ = gst_pad_get_pad_template_caps (pad);
|
||||||
} else if (gst_caps_is_any (caps)) {
|
|
||||||
gst_caps_unref (caps);
|
for (i = 0; i < gst_caps_get_size (templ); i++) {
|
||||||
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
/* pick fields from peer caps */
|
||||||
} else {
|
for (j = 0; j < gst_caps_get_size (othercaps); j++) {
|
||||||
caps = gst_caps_make_writable (caps);
|
GstStructure *s = gst_caps_get_structure (othercaps, j);
|
||||||
|
const GValue *val;
|
||||||
|
|
||||||
|
structure = gst_structure_copy (gst_caps_get_structure (templ, i));
|
||||||
|
if ((val = gst_structure_get_value (s, "width")))
|
||||||
|
gst_structure_set_value (structure, "width", val);
|
||||||
|
if ((val = gst_structure_get_value (s, "height")))
|
||||||
|
gst_structure_set_value (structure, "height", val);
|
||||||
|
if ((val = gst_structure_get_value (s, "framerate")))
|
||||||
|
gst_structure_set_value (structure, "framerate", val);
|
||||||
|
|
||||||
|
gst_caps_merge_structure (caps, structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < gst_caps_get_size (caps); i++) {
|
|
||||||
structure = gst_caps_get_structure (caps, i);
|
|
||||||
|
|
||||||
gst_structure_set_name (structure, "video/x-raw-yuv");
|
|
||||||
gst_structure_set (structure, "format", GST_TYPE_FOURCC,
|
|
||||||
GST_STR_FOURCC ("I420"), NULL);
|
|
||||||
}
|
}
|
||||||
gst_object_unref (jpegenc);
|
gst_object_unref (jpegenc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue