aboutsummaryrefslogtreecommitdiffstats
path: root/libavdevice/decklink_enc.cpp
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2016-06-18 16:55:47 +0200
committerMarton Balint <cus@passwd.hu>2016-06-26 19:17:45 +0200
commit38d75fe90696fb80a5a78840443bc9bb421fe924 (patch)
tree6260115dd2456b22c9da4d4d1bfa89d12a6e1568 /libavdevice/decklink_enc.cpp
parent4ce0a77ec80f71a9726e85d66063248bf4165bfb (diff)
downloadffmpeg-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_enc.cpp')
-rw-r--r--libavdevice/decklink_enc.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 3f4b22cdbf..f59bd82a6b 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -312,9 +312,8 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
{
struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
struct decklink_ctx *ctx;
- IDeckLinkIterator *iter;
- IDeckLink *dl = NULL;
unsigned int n;
+ int ret;
ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx));
if (!ctx)
@@ -324,35 +323,15 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
ctx->preroll = cctx->preroll;
cctx->ctx = ctx;
- iter = CreateDeckLinkIteratorInstance();
- if (!iter) {
- av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
- return AVERROR(EIO);
- }
-
/* List available devices. */
if (ctx->list_devices) {
ff_decklink_list_devices(avctx);
return AVERROR_EXIT;
}
- /* Open device. */
- while (iter->Next(&dl) == S_OK) {
- const char *displayName;
- ff_decklink_get_display_name(dl, &displayName);
- if (!strcmp(avctx->filename, displayName)) {
- av_free((void *) displayName);
- ctx->dl = dl;
- break;
- }
- av_free((void *) displayName);
- dl->Release();
- }
- iter->Release();
- if (!ctx->dl) {
- av_log(avctx, AV_LOG_ERROR, "Could not open '%s'\n", avctx->filename);
- return AVERROR(EIO);
- }
+ ret = ff_decklink_init_device(avctx, avctx->filename);
+ if (ret < 0)
+ return ret;
/* Get output device. */
if (ctx->dl->QueryInterface(IID_IDeckLinkOutput, (void **) &ctx->dlo) != S_OK) {