Showing the changes to libavdevice/decklink_common.cpp (1 of 6 files). Show all
Unified · Split
| @@ -98,6 +98,35 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName) · 97 unmodified lines | ||
| 98 | 98 | return hr; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | +static int decklink_select_input(AVFormatContext *avctx, BMDDeckLinkConfigurationID cfg_id) | |
| 102 | +{ | |
| 103 | + struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data; | |
| 104 | + struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; | |
| 105 | + BMDDeckLinkAttributeID attr_id = (cfg_id == bmdDeckLinkConfigAudioInputConnection) ? BMDDeckLinkAudioInputConnections : BMDDeckLinkVideoInputConnections; | |
| 106 | + int64_t bmd_input = (cfg_id == bmdDeckLinkConfigAudioInputConnection) ? ctx->audio_input : ctx->video_input; | |
| 107 | + const char *type_name = (cfg_id == bmdDeckLinkConfigAudioInputConnection) ? "audio" : "video"; | |
| 108 | + int64_t supported_connections = 0; | |
| 109 | + HRESULT res; | |
| 110 | + | |
| 111 | + if (bmd_input) { | |
| 112 | + res = ctx->attr->GetInt(attr_id, &supported_connections); | |
| 113 | + if (res != S_OK) { | |
| 114 | + av_log(avctx, AV_LOG_ERROR, "Failed to query supported %s inputs.\n", type_name); | |
| 115 | + return AVERROR_EXTERNAL; | |
| 116 | + } | |
| 117 | + if ((supported_connections & bmd_input) != bmd_input) { | |
| 118 | + av_log(avctx, AV_LOG_ERROR, "Device does not support selected %s input.\n", type_name); | |
| 119 | + return AVERROR(ENOSYS); | |
| 120 | + } | |
| 121 | + res = ctx->cfg->SetInt(cfg_id, bmd_input); | |
| 122 | + if (res != S_OK) { | |
| 123 | + av_log(avctx, AV_LOG_ERROR, "Failed to select %s input.\n", type_name); | |
| 124 | + return AVERROR_EXTERNAL; | |
| 125 | + } | |
| 126 | + } | |
| 127 | + return 0; | |
| 128 | +} | |
| 129 | + | |
| 101 | 130 | int ff_decklink_set_format(AVFormatContext *avctx, |
| 102 | 131 | int width, int height, |
| 103 | 132 | int tb_num, int tb_den, |
| @@ -129,6 +158,13 @@ int ff_decklink_set_format(AVFormatContext *avctx, · 25 unmodified lines | ||
| 129 | 158 | } |
| 130 | 159 | |
| 131 | 160 | if (direction == DIRECTION_IN) { |
| 161 | + int ret; | |
| 162 | + ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection); | |
| 163 | + if (ret < 0) | |
| 164 | + return ret; | |
| 165 | + ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection); | |
| 166 | + if (ret < 0) | |
| 167 | + return ret; | |
| 132 | 168 | res = ctx->dli->GetDisplayModeIterator (&itermode); |
| 133 | 169 | } else { |
| 134 | 170 | res = ctx->dlo->GetDisplayModeIterator (&itermode); |
| @@ -224,6 +260,13 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct · 89 unmodified lines | ||
| 224 | 260 | HRESULT res; |
| 225 | 261 | |
| 226 | 262 | if (direction == DIRECTION_IN) { |
| 263 | + int ret; | |
| 264 | + ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection); | |
| 265 | + if (ret < 0) | |
| 266 | + return ret; | |
| 267 | + ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection); | |
| 268 | + if (ret < 0) | |
| 269 | + return ret; | |
| 227 | 270 | res = ctx->dli->GetDisplayModeIterator (&itermode); |
| 228 | 271 | } else { |
| 229 | 272 | res = ctx->dlo->GetDisplayModeIterator (&itermode); |