| 506 | |
| 507 | |
| 508 | int ff_decklink_list_devices(AVFormatContext *avctx, |
| 509 | struct AVDeviceInfoList *device_list, |
| 510 | int show_inputs, int show_outputs) |
| 511 | { |
| 512 | IDeckLink *dl = NULL; |
| 513 | IDeckLinkIterator *iter = decklink_create_iterator(avctx); |
| 514 | int ret = 0; |
| 515 | |
| 516 | if (!iter) |
| 517 | return AVERROR(EIO); |
| 518 | |
| 519 | while (ret == 0 && iter->Next(&dl) == S_OK) { |
| 520 | IDeckLinkOutput_v14_2_1 *output_config; |
| 521 | IDeckLinkInput_v14_2_1 *input_config; |
| 522 | const char *display_name = NULL; |
| 523 | const char *unique_name = NULL; |
| 524 | AVDeviceInfo *new_device = NULL; |
| 525 | int add = 0; |
| 526 | |
| 527 | ret = decklink_get_attr_string(dl, BMDDeckLinkDisplayName, &display_name); |
| 528 | if (ret < 0) |
| 529 | goto next; |
| 530 | ret = decklink_get_attr_string(dl, BMDDeckLinkDeviceHandle, &unique_name); |
| 531 | if (ret < 0) |
| 532 | goto next; |
| 533 | |
| 534 | if (show_outputs) { |
| 535 | if (dl->QueryInterface(IID_IDeckLinkOutput_v14_2_1, (void **)&output_config) == S_OK) { |
| 536 | output_config->Release(); |
| 537 | add = 1; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | if (show_inputs) { |
| 542 | if (dl->QueryInterface(IID_IDeckLinkInput_v14_2_1, (void **)&input_config) == S_OK) { |
| 543 | input_config->Release(); |
| 544 | add = 1; |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | if (add == 1) { |
| 549 | new_device = (AVDeviceInfo *) av_mallocz(sizeof(AVDeviceInfo)); |
| 550 | if (!new_device) { |
| 551 | ret = AVERROR(ENOMEM); |
| 552 | goto next; |
| 553 | } |
| 554 | |
| 555 | new_device->device_name = av_strdup(unique_name ? unique_name : display_name); |
| 556 | new_device->device_description = av_strdup(display_name); |
| 557 | |
| 558 | if (!new_device->device_name || |
| 559 | !new_device->device_description || |
| 560 | av_dynarray_add_nofree(&device_list->devices, &device_list->nb_devices, new_device) < 0) { |
| 561 | ret = AVERROR(ENOMEM); |
| 562 | av_freep(&new_device->device_name); |
| 563 | av_freep(&new_device->device_description); |
| 564 | av_freep(&new_device); |
| 565 | goto next; |
no test coverage detected