1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
27 BMInterface::BMInterface()
32 void BMInterface::getBlackMagicDeviceList(KComboBox *devicelist, KComboBox *modelist)
34 IDeckLinkIterator* deckLinkIterator;
39 // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system
40 deckLinkIterator = CreateDeckLinkIteratorInstance();
41 if (deckLinkIterator == NULL)
43 kDebug()<< "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.";
47 // Enumerate all cards in this system
48 while (deckLinkIterator->Next(&deckLink) == S_OK)
50 char * deviceNameString = NULL;
52 // Increment the total number of DeckLink cards found
55 kDebug()<<"// FOUND a BM device\n\n+++++++++++++++++++++++++++++++++++++";
57 // *** Print the model name of the DeckLink card
58 result = deckLink->GetModelName((const char **) &deviceNameString);
61 QString deviceName(deviceNameString);
62 free(deviceNameString);
64 IDeckLinkInput* deckLinkInput = NULL;
65 IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
66 IDeckLinkDisplayMode* displayMode = NULL;
69 // Query the DeckLink for its configuration interface
70 result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput);
73 kDebug()<< "Could not obtain the IDeckLinkInput interface - result = "<<result;
77 // Obtain an IDeckLinkDisplayModeIterator to enumerate the display modes supported on output
78 result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator);
81 kDebug()<< "Could not obtain the video input display mode iterator - result = "<<result;
84 QStringList availableModes;
85 // List all supported output display modes
86 while (displayModeIterator->Next(&displayMode) == S_OK)
88 char * displayModeString = NULL;
90 result = displayMode->GetName((const char **) &displayModeString);
96 BMDTimeValue frameRateDuration;
97 BMDTimeScale frameRateScale;
98 //int pixelFormatIndex = 0; // index into the gKnownPixelFormats / gKnownFormatNames arrays
99 //BMDDisplayModeSupport displayModeSupport;
102 // Obtain the display mode's properties
103 modeWidth = displayMode->GetWidth();
104 modeHeight = displayMode->GetHeight();
105 displayMode->GetFrameRate(&frameRateDuration, &frameRateScale);
106 QString description = QString(displayModeString) + " (" + QString::number(modeWidth) + "x" + QString::number(modeHeight) + " - " + QString::number((double)frameRateScale / (double)frameRateDuration) + i18n("fps") + ")";
107 availableModes << description;
108 //modelist->addItem(description);
109 //printf(" %-20s \t %d x %d \t %7g FPS\t", displayModeString, modeWidth, modeHeight, (double)frameRateScale / (double)frameRateDuration);
111 // Print the supported pixel formats for this display mode
112 /*while ((gKnownPixelFormats[pixelFormatIndex] != 0) && (gKnownPixelFormatNames[pixelFormatIndex] != NULL))
114 if ((deckLinkOutput->DoesSupportVideoMode(displayMode->GetDisplayMode(), gKnownPixelFormats[pixelFormatIndex], bmdVideoOutputFlagDefault, &displayModeSupport, NULL) == S_OK)
115 && (displayModeSupport != bmdDisplayModeNotSupported))
117 printf("%s\t", gKnownPixelFormatNames[pixelFormatIndex]);
121 free(displayModeString);
124 // Release the IDeckLinkDisplayMode object to prevent a leak
125 displayMode->Release();
127 devicelist->addItem(deviceName, availableModes);
131 //print_attributes(deckLink);
133 // ** List the video output display modes supported by the card
134 //print_output_modes(deckLink);
136 // ** List the input and output capabilities of the card
137 //print_capabilities(deckLink);
139 // Release the IDeckLink instance when we've finished with it to prevent leaks
143 deckLinkIterator->Release();
144 if (modelist != NULL && devicelist->count() > 0) {
145 QStringList modes = devicelist->itemData(devicelist->currentIndex()).toStringList();
146 modelist->insertItems(0, modes);