History

avdevice/decklink: factorize device finder function

Marton Balint committed 10 years ago

Commit 38d75fe1 parent 4ce0a774 files · +38 −50Browse files

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

Unified · Split

libavdevice/decklink_common.cpp+29−0
@@ -252,3 +252,32 @@ void ff_decklink_cleanup(AVFormatContext *avctx) · 251 unmodified lines
252252 if (ctx->dl)
253253 ctx->dl->Release();
254254 }
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+}

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