2 * Copyright (C) 2011 David Schleef <ds@schleef.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
17 * Boston, MA 02110-1335, USA.
25 #include "gstdecklink.h"
26 #include "gstdecklinksrc.h"
27 #include "gstdecklinksink.h"
30 gst_decklink_mode_get_type (void)
35 static const GEnumValue modes[] = {
36 {GST_DECKLINK_MODE_NTSC, "ntsc", "NTSC SD 60i"},
37 {GST_DECKLINK_MODE_NTSC2398, "ntsc2398", "NTSC SD 60i (24 fps)"},
38 {GST_DECKLINK_MODE_PAL, "pal", "PAL SD 50i"},
39 {GST_DECKLINK_MODE_NTSC_P, "ntsc-p", "NTSC SD 60p"},
40 {GST_DECKLINK_MODE_PAL_P, "pal-p", "PAL SD 50p"},
42 {GST_DECKLINK_MODE_1080p2398, "1080p2398", "HD1080 23.98p"},
43 {GST_DECKLINK_MODE_1080p24, "1080p24", "HD1080 24p"},
44 {GST_DECKLINK_MODE_1080p25, "1080p25", "HD1080 25p"},
45 {GST_DECKLINK_MODE_1080p2997, "1080p2997", "HD1080 29.97p"},
46 {GST_DECKLINK_MODE_1080p30, "1080p30", "HD1080 30p"},
48 {GST_DECKLINK_MODE_1080i50, "1080i50", "HD1080 50i"},
49 {GST_DECKLINK_MODE_1080i5994, "1080i5994", "HD1080 59.94i"},
50 {GST_DECKLINK_MODE_1080i60, "1080i60", "HD1080 60i"},
52 {GST_DECKLINK_MODE_1080p50, "1080p50", "HD1080 50p"},
53 {GST_DECKLINK_MODE_1080p5994, "1080p5994", "HD1080 59.94p"},
54 {GST_DECKLINK_MODE_1080p60, "1080p60", "HD1080 60p"},
56 {GST_DECKLINK_MODE_720p50, "720p50", "HD720 50p"},
57 {GST_DECKLINK_MODE_720p5994, "720p5994", "HD720 59.94p"},
58 {GST_DECKLINK_MODE_720p60, "720p60", "HD720 60p"},
63 type = g_enum_register_static ("GstDecklinkModes", modes);
69 gst_decklink_connection_get_type (void)
74 static const GEnumValue connections[] = {
75 {GST_DECKLINK_CONNECTION_SDI, "sdi", "SDI"},
76 {GST_DECKLINK_CONNECTION_HDMI, "hdmi", "HDMI"},
77 {GST_DECKLINK_CONNECTION_OPTICAL_SDI, "optical-sdi", "Optical SDI"},
78 {GST_DECKLINK_CONNECTION_COMPONENT, "component", "Component"},
79 {GST_DECKLINK_CONNECTION_COMPOSITE, "composite", "Composite"},
80 {GST_DECKLINK_CONNECTION_SVIDEO, "svideo", "S-Video"},
84 type = g_enum_register_static ("GstDecklinkConnection", connections);
90 gst_decklink_audio_connection_get_type (void)
95 static const GEnumValue connections[] = {
96 {GST_DECKLINK_AUDIO_CONNECTION_AUTO, "auto", "Automatic"},
97 {GST_DECKLINK_AUDIO_CONNECTION_EMBEDDED, "embedded", "SDI/HDMI embedded audio"},
98 {GST_DECKLINK_AUDIO_CONNECTION_AES_EBU, "aes", "AES/EBU input"},
99 {GST_DECKLINK_AUDIO_CONNECTION_ANALOG, "analog", "Analog input"},
103 type = g_enum_register_static ("GstDecklinkAudioConnection", connections);
108 #define NTSC 10, 11, false, false
109 #define PAL 12, 11, true, false
110 #define HD 1, 1, false, true
112 static const GstDecklinkMode modes[] = {
113 {bmdModeNTSC, 720, 486, 30000, 1001, true, NTSC },
114 {bmdModeNTSC2398, 720, 486, 24000, 1001, true, NTSC },
115 {bmdModePAL, 720, 576, 25, 1, true, PAL },
116 {bmdModeNTSCp, 720, 486, 30000, 1001, false, NTSC },
117 {bmdModePALp, 720, 576, 25, 1, false, PAL },
119 {bmdModeHD1080p2398, 1920, 1080, 24000, 1001, false, HD },
120 {bmdModeHD1080p24, 1920, 1080, 24, 1, false, HD },
121 {bmdModeHD1080p25, 1920, 1080, 25, 1, false, HD },
122 {bmdModeHD1080p2997, 1920, 1080, 30000, 1001, false, HD },
123 {bmdModeHD1080p30, 1920, 1080, 30, 1, false, HD },
125 {bmdModeHD1080i50, 1920, 1080, 25, 1, true, HD },
126 {bmdModeHD1080i5994, 1920, 1080, 30000, 1001, true, HD },
127 {bmdModeHD1080i6000, 1920, 1080, 30, 1, true, HD },
129 {bmdModeHD1080p50, 1920, 1080, 50, 1, false, HD },
130 {bmdModeHD1080p5994, 1920, 1080, 30000, 1001, false, HD },
131 {bmdModeHD1080p6000, 1920, 1080, 60, 1, false, HD },
133 {bmdModeHD720p50, 1280, 720, 50, 1, false, HD },
134 {bmdModeHD720p5994, 1280, 720, 60000, 1001, false, HD },
135 {bmdModeHD720p60, 1280, 720, 60, 1, false, HD }
139 const GstDecklinkMode *
140 gst_decklink_get_mode (GstDecklinkModeEnum e)
145 static GstStructure *
146 gst_decklink_mode_get_structure (GstDecklinkModeEnum e)
148 const GstDecklinkMode *mode = &modes[e];
150 return gst_structure_new ("video/x-raw-yuv",
151 "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'),
152 "width", G_TYPE_INT, mode->width,
153 "height", G_TYPE_INT, mode->height,
154 "framerate", GST_TYPE_FRACTION, mode->fps_n, mode->fps_d,
155 "interlaced", G_TYPE_BOOLEAN, mode->interlaced,
156 "pixel-aspect-ratio", GST_TYPE_FRACTION, mode->par_n, mode->par_d,
157 "color-matrix", G_TYPE_STRING, mode->is_hdtv ? "hdtv" : "sdtv",
158 "chroma-site", G_TYPE_STRING, "mpeg2",
163 gst_decklink_mode_get_caps (GstDecklinkModeEnum e)
167 caps = gst_caps_new_empty ();
168 gst_caps_append_structure (caps, gst_decklink_mode_get_structure (e));
174 gst_decklink_mode_get_template_caps (void)
180 caps = gst_caps_new_empty ();
181 for(i=0;i<(int)G_N_ELEMENTS(modes);i++) {
182 s = gst_decklink_mode_get_structure ((GstDecklinkModeEnum)i);
183 gst_caps_append_structure (caps, s);
190 plugin_init (GstPlugin * plugin)
193 gst_element_register (plugin, "decklinksrc", GST_RANK_NONE,
194 gst_decklink_src_get_type ());
195 gst_element_register (plugin, "decklinksink", GST_RANK_NONE,
196 gst_decklink_sink_get_type ());
201 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
204 "Blackmagic Decklink plugin",
205 plugin_init, VERSION, "LGPL", PACKAGE_NAME, GST_PACKAGE_ORIGIN)