+static GstCaps *
+gst_decklink_audio_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
+{
+ GstDecklinkAudioSink *self = GST_DECKLINK_AUDIO_SINK_CAST (bsink);
+ GstDecklinkAudioSinkRingBuffer *buf =
+ GST_DECKLINK_AUDIO_SINK_RING_BUFFER_CAST (GST_AUDIO_BASE_SINK_CAST
+ (self)->ringbuffer);
+ GstCaps *caps = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink));
+
+ if (buf) {
+ GST_OBJECT_LOCK (buf);
+ if (buf->output && buf->output->attributes) {
+ gint64 max_channels = 0;
+ HRESULT ret;
+ GstStructure *s;
+ GValue arr = G_VALUE_INIT;
+ GValue v = G_VALUE_INIT;
+
+ ret = buf->output->attributes->GetInt (BMDDeckLinkMaximumAudioChannels, &max_channels);
+ /* 2 should always be supported */
+ if (ret != S_OK) {
+ max_channels = 2;
+ }
+
+ caps = gst_caps_make_writable (caps);
+ s = gst_caps_get_structure (caps, 0);
+
+ g_value_init (&arr, GST_TYPE_LIST);
+ g_value_init (&v, G_TYPE_INT);
+ if (max_channels >= 16) {
+ g_value_set_int (&v, 16);
+ gst_value_list_append_value (&arr, &v);
+ }
+ if (max_channels >= 8) {
+ g_value_set_int (&v, 8);
+ gst_value_list_append_value (&arr, &v);
+ }
+ g_value_set_int (&v, 2);
+ gst_value_list_append_value (&arr, &v);
+
+ gst_structure_set_value (s, "channels", &arr);
+ g_value_unset (&v);
+ g_value_unset (&arr);
+ }
+ GST_OBJECT_UNLOCK (buf);
+ }
+
+ if (filter) {
+ GstCaps *intersection = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
+ gst_caps_unref (caps);
+ caps = intersection;
+ }
+
+ return caps;
+}
+