mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
ges: Set restriction caps in the audio source caps filter
Otherwise we could have not negotiated errors in audiomixer when the channel/channel-mask do not match Differential Revision: https://phabricator.freedesktop.org/D493 Reviewed-by: Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
This commit is contained in:
parent
fcf8d5382e
commit
320b611ff7
3 changed files with 71 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"phabricator.uri" : "https:\/\/phabricator.freedesktop.org\/api\/",
|
"phabricator.uri" : "https://phabricator.freedesktop.org/",
|
||||||
"repository.callsign" : "GES",
|
"repository.callsign" : "GES",
|
||||||
"project": "GStreamer Editing Services"
|
"project": "GStreamer Editing Services",
|
||||||
|
"default-reviewers": "thiblahute,Mathieu_Du"
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ G_DEFINE_ABSTRACT_TYPE (GESAudioSource, ges_audio_source, GES_TYPE_SOURCE);
|
||||||
|
|
||||||
struct _GESAudioSourcePrivate
|
struct _GESAudioSourcePrivate
|
||||||
{
|
{
|
||||||
/* Dummy variable */
|
GstElement *capsfilter;
|
||||||
void *nothing;
|
GESTrack *current_track;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -89,6 +89,41 @@ _sync_element_to_layer_property_float (GESTrackElement * trksrc,
|
||||||
gst_object_unref (layer);
|
gst_object_unref (layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
restriction_caps_cb (GESTrack * track,
|
||||||
|
GParamSpec * arg G_GNUC_UNUSED, GESAudioSource * self)
|
||||||
|
{
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
g_object_get (track, "restriction-caps", &caps, NULL);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (self, "Setting capsfilter caps to %" GST_PTR_FORMAT, caps);
|
||||||
|
g_object_set (self->priv->capsfilter, "caps", caps, NULL);
|
||||||
|
|
||||||
|
if (caps)
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_track_changed_cb (GESAudioSource * self, GParamSpec * arg G_GNUC_UNUSED,
|
||||||
|
gpointer udata)
|
||||||
|
{
|
||||||
|
GESTrack *track = ges_track_element_get_track (GES_TRACK_ELEMENT (self));
|
||||||
|
|
||||||
|
if (self->priv->current_track) {
|
||||||
|
g_signal_handlers_disconnect_by_func (self->priv->current_track,
|
||||||
|
(GCallback) restriction_caps_cb, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
self->priv->current_track = track;
|
||||||
|
if (track) {
|
||||||
|
restriction_caps_cb (track, NULL, self);
|
||||||
|
|
||||||
|
g_signal_connect (track, "notify::restriction-caps",
|
||||||
|
G_CALLBACK (restriction_caps_cb), self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GstElement *
|
static GstElement *
|
||||||
ges_audio_source_create_element (GESTrackElement * trksrc)
|
ges_audio_source_create_element (GESTrackElement * trksrc)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +132,7 @@ ges_audio_source_create_element (GESTrackElement * trksrc)
|
||||||
GstElement *sub_element;
|
GstElement *sub_element;
|
||||||
GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_GET_CLASS (trksrc);
|
GESAudioSourceClass *source_class = GES_AUDIO_SOURCE_GET_CLASS (trksrc);
|
||||||
const gchar *props[] = { "volume", "mute", NULL };
|
const gchar *props[] = { "volume", "mute", NULL };
|
||||||
|
GESAudioSource *self = GES_AUDIO_SOURCE (trksrc);
|
||||||
|
|
||||||
if (!source_class->create_source)
|
if (!source_class->create_source)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -106,9 +142,15 @@ ges_audio_source_create_element (GESTrackElement * trksrc)
|
||||||
GST_DEBUG_OBJECT (trksrc, "Creating a bin sub_element ! volume");
|
GST_DEBUG_OBJECT (trksrc, "Creating a bin sub_element ! volume");
|
||||||
vbin =
|
vbin =
|
||||||
gst_parse_bin_from_description
|
gst_parse_bin_from_description
|
||||||
("audioconvert ! audioresample ! volume name=v", TRUE, NULL);
|
("audioconvert ! audioresample ! volume name=v ! capsfilter name=audio-track-caps-filter",
|
||||||
|
TRUE, NULL);
|
||||||
topbin = ges_source_create_topbin ("audiosrcbin", sub_element, vbin, NULL);
|
topbin = ges_source_create_topbin ("audiosrcbin", sub_element, vbin, NULL);
|
||||||
volume = gst_bin_get_by_name (GST_BIN (vbin), "v");
|
volume = gst_bin_get_by_name (GST_BIN (vbin), "v");
|
||||||
|
self->priv->capsfilter = gst_bin_get_by_name (GST_BIN (vbin),
|
||||||
|
"audio-track-caps-filter");
|
||||||
|
|
||||||
|
g_signal_connect (self, "notify::track", (GCallback) _track_changed_cb, NULL);
|
||||||
|
_track_changed_cb (self, NULL, NULL);
|
||||||
|
|
||||||
_sync_element_to_layer_property_float (trksrc, volume, GES_META_VOLUME,
|
_sync_element_to_layer_property_float (trksrc, volume, GES_META_VOLUME,
|
||||||
"volume");
|
"volume");
|
||||||
|
|
|
@ -219,20 +219,39 @@ ges_smart_adder_init (GESSmartAdder * self)
|
||||||
NULL, (GDestroyNotify) destroy_pad);
|
NULL, (GDestroyNotify) destroy_pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
restriction_caps_cb (GESTrack * track,
|
||||||
|
GParamSpec * arg G_GNUC_UNUSED, GESSmartAdder * self)
|
||||||
|
{
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
g_object_get (track, "restriction-caps", &caps, NULL);
|
||||||
|
|
||||||
|
if (!caps)
|
||||||
|
caps = gst_caps_from_string (DEFAULT_CAPS);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (self, "Setting adder caps to %" GST_PTR_FORMAT, caps);
|
||||||
|
g_object_set (self->adder, "caps", caps, NULL);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
GstElement *
|
GstElement *
|
||||||
ges_smart_adder_new (GESTrack * track)
|
ges_smart_adder_new (GESTrack * track)
|
||||||
{
|
{
|
||||||
GESSmartAdder *self;
|
GESSmartAdder *self;
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
self = g_object_new (GES_TYPE_SMART_ADDER, NULL);
|
self = g_object_new (GES_TYPE_SMART_ADDER, NULL);
|
||||||
|
|
||||||
self->track = track;
|
self->track = track;
|
||||||
|
|
||||||
|
if (track) {
|
||||||
|
restriction_caps_cb (track, NULL, self);
|
||||||
|
|
||||||
|
g_signal_connect (track, "notify::restriction-caps",
|
||||||
|
G_CALLBACK (restriction_caps_cb), self);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME Make adder smart and let it properly negotiate caps! */
|
/* FIXME Make adder smart and let it properly negotiate caps! */
|
||||||
caps = gst_caps_from_string (DEFAULT_CAPS);
|
|
||||||
g_object_set (self->adder, "caps", caps, NULL);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
|
|
||||||
return GST_ELEMENT (self);
|
return GST_ELEMENT (self);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue