1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Blackmagic DeckLink output
3cabdff1aSopenharmony_ci * Copyright (c) 2013-2014 Ramiro Polla
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci#include "libavformat/avformat.h"
23cabdff1aSopenharmony_ci#include "libavutil/opt.h"
24cabdff1aSopenharmony_ci
25cabdff1aSopenharmony_ci#include "decklink_common_c.h"
26cabdff1aSopenharmony_ci#include "decklink_enc.h"
27cabdff1aSopenharmony_ci
28cabdff1aSopenharmony_ci#define OFFSET(x) offsetof(struct decklink_cctx, x)
29cabdff1aSopenharmony_ci#define ENC AV_OPT_FLAG_ENCODING_PARAM
30cabdff1aSopenharmony_cistatic const AVOption options[] = {
31cabdff1aSopenharmony_ci    { "list_devices", "use ffmpeg -sinks decklink instead", OFFSET(list_devices), AV_OPT_TYPE_BOOL, { .i64 = 0   }, 0, 1, ENC | AV_OPT_FLAG_DEPRECATED},
32cabdff1aSopenharmony_ci    { "list_formats", "list supported formats"  , OFFSET(list_formats), AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 1, ENC },
33cabdff1aSopenharmony_ci    { "preroll"     , "video preroll in seconds", OFFSET(preroll     ), AV_OPT_TYPE_DOUBLE, { .dbl = 0.5 }, 0, 5, ENC },
34cabdff1aSopenharmony_ci#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000
35cabdff1aSopenharmony_ci    { "duplex_mode" , "duplex mode"             , OFFSET(duplex_mode ), AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 5, ENC, "duplex_mode"},
36cabdff1aSopenharmony_ci#else
37cabdff1aSopenharmony_ci    { "duplex_mode" , "duplex mode"             , OFFSET(duplex_mode ), AV_OPT_TYPE_INT   , { .i64 = 0   }, 0, 2, ENC, "duplex_mode"},
38cabdff1aSopenharmony_ci#endif
39cabdff1aSopenharmony_ci    { "unset"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "duplex_mode"},
40cabdff1aSopenharmony_ci    { "half"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "duplex_mode"},
41cabdff1aSopenharmony_ci    { "full"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "duplex_mode"},
42cabdff1aSopenharmony_ci#if BLACKMAGIC_DECKLINK_API_VERSION >= 0x0b000000
43cabdff1aSopenharmony_ci    { "one_sub_device_full",      NULL           ,0                   , AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "duplex_mode"},
44cabdff1aSopenharmony_ci    { "one_sub_device_half",      NULL           ,0                   , AV_OPT_TYPE_CONST , { .i64 = 3   }, 0, 0, ENC, "duplex_mode"},
45cabdff1aSopenharmony_ci    { "two_sub_device_full",      NULL           ,0                   , AV_OPT_TYPE_CONST , { .i64 = 4   }, 0, 0, ENC, "duplex_mode"},
46cabdff1aSopenharmony_ci    { "four_sub_device_half",     NULL           ,0                   , AV_OPT_TYPE_CONST , { .i64 = 5   }, 0, 0, ENC, "duplex_mode"},
47cabdff1aSopenharmony_ci#endif
48cabdff1aSopenharmony_ci    { "link" ,         "single/dual/quad SDI link configuration", OFFSET(link), AV_OPT_TYPE_INT, { .i64 = 0   }, 0, 3, ENC, "link"},
49cabdff1aSopenharmony_ci    { "unset"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "link"},
50cabdff1aSopenharmony_ci    { "single"      ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "link"},
51cabdff1aSopenharmony_ci    { "dual"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 2   }, 0, 0, ENC, "link"},
52cabdff1aSopenharmony_ci    { "quad"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 3   }, 0, 0, ENC, "link"},
53cabdff1aSopenharmony_ci    { "sqd"         , "set Square Division"     , OFFSET(sqd)         , AV_OPT_TYPE_INT,    { .i64 = -1  }, -1,1, ENC, "sqd"},
54cabdff1aSopenharmony_ci    { "unset"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = -1  }, 0, 0, ENC, "sqd"},
55cabdff1aSopenharmony_ci    { "false"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "sqd"},
56cabdff1aSopenharmony_ci    { "true"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "sqd"},
57cabdff1aSopenharmony_ci    { "level_a"     , "set SMPTE LevelA"        , OFFSET(level_a)     , AV_OPT_TYPE_INT,    { .i64 = -1  }, -1,1, ENC, "level_a"},
58cabdff1aSopenharmony_ci    { "unset"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = -1  }, 0, 0, ENC, "level_a"},
59cabdff1aSopenharmony_ci    { "false"       ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 0   }, 0, 0, ENC, "level_a"},
60cabdff1aSopenharmony_ci    { "true"        ,  NULL                     , 0                   , AV_OPT_TYPE_CONST , { .i64 = 1   }, 0, 0, ENC, "level_a"},
61cabdff1aSopenharmony_ci    { "timing_offset", "genlock timing pixel offset", OFFSET(timing_offset), AV_OPT_TYPE_INT,   { .i64 = INT_MIN }, INT_MIN, INT_MAX, ENC, "timing_offset"},
62cabdff1aSopenharmony_ci    { "unset"       ,  NULL                     , 0                        , AV_OPT_TYPE_CONST, { .i64 = INT_MIN },       0,       0, ENC, "timing_offset"},
63cabdff1aSopenharmony_ci    { NULL },
64cabdff1aSopenharmony_ci};
65cabdff1aSopenharmony_ci
66cabdff1aSopenharmony_cistatic const AVClass decklink_muxer_class = {
67cabdff1aSopenharmony_ci    .class_name = "Blackmagic DeckLink outdev",
68cabdff1aSopenharmony_ci    .item_name  = av_default_item_name,
69cabdff1aSopenharmony_ci    .option     = options,
70cabdff1aSopenharmony_ci    .version    = LIBAVUTIL_VERSION_INT,
71cabdff1aSopenharmony_ci    .category   = AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT,
72cabdff1aSopenharmony_ci};
73cabdff1aSopenharmony_ci
74cabdff1aSopenharmony_ciconst AVOutputFormat ff_decklink_muxer = {
75cabdff1aSopenharmony_ci    .name           = "decklink",
76cabdff1aSopenharmony_ci    .long_name      = NULL_IF_CONFIG_SMALL("Blackmagic DeckLink output"),
77cabdff1aSopenharmony_ci    .audio_codec    = AV_CODEC_ID_PCM_S16LE,
78cabdff1aSopenharmony_ci    .video_codec    = AV_CODEC_ID_WRAPPED_AVFRAME,
79cabdff1aSopenharmony_ci    .subtitle_codec = AV_CODEC_ID_NONE,
80cabdff1aSopenharmony_ci    .flags          = AVFMT_NOFILE,
81cabdff1aSopenharmony_ci    .get_device_list = ff_decklink_list_output_devices,
82cabdff1aSopenharmony_ci    .priv_class     = &decklink_muxer_class,
83cabdff1aSopenharmony_ci    .priv_data_size = sizeof(struct decklink_cctx),
84cabdff1aSopenharmony_ci    .write_header   = ff_decklink_write_header,
85cabdff1aSopenharmony_ci    .write_packet   = ff_decklink_write_packet,
86cabdff1aSopenharmony_ci    .write_trailer  = ff_decklink_write_trailer,
87cabdff1aSopenharmony_ci};
88