本文整理汇总了C++中IDeckLinkDisplayModeIterator类的典型用法代码示例。如果您正苦于以下问题:C++ IDeckLinkDisplayModeIterator类的具体用法?C++ IDeckLinkDisplayModeIterator怎么用?C++ IDeckLinkDisplayModeIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDeckLinkDisplayModeIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
IDeckLinkDisplayMode *BMDOutputDelegate::GetDisplayModeByIndex(int selectedIndex)
{
// Populate the display mode combo with a list of display modes supported by the installed DeckLink card
IDeckLinkDisplayModeIterator* displayModeIterator;
IDeckLinkDisplayMode* deckLinkDisplayMode;
IDeckLinkDisplayMode* selectedMode = NULL;
int index = 0;
if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK)
goto bail;
while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK)
{
const char *modeName;
if (deckLinkDisplayMode->GetName(&modeName) == S_OK)
{
if (index == selectedIndex)
{
printf("Selected mode: %s\n", modeName);
selectedMode = deckLinkDisplayMode;
goto bail;
}
}
index++;
}
bail:
displayModeIterator->Release();
return selectedMode;
}
示例2: getDisplayMode
BMDDisplayMode getDisplayMode( mlt_profile profile, int vancLines )
{
IDeckLinkDisplayModeIterator* iter = NULL;
IDeckLinkDisplayMode* mode = NULL;
BMDDisplayMode result = (BMDDisplayMode) bmdDisplayModeNotSupported;
if ( m_decklinkInput->GetDisplayModeIterator( &iter ) == S_OK )
{
while ( !result && iter->Next( &mode ) == S_OK )
{
int width = mode->GetWidth();
int height = mode->GetHeight();
BMDTimeValue duration;
BMDTimeScale timescale;
mode->GetFrameRate( &duration, ×cale );
double fps = (double) timescale / duration;
int p = mode->GetFieldDominance() == bmdProgressiveFrame;
m_topFieldFirst = mode->GetFieldDominance() == bmdUpperFieldFirst;
m_colorspace = ( mode->GetFlags() & bmdDisplayModeColorspaceRec709 ) ? 709 : 601;
mlt_log_verbose( getProducer(), "BMD mode %dx%d %.3f fps prog %d tff %d\n", width, height, fps, p, m_topFieldFirst );
if ( width == profile->width && p == profile->progressive
&& ( height + vancLines == profile->height || ( height == 486 && profile->height == 480 + vancLines ) )
&& fps == mlt_profile_fps( profile ) )
result = mode->GetDisplayMode();
SAFE_RELEASE( mode );
}
SAFE_RELEASE( iter );
}
return result;
}
示例3: getDisplayMode
IDeckLinkDisplayMode* getDisplayMode()
{
mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( getConsumer() ) );
IDeckLinkDisplayModeIterator* iter = NULL;
IDeckLinkDisplayMode* mode = NULL;
IDeckLinkDisplayMode* result = 0;
if ( m_deckLinkOutput->GetDisplayModeIterator( &iter ) == S_OK )
{
while ( !result && iter->Next( &mode ) == S_OK )
{
m_width = mode->GetWidth();
m_height = mode->GetHeight();
mode->GetFrameRate( &m_duration, &m_timescale );
m_fps = (double) m_timescale / m_duration;
int p = mode->GetFieldDominance() == bmdProgressiveFrame;
mlt_log_verbose( getConsumer(), "BMD mode %dx%d %.3f fps prog %d\n", m_width, m_height, m_fps, p );
if ( m_width == profile->width && p == profile->progressive
&& (int) m_fps == (int) mlt_profile_fps( profile )
&& ( m_height == profile->height || ( m_height == 486 && profile->height == 480 ) ) )
result = mode;
else
SAFE_RELEASE( mode );
}
SAFE_RELEASE( iter );
}
return result;
}
示例4: open_input
void open_input(unsigned int norm) {
IDeckLinkDisplayModeIterator *it;
assert(deckLink != NULL);
assert(norm < sizeof(norms) / sizeof(struct decklink_norm));
if (deckLink->QueryInterface(IID_IDeckLinkInput,
(void **) &deckLinkInput) != S_OK) {
throw std::runtime_error(
"DeckLink input: failed to get IDeckLinkInput"
);
}
if (deckLinkInput->GetDisplayModeIterator(&it) != S_OK) {
throw std::runtime_error(
"DeckLink input: failed to get display mode iterator"
);
}
dominance = find_dominance(norms[norm].mode, it);
it->Release( );
if (deckLinkInput->EnableVideoInput(norms[norm].mode,
bpf, 0) != S_OK) {
throw std::runtime_error(
"DeckLink input: failed to enable video input"
);
}
fprintf(stderr, "DeckLink: opening input using norm %s\n",
norms[norm].name);
}
示例5: while
bool PlaybackHelper::setupDeckLinkOutput()
{
bool result = false;
IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
IDeckLinkDisplayMode* deckLinkDisplayMode = NULL;
m_width = -1;
// set callback
m_deckLinkOutput->SetScheduledFrameCompletionCallback(this);
// get frame scale and duration for the video mode
if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK)
goto bail;
while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK)
{
if (deckLinkDisplayMode->GetDisplayMode() == bmdModeNTSC)
{
m_width = deckLinkDisplayMode->GetWidth();
m_height = deckLinkDisplayMode->GetHeight();
deckLinkDisplayMode->GetFrameRate(&m_frameDuration, &m_timeScale);
deckLinkDisplayMode->Release();
break;
}
deckLinkDisplayMode->Release();
}
displayModeIterator->Release();
if (m_width == -1)
{
fprintf(stderr, "Unable to find requested video mode\n");
goto bail;
}
// enable video output
if (m_deckLinkOutput->EnableVideoOutput(bmdModeNTSC, bmdVideoOutputFlagDefault) != S_OK)
{
fprintf(stderr, "Could not enable video output\n");
goto bail;
}
// create coloured frames
if (! createFrames())
goto bail;
result = true;
bail:
if (! result)
{
// release coloured frames
releaseFrames();
}
return result;
}
示例6: while
IDeckLinkDisplayMode *Player::GetDisplayModeByIndex(int selectedIndex)
{
// Populate the display mode combo with a list of display modes supported by the installed DeckLink card
IDeckLinkDisplayModeIterator *displayModeIterator;
IDeckLinkDisplayMode *deckLinkDisplayMode;
IDeckLinkDisplayMode *selectedMode = NULL;
int index = 0;
if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK)
goto bail;
while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK) {
BMDProbeString str;
if (deckLinkDisplayMode->GetName(&str) == S_OK) {
if (index == selectedIndex) {
printf("Selected mode: %s\n\n\n", ToStr(str));
selectedMode = deckLinkDisplayMode;
FreeStr(str);
goto bail;
}
}
index++;
}
bail:
displayModeIterator->Release();
return selectedMode;
}
示例7: RefreshDisplayModeMenu
void CSignalGeneratorDlg::RefreshDisplayModeMenu(void)
{
// Populate the display mode combo with a list of display modes supported by the installed DeckLink card
IDeckLinkDisplayModeIterator* displayModeIterator;
IDeckLinkDisplayMode* deckLinkDisplayMode;
BMDPixelFormat pixelFormat;
pixelFormat = (BMDPixelFormat)m_pixelFormatCombo.GetItemData(m_pixelFormatCombo.GetCurSel());
for (int i = 1; i < m_videoFormatCombo.GetCount(); i++)
{
deckLinkDisplayMode = (IDeckLinkDisplayMode*)m_videoFormatCombo.GetItemDataPtr(i-1);
deckLinkDisplayMode->Release();
}
m_videoFormatCombo.ResetContent();
if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK)
return;
while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK)
{
BSTR modeName;
int newIndex;
HRESULT hr;
BMDDisplayModeSupport displayModeSupport;
BMDVideoOutputFlags videoOutputFlags = bmdVideoOutputDualStream3D;
if (deckLinkDisplayMode->GetName(&modeName) != S_OK)
{
deckLinkDisplayMode->Release();
continue;
}
CString modeNameCString(modeName);
newIndex = m_videoFormatCombo.AddString(modeNameCString);
m_videoFormatCombo.SetItemDataPtr(newIndex, deckLinkDisplayMode);
hr = m_deckLinkOutput->DoesSupportVideoMode(deckLinkDisplayMode->GetDisplayMode(), pixelFormat, videoOutputFlags, &displayModeSupport, NULL);
if (hr != S_OK || ! displayModeSupport)
{
SysFreeString(modeName);
continue;
}
CString modeName3DCString(modeName);
modeName3DCString += _T(" 3D");
newIndex = m_videoFormatCombo.AddString(modeName3DCString);
m_videoFormatCombo.SetItemDataPtr(newIndex, deckLinkDisplayMode);
deckLinkDisplayMode->AddRef();
SysFreeString(modeName);
}
displayModeIterator->Release();
m_videoFormatCombo.SetCurSel(0);
}
示例8: selectDevice
bool DeckLinkController::selectDevice(int index) {
IDeckLinkAttributes* deckLinkAttributes = NULL;
IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
IDeckLinkDisplayMode* displayMode = NULL;
bool result = false;
// Check index
if (index >= deviceList.size()) {
ofLogError("DeckLinkController") << "This application was unable to select the device.";
goto bail;
}
// A new device has been selected.
// Release the previous selected device and mode list
if (deckLinkInput != NULL)
deckLinkInput->Release();
while(modeList.size() > 0) {
modeList.back()->Release();
modeList.pop_back();
}
// Get the IDeckLinkInput for the selected device
if ((deviceList[index]->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput) != S_OK)) {
ofLogError("DeckLinkController") << "This application was unable to obtain IDeckLinkInput for the selected device.";
deckLinkInput = NULL;
goto bail;
}
//
// Retrieve and cache mode list
if (deckLinkInput->GetDisplayModeIterator(&displayModeIterator) == S_OK) {
while (displayModeIterator->Next(&displayMode) == S_OK)
modeList.push_back(displayMode);
displayModeIterator->Release();
}
//
// Check if input mode detection format is supported.
supportFormatDetection = false; // assume unsupported until told otherwise
if (deviceList[index]->QueryInterface(IID_IDeckLinkAttributes, (void**) &deckLinkAttributes) == S_OK) {
if (deckLinkAttributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &supportFormatDetection) != S_OK)
supportFormatDetection = false;
deckLinkAttributes->Release();
}
result = true;
bail:
return result;
}
示例9: startDeckLink
bool Output::startDeckLink(BMDDisplayMode mode)
{
IDeckLinkDisplayModeIterator* pDLDisplayModeIterator = NULL;
IDeckLinkDisplayMode* pDLDisplayMode = NULL;
if (pDLOutput->GetDisplayModeIterator(&pDLDisplayModeIterator) == S_OK)
{
while (pDLDisplayModeIterator->Next(&pDLDisplayMode) == S_OK)
{
if (pDLDisplayMode->GetDisplayMode() == mode)
{
break;
}
}
pDLDisplayModeIterator->Release();
}
if (!pDLDisplayMode)
{
ofLogError("ofxDeckLinkAPI::Output") << "invalid display mode";
return false;
}
uiFrameWidth = pDLDisplayMode->GetWidth();
uiFrameHeight = pDLDisplayMode->GetHeight();
pixels[0].allocate(uiFrameWidth, uiFrameHeight, 4);
pixels[1].allocate(uiFrameWidth, uiFrameHeight, 4);
front_buffer = &pixels[0];
back_buffer = &pixels[1];
pDLDisplayMode->GetFrameRate(&frameDuration, &frameTimescale);
uiFPS = ((frameTimescale + (frameDuration - 1)) / frameDuration);
if (pDLOutput->EnableVideoOutput(pDLDisplayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) != S_OK)
return false;
if (pDLOutput->CreateVideoFrame(uiFrameWidth, uiFrameHeight, uiFrameWidth * 4, bmdFormat8BitARGB, bmdFrameFlagDefault, &pDLVideoFrame) != S_OK)
return false;
uiTotalFrames = 0;
resetFrame();
setPreroll();
pDLOutput->StartScheduledPlayback(0, frameTimescale, 1);
return true;
}
示例10: selectOutputDevice
// select output device
bool DeckLinkController::selectOutputDevice(int index) {
IDeckLinkAttributes* deckLinkAttributes = NULL;
IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
IDeckLinkDisplayMode* displayMode = NULL;
bool result = false;
// Check index
if (index >= deviceList.size()) {
ofLogError("DeckLinkController") << "This application was unable to select the device.";
goto bail;
}
// A new device has been selected.
// Release the previous selected device and mode list
if (deckLinkInput != NULL)
deckLinkInput->Release();
while(modeList.size() > 0) {
modeList.back()->Release();
modeList.pop_back();
}
// Get the IDeckLinkOutput for the selected device
if ((deviceList[index]->QueryInterface(IID_IDeckLinkOutput, (void**)&deckLinkOutput) != S_OK)) {
ofLogError("DeckLinkController") << "This application was unable to obtain IDeckLinkOutput for the selected device.";
deckLinkOutput = NULL;
goto bail;
}
if ((deckLinkOutput->CreateVideoFrame(1280, 720, 1280*4,bmdFormat8BitBGRA, bmdFrameFlagDefault, &videoFrame) != S_OK)) {
ofLogError("DeckLinkController") << "Create video frame error";
goto bail;
}
// Retrieve and cache mode list
if (deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) == S_OK) {
while (displayModeIterator->Next(&displayMode) == S_OK) {
modeList.push_back(displayMode);
}
displayModeIterator->Release();
}
result = true;
bail:
return result;
}
示例11: ff_decklink_list_formats
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
{
struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
IDeckLinkDisplayModeIterator *itermode;
IDeckLinkDisplayMode *mode;
uint32_t format_code;
HRESULT res;
if (direction == DIRECTION_IN) {
int ret;
ret = decklink_select_input(avctx, bmdDeckLinkConfigAudioInputConnection);
if (ret < 0)
return ret;
ret = decklink_select_input(avctx, bmdDeckLinkConfigVideoInputConnection);
if (ret < 0)
return ret;
res = ctx->dli->GetDisplayModeIterator (&itermode);
} else {
res = ctx->dlo->GetDisplayModeIterator (&itermode);
}
if (res!= S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not get Display Mode Iterator\n");
return AVERROR(EIO);
}
av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n\tformat_code\tdescription",
avctx->filename);
while (itermode->Next(&mode) == S_OK) {
BMDTimeValue tb_num, tb_den;
mode->GetFrameRate(&tb_num, &tb_den);
format_code = av_bswap32(mode->GetDisplayMode());
av_log(avctx, AV_LOG_INFO, "\n\t%.4s\t\t%ldx%ld at %d/%d fps",
(char*) &format_code, mode->GetWidth(), mode->GetHeight(),
(int) tb_den, (int) tb_num);
switch (mode->GetFieldDominance()) {
case bmdLowerFieldFirst:
av_log(avctx, AV_LOG_INFO, " (interlaced, lower field first)"); break;
case bmdUpperFieldFirst:
av_log(avctx, AV_LOG_INFO, " (interlaced, upper field first)"); break;
}
mode->Release();
}
av_log(avctx, AV_LOG_INFO, "\n");
itermode->Release();
return 0;
}
示例12: throw
//----------
Specification DeckLink::open(shared_ptr<Base::InitialisationSettings> initialisationSettings) {
auto settings = this->getTypedSettings<InitialisationSettings>(initialisationSettings);
auto devices = ofxBlackmagic::Iterator::getDeviceList();
if (devices.empty()) {
throw(ofxMachineVision::Exception("No DeckLink devices available"));
}
if (devices.size() <= (unsigned int)settings->deviceID) {
string str = "deviceID [" + ofToString(settings->deviceID) + "] out of range. [" + ofToString(devices.size()) + "] devices available";
throw(ofxMachineVision::Exception(str));
}
this->device = devices[settings->deviceID];
int width, height;
this->displayMode = static_cast<_BMDDisplayMode>(settings->displayMode.get());
try {
CHECK_ERRORS(device.device->QueryInterface(IID_IDeckLinkInput, (void**)&this->input), "Failed to query interface");
CHECK_ERRORS(this->input->SetCallback(this), "Failed to set input callback");
//find the current display mode
IDeckLinkDisplayModeIterator * displayModeIterator = 0;
CHECK_ERRORS(input->GetDisplayModeIterator(&displayModeIterator), "Couldn't get DisplayModeIterator");
IDeckLinkDisplayMode * displayModeTest = nullptr;
IDeckLinkDisplayMode * displayModeFound = nullptr;
while (displayModeIterator->Next(&displayModeTest) == S_OK) {
if (displayModeTest->GetDisplayMode() == this->displayMode) {
displayModeFound = displayModeTest;
}
}
if (!displayModeFound) {
CHECK_ERRORS(S_FALSE, "Cannot find displayMode");
}
width = displayModeFound->GetWidth();
height = displayModeFound->GetHeight();
}
catch (std::exception e) {
throw(ofxMachineVision::Exception(e.what()));
}
this->openTime = ofGetElapsedTimeMicros();
this->frameIndex = 0;
Specification specification(width, height, "BlackMagic", device.modelName);
specification.addFeature(ofxMachineVision::Feature::Feature_DeviceID);
specification.addFeature(ofxMachineVision::Feature::Feature_FreeRun);
return specification;
}
示例13: ff_decklink_list_formats
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction)
{
struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
IDeckLinkDisplayModeIterator *itermode;
IDeckLinkDisplayMode *mode;
int i=0;
HRESULT res;
if (direction == DIRECTION_IN) {
res = ctx->dli->GetDisplayModeIterator (&itermode);
} else {
res = ctx->dlo->GetDisplayModeIterator (&itermode);
}
if (res!= S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not get Display Mode Iterator\n");
return AVERROR(EIO);
}
av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n",
avctx->filename);
while (itermode->Next(&mode) == S_OK) {
BMDTimeValue tb_num, tb_den;
mode->GetFrameRate(&tb_num, &tb_den);
av_log(avctx, AV_LOG_INFO, "\t%d\t%ldx%ld at %d/%d fps",
++i,mode->GetWidth(), mode->GetHeight(),
(int) tb_den, (int) tb_num);
switch (mode->GetFieldDominance()) {
case bmdLowerFieldFirst:
av_log(avctx, AV_LOG_INFO, " (interlaced, lower field first)"); break;
case bmdUpperFieldFirst:
av_log(avctx, AV_LOG_INFO, " (interlaced, upper field first)"); break;
}
av_log(avctx, AV_LOG_INFO, "\n");
mode->Release();
}
itermode->Release();
return 0;
}
示例14: open_card
void open_card( ) {
IDeckLinkDisplayModeIterator *it;
/* get the DeckLinkOutput interface */
if (deckLink->QueryInterface(IID_IDeckLinkOutput,
(void **)&deckLinkOutput) != S_OK) {
throw std::runtime_error(
"Failed to get DeckLink output interface handle"
);
}
if (deckLinkOutput->SetScheduledFrameCompletionCallback(this)
!= S_OK) {
throw std::runtime_error(
"Failed to set DeckLink frame completion callback"
);
}
/* attempt to determine field dominance */
if (deckLinkOutput->GetDisplayModeIterator(&it) != S_OK) {
throw std::runtime_error(
"DeckLink output: failed to get display mode iterator"
);
}
dominance = find_dominance(norms[norm].mode, it);
it->Release( );
/* and we're off to the races */
if (deckLinkOutput->EnableVideoOutput(norms[norm].mode,
bmdVideoOutputFlagDefault) != S_OK) {
throw std::runtime_error(
"Failed to enable DeckLink video output"
);
}
}
示例15: GetDeckLinkDisplayMode
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;
}