本文整理汇总了C++中IDeckLinkDisplayMode::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IDeckLinkDisplayMode::Release方法的具体用法?C++ IDeckLinkDisplayMode::Release怎么用?C++ IDeckLinkDisplayMode::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDeckLinkDisplayMode
的用法示例。
在下文中一共展示了IDeckLinkDisplayMode::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: runtime_error
/* lookup the field dominance corresponding to this BMDDisplayMode */
static RawFrame::FieldDominance find_dominance(BMDDisplayMode mode,
IDeckLinkDisplayModeIterator *iterator) {
IDeckLinkDisplayMode *imode;
if (iterator->Next(&imode) != S_OK) {
throw std::runtime_error("DeckLink: failed to iterate display modes");
}
while (imode) {
BMDFieldDominance fd = imode->GetFieldDominance( );
BMDDisplayMode thismode = imode->GetDisplayMode( );
imode->Release( );
if (thismode == mode) {
switch (fd) {
case bmdLowerFieldFirst:
return RawFrame::BOTTOM_FIELD_FIRST;
case bmdUpperFieldFirst:
return RawFrame::TOP_FIELD_FIRST;
case bmdProgressiveFrame:
case bmdProgressiveSegmentedFrame:
return RawFrame::PROGRESSIVE;
default:
return RawFrame::UNKNOWN;
}
}
if (iterator->Next(&imode) != S_OK) {
throw std::runtime_error("failed to iterate display modes");
}
}
/* no modes matched so we don't know dominance */
return RawFrame::UNKNOWN;
}
示例4: SetMode
void DeckLinkDeviceMode::SetMode(IDeckLinkDisplayMode *mode_)
{
IDeckLinkDisplayMode *old = mode;
if (old != nullptr)
old->Release();
mode = mode_;
if (mode != nullptr)
mode->AddRef();
}
示例5: fprintf
int
usage (int status)
{
HRESULT result;
IDeckLinkDisplayMode *displayMode;
int displayModeCount = 0;
fprintf (stderr,
"Usage: Capture -m <mode id> [OPTIONS]\n" "\n" " -m <mode id>:\n");
while (displayModeIterator->Next (&displayMode) == S_OK) {
char *displayModeString = NULL;
result = displayMode->GetName ((const char **) &displayModeString);
if (result == S_OK) {
BMDTimeValue frameRateDuration, frameRateScale;
displayMode->GetFrameRate (&frameRateDuration, &frameRateScale);
fprintf (stderr, " %2d: %-20s \t %li x %li \t %g FPS\n",
displayModeCount, displayModeString, displayMode->GetWidth (),
displayMode->GetHeight (),
(double) frameRateScale / (double) frameRateDuration);
free (displayModeString);
displayModeCount++;
}
// Release the IDeckLinkDisplayMode object to prevent a leak
displayMode->Release ();
}
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"
" -f <filename> Filename raw video will be written to\n"
" -a <filename> Filename raw audio will be written to\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 -m2 -n 50 -f video.raw -a audio.raw\n"
" mplayer video.raw -demuxer rawvideo -rawvideo pal:uyvy -audiofile audio.raw -audio-demuxer 20 -rawaudio rate=48000\n");
exit (status);
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9:
static void print_output_modes (IDeckLink* deckLink)
{
IDeckLinkOutput* deckLinkOutput = NULL;
IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
IDeckLinkDisplayMode* displayMode = NULL;
HRESULT result;
// Query the DeckLink for its configuration interface
result = deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&deckLinkOutput);
if (result != S_OK)
{
fprintf(stderr, "Could not obtain the IDeckLinkOutput interface - result = %08x\n", result);
goto bail;
}
// Obtain an IDeckLinkDisplayModeIterator to enumerate the display modes supported on output
result = deckLinkOutput->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)
{
CFStringRef displayModeString;
result = displayMode->GetName(&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 ((deckLinkOutput->DoesSupportVideoMode(displayMode->GetDisplayMode(), gKnownPixelFormats[pixelFormatIndex], bmdVideoOutputFlagDefault, &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 (deckLinkOutput != NULL)
deckLinkOutput->Release();
}
示例10: 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,
//.........这里部分代码省略.........
示例11: ff_decklink_set_format
int ff_decklink_set_format(AVFormatContext *avctx,
int width, int height,
int tb_num, int tb_den,
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;
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);
}
if (tb_num == 1) {
tb_num *= 1000;
tb_den *= 1000;
}
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();
mode->GetFrameRate(&bmd_tb_num, &bmd_tb_den);
if ((bmd_width == width && bmd_height == height &&
bmd_tb_num == tb_num && bmd_tb_den == tb_den) || i == num) {
ctx->bmd_mode = mode->GetDisplayMode();
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 = mode->GetFieldDominance();
av_log(avctx, AV_LOG_INFO, "Found Decklink mode %d x %d with rate %.2f%s\n",
bmd_width, bmd_height, (float)bmd_tb_den/(float)bmd_tb_num,
(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,
bmdVideoOutputFlagDefault,
&support, NULL) != S_OK)
return -1;
}
if (support == bmdDisplayModeSupported)
return 0;
return -1;
}
示例12: while
// Prepare IDeckLinkInput to capture video:
// - Get frame width, height, duration, ...
// - Setup callback object and video mode and
// - Start streams
bool CaptureHelper::setupDeckLinkInput()
{
bool result = false;
IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
IDeckLinkDisplayMode* deckLinkDisplayMode = NULL;
m_width = -1;
// get frame scale and duration for the video mode
if (m_deckLinkInput->GetDisplayModeIterator(&displayModeIterator) != S_OK)
goto bail;
while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK)
{
if (deckLinkDisplayMode->GetDisplayMode() == BMD_DISPLAYMODE)
{
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)
{
printf("Unable to find requested video mode\n");
goto bail;
}
// convert the in- and out-point timecodes to a frame count
GET_FRAME_COUNT(m_inPointFrameCount, START_TC, m_timeScale, m_frameDuration);
GET_FRAME_COUNT(m_outPointFrameCount, STOP_TC, m_timeScale, m_frameDuration);
// set callback
m_deckLinkInput->SetCallback(this);
// enable video input
if (m_deckLinkInput->EnableVideoInput(BMD_DISPLAYMODE, PIXEL_FMT, bmdVideoInputFlagDefault) != S_OK)
{
printf("Could not enable video input\n");
goto bail;
}
// start streaming
if (m_deckLinkInput->StartStreams() != S_OK)
{
printf("Could not start streams\n");
goto bail;
}
result = true;
bail:
return result;
}
示例13: processArguments
/**
* process the arugments
* return negative value of failed
*/
int Window::processArguments(int argc, char* argv[]){
IDeckLinkAttributes *deckLinkAttributes = NULL;
DeckLinkCaptureDelegate *delegate;
IDeckLinkDisplayMode *displayMode;
BMDVideoInputFlags inputFlags = 0;
BMDDisplayMode selectedDisplayMode = bmdModeNTSC;
BMDPixelFormat pixelFormat = bmdFormat8BitYUV;
int displayModeCount = 0;
int exitStatus = 1;
int ch;
bool foundDisplayMode = false;
HRESULT result;
int dnum = 0;
IDeckLink *tempLink = NULL;
int found = 0;
bool supported = 0;
int64_t ports;
int itemCount;
int vinput = 0;
int64_t vport = 0;
IDeckLinkConfiguration *deckLinkConfiguration = NULL;
bool flickerremoval = true;
bool pnotpsf = true;
// Parse command line options
while ((ch = getopt(argc, argv, "?h3c:d:s:f:a:m:n:p:t:u::vi:jy")) != -1)
{
switch (ch)
{
case 'i':
vinput = atoi(optarg);
break;
case 'd':
card = atoi(optarg);
break;
case 'm':
g_videoModeIndex = atoi(optarg);
break;
case 'n':
g_maxFrames = atoi(optarg);
break;
case '3':
inputFlags |= bmdVideoInputDualStream3D;
break;
case 'p':
switch(atoi(optarg))
{
case 0: pixelFormat = bmdFormat8BitYUV; break;
case 1: pixelFormat = bmdFormat10BitYUV; break;
case 2: pixelFormat = bmdFormat10BitRGB; break;
default:
fprintf(stderr, "Invalid argument: Pixel format %d is not valid", atoi(optarg));
exit(1);
}
break;
case 't':
if (!strcmp(optarg, "rp188"))
g_timecodeFormat = bmdTimecodeRP188Any;
else if (!strcmp(optarg, "vitc"))
g_timecodeFormat = bmdTimecodeVITC;
else if (!strcmp(optarg, "serial"))
g_timecodeFormat = bmdTimecodeSerial;
else
{
fprintf(stderr, "Invalid argument: Timecode format \"%s\" is invalid\n", optarg);
exit(1);
}
break;
case '?':
case 'h':
usage();
}
}
if (!deckLinkIterator)
{
fprintf(stderr, "This application requires the DeckLink drivers installed.\n");
return -1;
}
/* Connect to the first DeckLink instance */
while (deckLinkIterator->Next(&tempLink) == S_OK)
{
if (card != dnum) {
dnum++;
// Release the IDeckLink instance when we've finished with it to prevent leaks
tempLink->Release();
continue;
}
else {
deckLink = tempLink;
found = 1;
}
dnum++;
}
//.........这里部分代码省略.........
示例14: Open
static int Open(vlc_object_t *p_this)
{
demux_t *demux = (demux_t*)p_this;
demux_sys_t *sys;
int ret = VLC_EGENERIC;
int card_index;
int physical_channels = 0;
int rate;
BMDVideoInputFlags flags = bmdVideoInputFlagDefault;
/* Only when selected */
if (*demux->psz_access == '\0')
return VLC_EGENERIC;
/* Set up demux */
demux->pf_demux = NULL;
demux->pf_control = Control;
demux->info.i_update = 0;
demux->info.i_title = 0;
demux->info.i_seekpoint = 0;
demux->p_sys = sys = (demux_sys_t*)calloc(1, sizeof(demux_sys_t));
if (!sys)
return VLC_ENOMEM;
vlc_mutex_init(&sys->pts_lock);
sys->tenbits = var_InheritBool(p_this, "decklink-tenbits");
IDeckLinkIterator *decklink_iterator = CreateDeckLinkIteratorInstance();
if (!decklink_iterator) {
msg_Err(demux, "DeckLink drivers not found.");
goto finish;
}
card_index = var_InheritInteger(demux, "decklink-card-index");
if (card_index < 0) {
msg_Err(demux, "Invalid card index %d", card_index);
goto finish;
}
for (int i = 0; i <= card_index; i++) {
if (sys->card)
sys->card->Release();
if (decklink_iterator->Next(&sys->card) != S_OK) {
msg_Err(demux, "DeckLink PCI card %d not found", card_index);
goto finish;
}
}
const char *model_name;
if (sys->card->GetModelName(&model_name) != S_OK)
model_name = "unknown";
msg_Dbg(demux, "Opened DeckLink PCI card %d (%s)", card_index, model_name);
if (sys->card->QueryInterface(IID_IDeckLinkInput, (void**)&sys->input) != S_OK) {
msg_Err(demux, "Card has no inputs");
goto finish;
}
/* Set up the video and audio sources. */
if (sys->card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&sys->config) != S_OK) {
msg_Err(demux, "Failed to get configuration interface");
goto finish;
}
if (sys->card->QueryInterface(IID_IDeckLinkAttributes, (void**)&sys->attributes) != S_OK) {
msg_Err(demux, "Failed to get attributes interface");
goto finish;
}
if (GetVideoConn(demux) || GetAudioConn(demux))
goto finish;
BMDPixelFormat fmt;
fmt = sys->tenbits ? bmdFormat10BitYUV : bmdFormat8BitYUV;
if (sys->attributes->GetFlag(BMDDeckLinkSupportsInputFormatDetection, &sys->autodetect) != S_OK) {
msg_Err(demux, "Failed to query card attribute");
goto finish;
}
/* Get the list of display modes. */
IDeckLinkDisplayModeIterator *mode_it;
if (sys->input->GetDisplayModeIterator(&mode_it) != S_OK) {
msg_Err(demux, "Failed to enumerate display modes");
goto finish;
}
union {
BMDDisplayMode id;
char str[4];
} u;
u.id = 0;
char *mode;
mode = var_CreateGetNonEmptyString(demux, "decklink-mode");
if (mode)
sys->autodetect = false; // disable autodetection if mode was set
//.........这里部分代码省略.........
示例15: krad_decklink_capture_info
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();
}
}