| 668 | } |
| 669 | |
| 670 | int ff_decklink_init_device(AVFormatContext *avctx, const char* name) |
| 671 | { |
| 672 | struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; |
| 673 | struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; |
| 674 | IDeckLink *dl = NULL; |
| 675 | IDeckLinkIterator *iter = decklink_create_iterator(avctx); |
| 676 | if (!iter) |
| 677 | return AVERROR_EXTERNAL; |
| 678 | |
| 679 | while (iter->Next(&dl) == S_OK) { |
| 680 | const char *display_name = NULL; |
| 681 | const char *unique_name = NULL; |
| 682 | decklink_get_attr_string(dl, BMDDeckLinkDisplayName, &display_name); |
| 683 | decklink_get_attr_string(dl, BMDDeckLinkDeviceHandle, &unique_name); |
| 684 | if (display_name && !strcmp(name, display_name) || unique_name && !strcmp(name, unique_name)) { |
| 685 | av_free((void *)unique_name); |
| 686 | av_free((void *)display_name); |
| 687 | ctx->dl = dl; |
| 688 | break; |
| 689 | } |
| 690 | av_free((void *)display_name); |
| 691 | av_free((void *)unique_name); |
| 692 | dl->Release(); |
| 693 | } |
| 694 | iter->Release(); |
| 695 | if (!ctx->dl) |
| 696 | return AVERROR(ENXIO); |
| 697 | |
| 698 | if (ctx->dl->QueryInterface(IID_IDeckLinkConfiguration, (void **)&ctx->cfg) != S_OK) { |
| 699 | av_log(avctx, AV_LOG_ERROR, "Could not get configuration interface for '%s'\n", name); |
| 700 | ff_decklink_cleanup(avctx); |
| 701 | return AVERROR_EXTERNAL; |
| 702 | } |
| 703 | |
| 704 | if (ctx->dl->QueryInterface(IID_IDeckLinkProfileAttributes, (void **)&ctx->attr) != S_OK) { |
| 705 | av_log(avctx, AV_LOG_ERROR, "Could not get attributes interface for '%s'\n", name); |
| 706 | ff_decklink_cleanup(avctx); |
| 707 | return AVERROR_EXTERNAL; |
| 708 | } |
| 709 | |
| 710 | return 0; |
| 711 | } |
no test coverage detected