diff options
author | Marton Balint <cus@passwd.hu> | 2016-06-18 16:55:47 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2016-06-26 19:17:45 +0200 |
commit | 38d75fe90696fb80a5a78840443bc9bb421fe924 (patch) | |
tree | 6260115dd2456b22c9da4d4d1bfa89d12a6e1568 /libavdevice/decklink_common.cpp | |
parent | 4ce0a77ec80f71a9726e85d66063248bf4165bfb (diff) | |
download | ffmpeg-38d75fe90696fb80a5a78840443bc9bb421fe924.tar.gz |
avdevice/decklink: factorize device finder function
Reviewed-by: Deti Fliegl <deti@fliegl.de>
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/decklink_common.cpp')
-rw-r--r-- | libavdevice/decklink_common.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index 43599b6b2b..2711fc1138 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -252,3 +252,32 @@ void ff_decklink_cleanup(AVFormatContext *avctx) if (ctx->dl) ctx->dl->Release(); } + +int ff_decklink_init_device(AVFormatContext *avctx, const char* name) +{ + struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; + struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; + IDeckLink *dl = NULL; + IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); + if (!iter) { + av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n"); + return AVERROR_EXTERNAL; + } + + while (iter->Next(&dl) == S_OK) { + const char *displayName; + ff_decklink_get_display_name(dl, &displayName); + if (!strcmp(name, displayName)) { + av_free((void *)displayName); + ctx->dl = dl; + break; + } + av_free((void *)displayName); + dl->Release(); + } + iter->Release(); + if (!ctx->dl) + return AVERROR(ENXIO); + + return 0; +} |