summaryrefslogtreecommitdiff
path: root/libavdevice/decklink_dec.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_dec.cpp
parent4ce0a77ec80f71a9726e85d66063248bf4165bfb (diff)
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_dec.cpp')
-rw-r--r--libavdevice/decklink_dec.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 0d652bc8db..0d789425fd 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -431,13 +431,12 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
{
struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
struct decklink_ctx *ctx;
- IDeckLinkIterator *iter;
- IDeckLink *dl = NULL;
AVStream *st;
HRESULT result;
char fname[1024];
char *tmp;
int mode_num = 0;
+ int ret;
ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx));
if (!ctx)
@@ -466,12 +465,6 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
return AVERROR(EINVAL);
}
- 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);
@@ -485,23 +478,9 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
*tmp = 0;
}
- /* Open device. */
- while (iter->Next(&dl) == S_OK) {
- const char *displayName;
- ff_decklink_get_display_name(dl, &displayName);
- if (!strcmp(fname, 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", fname);
- return AVERROR(EIO);
- }
+ ret = ff_decklink_init_device(avctx, fname);
+ if (ret < 0)
+ return ret;
/* Get input device. */
if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {