Showing the changes to libavdevice/decklink_common.cpp (1 of 4 files). Show all
Unified · Split
| @@ -252,3 +252,32 @@ void ff_decklink_cleanup(AVFormatContext *avctx) · 251 unmodified lines | ||
| 252 | 252 | if (ctx->dl) |
| 253 | 253 | ctx->dl->Release(); |
| 254 | 254 | } |
| 255 | + | |
| 256 | +int ff_decklink_init_device(AVFormatContext *avctx, const char* name) | |
| 257 | +{ | |
| 258 | + struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; | |
| 259 | + struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; | |
| 260 | + IDeckLink *dl = NULL; | |
| 261 | + IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance(); | |
| 262 | + if (!iter) { | |
| 263 | + av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n"); | |
| 264 | + return AVERROR_EXTERNAL; | |
| 265 | + } | |
| 266 | + | |
| 267 | + while (iter->Next(&dl) == S_OK) { | |
| 268 | + const char *displayName; | |
| 269 | + ff_decklink_get_display_name(dl, &displayName); | |
| 270 | + if (!strcmp(name, displayName)) { | |
| 271 | + av_free((void *)displayName); | |
| 272 | + ctx->dl = dl; | |
| 273 | + break; | |
| 274 | + } | |
| 275 | + av_free((void *)displayName); | |
| 276 | + dl->Release(); | |
| 277 | + } | |
| 278 | + iter->Release(); | |
| 279 | + if (!ctx->dl) | |
| 280 | + return AVERROR(ENXIO); | |
| 281 | + | |
| 282 | + return 0; | |
| 283 | +} | |