From f9898e42f6cd6fdab499a46d8c8d4e8d0f9af6fb Mon Sep 17 00:00:00 2001 From: Youri Westerman Date: Fri, 19 Jul 2013 20:09:28 +0200 Subject: [PATCH] decklink: add "device-number" to select from multiple devices https://bugzilla.gnome.org/show_bug.cgi?id=704505 --- sys/decklink/gstdecklinksink.cpp | 27 ++++++++++++--------------- sys/decklink/gstdecklinksink.h | 2 +- sys/decklink/gstdecklinksrc.cpp | 27 ++++++++++++--------------- sys/decklink/gstdecklinksrc.h | 2 +- 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/sys/decklink/gstdecklinksink.cpp b/sys/decklink/gstdecklinksink.cpp index 9abde79..b0c86ee 100644 --- a/sys/decklink/gstdecklinksink.cpp +++ b/sys/decklink/gstdecklinksink.cpp @@ -82,7 +82,7 @@ enum { PROP_0, PROP_MODE, - PROP_DEVICE + PROP_DEVICE_NUMBER }; /* pad templates */ @@ -120,14 +120,11 @@ gst_decklink_sink_class_init (GstDecklinkSinkClass * klass) (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT))); - /* FIXME: should be device-number or so, or turned into a string */ -#if 0 - g_object_class_install_property (gobject_class, PROP_DEVICE, - g_param_spec_int ("device", "Device", "Capture device instance to use", - 0, G_MAXINT, 0, + 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, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT))); -#endif gst_element_class_add_pad_template (element_class, gst_pad_template_new ("videosink", GST_PAD_SINK, GST_PAD_ALWAYS, @@ -182,7 +179,7 @@ gst_decklink_sink_init (GstDecklinkSink * decklinksink) g_cond_init (&decklinksink->audio_cond); decklinksink->mode = GST_DECKLINK_MODE_NTSC; - decklinksink->device = 0; + decklinksink->device_number = 0; decklinksink->callback = new Output; decklinksink->callback->decklinksink = decklinksink; @@ -219,8 +216,8 @@ gst_decklink_sink_set_property (GObject * object, guint property_id, case PROP_MODE: decklinksink->mode = (GstDecklinkModeEnum) g_value_get_enum (value); break; - case PROP_DEVICE: - decklinksink->device = g_value_get_int (value); + case PROP_DEVICE_NUMBER: + decklinksink->device_number = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -241,8 +238,8 @@ gst_decklink_sink_get_property (GObject * object, guint property_id, case PROP_MODE: g_value_set_enum (value, decklinksink->mode); break; - case PROP_DEVICE: - g_value_set_int (value, decklinksink->device); + case PROP_DEVICE_NUMBER: + g_value_set_int (value, decklinksink->device_number); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -331,13 +328,13 @@ gst_decklink_sink_start (GstDecklinkSink * decklinksink) const GstDecklinkMode *mode; BMDAudioSampleType sample_depth; - decklinksink->decklink = gst_decklink_get_nth_device (decklinksink->device); + decklinksink->decklink = gst_decklink_get_nth_device (decklinksink->device_number); if (!decklinksink->decklink) { - GST_WARNING ("failed to get device %d", decklinksink->device); + GST_WARNING ("failed to get device %d", decklinksink->device_number); return FALSE; } - decklinksink->output = gst_decklink_get_nth_output (decklinksink->device); + decklinksink->output = gst_decklink_get_nth_output (decklinksink->device_number); decklinksink->output->SetAudioCallback (decklinksink->callback); diff --git a/sys/decklink/gstdecklinksink.h b/sys/decklink/gstdecklinksink.h index 541e254..47ca22f 100644 --- a/sys/decklink/gstdecklinksink.h +++ b/sys/decklink/gstdecklinksink.h @@ -81,7 +81,7 @@ struct _GstDecklinkSink /* properties */ GstDecklinkModeEnum mode; - int device; + int device_number; #ifdef _MSC_VER gboolean comInitialized; diff --git a/sys/decklink/gstdecklinksrc.cpp b/sys/decklink/gstdecklinksrc.cpp index 5234c97..859016d 100644 --- a/sys/decklink/gstdecklinksrc.cpp +++ b/sys/decklink/gstdecklinksrc.cpp @@ -81,7 +81,7 @@ enum PROP_MODE, PROP_CONNECTION, PROP_AUDIO_INPUT, - PROP_DEVICE + PROP_DEVICE_NUMBER }; static GstStaticPadTemplate gst_decklink_src_audio_src_template = @@ -132,14 +132,11 @@ gst_decklink_src_class_init (GstDecklinkSrcClass * klass) (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT))); - /* FIXME: should be device-number or so, or turned into a string */ -#if 0 - g_object_class_install_property (gobject_class, PROP_DEVICE, - g_param_spec_int ("device", "Device", "Capture device instance to use", - 0, G_MAXINT, 0, + g_object_class_install_property (gobject_class, PROP_DEVICE_NUMBER, + g_param_spec_int ("device-number", "Device number", + "Capture device instance to use", 0, G_MAXINT, 0, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT))); -#endif gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_decklink_src_audio_src_template)); @@ -188,7 +185,7 @@ gst_decklink_src_init (GstDecklinkSrc * decklinksrc) decklinksrc->mode = GST_DECKLINK_MODE_NTSC; decklinksrc->connection = GST_DECKLINK_CONNECTION_SDI; decklinksrc->audio_connection = GST_DECKLINK_AUDIO_CONNECTION_AUTO; - decklinksrc->device = 0; + decklinksrc->device_number = 0; decklinksrc->stop = FALSE; decklinksrc->dropped_frames = 0; @@ -237,8 +234,8 @@ gst_decklink_src_set_property (GObject * object, guint property_id, decklinksrc->audio_connection = (GstDecklinkAudioConnectionEnum) g_value_get_enum (value); break; - case PROP_DEVICE: - decklinksrc->device = g_value_get_int (value); + case PROP_DEVICE_NUMBER: + decklinksrc->device_number = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -264,8 +261,8 @@ gst_decklink_src_get_property (GObject * object, guint property_id, case PROP_AUDIO_INPUT: g_value_set_enum (value, decklinksrc->audio_connection); break; - case PROP_DEVICE: - g_value_set_int (value, decklinksrc->device); + case PROP_DEVICE_NUMBER: + g_value_set_int (value, decklinksrc->device_number); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -419,12 +416,12 @@ gst_decklink_src_start (GstElement * element) GST_DEBUG_OBJECT (decklinksrc, "start"); - decklinksrc->decklink = gst_decklink_get_nth_device (decklinksrc->device); + decklinksrc->decklink = gst_decklink_get_nth_device (decklinksrc->device_number); if (decklinksrc->decklink == NULL) { return FALSE; } - decklinksrc->input = gst_decklink_get_nth_input (decklinksrc->device); + decklinksrc->input = gst_decklink_get_nth_input (decklinksrc->device_number); delegate = new DeckLinkCaptureDelegate (); delegate->priv = decklinksrc; @@ -434,7 +431,7 @@ gst_decklink_src_start (GstElement * element) return FALSE; } - decklinksrc->config = gst_decklink_get_nth_config (decklinksrc->device); + decklinksrc->config = gst_decklink_get_nth_config (decklinksrc->device_number); config = decklinksrc->config; switch (decklinksrc->connection) { diff --git a/sys/decklink/gstdecklinksrc.h b/sys/decklink/gstdecklinksrc.h index e6be409..f071b66 100644 --- a/sys/decklink/gstdecklinksrc.h +++ b/sys/decklink/gstdecklinksrc.h @@ -82,7 +82,7 @@ struct _GstDecklinkSrc GstDecklinkModeEnum mode; GstDecklinkConnectionEnum connection; GstDecklinkAudioConnectionEnum audio_connection; - int device; + int device_number; #ifdef _MSC_VER gboolean comInitialized; -- 2.7.4