Commit cdd0a9c8 authored by Edward Hervey's avatar Edward Hervey

encodebin: Convert to new GstElementClass::request_new_pad_full vmethod

parent 0a26cd9f
...@@ -198,7 +198,7 @@ static GstStateChangeReturn gst_encode_bin_change_state (GstElement * element, ...@@ -198,7 +198,7 @@ static GstStateChangeReturn gst_encode_bin_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
static GstPad *gst_encode_bin_request_new_pad (GstElement * element, static GstPad *gst_encode_bin_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name); GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
static void gst_encode_bin_release_pad (GstElement * element, GstPad * pad); static void gst_encode_bin_release_pad (GstElement * element, GstPad * pad);
static gboolean static gboolean
...@@ -283,7 +283,7 @@ gst_encode_bin_class_init (GstEncodeBinClass * klass) ...@@ -283,7 +283,7 @@ gst_encode_bin_class_init (GstEncodeBinClass * klass)
gstelement_klass->change_state = gstelement_klass->change_state =
GST_DEBUG_FUNCPTR (gst_encode_bin_change_state); GST_DEBUG_FUNCPTR (gst_encode_bin_change_state);
gstelement_klass->request_new_pad = gstelement_klass->request_new_pad_full =
GST_DEBUG_FUNCPTR (gst_encode_bin_request_new_pad); GST_DEBUG_FUNCPTR (gst_encode_bin_request_new_pad);
gstelement_klass->release_pad = gstelement_klass->release_pad =
GST_DEBUG_FUNCPTR (gst_encode_bin_release_pad); GST_DEBUG_FUNCPTR (gst_encode_bin_release_pad);
...@@ -513,38 +513,22 @@ next_unused_stream_profile (GstEncodeBin * ebin, GType ptype, GstCaps * caps) ...@@ -513,38 +513,22 @@ next_unused_stream_profile (GstEncodeBin * ebin, GType ptype, GstCaps * caps)
} }
static GstPad * static GstPad *
gst_encode_bin_request_new_pad (GstElement * element, request_pad_for_stream (GstEncodeBin * encodebin, GType ptype,
GstPadTemplate * templ, const gchar * name) const gchar * name, GstCaps * caps)
{ {
GstEncodeBin *ebin = (GstEncodeBin *) element;
GType ptype;
StreamGroup *sgroup; StreamGroup *sgroup;
GstEncodingProfile *sprof; GstEncodingProfile *sprof;
GST_DEBUG_OBJECT (element, "templ:%s, name:%s", templ->name_template, name); GST_DEBUG_OBJECT (encodebin, "name:%s caps:%" GST_PTR_FORMAT, name, caps);
/* Identify the stream group */
if (!strcmp (templ->name_template, "video_%d"))
ptype = GST_TYPE_ENCODING_VIDEO_PROFILE;
else if (!strcmp (templ->name_template, "audio_%d"))
ptype = GST_TYPE_ENCODING_AUDIO_PROFILE;
/* else if (!strcmp (templ->name_template, "text_%d")) */
/* ptype = GST_TYPE_ENCODING_TEXT_PROFILE; */
else
ptype = G_TYPE_NONE;
/* FIXME : Check uniqueness of pad */ /* Figure out if we have a unused GstEncodingProfile we can use for
/* FIXME : Check that the requested number is the last one, and if not, * these caps */
* update the last_pad_id variable so that we don't create a pad with sprof = next_unused_stream_profile (encodebin, ptype, caps);
* the same name/number in the future */
/* Find GstEncodingProfile which we need */
sprof = next_unused_stream_profile (ebin, ptype, NULL);
if (G_UNLIKELY (sprof == NULL)) if (G_UNLIKELY (sprof == NULL))
goto no_stream_profile; goto no_stream_profile;
sgroup = _create_stream_group (ebin, sprof, name, NULL); sgroup = _create_stream_group (encodebin, sprof, name, caps);
if (G_UNLIKELY (sgroup == NULL)) if (G_UNLIKELY (sgroup == NULL))
goto no_stream_group; goto no_stream_group;
...@@ -552,48 +536,56 @@ gst_encode_bin_request_new_pad (GstElement * element, ...@@ -552,48 +536,56 @@ gst_encode_bin_request_new_pad (GstElement * element,
no_stream_profile: no_stream_profile:
{ {
GST_WARNING_OBJECT (ebin, "Couldn't find a compatible stream profile"); GST_WARNING_OBJECT (encodebin, "Couldn't find a compatible stream profile");
return NULL; return NULL;
} }
no_stream_group: no_stream_group:
{ {
GST_WARNING_OBJECT (ebin, "Couldn't create a StreamGroup"); GST_WARNING_OBJECT (encodebin, "Couldn't create a StreamGroup");
return NULL; return NULL;
} }
} }
static GstPad * static GstPad *
gst_encode_bin_request_pad_signal (GstEncodeBin * encodebin, GstCaps * caps) gst_encode_bin_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
{ {
GstEncodingProfile *sprof; GstEncodeBin *ebin = (GstEncodeBin *) element;
StreamGroup *sgroup; GstPad *res = NULL;
GST_DEBUG_OBJECT (encodebin, "caps:%" GST_PTR_FORMAT, caps); GST_DEBUG_OBJECT (element, "templ:%s, name:%s", templ->name_template, name);
/* Figure out if we have a unused GstEncodingProfile we can use for /* Identify the stream group */
* these caps */ if (caps != NULL) {
sprof = next_unused_stream_profile (encodebin, G_TYPE_NONE, caps); res = request_pad_for_stream (ebin, G_TYPE_NONE, name, (GstCaps *) caps);
if (G_UNLIKELY (sprof == NULL)) }
goto no_stream_profile;
sgroup = _create_stream_group (encodebin, sprof, NULL, caps); if (res == NULL) {
if (G_UNLIKELY (sgroup == NULL)) GType ptype = G_TYPE_NONE;
goto no_stream_group;
return sgroup->ghostpad; if (!strcmp (templ->name_template, "video_%d"))
ptype = GST_TYPE_ENCODING_VIDEO_PROFILE;
else if (!strcmp (templ->name_template, "audio_%d"))
ptype = GST_TYPE_ENCODING_AUDIO_PROFILE;
/* else if (!strcmp (templ->name_template, "text_%d")) */
/* ptype = GST_TYPE_ENCODING_TEXT_PROFILE; */
no_stream_profile: /* FIXME : Check uniqueness of pad */
{ /* FIXME : Check that the requested number is the last one, and if not,
GST_WARNING_OBJECT (encodebin, "Couldn't find a compatible stream profile"); * update the last_pad_id variable so that we don't create a pad with
return NULL; * the same name/number in the future */
}
no_stream_group: res = request_pad_for_stream (ebin, ptype, name, NULL);
{
GST_WARNING_OBJECT (encodebin, "Couldn't create a StreamGroup");
return NULL;
} }
return res;
}
static GstPad *
gst_encode_bin_request_pad_signal (GstEncodeBin * encodebin, GstCaps * caps)
{
return request_pad_for_stream (encodebin, G_TYPE_NONE, NULL, caps);
} }
static inline StreamGroup * static inline StreamGroup *
...@@ -740,7 +732,7 @@ beach: ...@@ -740,7 +732,7 @@ beach:
} }
static GstPad * static GstPad *
gst_element_request_pad (GstElement * element, GstPadTemplate * templ, local_element_request_pad (GstElement * element, GstPadTemplate * templ,
const gchar * name) const gchar * name)
{ {
GstPad *newpad = NULL; GstPad *newpad = NULL;
...@@ -780,7 +772,7 @@ gst_element_get_pad_from_template (GstElement * element, GstPadTemplate * templ) ...@@ -780,7 +772,7 @@ gst_element_get_pad_from_template (GstElement * element, GstPadTemplate * templ)
break; break;
case GST_PAD_REQUEST: case GST_PAD_REQUEST:
ret = gst_element_request_pad (element, templ, NULL); ret = gst_element_request_pad (element, templ, NULL, NULL);
break; break;
} }
...@@ -1015,7 +1007,8 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, ...@@ -1015,7 +1007,8 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
/* Path 1 : Already-encoded data */ /* Path 1 : Already-encoded data */
sinkpad = gst_element_request_pad (sgroup->combiner, NULL, "passthroughsink"); sinkpad =
local_element_request_pad (sgroup->combiner, NULL, "passthroughsink");
if (G_UNLIKELY (sinkpad == NULL)) if (G_UNLIKELY (sinkpad == NULL))
goto no_combiner_sinkpad; goto no_combiner_sinkpad;
...@@ -1042,7 +1035,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, ...@@ -1042,7 +1035,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
g_object_unref (srcpad); g_object_unref (srcpad);
} }
srcpad = gst_element_request_pad (sgroup->splitter, NULL, "passthroughsrc"); srcpad = local_element_request_pad (sgroup->splitter, NULL, "passthroughsrc");
if (G_UNLIKELY (srcpad == NULL)) if (G_UNLIKELY (srcpad == NULL))
goto no_splitter_srcpad; goto no_splitter_srcpad;
...@@ -1061,7 +1054,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, ...@@ -1061,7 +1054,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
gst_bin_add ((GstBin *) ebin, sgroup->encoder); gst_bin_add ((GstBin *) ebin, sgroup->encoder);
tosync = g_list_append (tosync, sgroup->encoder); tosync = g_list_append (tosync, sgroup->encoder);
sinkpad = gst_element_request_pad (sgroup->combiner, NULL, "encodingsink"); sinkpad = local_element_request_pad (sgroup->combiner, NULL, "encodingsink");
if (G_UNLIKELY (sinkpad == NULL)) if (G_UNLIKELY (sinkpad == NULL))
goto no_combiner_sinkpad; goto no_combiner_sinkpad;
srcpad = gst_element_get_static_pad (sgroup->encoder, "src"); srcpad = gst_element_get_static_pad (sgroup->encoder, "src");
...@@ -1151,7 +1144,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, ...@@ -1151,7 +1144,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof,
/* Link to stream splitter */ /* Link to stream splitter */
sinkpad = gst_element_get_static_pad (last, "sink"); sinkpad = gst_element_get_static_pad (last, "sink");
srcpad = gst_element_request_pad (sgroup->splitter, NULL, "encodingsrc"); srcpad = local_element_request_pad (sgroup->splitter, NULL, "encodingsrc");
if (G_UNLIKELY (srcpad == NULL)) if (G_UNLIKELY (srcpad == NULL))
goto no_splitter_srcpad; goto no_splitter_srcpad;
if (G_UNLIKELY (fast_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)) if (G_UNLIKELY (fast_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK))
......
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