diff --git a/sys/decklink/gstdecklinkaudiosrc.cpp b/sys/decklink/gstdecklinkaudiosrc.cpp index 4ec47a81ca..5824f90870 100644 --- a/sys/decklink/gstdecklinkaudiosrc.cpp +++ b/sys/decklink/gstdecklinkaudiosrc.cpp @@ -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_stop (GstBaseSrc * bsrc); +static GstCaps *gst_decklink_audio_src_get_caps (GstBaseSrc * bsrc, + GstCaps * filter); static gboolean gst_decklink_audio_src_query (GstBaseSrc * bsrc, 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->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_stop = GST_DEBUG_FUNCPTR (gst_decklink_audio_src_unlock_stop); @@ -797,6 +800,42 @@ retry: 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 gst_decklink_audio_src_query (GstBaseSrc * bsrc, GstQuery * query) { diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 4edeffd668..40dc31db2a 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -223,6 +223,8 @@ static GstStateChangeReturn gst_decklink_video_src_change_state (GstElement * element, GstStateChange transition); +static GstCaps *gst_decklink_video_src_get_caps (GstBaseSrc * bsrc, + GstCaps * filter); static gboolean gst_decklink_video_src_query (GstBaseSrc * bsrc, GstQuery * query); 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->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_stop = GST_DEBUG_FUNCPTR (gst_decklink_video_src_unlock_stop); @@ -1374,6 +1377,31 @@ retry: 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 gst_decklink_video_src_query (GstBaseSrc * bsrc, GstQuery * query) {