encodebin: Fix usage of non-container profiles
This commit is contained in:
parent
e187dacc35
commit
d20b84f1d2
@ -88,6 +88,7 @@ struct _GstEncodeBin
|
|||||||
GList *streams; /* List of StreamGroup, not sorted */
|
GList *streams; /* List of StreamGroup, not sorted */
|
||||||
|
|
||||||
GstElement *muxer;
|
GstElement *muxer;
|
||||||
|
/* Ghostpad with changing target */
|
||||||
GstPad *srcpad;
|
GstPad *srcpad;
|
||||||
|
|
||||||
/* TRUE if in PAUSED/PLAYING */
|
/* TRUE if in PAUSED/PLAYING */
|
||||||
@ -835,7 +836,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
|
|||||||
const gchar * sinkpadname, GstCaps * sinkcaps)
|
const gchar * sinkpadname, GstCaps * sinkcaps)
|
||||||
{
|
{
|
||||||
StreamGroup *sgroup = NULL;
|
StreamGroup *sgroup = NULL;
|
||||||
GstPad *sinkpad, *srcpad, *muxerpad;
|
GstPad *sinkpad, *srcpad, *muxerpad = NULL;
|
||||||
/* Element we will link to the encoder */
|
/* Element we will link to the encoder */
|
||||||
GstElement *last = NULL;
|
GstElement *last = NULL;
|
||||||
GList *tmp, *tosync = NULL;
|
GList *tmp, *tosync = NULL;
|
||||||
@ -871,12 +872,14 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
|
|||||||
if (G_UNLIKELY (sgroup->encoder == NULL))
|
if (G_UNLIKELY (sgroup->encoder == NULL))
|
||||||
goto no_encoder;
|
goto no_encoder;
|
||||||
|
|
||||||
/* Muxer
|
/* Muxer.
|
||||||
* We first figure out if the muxer has a sinkpad compatible with the selected
|
* If we are handling a container profile, figure out if the muxer has a
|
||||||
* profile */
|
* sinkpad compatible with the selected profile */
|
||||||
|
if (ebin->muxer) {
|
||||||
muxerpad = get_compatible_muxer_sink_pad (ebin, NULL, format);
|
muxerpad = get_compatible_muxer_sink_pad (ebin, NULL, format);
|
||||||
if (G_UNLIKELY (muxerpad == NULL))
|
if (G_UNLIKELY (muxerpad == NULL))
|
||||||
goto no_muxer_pad;
|
goto no_muxer_pad;
|
||||||
|
}
|
||||||
|
|
||||||
/* Output Queue.
|
/* Output Queue.
|
||||||
* We only use a 1buffer long queue here, the actual queueing will be done
|
* We only use a 1buffer long queue here, the actual queueing will be done
|
||||||
@ -888,11 +891,15 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
|
|||||||
gst_bin_add (GST_BIN (ebin), sgroup->outqueue);
|
gst_bin_add (GST_BIN (ebin), sgroup->outqueue);
|
||||||
tosync = g_list_append (tosync, sgroup->outqueue);
|
tosync = g_list_append (tosync, sgroup->outqueue);
|
||||||
srcpad = gst_element_get_static_pad (sgroup->outqueue, "src");
|
srcpad = gst_element_get_static_pad (sgroup->outqueue, "src");
|
||||||
|
if (muxerpad) {
|
||||||
if (G_UNLIKELY (fast_pad_link (srcpad, muxerpad) != GST_PAD_LINK_OK)) {
|
if (G_UNLIKELY (fast_pad_link (srcpad, muxerpad) != GST_PAD_LINK_OK)) {
|
||||||
goto muxer_link_failure;
|
goto muxer_link_failure;
|
||||||
}
|
}
|
||||||
gst_object_unref (srcpad);
|
|
||||||
gst_object_unref (muxerpad);
|
gst_object_unref (muxerpad);
|
||||||
|
} else {
|
||||||
|
gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), srcpad);
|
||||||
|
}
|
||||||
|
gst_object_unref (srcpad);
|
||||||
|
|
||||||
/* Output capsfilter
|
/* Output capsfilter
|
||||||
* This will receive the format caps from the streamprofile */
|
* This will receive the format caps from the streamprofile */
|
||||||
@ -1264,12 +1271,6 @@ _get_muxer (GstEncodeBin * ebin)
|
|||||||
format = gst_encoding_profile_get_format (ebin->profile);
|
format = gst_encoding_profile_get_format (ebin->profile);
|
||||||
preset = gst_encoding_profile_get_preset (ebin->profile);
|
preset = gst_encoding_profile_get_preset (ebin->profile);
|
||||||
|
|
||||||
if (format == NULL) {
|
|
||||||
GST_DEBUG ("Container-less profile, using identity");
|
|
||||||
muxer = gst_element_factory_make ("identity", NULL);
|
|
||||||
goto beach;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_DEBUG ("Getting list of muxers for format %" GST_PTR_FORMAT, format);
|
GST_DEBUG ("Getting list of muxers for format %" GST_PTR_FORMAT, format);
|
||||||
|
|
||||||
muxers =
|
muxers =
|
||||||
@ -1327,6 +1328,7 @@ create_elements_and_pads (GstEncodeBin * ebin)
|
|||||||
GST_DEBUG ("Current profile : %s",
|
GST_DEBUG ("Current profile : %s",
|
||||||
gst_encoding_profile_get_name (ebin->profile));
|
gst_encoding_profile_get_name (ebin->profile));
|
||||||
|
|
||||||
|
if (GST_IS_ENCODING_CONTAINER_PROFILE (ebin->profile)) {
|
||||||
/* 1. Get the compatible muxer */
|
/* 1. Get the compatible muxer */
|
||||||
muxer = _get_muxer (ebin);
|
muxer = _get_muxer (ebin);
|
||||||
if (G_UNLIKELY (muxer == NULL))
|
if (G_UNLIKELY (muxer == NULL))
|
||||||
@ -1348,7 +1350,6 @@ create_elements_and_pads (GstEncodeBin * ebin)
|
|||||||
goto no_muxer_ghost_pad;
|
goto no_muxer_ghost_pad;
|
||||||
|
|
||||||
gst_object_unref (muxerpad);
|
gst_object_unref (muxerpad);
|
||||||
|
|
||||||
/* 3. Activate fixed presence streams */
|
/* 3. Activate fixed presence streams */
|
||||||
profiles =
|
profiles =
|
||||||
gst_encoding_container_profile_get_profiles
|
gst_encoding_container_profile_get_profiles
|
||||||
@ -1364,6 +1365,11 @@ create_elements_and_pads (GstEncodeBin * ebin)
|
|||||||
goto stream_error;
|
goto stream_error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (G_UNLIKELY (_create_stream_group (ebin, ebin->profile, NULL,
|
||||||
|
NULL) == NULL))
|
||||||
|
goto stream_error;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -1394,10 +1400,8 @@ no_muxer_ghost_pad:
|
|||||||
stream_error:
|
stream_error:
|
||||||
{
|
{
|
||||||
GST_WARNING ("Could not create Streams");
|
GST_WARNING ("Could not create Streams");
|
||||||
gst_element_remove_pad ((GstElement *) ebin, ebin->srcpad);
|
|
||||||
gst_bin_remove (GST_BIN (ebin), muxer);
|
gst_bin_remove (GST_BIN (ebin), muxer);
|
||||||
ebin->muxer = NULL;
|
ebin->muxer = NULL;
|
||||||
ebin->srcpad = NULL;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1434,6 +1438,7 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup)
|
|||||||
|
|
||||||
GST_DEBUG_OBJECT (ebin, "Freeing StreamGroup %p", sgroup);
|
GST_DEBUG_OBJECT (ebin, "Freeing StreamGroup %p", sgroup);
|
||||||
|
|
||||||
|
if (ebin->muxer) {
|
||||||
/* outqueue - Muxer */
|
/* outqueue - Muxer */
|
||||||
tmppad = gst_element_get_static_pad (sgroup->outqueue, "src");
|
tmppad = gst_element_get_static_pad (sgroup->outqueue, "src");
|
||||||
pad = gst_pad_get_peer (tmppad);
|
pad = gst_pad_get_peer (tmppad);
|
||||||
@ -1443,6 +1448,7 @@ stream_group_free (GstEncodeBin * ebin, StreamGroup * sgroup)
|
|||||||
gst_element_release_request_pad (ebin->muxer, pad);
|
gst_element_release_request_pad (ebin->muxer, pad);
|
||||||
gst_object_unref (tmppad);
|
gst_object_unref (tmppad);
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
|
}
|
||||||
if (sgroup->outqueue)
|
if (sgroup->outqueue)
|
||||||
gst_element_set_state (sgroup->outqueue, GST_STATE_NULL);
|
gst_element_set_state (sgroup->outqueue, GST_STATE_NULL);
|
||||||
|
|
||||||
@ -1538,6 +1544,15 @@ gst_encode_bin_tear_down_profile (GstEncodeBin * ebin)
|
|||||||
while (ebin->streams)
|
while (ebin->streams)
|
||||||
stream_group_remove (ebin, (StreamGroup *) ebin->streams->data);
|
stream_group_remove (ebin, (StreamGroup *) ebin->streams->data);
|
||||||
|
|
||||||
|
/* Set ghostpad target to NULL */
|
||||||
|
gst_ghost_pad_set_target (GST_GHOST_PAD (ebin->srcpad), NULL);
|
||||||
|
|
||||||
|
/* Remove muxer if present */
|
||||||
|
if (ebin->muxer) {
|
||||||
|
gst_bin_remove (GST_BIN (ebin), ebin->muxer);
|
||||||
|
ebin->muxer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* free/clear profile */
|
/* free/clear profile */
|
||||||
gst_encoding_profile_unref (ebin->profile);
|
gst_encoding_profile_unref (ebin->profile);
|
||||||
ebin->profile = NULL;
|
ebin->profile = NULL;
|
||||||
@ -1550,7 +1565,9 @@ gst_encode_bin_setup_profile (GstEncodeBin * ebin, GstEncodingProfile * profile)
|
|||||||
|
|
||||||
g_return_val_if_fail (ebin->profile == NULL, FALSE);
|
g_return_val_if_fail (ebin->profile == NULL, FALSE);
|
||||||
|
|
||||||
GST_DEBUG ("Setting up profile %s", gst_encoding_profile_get_name (profile));
|
GST_DEBUG ("Setting up profile %s (type:%s)",
|
||||||
|
gst_encoding_profile_get_name (profile),
|
||||||
|
gst_encoding_profile_get_type_nick (profile));
|
||||||
|
|
||||||
ebin->profile = profile;
|
ebin->profile = profile;
|
||||||
gst_mini_object_ref ((GstMiniObject *) ebin->profile);
|
gst_mini_object_ref ((GstMiniObject *) ebin->profile);
|
||||||
@ -1566,6 +1583,8 @@ gst_encode_bin_setup_profile (GstEncodeBin * ebin, GstEncodingProfile * profile)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gst_encode_bin_set_profile (GstEncodeBin * ebin, GstEncodingProfile * profile)
|
gst_encode_bin_set_profile (GstEncodeBin * ebin, GstEncodingProfile * profile)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (ebin, "profile : %s",
|
GST_DEBUG_OBJECT (ebin, "profile : %s",
|
||||||
gst_encoding_profile_get_name (profile));
|
gst_encoding_profile_get_name (profile));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user