Commit e310ee82 authored by Wim Taymans's avatar Wim Taymans

caps: improve caps handling

Avoid caps copy and leaks
parent 8f52f8c5
...@@ -1701,7 +1701,7 @@ gst_avi_mux_start_file (GstAviMux * avimux) ...@@ -1701,7 +1701,7 @@ gst_avi_mux_start_file (GstAviMux * avimux)
} }
} }
caps = gst_caps_copy (gst_pad_get_pad_template_caps (avimux->srcpad)); caps = gst_pad_get_pad_template_caps (avimux->srcpad);
gst_pad_set_caps (avimux->srcpad, caps); gst_pad_set_caps (avimux->srcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
......
...@@ -273,8 +273,6 @@ gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter) ...@@ -273,8 +273,6 @@ gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
pad = self->sinkpad; pad = self->sinkpad;
if (gst_pad_has_current_caps (pad)) { if (gst_pad_has_current_caps (pad)) {
ret = gst_pad_get_current_caps (pad); ret = gst_pad_get_current_caps (pad);
gst_caps_replace (&ret, gst_caps_copy (ret));
gst_caps_unref (ret);
goto done; goto done;
} }
......
...@@ -403,7 +403,8 @@ gst_alaw_enc_setcaps (GstALawEnc * alawenc, GstCaps * caps) ...@@ -403,7 +403,8 @@ gst_alaw_enc_setcaps (GstALawEnc * alawenc, GstCaps * caps)
gst_structure_get_int (structure, "channels", &alawenc->channels); gst_structure_get_int (structure, "channels", &alawenc->channels);
gst_structure_get_int (structure, "rate", &alawenc->rate); gst_structure_get_int (structure, "rate", &alawenc->rate);
base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (alawenc->srcpad)); base_caps = gst_pad_get_pad_template_caps (alawenc->srcpad);
base_caps = gst_caps_make_writable (base_caps);
structure = gst_caps_get_structure (base_caps, 0); structure = gst_caps_get_structure (base_caps, 0);
gst_structure_set (structure, "rate", G_TYPE_INT, alawenc->rate, NULL); gst_structure_set (structure, "rate", G_TYPE_INT, alawenc->rate, NULL);
gst_structure_set (structure, "channels", G_TYPE_INT, alawenc->channels, gst_structure_set (structure, "channels", G_TYPE_INT, alawenc->channels,
......
...@@ -159,7 +159,8 @@ mulawenc_setcaps (GstMuLawEnc * mulawenc, GstCaps * caps) ...@@ -159,7 +159,8 @@ mulawenc_setcaps (GstMuLawEnc * mulawenc, GstCaps * caps)
gst_structure_get_int (structure, "channels", &mulawenc->channels); gst_structure_get_int (structure, "channels", &mulawenc->channels);
gst_structure_get_int (structure, "rate", &mulawenc->rate); gst_structure_get_int (structure, "rate", &mulawenc->rate);
base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (mulawenc->srcpad)); base_caps = gst_pad_get_pad_template_caps (mulawenc->srcpad);
base_caps = gst_caps_make_writable (base_caps);
structure = gst_caps_get_structure (base_caps, 0); structure = gst_caps_get_structure (base_caps, 0);
gst_structure_set (structure, "rate", G_TYPE_INT, mulawenc->rate, NULL); gst_structure_set (structure, "rate", G_TYPE_INT, mulawenc->rate, NULL);
......
...@@ -3000,20 +3000,17 @@ gst_matroska_demux_check_aac (GstElement * element, ...@@ -3000,20 +3000,17 @@ gst_matroska_demux_check_aac (GstElement * element,
size = gst_buffer_get_size (*buf); size = gst_buffer_get_size (*buf);
if (size > 2 && data[0] == 0xff && (data[1] >> 4 == 0x0f)) { if (size > 2 && data[0] == 0xff && (data[1] >> 4 == 0x0f)) {
GstCaps *new_caps;
GstStructure *s; GstStructure *s;
/* tss, ADTS data, remove codec_data /* tss, ADTS data, remove codec_data
* still assume it is at least parsed */ * still assume it is at least parsed */
new_caps = gst_caps_copy (stream->caps); stream->caps = gst_caps_make_writable (stream->caps);
s = gst_caps_get_structure (new_caps, 0); s = gst_caps_get_structure (stream->caps, 0);
g_assert (s); g_assert (s);
gst_structure_remove_field (s, "codec_data"); gst_structure_remove_field (s, "codec_data");
gst_caps_replace (&stream->caps, new_caps); gst_pad_set_caps (stream->pad, stream->caps);
gst_pad_set_caps (stream->pad, new_caps);
GST_DEBUG_OBJECT (element, "ADTS AAC audio data; removing codec-data, " GST_DEBUG_OBJECT (element, "ADTS AAC audio data; removing codec-data, "
"new caps: %" GST_PTR_FORMAT, new_caps); "new caps: %" GST_PTR_FORMAT, stream->caps);
gst_caps_unref (new_caps);
} }
/* disable subsequent checking */ /* disable subsequent checking */
......
...@@ -175,8 +175,7 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) ...@@ -175,8 +175,7 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
if (!gst_pad_has_current_caps (asteriskh263->srcpad)) { if (!gst_pad_has_current_caps (asteriskh263->srcpad)) {
GstCaps *caps; GstCaps *caps;
caps = gst_caps_copy caps = gst_pad_get_pad_template_caps (asteriskh263->srcpad);
(gst_pad_get_pad_template_caps (asteriskh263->srcpad));
gst_pad_set_caps (asteriskh263->srcpad, caps); gst_pad_set_caps (asteriskh263->srcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
} }
......
...@@ -176,9 +176,9 @@ gst_rtp_L16_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -176,9 +176,9 @@ gst_rtp_L16_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
GstCaps *otherpadcaps; GstCaps *otherpadcaps;
GstCaps *caps; GstCaps *caps;
otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad); caps = gst_pad_get_pad_template_caps (pad);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad);
if (otherpadcaps) { if (otherpadcaps) {
if (!gst_caps_is_empty (otherpadcaps)) { if (!gst_caps_is_empty (otherpadcaps)) {
GstStructure *structure; GstStructure *structure;
...@@ -187,6 +187,7 @@ gst_rtp_L16_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -187,6 +187,7 @@ gst_rtp_L16_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
gint rate; gint rate;
structure = gst_caps_get_structure (otherpadcaps, 0); structure = gst_caps_get_structure (otherpadcaps, 0);
caps = gst_caps_make_writable (caps);
if (gst_structure_get_int (structure, "channels", &channels)) { if (gst_structure_get_int (structure, "channels", &channels)) {
gst_caps_set_simple (caps, "channels", G_TYPE_INT, channels, NULL); gst_caps_set_simple (caps, "channels", G_TYPE_INT, channels, NULL);
......
...@@ -179,9 +179,9 @@ gst_rtp_bv_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -179,9 +179,9 @@ gst_rtp_bv_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
GstCaps *otherpadcaps; GstCaps *otherpadcaps;
GstCaps *caps; GstCaps *caps;
otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad); caps = gst_pad_get_pad_template_caps (pad);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad);
if (otherpadcaps) { if (otherpadcaps) {
if (!gst_caps_is_empty (otherpadcaps)) { if (!gst_caps_is_empty (otherpadcaps)) {
GstStructure *structure; GstStructure *structure;
...@@ -201,6 +201,7 @@ gst_rtp_bv_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -201,6 +201,7 @@ gst_rtp_bv_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
mode = -1; mode = -1;
if (mode == 16 || mode == 32) { if (mode == 16 || mode == 32) {
caps = gst_caps_make_writable (caps);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "mode", G_TYPE_INT, mode, NULL); gst_structure_set (structure, "mode", G_TYPE_INT, mode, NULL);
} }
......
...@@ -164,15 +164,20 @@ gst_rtp_celt_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad, ...@@ -164,15 +164,20 @@ gst_rtp_celt_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad,
GstCaps *caps; GstCaps *caps;
const gchar *params; const gchar *params;
otherpadcaps = gst_pad_get_allowed_caps (payload->srcpad); caps = gst_pad_get_pad_template_caps (pad);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
otherpadcaps = gst_pad_get_allowed_caps (payload->srcpad);
if (otherpadcaps) { if (otherpadcaps) {
if (!gst_caps_is_empty (otherpadcaps)) { if (!gst_caps_is_empty (otherpadcaps)) {
GstStructure *ps = gst_caps_get_structure (otherpadcaps, 0); GstStructure *ps;
GstStructure *s = gst_caps_get_structure (caps, 0); GstStructure *s;
gint clock_rate = 0, frame_size = 0, channels = 1; gint clock_rate = 0, frame_size = 0, channels = 1;
caps = gst_caps_make_writable (caps);
ps = gst_caps_get_structure (otherpadcaps, 0);
s = gst_caps_get_structure (caps, 0);
if (gst_structure_get_int (ps, "clock-rate", &clock_rate)) { if (gst_structure_get_int (ps, "clock-rate", &clock_rate)) {
gst_structure_fixate_field_nearest_int (s, "rate", clock_rate); gst_structure_fixate_field_nearest_int (s, "rate", clock_rate);
} }
......
...@@ -196,10 +196,11 @@ gst_rtp_g722_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -196,10 +196,11 @@ gst_rtp_g722_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
GstCaps *caps; GstCaps *caps;
otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad); otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); caps = gst_pad_get_pad_template_caps (pad);
if (otherpadcaps) { if (otherpadcaps) {
if (!gst_caps_is_empty (otherpadcaps)) { if (!gst_caps_is_empty (otherpadcaps)) {
caps = gst_caps_make_writable (caps);
gst_caps_set_simple (caps, "channels", G_TYPE_INT, 1, NULL); gst_caps_set_simple (caps, "channels", G_TYPE_INT, 1, NULL);
gst_caps_set_simple (caps, "rate", G_TYPE_INT, 16000, NULL); gst_caps_set_simple (caps, "rate", G_TYPE_INT, 16000, NULL);
} }
......
...@@ -235,7 +235,7 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, ...@@ -235,7 +235,7 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad,
GstCaps * filter) GstCaps * filter)
{ {
GstRtpH263PPay *rtph263ppay; GstRtpH263PPay *rtph263ppay;
GstCaps *caps = NULL; GstCaps *caps = NULL, *templ;
GstCaps *peercaps = NULL; GstCaps *peercaps = NULL;
GstCaps *intersect = NULL; GstCaps *intersect = NULL;
guint i; guint i;
...@@ -246,12 +246,12 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad, ...@@ -246,12 +246,12 @@ gst_rtp_h263p_pay_sink_getcaps (GstRTPBasePayload * payload, GstPad * pad,
gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), filter); gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), filter);
if (!peercaps) if (!peercaps)
return return
gst_caps_copy (gst_pad_get_pad_template_caps gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SINKPAD (payload));
(GST_RTP_BASE_PAYLOAD_SINKPAD (payload)));
intersect = gst_caps_intersect (peercaps, templ = gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload));
gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload))); intersect = gst_caps_intersect (peercaps, templ);
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
gst_caps_unref (templ);
if (gst_caps_is_empty (intersect)) if (gst_caps_is_empty (intersect))
return intersect; return intersect;
......
...@@ -183,7 +183,7 @@ gst_rtp_ilbc_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -183,7 +183,7 @@ gst_rtp_ilbc_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
GstCaps *caps; GstCaps *caps;
otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad); otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); caps = gst_pad_get_pad_template_caps (pad);
if (otherpadcaps) { if (otherpadcaps) {
if (!gst_caps_is_empty (otherpadcaps)) { if (!gst_caps_is_empty (otherpadcaps)) {
...@@ -198,6 +198,7 @@ gst_rtp_ilbc_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad, ...@@ -198,6 +198,7 @@ gst_rtp_ilbc_pay_sink_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
if (mode_str) { if (mode_str) {
mode = strtol (mode_str, NULL, 10); mode = strtol (mode_str, NULL, 10);
if (mode == 20 || mode == 30) { if (mode == 20 || mode == 30) {
caps = gst_caps_make_writable (caps);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
gst_structure_set (structure, "mode", G_TYPE_INT, mode, NULL); gst_structure_set (structure, "mode", G_TYPE_INT, mode, NULL);
} }
......
...@@ -114,14 +114,18 @@ gst_rtp_speex_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad, ...@@ -114,14 +114,18 @@ gst_rtp_speex_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad,
GstCaps *caps; GstCaps *caps;
otherpadcaps = gst_pad_get_allowed_caps (payload->srcpad); otherpadcaps = gst_pad_get_allowed_caps (payload->srcpad);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); caps = gst_pad_get_pad_template_caps (pad);
if (otherpadcaps) { if (otherpadcaps) {
if (!gst_caps_is_empty (otherpadcaps)) { if (!gst_caps_is_empty (otherpadcaps)) {
GstStructure *ps = gst_caps_get_structure (otherpadcaps, 0); GstStructure *ps;
GstStructure *s = gst_caps_get_structure (caps, 0); GstStructure *s;
gint clock_rate; gint clock_rate;
ps = gst_caps_get_structure (otherpadcaps, 0);
caps = gst_caps_make_writable (caps);
s = gst_caps_get_structure (caps, 0);
if (gst_structure_get_int (ps, "clock-rate", &clock_rate)) { if (gst_structure_get_int (ps, "clock-rate", &clock_rate)) {
gst_structure_fixate_field_nearest_int (s, "rate", clock_rate); gst_structure_fixate_field_nearest_int (s, "rate", clock_rate);
} }
......
...@@ -327,17 +327,19 @@ static GstCaps * ...@@ -327,17 +327,19 @@ static GstCaps *
gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter) gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter)
{ {
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad)); GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
GstCaps *ret, *tmp; GstCaps *templ, *ret, *tmp;
if (gst_pad_has_current_caps (pad)) if (gst_pad_has_current_caps (pad))
return gst_pad_get_current_caps (pad); return gst_pad_get_current_caps (pad);
templ = gst_pad_get_pad_template_caps (pad);
tmp = gst_pad_peer_query_caps (self->srcpad, NULL); tmp = gst_pad_peer_query_caps (self->srcpad, NULL);
if (tmp) { if (tmp) {
ret = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad)); ret = gst_caps_intersect (tmp, templ);
gst_caps_unref (templ);
gst_caps_unref (tmp); gst_caps_unref (tmp);
} else { } else {
ret = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); ret = templ;
} }
GST_LOG_OBJECT (pad, "srcpad accepted caps: %" GST_PTR_FORMAT, ret); GST_LOG_OBJECT (pad, "srcpad accepted caps: %" GST_PTR_FORMAT, ret);
...@@ -365,6 +367,7 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter) ...@@ -365,6 +367,7 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter)
if (self->vinfo.height && self->vinfo.width) { if (self->vinfo.height && self->vinfo.width) {
guint i, n; guint i, n;
ret = gst_caps_make_writable (ret);
n = gst_caps_get_size (ret); n = gst_caps_get_size (ret);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (ret, i); GstStructure *s = gst_caps_get_structure (ret, i);
...@@ -381,15 +384,13 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter) ...@@ -381,15 +384,13 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad, GstCaps * filter)
GstCaps *intersection, *tmp2; GstCaps *intersection, *tmp2;
guint i, n; guint i, n;
tmp = gst_caps_make_writable (tmp); tmp2 = gst_pad_get_pad_template_caps (self->mask_sinkpad);
tmp2 = gst_caps_copy (gst_pad_get_pad_template_caps (self->mask_sinkpad));
intersection = gst_caps_intersect (tmp, tmp2); intersection = gst_caps_intersect (tmp, tmp2);
gst_caps_unref (tmp); gst_caps_unref (tmp);
gst_caps_unref (tmp2); gst_caps_unref (tmp2);
tmp = intersection; tmp = intersection;
tmp = gst_caps_make_writable (tmp);
n = gst_caps_get_size (tmp); n = gst_caps_get_size (tmp);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
...@@ -463,7 +464,7 @@ gst_shape_wipe_mask_sink_getcaps (GstPad * pad, GstCaps * filter) ...@@ -463,7 +464,7 @@ gst_shape_wipe_mask_sink_getcaps (GstPad * pad, GstCaps * filter)
gst_pad_get_pad_template_caps (self->video_sinkpad)); gst_pad_get_pad_template_caps (self->video_sinkpad));
gst_caps_unref (tmp); gst_caps_unref (tmp);
} else { } else {
ret = gst_caps_copy (gst_pad_get_pad_template_caps (self->video_sinkpad)); ret = gst_pad_get_pad_template_caps (self->video_sinkpad);
} }
GST_LOG_OBJECT (pad, "video sink accepted caps: %" GST_PTR_FORMAT, ret); GST_LOG_OBJECT (pad, "video sink accepted caps: %" GST_PTR_FORMAT, ret);
...@@ -536,21 +537,21 @@ static GstCaps * ...@@ -536,21 +537,21 @@ static GstCaps *
gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter) gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter)
{ {
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad)); GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
GstCaps *ret, *tmp; GstCaps *templ, *ret, *tmp;
if (gst_pad_has_current_caps (pad)) if (gst_pad_has_current_caps (pad))
return gst_pad_get_current_caps (pad); return gst_pad_get_current_caps (pad);
else if (gst_pad_has_current_caps (self->video_sinkpad)) else if (gst_pad_has_current_caps (self->video_sinkpad))
return gst_pad_get_current_caps (self->video_sinkpad); return gst_pad_get_current_caps (self->video_sinkpad);
templ = gst_pad_get_pad_template_caps (self->video_sinkpad);
tmp = gst_pad_peer_query_caps (self->video_sinkpad, NULL); tmp = gst_pad_peer_query_caps (self->video_sinkpad, NULL);
if (tmp) { if (tmp) {
ret = ret = gst_caps_intersect (tmp, templ);
gst_caps_intersect (tmp, gst_caps_unref (templ);
gst_pad_get_pad_template_caps (self->video_sinkpad));
gst_caps_unref (tmp); gst_caps_unref (tmp);
} else { } else {
ret = gst_caps_copy (gst_pad_get_pad_template_caps (self->video_sinkpad)); ret = templ;
} }
GST_LOG_OBJECT (pad, "video sink accepted caps: %" GST_PTR_FORMAT, ret); GST_LOG_OBJECT (pad, "video sink accepted caps: %" GST_PTR_FORMAT, ret);
...@@ -577,6 +578,7 @@ gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter) ...@@ -577,6 +578,7 @@ gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter)
if (self->vinfo.height && self->vinfo.width) { if (self->vinfo.height && self->vinfo.width) {
guint i, n; guint i, n;
ret = gst_caps_make_writable (ret);
n = gst_caps_get_size (ret); n = gst_caps_get_size (ret);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (ret, i); GstStructure *s = gst_caps_get_structure (ret, i);
...@@ -592,14 +594,12 @@ gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter) ...@@ -592,14 +594,12 @@ gst_shape_wipe_src_getcaps (GstPad * pad, GstCaps * filter)
GstCaps *intersection, *tmp2; GstCaps *intersection, *tmp2;
guint i, n; guint i, n;
tmp = gst_caps_make_writable (tmp); tmp2 = gst_pad_get_pad_template_caps (self->mask_sinkpad);
tmp2 = gst_caps_copy (gst_pad_get_pad_template_caps (self->mask_sinkpad));
intersection = gst_caps_intersect (tmp, tmp2); intersection = gst_caps_intersect (tmp, tmp2);
gst_caps_unref (tmp); gst_caps_unref (tmp);
gst_caps_unref (tmp2); gst_caps_unref (tmp2);
tmp = intersection; tmp = gst_caps_make_writable (intersection);
n = gst_caps_get_size (tmp); n = gst_caps_get_size (tmp);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
......
...@@ -545,13 +545,14 @@ gst_smpte_collected (GstCollectPads2 * pads, GstSMPTE * smpte) ...@@ -545,13 +545,14 @@ gst_smpte_collected (GstCollectPads2 * pads, GstSMPTE * smpte)
GstSegment segment; GstSegment segment;
caps = caps =
gst_caps_copy (gst_static_caps_get gst_caps_make_writable (gst_static_caps_get
(&gst_smpte_src_template.static_caps)); (&gst_smpte_src_template.static_caps));
gst_caps_set_simple (caps, "width", G_TYPE_INT, smpte->width, "height", gst_caps_set_simple (caps, "width", G_TYPE_INT, smpte->width, "height",
G_TYPE_INT, smpte->height, "framerate", GST_TYPE_FRACTION, G_TYPE_INT, smpte->height, "framerate", GST_TYPE_FRACTION,
smpte->fps_num, smpte->fps_denom, NULL); smpte->fps_num, smpte->fps_denom, NULL);
gst_pad_set_caps (smpte->srcpad, caps); gst_pad_set_caps (smpte->srcpad, caps);
gst_caps_unref (caps);
gst_segment_init (&segment, GST_FORMAT_TIME); gst_segment_init (&segment, GST_FORMAT_TIME);
gst_pad_push_event (smpte->srcpad, gst_event_new_segment (&segment)); gst_pad_push_event (smpte->srcpad, gst_event_new_segment (&segment));
......
...@@ -294,14 +294,13 @@ gst_oss_sink_getcaps (GstBaseSink * bsink) ...@@ -294,14 +294,13 @@ gst_oss_sink_getcaps (GstBaseSink * bsink)
osssink = GST_OSSSINK (bsink); osssink = GST_OSSSINK (bsink);
if (osssink->fd == -1) { if (osssink->fd == -1) {
caps = gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD caps = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink));
(bsink)));
} else if (osssink->probed_caps) { } else if (osssink->probed_caps) {
caps = gst_caps_copy (osssink->probed_caps); caps = gst_caps_ref (osssink->probed_caps);
} else { } else {
caps = gst_oss_helper_probe_caps (osssink->fd); caps = gst_oss_helper_probe_caps (osssink->fd);
if (caps && !gst_caps_is_empty (caps)) { if (caps && !gst_caps_is_empty (caps)) {
osssink->probed_caps = gst_caps_copy (caps); osssink->probed_caps = gst_caps_ref (caps);
} }
} }
......
...@@ -513,9 +513,7 @@ gst_v4l2sink_get_caps (GstBaseSink * bsink, GstCaps * filter) ...@@ -513,9 +513,7 @@ gst_v4l2sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
if (!GST_V4L2_IS_OPEN (v4l2sink->v4l2object)) { if (!GST_V4L2_IS_OPEN (v4l2sink->v4l2object)) {
/* FIXME: copy? */ /* FIXME: copy? */
GST_DEBUG_OBJECT (v4l2sink, "device is not open"); GST_DEBUG_OBJECT (v4l2sink, "device is not open");
return return gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (v4l2sink));
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD
(v4l2sink)));
} }
if (v4l2sink->probed_caps == NULL) { if (v4l2sink->probed_caps == NULL) {
......
...@@ -442,10 +442,7 @@ gst_v4l2src_get_caps (GstBaseSrc * src, GstCaps * filter) ...@@ -442,10 +442,7 @@ gst_v4l2src_get_caps (GstBaseSrc * src, GstCaps * filter)
obj = v4l2src->v4l2object; obj = v4l2src->v4l2object;
if (!GST_V4L2_IS_OPEN (obj)) { if (!GST_V4L2_IS_OPEN (obj)) {
/* FIXME: copy? */ return gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (v4l2src));
return
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
(v4l2src)));
} }
if (v4l2src->probed_caps) if (v4l2src->probed_caps)
......
...@@ -1022,14 +1022,10 @@ gst_ximage_src_get_caps (GstBaseSrc * bs, GstCaps * filter) ...@@ -1022,14 +1022,10 @@ gst_ximage_src_get_caps (GstBaseSrc * bs, GstCaps * filter)
GstVideoFormat format; GstVideoFormat format;
if ((!s->xcontext) && (!gst_ximage_src_open_display (s, s->display_name))) if ((!s->xcontext) && (!gst_ximage_src_open_display (s, s->display_name)))
return return gst_pad_get_pad_template_caps (GST_BASE_SRC (s)->srcpad);
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC
(s)->srcpad));
if (!gst_ximage_src_recalc (s)) if (!gst_ximage_src_recalc (s))
return return gst_pad_get_pad_template_caps (GST_BASE_SRC (s)->srcpad);
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC
(s)->srcpad));
xcontext = s->xcontext; xcontext = s->xcontext;
width = s->xcontext->width; width = s->xcontext->width;
......
...@@ -208,7 +208,7 @@ check_qtmux_pad (GstStaticPadTemplate * srctemplate, const gchar * sinkname, ...@@ -208,7 +208,7 @@ check_qtmux_pad (GstStaticPadTemplate * srctemplate, const gchar * sinkname,
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
inbuffer = gst_buffer_new_and_alloc (1); inbuffer = gst_buffer_new_and_alloc (1);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (mysrcpad)); caps = gst_pad_get_pad_template_caps (mysrcpad);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
...@@ -296,7 +296,7 @@ check_qtmux_pad_fragmented (GstStaticPadTemplate * srctemplate, ...@@ -296,7 +296,7 @@ check_qtmux_pad_fragmented (GstStaticPadTemplate * srctemplate,
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
inbuffer = gst_buffer_new_and_alloc (1); inbuffer = gst_buffer_new_and_alloc (1);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (mysrcpad)); caps = gst_pad_get_pad_template_caps (mysrcpad);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
...@@ -526,7 +526,7 @@ GST_START_TEST (test_reuse) ...@@ -526,7 +526,7 @@ GST_START_TEST (test_reuse)
inbuffer = gst_buffer_new_and_alloc (1); inbuffer = gst_buffer_new_and_alloc (1);
fail_unless (inbuffer != NULL); fail_unless (inbuffer != NULL);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (mysrcpad)); caps = gst_pad_get_pad_template_caps (mysrcpad);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
GST_BUFFER_TIMESTAMP (inbuffer) = 0; GST_BUFFER_TIMESTAMP (inbuffer) = 0;
...@@ -817,7 +817,7 @@ test_average_bitrate_custom (const gchar * elementname, ...@@ -817,7 +817,7 @@ test_average_bitrate_custom (const gchar * elementname,
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
inbuffer = gst_buffer_new_and_alloc (bytes[i]); inbuffer = gst_buffer_new_and_alloc (bytes[i]);
caps = gst_caps_copy (gst_pad_get_pad_template_caps (mysrcpad)); caps = gst_pad_get_pad_template_caps (mysrcpad);
gst_pad_set_caps (mysrcpad, caps); gst_pad_set_caps (mysrcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
GST_BUFFER_TIMESTAMP (inbuffer) = total_duration; GST_BUFFER_TIMESTAMP (inbuffer) = total_duration;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment