2011-06-06 04:24:58 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2011 David Schleef <ds@schleef.org>
|
2014-12-13 16:23:31 +00:00
|
|
|
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
|
2015-01-06 13:02:38 +00:00
|
|
|
* Copyright (C) 2015 Florian Langlois <florian.langlois@fr.thalesgroup.com>
|
2011-06-06 04:24:58 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2011-06-06 04:24:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GST_DECKLINK_H_
|
|
|
|
#define _GST_DECKLINK_H_
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2016-04-14 15:26:33 +00:00
|
|
|
#include <gst/video/video.h>
|
2011-08-22 01:44:43 +00:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
#include "linux/DeckLinkAPI.h"
|
|
|
|
#endif
|
2011-06-06 04:24:58 +00:00
|
|
|
|
2011-08-22 01:44:43 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include "win/DeckLinkAPI.h"
|
2011-07-07 20:44:31 +00:00
|
|
|
|
|
|
|
#include <comutil.h>
|
|
|
|
|
|
|
|
#define bool BOOL
|
|
|
|
|
|
|
|
#define COMSTR_T BSTR*
|
|
|
|
#define FREE_COM_STRING(s) delete[] s;
|
|
|
|
#define CONVERT_COM_STRING(s) BSTR _s = (BSTR)s; s = _com_util::ConvertBSTRToString(_s); ::SysFreeString(_s);
|
|
|
|
#else
|
|
|
|
#define COMSTR_T char*
|
|
|
|
#define FREE_COM_STRING(s) free ((void *) s)
|
|
|
|
#define CONVERT_COM_STRING(s)
|
|
|
|
#endif /* _MSC_VER */
|
2011-06-06 04:24:58 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2015-01-08 15:42:31 +00:00
|
|
|
GST_DECKLINK_MODE_AUTO,
|
|
|
|
|
2011-06-06 04:24:58 +00:00
|
|
|
GST_DECKLINK_MODE_NTSC,
|
2011-06-29 06:47:18 +00:00
|
|
|
GST_DECKLINK_MODE_NTSC2398,
|
2011-06-06 04:24:58 +00:00
|
|
|
GST_DECKLINK_MODE_PAL,
|
2011-06-29 06:47:18 +00:00
|
|
|
GST_DECKLINK_MODE_NTSC_P,
|
|
|
|
GST_DECKLINK_MODE_PAL_P,
|
|
|
|
|
|
|
|
GST_DECKLINK_MODE_1080p2398,
|
|
|
|
GST_DECKLINK_MODE_1080p24,
|
|
|
|
GST_DECKLINK_MODE_1080p25,
|
|
|
|
GST_DECKLINK_MODE_1080p2997,
|
|
|
|
GST_DECKLINK_MODE_1080p30,
|
|
|
|
|
2011-06-06 04:24:58 +00:00
|
|
|
GST_DECKLINK_MODE_1080i50,
|
2011-06-29 06:47:18 +00:00
|
|
|
GST_DECKLINK_MODE_1080i5994,
|
2011-06-06 04:24:58 +00:00
|
|
|
GST_DECKLINK_MODE_1080i60,
|
2011-06-29 06:47:18 +00:00
|
|
|
|
|
|
|
GST_DECKLINK_MODE_1080p50,
|
|
|
|
GST_DECKLINK_MODE_1080p5994,
|
|
|
|
GST_DECKLINK_MODE_1080p60,
|
|
|
|
|
2011-06-06 04:24:58 +00:00
|
|
|
GST_DECKLINK_MODE_720p50,
|
2011-06-29 06:47:18 +00:00
|
|
|
GST_DECKLINK_MODE_720p5994,
|
2014-11-24 13:07:19 +00:00
|
|
|
GST_DECKLINK_MODE_720p60,
|
|
|
|
|
2015-05-11 10:18:28 +00:00
|
|
|
GST_DECKLINK_MODE_1556p2398,
|
|
|
|
GST_DECKLINK_MODE_1556p24,
|
|
|
|
GST_DECKLINK_MODE_1556p25,
|
2014-12-29 10:49:51 +00:00
|
|
|
|
2015-05-11 10:02:47 +00:00
|
|
|
GST_DECKLINK_MODE_2160p2398,
|
|
|
|
GST_DECKLINK_MODE_2160p24,
|
|
|
|
GST_DECKLINK_MODE_2160p25,
|
|
|
|
GST_DECKLINK_MODE_2160p2997,
|
|
|
|
GST_DECKLINK_MODE_2160p30,
|
|
|
|
GST_DECKLINK_MODE_2160p50,
|
|
|
|
GST_DECKLINK_MODE_2160p5994,
|
|
|
|
GST_DECKLINK_MODE_2160p60
|
2011-06-06 04:24:58 +00:00
|
|
|
} GstDecklinkModeEnum;
|
|
|
|
#define GST_TYPE_DECKLINK_MODE (gst_decklink_mode_get_type ())
|
|
|
|
GType gst_decklink_mode_get_type (void);
|
|
|
|
|
2011-06-20 07:38:05 +00:00
|
|
|
typedef enum {
|
2015-01-08 11:17:45 +00:00
|
|
|
GST_DECKLINK_CONNECTION_AUTO,
|
2011-06-20 07:38:05 +00:00
|
|
|
GST_DECKLINK_CONNECTION_SDI,
|
|
|
|
GST_DECKLINK_CONNECTION_HDMI,
|
|
|
|
GST_DECKLINK_CONNECTION_OPTICAL_SDI,
|
|
|
|
GST_DECKLINK_CONNECTION_COMPONENT,
|
|
|
|
GST_DECKLINK_CONNECTION_COMPOSITE,
|
|
|
|
GST_DECKLINK_CONNECTION_SVIDEO
|
|
|
|
} GstDecklinkConnectionEnum;
|
|
|
|
#define GST_TYPE_DECKLINK_CONNECTION (gst_decklink_connection_get_type ())
|
|
|
|
GType gst_decklink_connection_get_type (void);
|
2011-06-06 04:24:58 +00:00
|
|
|
|
2011-07-07 23:07:50 +00:00
|
|
|
typedef enum {
|
|
|
|
GST_DECKLINK_AUDIO_CONNECTION_AUTO,
|
|
|
|
GST_DECKLINK_AUDIO_CONNECTION_EMBEDDED,
|
|
|
|
GST_DECKLINK_AUDIO_CONNECTION_AES_EBU,
|
2015-01-08 11:23:53 +00:00
|
|
|
GST_DECKLINK_AUDIO_CONNECTION_ANALOG,
|
|
|
|
GST_DECKLINK_AUDIO_CONNECTION_ANALOG_XLR,
|
|
|
|
GST_DECKLINK_AUDIO_CONNECTION_ANALOG_RCA
|
2011-07-07 23:07:50 +00:00
|
|
|
} GstDecklinkAudioConnectionEnum;
|
|
|
|
#define GST_TYPE_DECKLINK_AUDIO_CONNECTION (gst_decklink_audio_connection_get_type ())
|
|
|
|
GType gst_decklink_audio_connection_get_type (void);
|
|
|
|
|
2016-04-14 15:26:33 +00:00
|
|
|
typedef enum {
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_AUTO,
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_8BIT_YUV, /* bmdFormat8BitYUV */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_10BIT_YUV, /* bmdFormat10BitYUV */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_8BIT_ARGB, /* bmdFormat8BitARGB */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_8BIT_BGRA, /* bmdFormat8BitBGRA */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_10BIT_RGB, /* bmdFormat10BitRGB */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_12BIT_RGB, /* bmdFormat12BitRGB */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_12BIT_RGBLE, /* bmdFormat12BitRGBLE */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_10BIT_RGBXLE, /* bmdFormat10BitRGBXLE */
|
|
|
|
GST_DECKLINK_VIDEO_FORMAT_10BIT_RGBX, /* bmdFormat10BitRGBX */
|
|
|
|
} GstDecklinkVideoFormat;
|
|
|
|
#define GST_TYPE_DECKLINK_VIDEO_FORMAT (gst_decklink_video_format_get_type ())
|
|
|
|
GType gst_decklink_video_format_get_type (void);
|
|
|
|
|
|
|
|
const BMDPixelFormat gst_decklink_pixel_format_from_type (GstDecklinkVideoFormat t);
|
|
|
|
const gint gst_decklink_bpp_from_type (GstDecklinkVideoFormat t);
|
|
|
|
const GstDecklinkVideoFormat gst_decklink_type_from_video_format (GstVideoFormat f);
|
|
|
|
|
2011-06-06 04:24:58 +00:00
|
|
|
typedef struct _GstDecklinkMode GstDecklinkMode;
|
|
|
|
struct _GstDecklinkMode {
|
|
|
|
BMDDisplayMode mode;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int fps_n;
|
|
|
|
int fps_d;
|
|
|
|
gboolean interlaced;
|
2011-06-29 06:47:18 +00:00
|
|
|
int par_n;
|
|
|
|
int par_d;
|
|
|
|
gboolean tff;
|
2015-01-13 18:56:24 +00:00
|
|
|
const gchar *colorimetry;
|
2011-06-06 04:24:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const GstDecklinkMode * gst_decklink_get_mode (GstDecklinkModeEnum e);
|
2015-01-08 15:42:31 +00:00
|
|
|
const GstDecklinkModeEnum gst_decklink_get_mode_enum_from_bmd (BMDDisplayMode mode);
|
2015-01-06 13:02:38 +00:00
|
|
|
const BMDVideoConnection gst_decklink_get_connection (GstDecklinkConnectionEnum e);
|
2016-01-13 21:05:49 +00:00
|
|
|
GstCaps * gst_decklink_mode_get_caps (GstDecklinkModeEnum e, BMDPixelFormat f);
|
2011-06-29 06:47:18 +00:00
|
|
|
GstCaps * gst_decklink_mode_get_template_caps (void);
|
2011-06-06 04:24:58 +00:00
|
|
|
|
2014-12-13 16:23:31 +00:00
|
|
|
typedef struct _GstDecklinkOutput GstDecklinkOutput;
|
|
|
|
struct _GstDecklinkOutput {
|
|
|
|
IDeckLink *device;
|
|
|
|
IDeckLinkOutput *output;
|
|
|
|
GstClock *clock;
|
2015-09-23 13:56:26 +00:00
|
|
|
GstClockTime clock_start_time, clock_last_time, clock_epoch;
|
2015-01-28 13:21:40 +00:00
|
|
|
GstClockTimeDiff clock_offset;
|
|
|
|
gboolean started, clock_restart;
|
2014-12-13 16:23:31 +00:00
|
|
|
|
|
|
|
/* Everything below protected by mutex */
|
|
|
|
GMutex lock;
|
|
|
|
|
2014-12-19 11:03:09 +00:00
|
|
|
/* Set by the video source */
|
|
|
|
/* Configured mode or NULL */
|
|
|
|
const GstDecklinkMode *mode;
|
|
|
|
|
2014-12-13 16:23:31 +00:00
|
|
|
/* Set by the audio sink */
|
|
|
|
GstClock *audio_clock;
|
|
|
|
|
|
|
|
GstElement *audiosink;
|
2015-01-28 13:21:40 +00:00
|
|
|
gboolean audio_enabled;
|
2014-12-13 16:23:31 +00:00
|
|
|
GstElement *videosink;
|
2015-01-28 13:21:40 +00:00
|
|
|
gboolean video_enabled;
|
2015-01-28 14:48:26 +00:00
|
|
|
void (*start_scheduled_playback) (GstElement *videosink);
|
2014-12-13 16:23:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GstDecklinkInput GstDecklinkInput;
|
|
|
|
struct _GstDecklinkInput {
|
|
|
|
IDeckLink *device;
|
|
|
|
IDeckLinkInput *input;
|
|
|
|
IDeckLinkConfiguration *config;
|
2015-01-08 15:42:31 +00:00
|
|
|
IDeckLinkAttributes *attributes;
|
2014-12-13 16:23:31 +00:00
|
|
|
GstClock *clock;
|
2015-09-23 13:56:26 +00:00
|
|
|
GstClockTime clock_start_time, clock_offset, clock_last_time, clock_epoch;
|
2015-01-28 13:21:40 +00:00
|
|
|
gboolean started, clock_restart;
|
2014-12-13 16:23:31 +00:00
|
|
|
|
|
|
|
/* Everything below protected by mutex */
|
|
|
|
GMutex lock;
|
|
|
|
|
2014-12-18 16:31:20 +00:00
|
|
|
/* Set by the video source */
|
2015-02-09 16:17:37 +00:00
|
|
|
void (*got_video_frame) (GstElement *videosrc, IDeckLinkVideoInputFrame * frame, GstDecklinkModeEnum mode, GstClockTime capture_time, GstClockTime capture_duration);
|
2014-12-19 11:03:09 +00:00
|
|
|
/* Configured mode or NULL */
|
|
|
|
const GstDecklinkMode *mode;
|
2016-01-13 21:05:49 +00:00
|
|
|
BMDPixelFormat format;
|
2014-12-18 16:31:20 +00:00
|
|
|
|
2014-12-13 16:23:31 +00:00
|
|
|
/* Set by the audio source */
|
2016-04-04 19:21:30 +00:00
|
|
|
void (*got_audio_packet) (GstElement *videosrc, IDeckLinkAudioInputPacket * packet, GstClockTime capture_time, gboolean discont);
|
2014-12-13 16:23:31 +00:00
|
|
|
|
|
|
|
GstElement *audiosrc;
|
2015-01-28 13:21:40 +00:00
|
|
|
gboolean audio_enabled;
|
2016-04-04 19:21:30 +00:00
|
|
|
gboolean audio_discont;
|
2014-12-13 16:23:31 +00:00
|
|
|
GstElement *videosrc;
|
2015-01-28 13:21:40 +00:00
|
|
|
gboolean video_enabled;
|
2015-01-28 14:26:17 +00:00
|
|
|
void (*start_streams) (GstElement *videosrc);
|
2014-12-13 16:23:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
GstDecklinkOutput * gst_decklink_acquire_nth_output (gint n, GstElement * sink, gboolean is_audio);
|
|
|
|
void gst_decklink_release_nth_output (gint n, GstElement * sink, gboolean is_audio);
|
|
|
|
|
|
|
|
void gst_decklink_output_set_audio_clock (GstDecklinkOutput * output, GstClock * clock);
|
|
|
|
GstClock * gst_decklink_output_get_audio_clock (GstDecklinkOutput * output);
|
2011-06-06 04:24:58 +00:00
|
|
|
|
2014-12-18 16:31:20 +00:00
|
|
|
GstDecklinkInput * gst_decklink_acquire_nth_input (gint n, GstElement * src, gboolean is_audio);
|
|
|
|
void gst_decklink_release_nth_input (gint n, GstElement * src, gboolean is_audio);
|
|
|
|
|
2015-12-17 15:26:29 +00:00
|
|
|
const GstDecklinkMode * gst_decklink_find_mode_for_caps (GstCaps * caps);
|
2016-04-14 15:26:33 +00:00
|
|
|
const GstDecklinkMode * gst_decklink_find_mode_and_format_for_caps (GstCaps * caps, BMDPixelFormat * format);
|
|
|
|
GstCaps * gst_decklink_mode_get_caps_all_formats (GstDecklinkModeEnum e);
|
|
|
|
GstCaps * gst_decklink_pixel_format_get_caps (BMDPixelFormat f);
|
2015-12-17 15:26:29 +00:00
|
|
|
|
2011-06-06 04:24:58 +00:00
|
|
|
#endif
|