diff options
author | Marton Balint <cus@passwd.hu> | 2016-06-18 12:04:15 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2016-06-26 19:18:02 +0200 |
commit | da89c6e37cf2fb3645611e8196cc28b6acfb9bd6 (patch) | |
tree | a53225df829e12250d4bb8c0e316dde7eb8dd317 /libavdevice/decklink_common.cpp | |
parent | 8f9fa49bd8bfd8cd2008da97eec7acf18873b960 (diff) | |
download | ffmpeg-da89c6e37cf2fb3645611e8196cc28b6acfb9bd6.tar.gz |
avdevice/decklink: add support for audio and video input selection
Reviewed-by: Deti Fliegl <deti@fliegl.de>
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/decklink_common.cpp')
-rw-r--r-- | libavdevice/decklink_common.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index b6a2c96584..362567341e 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -98,6 +98,35 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName) return hr; } +static int decklink_select_input(AVFormatContext *avctx, BMDDeckLinkConfigurationID cfg_id) +{ + struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data; + struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; + BMDDeckLinkAttributeID attr_id = (cfg_id == bmdDeckLinkConfigAudioInputConnection) ? BMDDeckLinkAudioInputConnections : BMDDeckLinkVideoInputConnections; + int64_t bmd_input = (cfg_id == bmdDeckLinkConfigAudioInputConnection) ? ctx->audio_input : ctx->video_input; + const char *type_name = (cfg_id == bmdDeckLinkConfigAudioInputConnection) ? "audio" : "video"; + int64_t supported_connections = 0; + HRESULT res; + + if (bmd_input) { + res = ctx->attr->GetInt(attr_id, &supported_connections); + if (res != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Failed to query supported %s inputs.\n", type_name); + return AVERROR_EXTERNAL; + } + if ((supported_connections & bmd_input) != bmd_input) { + av_log(avctx, AV_LOG_ERROR, "Device does not support selected %s input.\n", type_name); + return AVERROR(ENOSYS); + } + res = ctx->cfg->SetInt(cfg_id, bmd_input); + if (res != S_OK) { + av_log(avctx, AV_LOG_ERROR, "Failed to select %s input.\n", type_name); + return AVERROR_EXTERNAL; + } + } + return 0; +} + int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, @@ -129,6 +158,13 @@ int ff_decklink_set_format(AVFormatContext *avctx, } if (direction == DIRECTION_IN) { + int ret; + ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection); + if (ret < 0) + return ret; + ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection); + if (ret < 0) + return ret; res = ctx->dli->GetDisplayModeIterator (&itermode); } else { res = ctx->dlo->GetDisplayModeIterator (&itermode); @@ -224,6 +260,13 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct HRESULT res; if (direction == DIRECTION_IN) { + int ret; + ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection); + if (ret < 0) + return ret; + ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection); + if (ret < 0) + return ret; res = ctx->dli->GetDisplayModeIterator (&itermode); } else { res = ctx->dlo->GetDisplayModeIterator (&itermode); |