コード例 #1
0
ファイル: decklink.cpp プロジェクト: mikaelpfi/exacore
        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"
                );
            }
        }
コード例 #2
0
	bool start( unsigned preroll )
	{
		m_displayMode = getDisplayMode();
		if ( !m_displayMode )
		{
			mlt_log_error( &m_consumer, "Profile is not compatible with decklink.\n" );
			return false;
		}
		
		// Set the video output mode
		if ( S_OK != m_deckLinkOutput->EnableVideoOutput( m_displayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) )
		{
			mlt_log_error( &m_consumer, "Failed to enable video output\n" );
			return false;
		}
		
		// Set the audio output mode
		m_channels = 2;
		if ( S_OK != m_deckLinkOutput->EnableAudioOutput( bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger,
			m_channels, bmdAudioOutputStreamContinuous ) )
		{
			mlt_log_error( &m_consumer, "Failed to enable audio output\n" );
			stop();
			return false;
		}
		m_fifo = sample_fifo_init();
		
		// Preroll
		m_isPrerolling = true;
		m_prerollCounter = 0;
		m_preroll = preroll < PREROLL_MINIMUM ? PREROLL_MINIMUM : preroll;
		m_count = 0;
		m_deckLinkOutput->BeginAudioPreroll();
		
		return true;
	}
コード例 #3
0
ファイル: BMDOutput.cpp プロジェクト: TritonSailor/livepro
void BMDOutputDelegate::StartRunning ()
{
	IDeckLinkDisplayMode*	videoDisplayMode = NULL;
	
	// Get the display mode for 1080i 59.95 - mode 6
	// Changed to NTSC 23.98 - JB 20110215
	videoDisplayMode = GetDisplayModeByIndex(1);

	if (!videoDisplayMode)
		return;

	m_frameWidth = videoDisplayMode->GetWidth();
	m_frameHeight = videoDisplayMode->GetHeight();
	videoDisplayMode->GetFrameRate(&m_frameDuration, &m_frameTimescale);
	
	// Calculate the number of frames per second, rounded up to the nearest integer.  For example, for NTSC (29.97 FPS), framesPerSecond == 30.
	m_framesPerSecond = (unsigned long)((m_frameTimescale + (m_frameDuration-1))  /  m_frameDuration);
	
	
	QImage image(m_frameWidth,m_frameHeight, QImage::Format_ARGB32);
	image.fill(Qt::green);
	//m_frame = VideoFramePtr(new VideoFrame(image, 1000/30));
	
	HRESULT res;
	
	// Set the video output mode
	if (m_deckLinkOutput->EnableVideoOutput(videoDisplayMode->GetDisplayMode(), bmdVideoOutputFlagDefault) != S_OK)
	{
		//fprintf(stderr, "Failed to enable video output\n");
		qDebug() << "BMDOutputDelegate::StartRunning(): Failed to EnableVideoOutput()";
		goto bail;
	}
	
	res = m_deckLinkOutput->CreateVideoFrame(
		m_frameWidth,
		m_frameHeight,
		m_frameWidth * 4,
		bmdFormat8BitBGRA, 
		bmdFrameFlagDefault,
		&m_rgbFrame);
	
	if(res != S_OK)
	{
		qDebug() << "BMDOutputDelegate::StartRunning: Error creating RGB frame, res:"<<res;
		goto bail;
	}
	
	res = m_deckLinkOutput->CreateVideoFrame(
		m_frameWidth,
		m_frameHeight,
		m_frameWidth * 2,
		bmdFormat8BitYUV, 
		bmdFrameFlagDefault,
		&m_yuvFrame);
	
	if(res != S_OK)
	{
		qDebug() << "BMDOutputDelegate::StartRunning: Error creating YUV frame, res:"<<res;
		goto bail;
	}


// 	// Generate a frame of black
// 	if (m_deckLinkOutput->CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth*2, bmdFormat8BitYUV, bmdFrameFlagDefault, &m_videoFrameBlack) != S_OK)
// 	{
// 		fprintf(stderr, "Failed to create video frame\n");	
// 		goto bail;
// 	}
// 	FillBlack(m_videoFrameBlack);
// 	
// 	// Generate a frame of colour bars
// 	if (m_deckLinkOutput->CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth*2, bmdFormat8BitYUV, bmdFrameFlagDefault, &m_videoFrameBars) != S_OK)
// 	{
// 		fprintf(stderr, "Failed to create video frame\n");
// 		goto bail;
// 	}
// 	FillColourBars(m_videoFrameBars);
	
	
	// Begin video preroll by scheduling a second of frames in hardware
	m_totalFramesScheduled = 0;
  	for (unsigned i = 0; i < m_framesPerSecond; i++)
  	{
  		PrepareFrame();
 		ScheduleNextFrame(true);
 	}
	
	// Args: startTime, timeScale, playback speed (1.0 = normal)
	m_deckLinkOutput->StartScheduledPlayback(0, 100, 1.0);
	
	m_running = true;
	
	return;
	
bail:
	// *** Error-handling code.  Cleanup any resources that were allocated. *** //
	StopRunning();
}