diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2018-04-22 10:49:29 -0300 |
---|---|---|
committer | Thibault Saunier <tsaunier@igalia.com> | 2018-05-02 09:53:21 +0200 |
commit | d91638b2bed69ef2aae181c5492f7d4f7887dcc5 (patch) | |
tree | b27b0742e17d67937b12ee1d04ac142be1ec5155 /gst | |
parent | 19026c822dba506482cfa27e78c1c05bb2b7fe0b (diff) | |
download | gstreamer-plugins-base-d91638b2bed69ef2aae181c5492f7d4f7887dcc5.tar.gz |
encodebin: Also lock input caps when dynamic output is disabled
With the way caps negotiation work in encoders, the only way to ensure
that no downstream renegotiation is done in the encoder is to also lock
upstream caps. Anyway with the current behavior upstream of encoders
*require* to handle any file format so locking upstream format should
be safe.
https://bugzilla.gnome.org/show_bug.cgi?id=795464
Diffstat (limited to 'gst')
-rw-r--r-- | gst/encoding/gstencodebin.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/gst/encoding/gstencodebin.c b/gst/encoding/gstencodebin.c index 53c22e0f9..573ea94a8 100644 --- a/gst/encoding/gstencodebin.c +++ b/gst/encoding/gstencodebin.c @@ -202,6 +202,7 @@ struct _StreamGroup GstElement *splitter; GList *converters; /* List of conversion GstElement */ GstElement *capsfilter; /* profile->restriction (if non-NULL/ANY) */ + gulong inputfilter_caps_sid; GstElement *encoder; /* Encoder (can be NULL) */ GstElement *fakesink; /* Fakesink (can be NULL) */ GstElement *combiner; @@ -1118,21 +1119,21 @@ _profile_restriction_caps_cb (GstEncodingProfile * profile, } static void -_outfilter_caps_set_cb (GstPad * outfilter_sinkpad, - GParamSpec * arg G_GNUC_UNUSED, StreamGroup * group) +_capsfilter_force_format (GstPad * pad, + GParamSpec * arg G_GNUC_UNUSED, gulong * signal_id) { GstCaps *caps; GstStructure *structure; - g_object_get (outfilter_sinkpad, "caps", &caps, NULL); + g_object_get (pad, "caps", &caps, NULL); caps = gst_caps_copy (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_remove_field (structure, "streamheader"); - GST_INFO_OBJECT (group->ebin, "Forcing caps to %" GST_PTR_FORMAT, caps); - g_object_set (group->outfilter, "caps", caps, NULL); - g_signal_handler_disconnect (outfilter_sinkpad, group->outputfilter_caps_sid); - group->outputfilter_caps_sid = 0; + GST_DEBUG_OBJECT (pad, "Forcing caps to %" GST_PTR_FORMAT, caps); + g_object_set (GST_OBJECT_PARENT (pad), "caps", caps, NULL); + g_signal_handler_disconnect (pad, *signal_id); + *signal_id = 0; gst_caps_unref (caps); } @@ -1146,7 +1147,8 @@ _set_group_caps_format (StreamGroup * sgroup, GstEncodingProfile * prof, if (!sgroup->outputfilter_caps_sid) { sgroup->outputfilter_caps_sid = g_signal_connect (sgroup->outfilter->sinkpads->data, - "notify::caps", G_CALLBACK (_outfilter_caps_set_cb), sgroup); + "notify::caps", G_CALLBACK (_capsfilter_force_format), + &sgroup->outputfilter_caps_sid); } } } @@ -1439,6 +1441,16 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, last = sgroup->capsfilter = gst_element_factory_make ("capsfilter", NULL); if (restriction && !gst_caps_is_any (restriction)) g_object_set (sgroup->capsfilter, "caps", restriction, NULL); + + if (!gst_encoding_profile_get_allow_dynamic_output (sprof)) { + if (!sgroup->inputfilter_caps_sid) { + sgroup->inputfilter_caps_sid = + g_signal_connect (sgroup->capsfilter->sinkpads->data, + "notify::caps", G_CALLBACK (_capsfilter_force_format), + &sgroup->inputfilter_caps_sid); + } + } + gst_bin_add ((GstBin *) ebin, sgroup->capsfilter); tosync = g_list_append (tosync, sgroup->capsfilter); if (sgroup->encoder == NULL) { @@ -2105,6 +2117,12 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup) gst_element_unlink (sgroup->capsfilter, sgroup->encoder); else gst_element_unlink (sgroup->capsfilter, sgroup->fakesink); + + if (sgroup->inputfilter_caps_sid) { + g_signal_handler_disconnect (sgroup->capsfilter->sinkpads->data, + sgroup->inputfilter_caps_sid); + sgroup->inputfilter_caps_sid = 0; + } gst_bin_remove ((GstBin *) ebin, sgroup->capsfilter); } |