From 81c1ef190d1abc5ac122ecfa1063f4af4747190e Mon Sep 17 00:00:00 2001 From: Florian Langlois Date: Tue, 6 Jan 2015 14:02:38 +0100 Subject: [PATCH] decklink: Add property for configuring the input connection of the video sources --- sys/decklink/gstdecklink.cpp | 20 ++++++++++++++++ sys/decklink/gstdecklink.h | 2 ++ sys/decklink/gstdecklinkvideosrc.cpp | 34 ++++++++++++++++++++++++++++ sys/decklink/gstdecklinkvideosrc.h | 2 ++ 4 files changed, 58 insertions(+) diff --git a/sys/decklink/gstdecklink.cpp b/sys/decklink/gstdecklink.cpp index 7e207b7b90..fed5f3056f 100644 --- a/sys/decklink/gstdecklink.cpp +++ b/sys/decklink/gstdecklink.cpp @@ -1,6 +1,7 @@ /* GStreamer * Copyright (C) 2011 David Schleef * Copyright (C) 2014 Sebastian Dröge + * Copyright (C) 2015 Florian Langlois * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -175,9 +176,28 @@ static const GstDecklinkMode modes[] = { const GstDecklinkMode * gst_decklink_get_mode (GstDecklinkModeEnum e) { + if (e < GST_DECKLINK_MODE_NTSC || e > GST_DECKLINK_MODE_3184p60) + return NULL; return &modes[e]; } +static const BMDVideoConnection connections[] = { + bmdVideoConnectionSDI, + bmdVideoConnectionHDMI, + bmdVideoConnectionOpticalSDI, + bmdVideoConnectionComponent, + bmdVideoConnectionComposite, + bmdVideoConnectionSVideo +}; + +const BMDVideoConnection +gst_decklink_get_connection (GstDecklinkConnectionEnum e) +{ + if (e < GST_DECKLINK_CONNECTION_SDI || e > GST_DECKLINK_CONNECTION_SVIDEO) + e = GST_DECKLINK_CONNECTION_SDI; + return connections[e]; +} + static GstStructure * gst_decklink_mode_get_structure (GstDecklinkModeEnum e) { diff --git a/sys/decklink/gstdecklink.h b/sys/decklink/gstdecklink.h index 3c25ed9fc0..80e6348fc6 100644 --- a/sys/decklink/gstdecklink.h +++ b/sys/decklink/gstdecklink.h @@ -1,6 +1,7 @@ /* GStreamer * Copyright (C) 2011 David Schleef * Copyright (C) 2014 Sebastian Dröge + * Copyright (C) 2015 Florian Langlois * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -118,6 +119,7 @@ struct _GstDecklinkMode { }; const GstDecklinkMode * gst_decklink_get_mode (GstDecklinkModeEnum e); +const BMDVideoConnection gst_decklink_get_connection (GstDecklinkConnectionEnum e); GstCaps * gst_decklink_mode_get_caps (GstDecklinkModeEnum e); GstCaps * gst_decklink_mode_get_template_caps (void); diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index 1cbbb08e59..7014eff5e4 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -1,6 +1,7 @@ /* GStreamer * Copyright (C) 2011 David Schleef * Copyright (C) 2014 Sebastian Dröge + * Copyright (C) 2015 Florian Langlois * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -34,6 +35,7 @@ enum { PROP_0, PROP_MODE, + PROP_CONNECTION, PROP_DEVICE_NUMBER, PROP_BUFFER_SIZE }; @@ -129,6 +131,13 @@ gst_decklink_video_src_class_init (GstDecklinkVideoSrcClass * klass) (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT))); + g_object_class_install_property (gobject_class, PROP_CONNECTION, + g_param_spec_enum ("connection", "Connection", + "Video input connection to use", + GST_TYPE_DECKLINK_CONNECTION, GST_DECKLINK_CONNECTION_SDI, + (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | + G_PARAM_CONSTRUCT))); + g_object_class_install_property (gobject_class, PROP_DEVICE_NUMBER, g_param_spec_int ("device-number", "Device number", "Output device instance to use", 0, G_MAXINT, 0, @@ -158,6 +167,7 @@ static void gst_decklink_video_src_init (GstDecklinkVideoSrc * self) { self->mode = GST_DECKLINK_MODE_NTSC; + self->connection = GST_DECKLINK_CONNECTION_SDI; self->device_number = 0; self->buffer_size = DEFAULT_BUFFER_SIZE; @@ -180,6 +190,9 @@ gst_decklink_video_src_set_property (GObject * object, guint property_id, case PROP_MODE: self->mode = (GstDecklinkModeEnum) g_value_get_enum (value); break; + case PROP_CONNECTION: + self->connection = (GstDecklinkConnectionEnum) g_value_get_enum (value); + break; case PROP_DEVICE_NUMBER: self->device_number = g_value_get_int (value); break; @@ -202,6 +215,9 @@ gst_decklink_video_src_get_property (GObject * object, guint property_id, case PROP_MODE: g_value_set_enum (value, self->mode); break; + case PROP_CONNECTION: + g_value_set_enum (value, self->connection); + break; case PROP_DEVICE_NUMBER: g_value_set_int (value, self->device_number); break; @@ -410,6 +426,24 @@ gst_decklink_video_src_open (GstDecklinkVideoSrc * self) return FALSE; } + if (self->input->config) { + ret = self->input->config->SetInt (bmdDeckLinkConfigVideoInputConnection, + gst_decklink_get_connection(self->connection)); + if (ret != S_OK) { + GST_ERROR_OBJECT (self, "Failed to set configuration (input source)"); + return FALSE; + } + + if (self->connection == GST_DECKLINK_CONNECTION_COMPOSITE) { + ret = self->input->config->SetInt (bmdDeckLinkConfigAnalogVideoInputFlags, + bmdAnalogVideoFlagCompositeSetup75); + if (ret != S_OK) { + GST_ERROR_OBJECT (self, "Failed to set configuration (composite setup)"); + return FALSE; + } + } + } + mode = gst_decklink_get_mode (self->mode); g_assert (mode != NULL); diff --git a/sys/decklink/gstdecklinkvideosrc.h b/sys/decklink/gstdecklinkvideosrc.h index e8e5448480..da2da7dd0b 100644 --- a/sys/decklink/gstdecklinkvideosrc.h +++ b/sys/decklink/gstdecklinkvideosrc.h @@ -2,6 +2,7 @@ * * Copyright (C) 2011 David Schleef * Copyright (C) 2014 Sebastian Dröge + * Copyright (C) 2015 Florian Langlois * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -50,6 +51,7 @@ struct _GstDecklinkVideoSrc GstPushSrc parent; GstDecklinkModeEnum mode; + GstDecklinkConnectionEnum connection; gint device_number; GstVideoInfo info;