mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
matroskamux: rework _request_new_pad to handle explict req-pad-names
Don't ignore explicit pad-names.
This commit is contained in:
parent
1e034cb01f
commit
8d5be2e8a4
1 changed files with 46 additions and 10 deletions
|
@ -46,6 +46,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <gst/riff/riff-media.h>
|
#include <gst/riff/riff-media.h>
|
||||||
|
@ -1790,32 +1791,55 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
*/
|
*/
|
||||||
static GstPad *
|
static GstPad *
|
||||||
gst_matroska_mux_request_new_pad (GstElement * element,
|
gst_matroska_mux_request_new_pad (GstElement * element,
|
||||||
GstPadTemplate * templ, const gchar * pad_name)
|
GstPadTemplate * templ, const gchar * req_name)
|
||||||
{
|
{
|
||||||
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
|
||||||
GstMatroskaMux *mux = GST_MATROSKA_MUX (element);
|
GstMatroskaMux *mux = GST_MATROSKA_MUX (element);
|
||||||
GstMatroskaPad *collect_pad;
|
GstMatroskaPad *collect_pad;
|
||||||
GstPad *newpad = NULL;
|
GstPad *newpad = NULL;
|
||||||
gchar *name = NULL;
|
gchar *name = NULL;
|
||||||
|
const gchar *pad_name = NULL;
|
||||||
GstPadSetCapsFunction setcapsfunc = NULL;
|
GstPadSetCapsFunction setcapsfunc = NULL;
|
||||||
GstMatroskaTrackContext *context = NULL;
|
GstMatroskaTrackContext *context = NULL;
|
||||||
|
gint pad_id;
|
||||||
|
|
||||||
if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
|
if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
|
||||||
|
/* don't mix named and unnamed pads, if the pad already exists we fail when
|
||||||
|
* trying to add it */
|
||||||
|
if (req_name != NULL && sscanf (req_name, "audio_%d", &pad_id) == 1) {
|
||||||
|
pad_name = req_name;
|
||||||
|
} else {
|
||||||
name = g_strdup_printf ("audio_%d", mux->num_a_streams++);
|
name = g_strdup_printf ("audio_%d", mux->num_a_streams++);
|
||||||
|
pad_name = name;
|
||||||
|
}
|
||||||
setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_audio_pad_setcaps);
|
setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_audio_pad_setcaps);
|
||||||
context = (GstMatroskaTrackContext *)
|
context = (GstMatroskaTrackContext *)
|
||||||
g_new0 (GstMatroskaTrackAudioContext, 1);
|
g_new0 (GstMatroskaTrackAudioContext, 1);
|
||||||
context->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
|
context->type = GST_MATROSKA_TRACK_TYPE_AUDIO;
|
||||||
context->name = g_strdup ("Audio");
|
context->name = g_strdup ("Audio");
|
||||||
} else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
|
} else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
|
||||||
|
/* don't mix named and unnamed pads, if the pad already exists we fail when
|
||||||
|
* trying to add it */
|
||||||
|
if (req_name != NULL && sscanf (req_name, "video_%d", &pad_id) == 1) {
|
||||||
|
pad_name = req_name;
|
||||||
|
} else {
|
||||||
name = g_strdup_printf ("video_%d", mux->num_v_streams++);
|
name = g_strdup_printf ("video_%d", mux->num_v_streams++);
|
||||||
|
pad_name = name;
|
||||||
|
}
|
||||||
setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_video_pad_setcaps);
|
setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_video_pad_setcaps);
|
||||||
context = (GstMatroskaTrackContext *)
|
context = (GstMatroskaTrackContext *)
|
||||||
g_new0 (GstMatroskaTrackVideoContext, 1);
|
g_new0 (GstMatroskaTrackVideoContext, 1);
|
||||||
context->type = GST_MATROSKA_TRACK_TYPE_VIDEO;
|
context->type = GST_MATROSKA_TRACK_TYPE_VIDEO;
|
||||||
context->name = g_strdup ("Video");
|
context->name = g_strdup ("Video");
|
||||||
} else if (templ == gst_element_class_get_pad_template (klass, "subtitle_%d")) {
|
} else if (templ == gst_element_class_get_pad_template (klass, "subtitle_%d")) {
|
||||||
|
/* don't mix named and unnamed pads, if the pad already exists we fail when
|
||||||
|
* trying to add it */
|
||||||
|
if (req_name != NULL && sscanf (req_name, "subtitle_%d", &pad_id) == 1) {
|
||||||
|
pad_name = req_name;
|
||||||
|
} else {
|
||||||
name = g_strdup_printf ("subtitle_%d", mux->num_t_streams++);
|
name = g_strdup_printf ("subtitle_%d", mux->num_t_streams++);
|
||||||
|
pad_name = name;
|
||||||
|
}
|
||||||
setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_subtitle_pad_setcaps);
|
setcapsfunc = GST_DEBUG_FUNCPTR (gst_matroska_mux_subtitle_pad_setcaps);
|
||||||
context = (GstMatroskaTrackContext *)
|
context = (GstMatroskaTrackContext *)
|
||||||
g_new0 (GstMatroskaTrackSubtitleContext, 1);
|
g_new0 (GstMatroskaTrackSubtitleContext, 1);
|
||||||
|
@ -1826,7 +1850,7 @@ gst_matroska_mux_request_new_pad (GstElement * element,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
newpad = gst_pad_new_from_template (templ, name);
|
newpad = gst_pad_new_from_template (templ, pad_name);
|
||||||
g_free (name);
|
g_free (name);
|
||||||
collect_pad = (GstMatroskaPad *)
|
collect_pad = (GstMatroskaPad *)
|
||||||
gst_collect_pads_add_pad_full (mux->collect, newpad,
|
gst_collect_pads_add_pad_full (mux->collect, newpad,
|
||||||
|
@ -1850,10 +1874,22 @@ gst_matroska_mux_request_new_pad (GstElement * element,
|
||||||
|
|
||||||
gst_pad_set_setcaps_function (newpad, setcapsfunc);
|
gst_pad_set_setcaps_function (newpad, setcapsfunc);
|
||||||
gst_pad_set_active (newpad, TRUE);
|
gst_pad_set_active (newpad, TRUE);
|
||||||
gst_element_add_pad (element, newpad);
|
if (!gst_element_add_pad (element, newpad))
|
||||||
|
goto pad_add_failed;
|
||||||
|
|
||||||
mux->num_streams++;
|
mux->num_streams++;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (newpad, "Added new request pad");
|
||||||
|
|
||||||
return newpad;
|
return newpad;
|
||||||
|
|
||||||
|
/* ERROR cases */
|
||||||
|
pad_add_failed:
|
||||||
|
{
|
||||||
|
GST_WARNING_OBJECT (mux, "Adding the new pad '%s' failed", pad_name);
|
||||||
|
gst_object_unref (newpad);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue