本文整理汇总了C++中IDeckLinkDisplayModeIterator::Next方法的典型用法代码示例。如果您正苦于以下问题:C++ IDeckLinkDisplayModeIterator::Next方法的具体用法?C++ IDeckLinkDisplayModeIterator::Next怎么用?C++ IDeckLinkDisplayModeIterator::Next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDeckLinkDisplayModeIterator
的用法示例。
在下文中一共展示了IDeckLinkDisplayModeIterator::Next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4:
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;
}
示例5: 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;
}
示例6: 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);
}
示例7: 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;
}
示例8: 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;
}
示例9: open
//----------
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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: Init
bool DeckLinkDevice::Init()
{
ComPtr<IDeckLinkAttributes> attributes;
const HRESULT result = device->QueryInterface(IID_IDeckLinkAttributes,
(void **)&attributes);
if (result == S_OK) {
decklink_bool_t detectable = false;
if (attributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection,
&detectable) == S_OK && !!detectable) {
DeckLinkDeviceMode *mode = new DeckLinkDeviceMode(
"Auto",
MODE_ID_AUTO);
inputModes.push_back(mode);
inputModeIdMap[MODE_ID_AUTO] = mode;
}
}
// Find input modes
ComPtr<IDeckLinkInput> input;
if (device->QueryInterface(IID_IDeckLinkInput, (void **) &input) == S_OK) {
IDeckLinkDisplayModeIterator *modeIterator;
if (input->GetDisplayModeIterator(&modeIterator) == S_OK) {
IDeckLinkDisplayMode *displayMode;
long long modeId = 1;
while (modeIterator->Next(&displayMode) == S_OK) {
if (displayMode == nullptr)
continue;
DeckLinkDeviceMode *mode =
new DeckLinkDeviceMode(displayMode, modeId);
inputModes.push_back(mode);
inputModeIdMap[modeId] = mode;
displayMode->Release();
++modeId;
}
modeIterator->Release();
}
}
// find output modes
ComPtr<IDeckLinkOutput> output;
if (device->QueryInterface(IID_IDeckLinkOutput, (void **) &output) == S_OK) {
IDeckLinkDisplayModeIterator *modeIterator;
if (output->GetDisplayModeIterator(&modeIterator) == S_OK) {
IDeckLinkDisplayMode *displayMode;
long long modeId = 1;
while (modeIterator->Next(&displayMode) == S_OK) {
if (displayMode == nullptr)
continue;
DeckLinkDeviceMode *mode =
new DeckLinkDeviceMode(displayMode, modeId);
outputModes.push_back(mode);
outputModeIdMap[modeId] = mode;
displayMode->Release();
++modeId;
}
modeIterator->Release();
}
}
// get keyer support
attributes->GetFlag(BMDDeckLinkSupportsExternalKeying, &supportsExternalKeyer);
attributes->GetFlag(BMDDeckLinkSupportsInternalKeying, &supportsInternalKeyer);
decklink_string_t decklinkModelName;
decklink_string_t decklinkDisplayName;
if (device->GetModelName(&decklinkModelName) != S_OK)
return false;
DeckLinkStringToStdString(decklinkModelName, name);
if (device->GetDisplayName(&decklinkDisplayName) != S_OK)
return false;
DeckLinkStringToStdString(decklinkDisplayName, displayName);
hash = displayName;
if (result != S_OK)
return true;
int64_t channels;
/* Intensity Shuttle for Thunderbolt return 2; however, it supports 8 channels */
if (name == "Intensity Shuttle Thunderbolt")
maxChannel = 8;
else if (attributes->GetInt(BMDDeckLinkMaximumAudioChannels, &channels) == S_OK)
maxChannel = (int32_t)channels;
else
maxChannel = 2;
/* http://forum.blackmagicdesign.com/viewtopic.php?f=12&t=33967
* BMDDeckLinkTopologicalID for older devices
* BMDDeckLinkPersistentID for newer ones */
//.........这里部分代码省略.........
示例15: ff_decklink_set_format
int ff_decklink_set_format(AVFormatContext *avctx,
int width, int height,
int tb_num, int tb_den,
enum AVFieldOrder field_order,
decklink_direction_t direction, int num)
{
struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
BMDDisplayModeSupport support;
IDeckLinkDisplayModeIterator *itermode;
IDeckLinkDisplayMode *mode;
int i = 1;
HRESULT res;
av_log(avctx, AV_LOG_DEBUG, "Trying to find mode for frame size %dx%d, frame timing %d/%d, field order %d, direction %d, mode number %d, format code %s\n",
width, height, tb_num, tb_den, field_order, direction, num, (cctx->format_code) ? cctx->format_code : "(unset)");
if (ctx->duplex_mode) {
DECKLINK_BOOL duplex_supported = false;
if (ctx->attr->GetFlag(BMDDeckLinkSupportsDuplexModeConfiguration, &duplex_supported) != S_OK)
duplex_supported = false;
if (duplex_supported) {
res = ctx->cfg->SetInt(bmdDeckLinkConfigDuplexMode, ctx->duplex_mode == 2 ? bmdDuplexModeFull : bmdDuplexModeHalf);
if (res != S_OK)
av_log(avctx, AV_LOG_WARNING, "Setting duplex mode failed.\n");
else
av_log(avctx, AV_LOG_VERBOSE, "Successfully set duplex mode to %s duplex.\n", ctx->duplex_mode == 2 ? "full" : "half");
} else {
av_log(avctx, AV_LOG_WARNING, "Unable to set duplex mode, because it is not supported.\n");
}
}
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);
}
char format_buf[] = " ";
if (cctx->format_code)
memcpy(format_buf, cctx->format_code, FFMIN(strlen(cctx->format_code), sizeof(format_buf)));
BMDDisplayMode target_mode = (BMDDisplayMode)AV_RB32(format_buf);
AVRational target_tb = av_make_q(tb_num, tb_den);
ctx->bmd_mode = bmdModeUnknown;
while ((ctx->bmd_mode == bmdModeUnknown) && itermode->Next(&mode) == S_OK) {
BMDTimeValue bmd_tb_num, bmd_tb_den;
int bmd_width = mode->GetWidth();
int bmd_height = mode->GetHeight();
BMDDisplayMode bmd_mode = mode->GetDisplayMode();
BMDFieldDominance bmd_field_dominance = mode->GetFieldDominance();
mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
AVRational mode_tb = av_make_q(bmd_tb_num, bmd_tb_den);
if ((bmd_width == width &&
bmd_height == height &&
!av_cmp_q(mode_tb, target_tb) &&
field_order_eq(field_order, bmd_field_dominance))
|| i == num
|| target_mode == bmd_mode) {
ctx->bmd_mode = bmd_mode;
ctx->bmd_width = bmd_width;
ctx->bmd_height = bmd_height;
ctx->bmd_tb_den = bmd_tb_den;
ctx->bmd_tb_num = bmd_tb_num;
ctx->bmd_field_dominance = bmd_field_dominance;
av_log(avctx, AV_LOG_INFO, "Found Decklink mode %d x %d with rate %.2f%s\n",
bmd_width, bmd_height, 1/av_q2d(mode_tb),
(ctx->bmd_field_dominance==bmdLowerFieldFirst || ctx->bmd_field_dominance==bmdUpperFieldFirst)?"(i)":"");
}
mode->Release();
i++;
}
itermode->Release();
if (ctx->bmd_mode == bmdModeUnknown)
return -1;
if (direction == DIRECTION_IN) {
if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV,
bmdVideoOutputFlagDefault,
&support, NULL) != S_OK)
return -1;
} else {
if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV,
//.........这里部分代码省略.........