mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
gst: Don't assume that get_current_caps() returns non-NULL caps after has_current_caps()
Remove calls to gst_pad_has_current_caps() which then go on to call gst_pad_get_current_caps() as the caps can go to NULL in between. Instead just use gst_pad_get_current_caps() and check for NULL. https://bugzilla.gnome.org/show_bug.cgi?id=759539
This commit is contained in:
parent
6cdbf40622
commit
211c8492b3
6 changed files with 33 additions and 24 deletions
|
@ -766,9 +766,8 @@ gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter)
|
||||||
|
|
||||||
pad = GST_AUDIO_ENCODER_SINK_PAD (enc);
|
pad = GST_AUDIO_ENCODER_SINK_PAD (enc);
|
||||||
|
|
||||||
if (gst_pad_has_current_caps (pad)) {
|
|
||||||
ret = gst_pad_get_current_caps (pad);
|
ret = gst_pad_get_current_caps (pad);
|
||||||
} else {
|
if (ret == NULL) {
|
||||||
ret = gst_pad_get_pad_template_caps (pad);
|
ret = gst_pad_get_pad_template_caps (pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,9 +1280,8 @@ gst_flac_enc_sink_query (GstAudioEncoder * enc, GstQuery * query)
|
||||||
case GST_QUERY_ACCEPT_CAPS:{
|
case GST_QUERY_ACCEPT_CAPS:{
|
||||||
GstCaps *acceptable, *caps;
|
GstCaps *acceptable, *caps;
|
||||||
|
|
||||||
if (gst_pad_has_current_caps (pad)) {
|
|
||||||
acceptable = gst_pad_get_current_caps (pad);
|
acceptable = gst_pad_get_current_caps (pad);
|
||||||
} else {
|
if (acceptable == NULL) {
|
||||||
acceptable = gst_pad_get_pad_template_caps (pad);
|
acceptable = gst_pad_get_pad_template_caps (pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -830,6 +830,7 @@ tags:
|
||||||
|
|
||||||
if (mux->have_video) {
|
if (mux->have_video) {
|
||||||
GstPad *video_pad = NULL;
|
GstPad *video_pad = NULL;
|
||||||
|
GstCaps *caps = NULL;
|
||||||
GstFlvPad *cpad;
|
GstFlvPad *cpad;
|
||||||
GSList *l = mux->collect->data;
|
GSList *l = mux->collect->data;
|
||||||
|
|
||||||
|
@ -841,8 +842,11 @@ tags:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_pad && gst_pad_has_current_caps (video_pad)) {
|
if (video_pad) {
|
||||||
GstCaps *caps;
|
caps = gst_pad_get_current_caps (video_pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (caps != NULL) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
gint size;
|
gint size;
|
||||||
gint num, den;
|
gint num, den;
|
||||||
|
@ -855,7 +859,6 @@ tags:
|
||||||
script_tag = gst_buffer_append (script_tag, tmp);
|
script_tag = gst_buffer_append (script_tag, tmp);
|
||||||
tags_written++;
|
tags_written++;
|
||||||
|
|
||||||
caps = gst_pad_get_current_caps (video_pad);
|
|
||||||
s = gst_caps_get_structure (caps, 0);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
|
|
|
@ -265,8 +265,8 @@ gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
|
|
||||||
pad = self->sinkpad;
|
pad = self->sinkpad;
|
||||||
if (gst_pad_has_current_caps (pad)) {
|
|
||||||
ret = gst_pad_get_current_caps (pad);
|
ret = gst_pad_get_current_caps (pad);
|
||||||
|
if (ret != NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,6 +267,7 @@ gst_rtp_h264_set_src_caps (GstRtpH264Depay * rtph264depay)
|
||||||
{
|
{
|
||||||
gboolean res;
|
gboolean res;
|
||||||
GstCaps *srccaps;
|
GstCaps *srccaps;
|
||||||
|
GstCaps *old_caps;
|
||||||
|
|
||||||
if (!rtph264depay->byte_stream &&
|
if (!rtph264depay->byte_stream &&
|
||||||
(!rtph264depay->new_codec_data ||
|
(!rtph264depay->new_codec_data ||
|
||||||
|
@ -397,10 +398,10 @@ gst_rtp_h264_set_src_caps (GstRtpH264Depay * rtph264depay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (gst_pad_has_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay))) {
|
old_caps =
|
||||||
GstCaps *old_caps =
|
|
||||||
gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay));
|
gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (rtph264depay));
|
||||||
|
|
||||||
|
if (old_caps != NULL) {
|
||||||
/* Only update the caps if they are not equal. For
|
/* Only update the caps if they are not equal. For
|
||||||
* AVC we don't update caps if only the codec_data
|
* AVC we don't update caps if only the codec_data
|
||||||
* changes. This is the same behaviour as in h264parse
|
* changes. This is the same behaviour as in h264parse
|
||||||
|
|
|
@ -329,8 +329,9 @@ gst_shape_wipe_video_sink_getcaps (GstShapeWipe * self, GstPad * pad,
|
||||||
{
|
{
|
||||||
GstCaps *templ, *ret, *tmp;
|
GstCaps *templ, *ret, *tmp;
|
||||||
|
|
||||||
if (gst_pad_has_current_caps (pad))
|
ret = gst_pad_get_current_caps (pad);
|
||||||
return gst_pad_get_current_caps (pad);
|
if (ret != NULL)
|
||||||
|
return ret;
|
||||||
|
|
||||||
templ = gst_pad_get_pad_template_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);
|
||||||
|
@ -451,8 +452,9 @@ gst_shape_wipe_mask_sink_getcaps (GstShapeWipe * self, GstPad * pad,
|
||||||
GstCaps *ret, *tmp, *tcaps;
|
GstCaps *ret, *tmp, *tcaps;
|
||||||
guint i, n;
|
guint i, n;
|
||||||
|
|
||||||
if (gst_pad_has_current_caps (pad))
|
ret = gst_pad_get_current_caps (pad);
|
||||||
return gst_pad_get_current_caps (pad);
|
if (ret != NULL)
|
||||||
|
return ret;
|
||||||
|
|
||||||
tcaps = gst_pad_get_pad_template_caps (self->video_sinkpad);
|
tcaps = 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);
|
||||||
|
@ -535,10 +537,13 @@ 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 *templ, *ret, *tmp;
|
GstCaps *templ, *ret, *tmp;
|
||||||
|
|
||||||
if (gst_pad_has_current_caps (pad))
|
ret = gst_pad_get_current_caps (pad);
|
||||||
return gst_pad_get_current_caps (pad);
|
if (ret != NULL)
|
||||||
else if (gst_pad_has_current_caps (self->video_sinkpad))
|
return ret;
|
||||||
return gst_pad_get_current_caps (self->video_sinkpad);
|
|
||||||
|
ret = gst_pad_get_current_caps (self->video_sinkpad);
|
||||||
|
if (ret != NULL)
|
||||||
|
return ret;
|
||||||
|
|
||||||
templ = gst_pad_get_pad_template_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);
|
||||||
|
|
|
@ -464,9 +464,11 @@ gst_aspect_ratio_crop_set_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
if (recheck) {
|
if (recheck) {
|
||||||
GstCaps *caps = gst_pad_get_current_caps (aspect_ratio_crop->sink);
|
GstCaps *caps = gst_pad_get_current_caps (aspect_ratio_crop->sink);
|
||||||
|
if (caps != NULL) {
|
||||||
gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
|
gst_aspect_ratio_crop_set_caps (aspect_ratio_crop, caps);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue