int main (int argc, char* argv[]) { printf("DeckControl Test Application\n\n"); IDeckLinkIterator* deckLinkIterator; IDeckLink* deckLink; int numDevices = 0; HRESULT result; fdSerial = -1; // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system deckLinkIterator = CreateDeckLinkIteratorInstance(); if (deckLinkIterator == NULL) { fprintf(stderr, "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.\n"); return 1; } // Enumerate all cards in this system while (deckLinkIterator->Next(&deckLink) == S_OK) { CFStringRef deviceNameCFString = NULL; // Increment the total number of DeckLink cards found numDevices++; if (numDevices > 1) printf("\n\n"); // *** Print the model name of the DeckLink card result = deckLink->GetModelName(&deviceNameCFString); if (result == S_OK) { IDeckLinkAttributes* deckLinkAttributes; char deviceName[64]; HRESULT attributeResult; CFStringRef serialName; bool serialSupported; CFStringGetCString(deviceNameCFString, deviceName, sizeof(deviceName), kCFStringEncodingMacRoman); printf("Found Blackmagic device: %s\n", deviceName); attributeResult = deckLink->QueryInterface(IID_IDeckLinkAttributes, (void**)&deckLinkAttributes); if (attributeResult != S_OK) { fprintf(stderr, "Could not obtain the IDeckLinkAttributes interface"); } else { attributeResult = deckLinkAttributes->GetFlag(BMDDeckLinkHasSerialPort, &serialSupported); // are serial ports supported on device? if (attributeResult == S_OK && serialSupported) { attributeResult = deckLinkAttributes->GetString(BMDDeckLinkSerialPortDeviceName, &serialName); // get serial port name if (attributeResult == S_OK) { char portName[64]; CFStringGetCString(serialName, portName, sizeof(portName), kCFStringEncodingMacRoman); printf("Serial port name: %s\n",portName); if (openSerialDevice((char*)&portName)== true) // open serial port { printf("Device opened\n"); playCommand(); // Play deck, printf("Delay 3 seconds\n"); sleep(3); timeCodeCommand(); // DisplayTC printf("Delay 3 seconds\n"); sleep(3); stopCommand(); // Stop deck closeSerialDevice(); // close serial port } else printf("Device open fail\n"); CFRelease(serialName); } else printf("Unable to get serial port device name\n"); } else printf("Serial port not supported\n"); } CFRelease(deviceNameCFString); // Release the IDeckLink instance when we've finished with it to prevent leaks } deckLink->Release(); } if (deckLinkIterator) deckLinkIterator->Release(); // If no DeckLink cards were found in the system, inform the user if (numDevices == 0) printf("No Blackmagic Design devices were found.\n"); printf("\n"); return 0; }
static void print_attributes (IDeckLink* deckLink) { IDeckLinkAttributes* deckLinkAttributes = NULL; bool supported; int64_t count; char * serialPortName = NULL; HRESULT result; // Query the DeckLink for its attributes interface result = deckLink->QueryInterface(IID_IDeckLinkAttributes, (void**)&deckLinkAttributes); if (result != S_OK) { fprintf(stderr, "Could not obtain the IDeckLinkAttributes interface - result = %08x\n", result); goto bail; } // List attributes and their value printf("Attribute list:\n"); result = deckLinkAttributes->GetFlag(BMDDeckLinkHasSerialPort, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Serial port present ?", (supported == true) ? "Yes" : "No"); if (supported) { CFStringRef serialPortNameString = CFStringCreateWithCString(kCFAllocatorDefault, serialPortName, kCFStringEncodingMacRoman); result = deckLinkAttributes->GetString(BMDDeckLinkSerialPortDeviceName, &serialPortNameString); if (result == S_OK) { printf(" %-40s %s\n", "Serial port name: ", serialPortName); free(serialPortName); } else { fprintf(stderr, "Could not query the serial port presence attribute- result = %08x\n", result); } } } else { fprintf(stderr, "Could not query the serial port presence attribute- result = %08x\n", result); } result = deckLinkAttributes->GetInt(BMDDeckLinkNumberOfSubDevices, &count); if (result == S_OK) { printf(" %-40s %lld\n", "Number of sub-devices:", count); if (count != 0) { result = deckLinkAttributes->GetInt(BMDDeckLinkSubDeviceIndex, &count); if (result == S_OK) { printf(" %-40s %lld\n", "Sub-device index:", count); } else { fprintf(stderr, "Could not query the sub-device index attribute- result = %08x\n", result); } } } else { fprintf(stderr, "Could not query the number of sub-device attribute- result = %08x\n", result); } result = deckLinkAttributes->GetInt(BMDDeckLinkMaximumAudioChannels, &count); if (result == S_OK) { printf(" %-40s %lld\n", "Number of audio channels:", count); } else { fprintf(stderr, "Could not query the number of supported audio channels attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Input mode detection supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the input mode detection attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsInternalKeying, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Internal keying supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the internal keying attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsExternalKeying, &supported); if (result == S_OK) { printf(" %-40s %s\n", "External keying supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the external keying attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsHDKeying, &supported); if (result == S_OK) { printf(" %-40s %s\n", "HD-mode keying supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the HD-mode keying attribute- result = %08x\n", result); } bail: printf("\n"); if(deckLinkAttributes != NULL) deckLinkAttributes->Release(); }
void print_attributes (IDeckLink* deckLink) { IDeckLinkAttributes* deckLinkAttributes = NULL; bool supported; int64_t value; char * serialPortName = NULL; HRESULT result; // Query the DeckLink for its attributes interface result = deckLink->QueryInterface(IID_IDeckLinkAttributes, (void**)&deckLinkAttributes); if (result != S_OK) { fprintf(stderr, "Could not obtain the IDeckLinkAttributes interface - result = %08x\n", result); goto bail; } // List attributes and their value printf("Attribute list:\n"); result = deckLinkAttributes->GetFlag(BMDDeckLinkHasSerialPort, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Serial port present ?", (supported == true) ? "Yes" : "No"); if (supported) { result = deckLinkAttributes->GetString(BMDDeckLinkSerialPortDeviceName, (const char **) &serialPortName); if (result == S_OK) { printf(" %-40s %s\n", "Serial port name: ", serialPortName); free(serialPortName); } else { fprintf(stderr, "Could not query the serial port presence attribute- result = %08x\n", result); } } } else { fprintf(stderr, "Could not query the serial port presence attribute- result = %08x\n", result); } result = deckLinkAttributes->GetInt(BMDDeckLinkPersistentID, &value); if (result == S_OK) { printf(" %-40s %llx\n", "Device Persistent ID:", value); } else { printf(" %-40s %s\n", "Device Persistent ID:", "Not Supported on this device"); } result = deckLinkAttributes->GetInt(BMDDeckLinkTopologicalID, &value); if (result == S_OK) { printf(" %-40s %llx\n", "Device Topological ID:", value); } else { printf(" %-40s %s\n", "Device Topological ID:", "Not Supported on this device"); } result = deckLinkAttributes->GetInt(BMDDeckLinkNumberOfSubDevices, &value); if (result == S_OK) { printf(" %-40s %" PRId64 "\n", "Number of sub-devices:", value); if (value != 0) { result = deckLinkAttributes->GetInt(BMDDeckLinkSubDeviceIndex, &value); if (result == S_OK) { printf(" %-40s %" PRId64 "\n", "Sub-device index:", value); } else { fprintf(stderr, "Could not query the sub-device index attribute- result = %08x\n", result); } } } else { fprintf(stderr, "Could not query the number of sub-device attribute- result = %08x\n", result); } result = deckLinkAttributes->GetInt(BMDDeckLinkMaximumAudioChannels, &value); if (result == S_OK) { printf(" %-40s %" PRId64 "\n", "Number of audio channels:", value); } else { fprintf(stderr, "Could not query the number of supported audio channels attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Input mode detection supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the input mode detection attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsFullDuplex, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Full duplex operation supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the full duplex operation supported attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsInternalKeying, &supported); if (result == S_OK) { printf(" %-40s %s\n", "Internal keying supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the internal keying attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsExternalKeying, &supported); if (result == S_OK) { printf(" %-40s %s\n", "External keying supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the external keying attribute- result = %08x\n", result); } result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsHDKeying, &supported); if (result == S_OK) { printf(" %-40s %s\n", "HD-mode keying supported ?", (supported == true) ? "Yes" : "No"); } else { fprintf(stderr, "Could not query the HD-mode keying attribute- result = %08x\n", result); } bail: printf("\n"); if(deckLinkAttributes != NULL) deckLinkAttributes->Release(); }