History

avdevice/decklink: add support for setting duplex mode

This patch also makes BlackMagic drivers v10.6.1 a hard requirement.

Marton Balint committed 10 years ago

Commit 8f9fa491 parent e22760a7 files · +48 −1Browse files

Unified · Split

7 files
  1. configure +2 −1
  2. doc/indevs.texi +4 −0
  3. libavdevice/decklink_common.cpp +33 −0
  4. libavdevice/decklink_common.h +3 −0
  5. libavdevice/decklink_common_c.h +1 −0
  6. libavdevice/decklink_dec.cpp +1 −0
  7. libavdevice/decklink_dec_c.c +4 −0
configure+2−1
@@ -5625,7 +5625,8 @@ enabled cuvid && { check_lib cuviddec.h cuvidCreateDecoder -lnvcuvid · 5624 unmodified lines
56255625 enabled chromaprint && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint
56265626 enabled coreimage_filter && { check_header_objcc QuartzCore/CoreImage.h || disable coreimage_filter; }
56275627 enabled coreimagesrc_filter && { check_header_objcc QuartzCore/CoreImage.h || disable coreimagesrc_filter; }
5628−enabled decklink && { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; }
5628+enabled decklink && { { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; } &&
5629+ { check_cpp_condition DeckLinkAPIVersion.h "BLACKMAGIC_DECKLINK_API_VERSION >= 0x0a060100" || die "ERROR: Decklink API version must be >= 10.6.1."; } }
56295630 enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
56305631 enabled gmp && require2 gmp gmp.h mpz_export -lgmp
56315632 enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
doc/indevs.texi+4−0
@@ -251,6 +251,10 @@ To use this option, ffmpeg needs to be compiled with @code{--enable-libzvbi}. · 250 unmodified lines
251251 Defines number of audio channels to capture. Must be @samp{2}, @samp{8} or @samp{16}.
252252 Defaults to @samp{2}.
253253
254+@item duplex_mode
255+Sets the decklink device duplex mode. Must be @samp{unset}, @samp{half} or @samp{full}.
256+Defaults to @samp{unset}.
257+
254258 @end table
255259
256260 @subsection Examples
libavdevice/decklink_common.cpp+33−0
@@ -111,6 +111,23 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 110 unmodified lines
111111 int i = 1;
112112 HRESULT res;
113113
114+ if (ctx->duplex_mode) {
115+ bool duplex_supported = false;
116+
117+ if (ctx->attr->GetFlag(BMDDeckLinkSupportsDuplexModeConfiguration, &duplex_supported) != S_OK)
118+ duplex_supported = false;
119+
120+ if (duplex_supported) {
121+ res = ctx->cfg->SetInt(bmdDeckLinkConfigDuplexMode, ctx->duplex_mode == 2 ? bmdDuplexModeFull : bmdDuplexModeHalf);
122+ if (res != S_OK)
123+ av_log(avctx, AV_LOG_WARNING, "Setting duplex mode failed.\n");
124+ else
125+ av_log(avctx, AV_LOG_VERBOSE, "Succesfully set duplex mode to %s duplex.\n", ctx->duplex_mode == 2 ? "full" : "half");
126+ } else {
127+ av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because it is not supported.\n");
128+ }
129+ }
130+
114131 if (direction == DIRECTION_IN) {
115132 res = ctx->dli->GetDisplayModeIterator (&itermode);
116133 } else {
@@ -249,6 +266,10 @@ void ff_decklink_cleanup(AVFormatContext *avctx) · 132 unmodified lines
249266 ctx->dli->Release();
250267 if (ctx->dlo)
251268 ctx->dlo->Release();
269+ if (ctx->attr)
270+ ctx->attr->Release();
271+ if (ctx->cfg)
272+ ctx->cfg->Release();
252273 if (ctx->dl)
253274 ctx->dl->Release();
254275 }
@@ -279,5 +300,17 @@ int ff_decklink_init_device(AVFormatContext *avctx, const char* name) · 24 unmodified lines
279300 if (!ctx->dl)
280301 return AVERROR(ENXIO);
281302
303+ if (ctx->dl->QueryInterface(IID_IDeckLinkConfiguration, (void **)&ctx->cfg) != S_OK) {
304+ av_log(avctx, AV_LOG_ERROR, "Could not get configuration interface for '%s'\n", name);
305+ ff_decklink_cleanup(avctx);
306+ return AVERROR_EXTERNAL;
307+ }
308+
309+ if (ctx->dl->QueryInterface(IID_IDeckLinkAttributes, (void **)&ctx->attr) != S_OK) {
310+ av_log(avctx, AV_LOG_ERROR, "Could not get attributes interface for '%s'\n", name);
311+ ff_decklink_cleanup(avctx);
312+ return AVERROR_EXTERNAL;
313+ }
314+
282315 return 0;
283316 }
libavdevice/decklink_common.h+3−0
@@ -44,6 +44,8 @@ struct decklink_ctx { · 43 unmodified lines
4444 IDeckLink *dl;
4545 IDeckLinkOutput *dlo;
4646 IDeckLinkInput *dli;
47+ IDeckLinkConfiguration *cfg;
48+ IDeckLinkAttributes *attr;
4749 decklink_output_callback *output_callback;
4850 decklink_input_callback *input_callback;
4951
@@ -77,6 +79,7 @@ struct decklink_ctx { · 27 unmodified lines
7779 int list_formats;
7880 int64_t teletext_lines;
7981 double preroll;
82+ int duplex_mode;
8083
8184 int frames_preroll;
8285 int frames_buffer;
libavdevice/decklink_common_c.h+1−0
@@ -34,6 +34,7 @@ struct decklink_cctx { · 33 unmodified lines
3434 double preroll;
3535 int v210;
3636 int audio_channels;
37+ int duplex_mode;
3738 };
3839
3940 #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
libavdevice/decklink_dec.cpp+1−0
@@ -445,6 +445,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 444 unmodified lines
445445 ctx->list_formats = cctx->list_formats;
446446 ctx->teletext_lines = cctx->teletext_lines;
447447 ctx->preroll = cctx->preroll;
448+ ctx->duplex_mode = cctx->duplex_mode;
448449 cctx->ctx = ctx;
449450
450451 #if !CONFIG_LIBZVBI
libavdevice/decklink_dec_c.c+4−0
@@ -36,6 +36,10 @@ static const AVOption options[] = { · 35 unmodified lines
3636 { "standard", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7fff9fffeLL}, 0, 0, DEC, "teletext_lines"},
3737 { "all", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0x7ffffffffLL}, 0, 0, DEC, "teletext_lines"},
3838 { "channels", "number of audio channels", OFFSET(audio_channels), AV_OPT_TYPE_INT , { .i64 = 2 }, 2, 16, DEC },
39+ { "duplex_mode", "duplex mode", OFFSET(duplex_mode), AV_OPT_TYPE_INT, { .i64 = 0}, 0, 2, DEC, "duplex_mode"},
40+ { "unset", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0}, 0, 0, DEC, "duplex_mode"},
41+ { "half", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1}, 0, 0, DEC, "duplex_mode"},
42+ { "full", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2}, 0, 0, DEC, "duplex_mode"},
3943 { NULL },
4044 };
4145

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t