History

avdevice/decklink: add support for audio and video input selection

Marton Balint committed 10 years ago

Commit da89c6e1 parent 8f9fa496 files · +97 −0Browse files

Showing the changes to libavdevice/decklink_common.cpp (1 of 6 files). Show all

Unified · Split

libavdevice/decklink_common.cpp+43−0
@@ -98,6 +98,35 @@ HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName) · 97 unmodified lines
98 return hr;98 return hr;
99}99}
100 100
101static 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
101int ff_decklink_set_format(AVFormatContext *avctx,130int ff_decklink_set_format(AVFormatContext *avctx,
102 int width, int height,131 int width, int height,
103 int tb_num, int tb_den,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 if (direction == DIRECTION_IN) {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 res = ctx->dli->GetDisplayModeIterator (&itermode);168 res = ctx->dli->GetDisplayModeIterator (&itermode);
133 } else {169 } else {
134 res = ctx->dlo->GetDisplayModeIterator (&itermode);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 HRESULT res;260 HRESULT res;
225 261
226 if (direction == DIRECTION_IN) {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 res = ctx->dli->GetDisplayModeIterator (&itermode);270 res = ctx->dli->GetDisplayModeIterator (&itermode);
228 } else {271 } else {
229 res = ctx->dlo->GetDisplayModeIterator (&itermode);272 res = ctx->dlo->GetDisplayModeIterator (&itermode);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t