mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
decklink: Implement GstBaseSrc::get_caps() to return more constrained caps
Instead of the template caps we can return a subset of them based on the selected properties. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1868>
This commit is contained in:
parent
be0df31b15
commit
c123b79900
2 changed files with 67 additions and 0 deletions
|
@ -125,6 +125,8 @@ gst_decklink_audio_src_change_state (GstElement * element,
|
||||||
|
|
||||||
static gboolean gst_decklink_audio_src_unlock (GstBaseSrc * bsrc);
|
static gboolean gst_decklink_audio_src_unlock (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_decklink_audio_src_unlock_stop (GstBaseSrc * bsrc);
|
static gboolean gst_decklink_audio_src_unlock_stop (GstBaseSrc * bsrc);
|
||||||
|
static GstCaps *gst_decklink_audio_src_get_caps (GstBaseSrc * bsrc,
|
||||||
|
GstCaps * filter);
|
||||||
static gboolean gst_decklink_audio_src_query (GstBaseSrc * bsrc,
|
static gboolean gst_decklink_audio_src_query (GstBaseSrc * bsrc,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
|
||||||
|
@ -156,6 +158,7 @@ gst_decklink_audio_src_class_init (GstDecklinkAudioSrcClass * klass)
|
||||||
|
|
||||||
basesrc_class->query = GST_DEBUG_FUNCPTR (gst_decklink_audio_src_query);
|
basesrc_class->query = GST_DEBUG_FUNCPTR (gst_decklink_audio_src_query);
|
||||||
basesrc_class->negotiate = NULL;
|
basesrc_class->negotiate = NULL;
|
||||||
|
basesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_decklink_audio_src_get_caps);
|
||||||
basesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_decklink_audio_src_unlock);
|
basesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_decklink_audio_src_unlock);
|
||||||
basesrc_class->unlock_stop =
|
basesrc_class->unlock_stop =
|
||||||
GST_DEBUG_FUNCPTR (gst_decklink_audio_src_unlock_stop);
|
GST_DEBUG_FUNCPTR (gst_decklink_audio_src_unlock_stop);
|
||||||
|
@ -797,6 +800,42 @@ retry:
|
||||||
return flow_ret;
|
return flow_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_decklink_audio_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter)
|
||||||
|
{
|
||||||
|
GstDecklinkAudioSrc *self = GST_DECKLINK_AUDIO_SRC_CAST (bsrc);
|
||||||
|
GstCaps *caps, *template_caps;
|
||||||
|
const GstStructure *s;
|
||||||
|
gint channels;
|
||||||
|
|
||||||
|
channels = self->channels;
|
||||||
|
if (channels == 0)
|
||||||
|
channels = self->channels_found;
|
||||||
|
|
||||||
|
template_caps = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc));
|
||||||
|
if (channels == 0) {
|
||||||
|
caps = template_caps;
|
||||||
|
} else {
|
||||||
|
if (channels > 2)
|
||||||
|
s = gst_caps_get_structure (template_caps, 1);
|
||||||
|
else
|
||||||
|
s = gst_caps_get_structure (template_caps, 0);
|
||||||
|
|
||||||
|
caps = gst_caps_new_full (gst_structure_copy (s), NULL);
|
||||||
|
gst_caps_set_simple (caps, "channels", G_TYPE_INT, channels, NULL);
|
||||||
|
gst_caps_unref (template_caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
GstCaps *tmp =
|
||||||
|
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
caps = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_decklink_audio_src_query (GstBaseSrc * bsrc, GstQuery * query)
|
gst_decklink_audio_src_query (GstBaseSrc * bsrc, GstQuery * query)
|
||||||
{
|
{
|
||||||
|
|
|
@ -223,6 +223,8 @@ static GstStateChangeReturn
|
||||||
gst_decklink_video_src_change_state (GstElement * element,
|
gst_decklink_video_src_change_state (GstElement * element,
|
||||||
GstStateChange transition);
|
GstStateChange transition);
|
||||||
|
|
||||||
|
static GstCaps *gst_decklink_video_src_get_caps (GstBaseSrc * bsrc,
|
||||||
|
GstCaps * filter);
|
||||||
static gboolean gst_decklink_video_src_query (GstBaseSrc * bsrc,
|
static gboolean gst_decklink_video_src_query (GstBaseSrc * bsrc,
|
||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
static gboolean gst_decklink_video_src_unlock (GstBaseSrc * bsrc);
|
static gboolean gst_decklink_video_src_unlock (GstBaseSrc * bsrc);
|
||||||
|
@ -259,6 +261,7 @@ gst_decklink_video_src_class_init (GstDecklinkVideoSrcClass * klass)
|
||||||
|
|
||||||
basesrc_class->query = GST_DEBUG_FUNCPTR (gst_decklink_video_src_query);
|
basesrc_class->query = GST_DEBUG_FUNCPTR (gst_decklink_video_src_query);
|
||||||
basesrc_class->negotiate = NULL;
|
basesrc_class->negotiate = NULL;
|
||||||
|
basesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_decklink_video_src_get_caps);
|
||||||
basesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_decklink_video_src_unlock);
|
basesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_decklink_video_src_unlock);
|
||||||
basesrc_class->unlock_stop =
|
basesrc_class->unlock_stop =
|
||||||
GST_DEBUG_FUNCPTR (gst_decklink_video_src_unlock_stop);
|
GST_DEBUG_FUNCPTR (gst_decklink_video_src_unlock_stop);
|
||||||
|
@ -1374,6 +1377,31 @@ retry:
|
||||||
return flow_ret;
|
return flow_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_decklink_video_src_get_caps (GstBaseSrc * bsrc, GstCaps * filter)
|
||||||
|
{
|
||||||
|
GstDecklinkVideoSrc *self = GST_DECKLINK_VIDEO_SRC_CAST (bsrc);
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
if (self->mode != GST_DECKLINK_MODE_AUTO) {
|
||||||
|
caps = gst_decklink_mode_get_caps (self->mode, self->caps_format, TRUE);
|
||||||
|
} else if (self->caps_mode != GST_DECKLINK_MODE_AUTO) {
|
||||||
|
caps =
|
||||||
|
gst_decklink_mode_get_caps (self->caps_mode, self->caps_format, TRUE);
|
||||||
|
} else {
|
||||||
|
caps = gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (bsrc));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
GstCaps *tmp =
|
||||||
|
gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
caps = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_decklink_video_src_query (GstBaseSrc * bsrc, GstQuery * query)
|
gst_decklink_video_src_query (GstBaseSrc * bsrc, GstQuery * query)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue