QStringList BMDOutputDelegate::enumDeviceNames(bool forceReload) { if(!s_knownDevices.isEmpty()) { if(!forceReload) return s_knownDevices; else s_knownDevices.clear(); } IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance(); if (deckLinkIterator == NULL) { fprintf(stderr, "BMDCaptureDelegate::enumDeviceNames: A DeckLink iterator could not be created. The DeckLink drivers may not be installed.\n"); return QStringList(); } IDeckLink *deckLink; IDeckLinkInput *deckLinkOutput; int index = 0; // Enumerate all cards in this system while (deckLinkIterator->Next(&deckLink) == S_OK) { if (deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&deckLinkOutput) == S_OK) { s_knownDevices << QString("bmd:%1").arg(index); deckLinkOutput->Release(); deckLinkOutput = NULL; } index ++; // Release the IDeckLink instance when we've finished with it to prevent leaks deckLink->Release(); } deckLinkIterator->Release(); return s_knownDevices; }
IDeckLinkDisplayMode* BMDConfig::GetDeckLinkDisplayMode(IDeckLink* deckLink, int idx) { HRESULT result; IDeckLinkDisplayMode* displayMode = NULL; IDeckLinkInput* deckLinkInput = NULL; IDeckLinkDisplayModeIterator* displayModeIterator = NULL; int i = idx; result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput); if (result != S_OK) goto bail; result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator); if (result != S_OK) goto bail; while ((result = displayModeIterator->Next(&displayMode)) == S_OK) { if (i == 0) break; --i; displayMode->Release(); } if (result != S_OK) goto bail; bail: if (displayModeIterator) displayModeIterator->Release(); if (deckLinkInput) deckLinkInput->Release(); return displayMode; }
void krad_decklink_capture_info () { IDeckLink *deckLink; IDeckLinkInput *deckLinkInput; IDeckLinkIterator *deckLinkIterator; IDeckLinkDisplayModeIterator *displayModeIterator; IDeckLinkDisplayMode *displayMode; HRESULT result; int displayModeCount; char *displayModeString; displayModeString = NULL; displayModeCount = 0; deckLinkIterator = CreateDeckLinkIteratorInstance(); if (!deckLinkIterator) { printke ("Krad Decklink: This application requires the DeckLink drivers installed.\n"); } /* Connect to the first DeckLink instance */ result = deckLinkIterator->Next(&deckLink); if (result != S_OK) { printke ("Krad Decklink: No DeckLink PCI cards found.\n"); } result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput); if (result != S_OK) { printke ("Krad Decklink: Fail QueryInterface\n"); } result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator); if (result != S_OK) { printke ("Krad Decklink: Could not obtain the video output display mode iterator - result = %08x\n", result); } while (displayModeIterator->Next(&displayMode) == S_OK) { result = displayMode->GetName((const char **) &displayModeString); if (result == S_OK) { BMDTimeValue frameRateDuration, frameRateScale; displayMode->GetFrameRate(&frameRateDuration, &frameRateScale); printkd ("%2d: %-20s \t %li x %li \t %g FPS\n", displayModeCount, displayModeString, displayMode->GetWidth(), displayMode->GetHeight(), (double)frameRateScale / (double)frameRateDuration); free (displayModeString); displayModeCount++; } displayMode->Release(); } if (displayModeIterator != NULL) { displayModeIterator->Release(); displayModeIterator = NULL; } if (deckLinkInput != NULL) { deckLinkInput->Release(); deckLinkInput = NULL; } if (deckLink != NULL) { deckLink->Release(); deckLink = NULL; } if (deckLinkIterator != NULL) { deckLinkIterator->Release(); } }
void print_output_modes(IDeckLink *deckLink) { IDeckLinkInput *deckLinkInput = NULL; IDeckLinkDisplayModeIterator *displayModeIterator = NULL; IDeckLinkDisplayMode *displayMode = NULL; HRESULT result; int displayModeCount = 0; // Query the DeckLink for its configuration interface result = deckLink->QueryInterface(IID_IDeckLinkInput, (void **)&deckLinkInput); if (result != S_OK) { fprintf( stderr, "Could not obtain the IDeckLinkInput interface - result = %08x\n", result); goto bail; } // Obtain an IDeckLinkDisplayModeIterator to enumerate the display modes supported on output result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator); if (result != S_OK) { fprintf( stderr, "Could not obtain the video output display mode iterator - result = %08x\n", result); goto bail; } // List all supported output display modes printf("Supported video output display modes and pixel formats:\n"); while (displayModeIterator->Next(&displayMode) == S_OK) { BMDProbeString str; result = displayMode->GetName(&str); if (result == S_OK) { char modeName[64]; int modeWidth; int modeHeight; BMDTimeValue frameRateDuration; BMDTimeScale frameRateScale; int pixelFormatIndex = 0; // index into the gKnownPixelFormats / gKnownFormatNames arrays BMDDisplayModeSupport displayModeSupport; // Obtain the display mode's properties modeWidth = displayMode->GetWidth(); modeHeight = displayMode->GetHeight(); displayMode->GetFrameRate(&frameRateDuration, &frameRateScale); printf(" %2d: %-20s \t %d x %d \t %7g FPS\n", displayModeCount++, ToStr(str), modeWidth, modeHeight, (double)frameRateScale / (double)frameRateDuration); FreeStr(str); } // Release the IDeckLinkDisplayMode object to prevent a leak displayMode->Release(); } // printf("\n"); bail: // Ensure that the interfaces we obtained are released to prevent a memory leak if (displayModeIterator != NULL) { displayModeIterator->Release(); } if (deckLinkInput != NULL) { deckLinkInput->Release(); } }
~DeckLinkCaptureDelegate() { m_deckLinkInput->Release(); pthread_mutex_destroy(&m_mutex); }
void BMDConfig::DisplayUsage(int status) { HRESULT result = E_FAIL; IDeckLinkIterator* deckLinkIterator = CreateDeckLinkIteratorInstance(); IDeckLinkDisplayModeIterator* displayModeIterator = NULL; IDeckLink* deckLink = NULL; IDeckLink* deckLinkSelected = NULL; int deckLinkCount = 0; char* deckLinkName = NULL; IDeckLinkAttributes* deckLinkAttributes = NULL; bool formatDetectionSupported; IDeckLinkInput* deckLinkInput = NULL; IDeckLinkDisplayMode* displayModeUsage; int displayModeCount = 0; char* displayModeName; fprintf(stderr, "Usage: Capture -d <device id> -m <mode id> [OPTIONS]\n" "\n" " -d <device id>:\n" ); // Loop through all available devices while (deckLinkIterator->Next(&deckLink) == S_OK) { result = deckLink->GetModelName((const char**)&deckLinkName); if (result == S_OK) { fprintf(stderr, " %2d: %s%s\n", deckLinkCount, deckLinkName, deckLinkCount == m_deckLinkIndex ? " (selected)" : "" ); free(deckLinkName); } if (deckLinkCount == m_deckLinkIndex) deckLinkSelected = deckLink; else deckLink->Release(); ++deckLinkCount; } if (deckLinkCount == 0) fprintf(stderr, " No DeckLink devices found. Is the driver loaded?\n"); deckLinkName = NULL; if (deckLinkSelected != NULL) deckLinkSelected->GetModelName((const char**)&deckLinkName); fprintf(stderr, " -m <mode id>: (%s)\n", deckLinkName ? deckLinkName : "" ); if (deckLinkName != NULL) free(deckLinkName); // Loop through all available display modes on the delected DeckLink device if (deckLinkSelected == NULL) { fprintf(stderr, " No DeckLink device selected\n"); goto bail; } result = deckLinkSelected->QueryInterface(IID_IDeckLinkAttributes, (void**)&deckLinkAttributes); if (result == S_OK) { result = deckLinkAttributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &formatDetectionSupported); if (result == S_OK && formatDetectionSupported) fprintf(stderr, " -1: auto detect format\n"); } result = deckLinkSelected->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput); if (result != S_OK) goto bail; result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator); if (result != S_OK) goto bail; while (displayModeIterator->Next(&displayModeUsage) == S_OK) { result = displayModeUsage->GetName((const char **)&displayModeName); if (result == S_OK) { BMDTimeValue frameRateDuration; BMDTimeValue frameRateScale; displayModeUsage->GetFrameRate(&frameRateDuration, &frameRateScale); fprintf(stderr, " %2d: %-20s \t %li x %li \t %g FPS\n", displayModeCount, displayModeName, displayModeUsage->GetWidth(), displayModeUsage->GetHeight(), (double)frameRateScale / (double)frameRateDuration ); free(displayModeName); } displayModeUsage->Release(); ++displayModeCount; } bail: fprintf(stderr, " -p <pixelformat>\n" " 0: 8 bit YUV (4:2:2) (default)\n" " 1: 10 bit YUV (4:2:2)\n" " 2: 10 bit RGB (4:4:4)\n" " -t <format> Print timecode\n" " rp188: RP 188\n" " vitc: VITC\n" " serial: Serial Timecode\n" " -v <filename> Filename raw video will be written to\n" " -a <filename> Filename raw audio will be written to\n" " -l <lcm channel> Channel name to publish images to LCM\n" " -q <jpeg quality> JPEG compression quality for LCM images (1-100 - default is 90)\n" " -c <channels> Audio Channels (2, 8 or 16 - default is 2)\n" " -s <depth> Audio Sample Depth (16 or 32 - default is 16)\n" " -n <frames> Number of frames to capture (default is unlimited)\n" " -3 Capture Stereoscopic 3D (Requires 3D Hardware support)\n" "\n" "Capture video and/or audio to a file. Raw video and/or audio can be viewed with mplayer eg:\n" "\n" " Capture -d 0 -m 2 -n 50 -v video.raw -a audio.raw\n" " mplayer video.raw -demuxer rawvideo -rawvideo pal:uyvy -audiofile audio.raw -audio-demuxer 20 -rawaudio rate=48000\n" "\n" "LCM capture example command line:\n" "\n" " DecklinkCapture -d 0 -m 14 -q 95 -l DECKLINK_VIDEO_CAPTURE\n" "\n" ); if (deckLinkIterator != NULL) deckLinkIterator->Release(); if (displayModeIterator != NULL) displayModeIterator->Release(); if (deckLinkInput != NULL) deckLinkInput->Release(); if (deckLinkAttributes != NULL) deckLinkAttributes->Release(); if (deckLinkSelected != NULL) deckLinkSelected->Release(); exit(status); }
void print_input_modes (IDeckLink* deckLink) { IDeckLinkInput* deckLinkInput = NULL; IDeckLinkDisplayModeIterator* displayModeIterator = NULL; IDeckLinkDisplayMode* displayMode = NULL; HRESULT result; // Query the DeckLink for its configuration interface result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput); if (result != S_OK) { fprintf(stderr, "Could not obtain the IDeckLinkInput interface - result = %08x\n", result); goto bail; } // Obtain an IDeckLinkDisplayModeIterator to enumerate the display modes supported on input result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator); if (result != S_OK) { fprintf(stderr, "Could not obtain the video input display mode iterator - result = %08x\n", result); goto bail; } // List all supported input display modes printf("Supported video input display modes and pixel formats:\n"); while (displayModeIterator->Next(&displayMode) == S_OK) { char * displayModeString = NULL; result = displayMode->GetName((const char **) &displayModeString); if (result == S_OK) { char modeName[64]; int modeWidth; int modeHeight; BMDTimeValue frameRateDuration; BMDTimeScale frameRateScale; int pixelFormatIndex = 0; // index into the gKnownPixelFormats / gKnownFormatNames arrays BMDDisplayModeSupport displayModeSupport; // Obtain the display mode's properties modeWidth = displayMode->GetWidth(); modeHeight = displayMode->GetHeight(); displayMode->GetFrameRate(&frameRateDuration, &frameRateScale); printf(" %-20s \t %d x %d \t %7g FPS\t", displayModeString, modeWidth, modeHeight, (double)frameRateScale / (double)frameRateDuration); // Print the supported pixel formats for this display mode while ((gKnownPixelFormats[pixelFormatIndex] != 0) && (gKnownPixelFormatNames[pixelFormatIndex] != NULL)) { if ((deckLinkInput->DoesSupportVideoMode(displayMode->GetDisplayMode(), gKnownPixelFormats[pixelFormatIndex], bmdVideoInputFlagDefault, &displayModeSupport, NULL) == S_OK) && (displayModeSupport != bmdDisplayModeNotSupported)) { printf("%s\t", gKnownPixelFormatNames[pixelFormatIndex]); } pixelFormatIndex++; } printf("\n"); free(displayModeString); } // Release the IDeckLinkDisplayMode object to prevent a leak displayMode->Release(); } printf("\n"); bail: // Ensure that the interfaces we obtained are released to prevent a memory leak if (displayModeIterator != NULL) displayModeIterator->Release(); if (deckLinkInput != NULL) deckLinkInput->Release(); }