Commit 2709b32e authored by Thibault Saunier's avatar Thibault Saunier

encodebin: Ensure that a single segment is pushed into encoders

Following the [design document] encodebin needs to handle sources that
output multiple streams, for that purpose and to make it simpler,
we ensure that a single segment is outputted to the encoders by using
an `identity single-segment=true` at the beginning of streams chains.

Added API to enable or disable the use of that new feature.
Added support for the encoding profile parser for that new property,
keeping backward compatibility

[design document]:
parent e8edb0eb
Pipeline #67437 failed with stages
in 100 minutes and 45 seconds
This diff is collapsed.
......@@ -152,6 +152,13 @@ GST_PBUTILS_API
void gst_encoding_profile_set_allow_dynamic_output (GstEncodingProfile *profile,
gboolean allow_dynamic_output);
gboolean gst_encoding_profile_get_single_segment (GstEncodingProfile *profile);
void gst_encoding_profile_set_single_segment (GstEncodingProfile *profile,
gboolean single_segment);
const gchar * gst_encoding_profile_get_preset (GstEncodingProfile *profile);
......@@ -198,7 +198,8 @@ struct _StreamGroup
GstEncodeBin *ebin;
GstEncodingProfile *profile;
GstPad *ghostpad; /* Sink ghostpad */
GstElement *inqueue; /* Queue just after the ghostpad */
GstElement *identity; /* Identity just after the ghostpad */
GstElement *inqueue; /* Queue just after the identity */
GstElement *splitter;
GList *converters; /* List of conversion GstElement */
GstElement *capsfilter; /* profile->restriction (if non-NULL/ANY) */
......@@ -1328,6 +1329,13 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
gst_bin_add (GST_BIN (ebin), sgroup->splitter);
tosync = g_list_append (tosync, sgroup->splitter);
if (gst_encoding_profile_get_single_segment (sprof)) {
sgroup->identity = gst_element_factory_make ("identity", NULL);
g_object_set (sgroup->identity, "single-segment", TRUE, NULL);
gst_bin_add (GST_BIN (ebin), sgroup->identity);
tosync = g_list_append (tosync, sgroup->identity);
/* Input queue
* FIXME : figure out what max-size to use for the input queue */
sgroup->inqueue = gst_element_factory_make ("queue", NULL);
......@@ -1338,11 +1346,11 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
gst_bin_add (GST_BIN (ebin), sgroup->inqueue);
tosync = g_list_append (tosync, sgroup->inqueue);
if (G_UNLIKELY (!fast_element_link (sgroup->inqueue, sgroup->splitter)))
goto splitter_link_failure;
/* Expose input queue sink pad as ghostpad */
sinkpad = gst_element_get_static_pad (sgroup->inqueue, "sink");
/* Expose input queue or identity sink pad as ghostpad */
sinkpad =
gst_element_get_static_pad (sgroup->identity ? sgroup->
identity : sgroup->inqueue, "sink");
if (sinkpadname == NULL) {
gchar *pname =
g_strdup_printf ("%s_%u", gst_encoding_profile_get_type_nick (sprof),
......@@ -1354,6 +1362,13 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
sgroup->ghostpad = gst_ghost_pad_new (sinkpadname, sinkpad);
gst_object_unref (sinkpad);
if (sgroup->identity
&& G_UNLIKELY (!fast_element_link (sgroup->identity, sgroup->inqueue)))
goto queue_link_failure;
if (G_UNLIKELY (!fast_element_link (sgroup->inqueue, sgroup->splitter)))
goto splitter_link_failure;
/* Path 1 : Already-encoded data */
sinkpad =
......@@ -1669,6 +1684,10 @@ splitter_link_failure:
GST_ERROR_OBJECT (ebin, "Failure linking to the splitter");
goto cleanup;
GST_ERROR_OBJECT (ebin, "Failure linking to the inqueue");
goto cleanup;
GST_ERROR_OBJECT (ebin, "Failure linking to the combiner");
goto cleanup;
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