// Create an array of 'NUM_FRAMES' IDeckLinkMutableVideoFrames // and fill in each frame with its own colour bool PlaybackHelper::createFrames() { int i; bool result = false; //allocate and reset frame array m_videoFrames = (IDeckLinkMutableVideoFrame **) malloc(NUM_FRAMES * sizeof(IDeckLinkMutableVideoFrame *)); memset(m_videoFrames, 0x0, NUM_FRAMES * sizeof(IDeckLinkMutableVideoFrame *)); // allocate IDeckLink video frames for(i = 0; i<NUM_FRAMES; i++) { if (m_deckLinkOutput->CreateVideoFrame(m_width, m_height, m_width * 2, bmdFormat8BitYUV, bmdFrameFlagDefault, &m_videoFrames[i]) != S_OK) { fprintf(stderr, "Could not obtain frame %d\n", (i+1)); goto bail; } // fill in frame buffer fillFrame(i); } result = true; bail: if (! result) releaseFrames(); return result; }
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; }
void PlaybackHelper::cleanupDeckLinkOutput() { m_deckLinkOutput->StopScheduledPlayback(0, NULL, 0); m_deckLinkOutput->DisableVideoOutput(); m_deckLinkOutput->SetScheduledFrameCompletionCallback(NULL); releaseFrames(); }
void VideoAnalyzer::release() { releaseFrameCallback(); releaseAnalyzerCallback(); releaseFrames(); releaseVideoCapture(); }