| 59 | #include "decklink_common.h" |
| 60 | |
| 61 | static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx) |
| 62 | { |
| 63 | IDeckLinkIterator *iter; |
| 64 | |
| 65 | #ifdef _WIN32 |
| 66 | if (CoInitialize(NULL) < 0) { |
| 67 | av_log(avctx, AV_LOG_ERROR, "COM initialization failed.\n"); |
| 68 | return NULL; |
| 69 | } |
| 70 | |
| 71 | if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, |
| 72 | IID_IDeckLinkIterator, (void**) &iter) != S_OK) { |
| 73 | iter = NULL; |
| 74 | } |
| 75 | #else |
| 76 | iter = CreateDeckLinkIteratorInstance(); |
| 77 | #endif |
| 78 | if (!iter) { |
| 79 | av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator. " |
| 80 | "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); |
| 81 | } else { |
| 82 | IDeckLinkAPIInformation *api; |
| 83 | int64_t version; |
| 84 | #ifdef _WIN32 |
| 85 | if (CoCreateInstance(CLSID_CDeckLinkAPIInformation, NULL, CLSCTX_ALL, |
| 86 | IID_IDeckLinkAPIInformation, (void**) &api) != S_OK) { |
| 87 | api = NULL; |
| 88 | } |
| 89 | #else |
| 90 | api = CreateDeckLinkAPIInformationInstance(); |
| 91 | #endif |
| 92 | if (api && api->GetInt(BMDDeckLinkAPIVersion, &version) == S_OK) { |
| 93 | if (version < BLACKMAGIC_DECKLINK_API_VERSION) |
| 94 | av_log(avctx, AV_LOG_WARNING, "Installed DeckLink drivers are too old and may be incompatible with the SDK this module was built against. " |
| 95 | "Make sure you have DeckLink drivers " BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n"); |
| 96 | } else { |
| 97 | av_log(avctx, AV_LOG_ERROR, "Failed to check installed DeckLink API version.\n"); |
| 98 | } |
| 99 | if (api) |
| 100 | api->Release(); |
| 101 | } |
| 102 | |
| 103 | return iter; |
| 104 | } |
| 105 | |
| 106 | static int decklink_get_attr_string(IDeckLink *dl, BMDDeckLinkAttributeID cfg_id, const char **s) |
| 107 | { |
no test coverage detected