当前位置: 首页>>代码示例>>C++>>正文


C++ IDeckLinkOutput类代码示例

本文整理汇总了C++中IDeckLinkOutput的典型用法代码示例。如果您正苦于以下问题:C++ IDeckLinkOutput类的具体用法?C++ IDeckLinkOutput怎么用?C++ IDeckLinkOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IDeckLinkOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: open

	bool open( unsigned card = 0 )
	{
		IDeckLinkIterator* deckLinkIterator = CreateDeckLinkIteratorInstance();
		unsigned i = 0;
		
		if ( !deckLinkIterator )
		{
			mlt_log_verbose( NULL, "The DeckLink drivers not installed.\n" );
			return false;
		}
		
		// Connect to the Nth DeckLink instance
		do {
			if ( deckLinkIterator->Next( &m_deckLink ) != S_OK )
			{
				mlt_log_verbose( NULL, "DeckLink card not found\n" );
				deckLinkIterator->Release();
				return false;
			}
		} while ( ++i <= card );
		
		// Obtain the audio/video output interface (IDeckLinkOutput)
		if ( m_deckLink->QueryInterface( IID_IDeckLinkOutput, (void**)&m_deckLinkOutput ) != S_OK )
		{
			mlt_log_verbose( NULL, "No DeckLink cards support output\n" );
			m_deckLink->Release();
			m_deckLink = 0;
			deckLinkIterator->Release();
			return false;
		}
		
		// Provide this class as a delegate to the audio and video output interfaces
		m_deckLinkOutput->SetScheduledFrameCompletionCallback( this );
		m_deckLinkOutput->SetAudioCallback( this );
		
		pthread_mutex_init( &m_mutex, NULL );
		pthread_cond_init( &m_condition, NULL );
		m_maxAudioBuffer = bmdAudioSampleRate48kHz;
		m_videoFrameQ = mlt_deque_init();
		
		return true;
	}
开发者ID:zaenalarifin,项目名称:mlt,代码行数:42,代码来源:consumer_decklink.cpp

示例2: 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"
                );
            }
        }
开发者ID:mikaelpfi,项目名称:exacore,代码行数:40,代码来源:decklink.cpp

示例3: print_output_modes

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();
}
开发者ID:kylemcdonald,项目名称:ofxBlackmagicGrabber,代码行数:76,代码来源:ofxBlackmagicGrabber.cpp

示例4: start_video

 void start_video( ) {
     if (deckLinkOutput->StartScheduledPlayback(0, 100, 1.0) != S_OK) {
         throw std::runtime_error(
             "Failed to start scheduled playback!\n"
         );
     }
 }
开发者ID:mikaelpfi,项目名称:exacore,代码行数:7,代码来源:decklink.cpp

示例5: getDisplayMode

	IDeckLinkDisplayMode* getDisplayMode()
	{
		mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( &m_consumer ) );
		IDeckLinkDisplayModeIterator* iter;
		IDeckLinkDisplayMode* mode;
		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( &m_consumer, "BMD mode %dx%d %.3f fps prog %d\n", m_width, m_height, m_fps, p );
				
				if ( m_width == profile->width && m_height == profile->height && p == profile->progressive
					 && m_fps == mlt_profile_fps( profile ) )
					result = mode;
			}
		}
		
		return result;
	}
开发者ID:zaenalarifin,项目名称:mlt,代码行数:26,代码来源:consumer_decklink.cpp

示例6: schedule_frame

        void schedule_frame(IDeckLinkMutableVideoFrame *frame) {
            RawFrame *input = NULL;
            void *data;

            if (in_pipe.data_ready( )) {
                input = in_pipe.get( );
            } else if (last_frame != NULL) {
                /* use the stale frame */
                fprintf(stderr, "DeckLink: stale frame\n");
                input = last_frame;
            } else {
                /* this should likewise be a black frame */
                input = NULL;
            }
            
            if (input != NULL) {
                frame->GetBytes(&data);
                input->unpack->CbYCrY8422((uint8_t *) data);
            } else {
                fprintf(stderr, "DeckLink: on fire\n");
            }
            
            deckLinkOutput->ScheduleVideoFrame(frame, 
                frame_counter * frame_duration, frame_duration, time_base);

            frame_counter++;

            if (last_frame != input) {
                delete last_frame;
                last_frame = input;
            }
        }
开发者ID:mikaelpfi,项目名称:exacore,代码行数:32,代码来源:decklink.cpp

示例7: createFrame

	void createFrame()
	{
		m_videoFrame = 0;
		// Generate a DeckLink video frame
		if ( S_OK != m_deckLinkOutput->CreateVideoFrame( m_width, m_height,
			m_width * 2, bmdFormat8BitYUV, bmdFrameFlagDefault, &m_videoFrame ) )
		{
			mlt_log_verbose( &m_consumer, "Failed to create video frame\n" );
			stop();
			return;
		}
		
		// Make the first line black for field order correction.
		uint8_t *buffer = 0;
		if ( S_OK == m_videoFrame->GetBytes( (void**) &buffer ) && buffer )
		{
			for ( int i = 0; i < m_width; i++ )
			{
				*buffer++ = 128;
				*buffer++ = 16;
			}
		}
		mlt_log_debug( &m_consumer, "created video frame\n" );
		mlt_deque_push_back( m_videoFrameQ, m_videoFrame );
	}
开发者ID:zaenalarifin,项目名称:mlt,代码行数:25,代码来源:consumer_decklink.cpp

示例8:

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; 
}
开发者ID:TritonSailor,项目名称:livepro,代码行数:30,代码来源:BMDOutput.cpp

示例9: stop

	void stop()
	{
		// Stop the audio and video output streams immediately
		if ( m_deckLinkOutput )
		{
			m_deckLinkOutput->StopScheduledPlayback( 0, 0, 0 );
			m_deckLinkOutput->DisableAudioOutput();
			m_deckLinkOutput->DisableVideoOutput();
		}
		while ( mlt_deque_count( m_videoFrameQ ) )
		{
			m_videoFrame = (IDeckLinkMutableVideoFrame*) mlt_deque_pop_back( m_videoFrameQ );
			m_videoFrame->Release();
		}
		m_videoFrame = 0;
		if ( m_fifo ) sample_fifo_close( m_fifo );
	}
开发者ID:zaenalarifin,项目名称:mlt,代码行数:17,代码来源:consumer_decklink.cpp

示例10: setup_audio

        void setup_audio( ) {
            /* FIXME hard coded default */
            n_channels = 2; 

            audio_in_pipe = new Pipe<AudioPacket *>(OUT_PIPE_SIZE);

            /* FIXME magic 29.97 related number */
            /* Set up empty audio packet for prerolling */
            current_audio_pkt = new AudioPacket(48000, n_channels, 2, 25626);
            samples_written_from_current_audio_pkt = 0;

            assert(deckLinkOutput != NULL);

            if (deckLinkOutput->SetAudioCallback(this) != S_OK) {
                throw std::runtime_error(
                    "Failed to set DeckLink audio callback"
                );
            }

            if (deckLinkOutput->EnableAudioOutput( 
                    bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 
                    n_channels, bmdAudioOutputStreamContinuous) != S_OK) {
                throw std::runtime_error(
                    "Failed to enable DeckLink audio output"
                );
            }

            audio_preroll_done = 0;

            if (deckLinkOutput->BeginAudioPreroll( ) != S_OK) {
                throw std::runtime_error(
                    "Failed to begin DeckLink audio preroll"
                );
            }

            while (audio_preroll_done == 0) { 
                /* FIXME: busy wait */
            }

            if (deckLinkOutput->EndAudioPreroll( ) != S_OK) {
                throw std::runtime_error(
                    "Failed to end DeckLink audio preroll"
                );
            }
        }
开发者ID:mikaelpfi,项目名称:exacore,代码行数:45,代码来源:decklink.cpp

示例11:

	~DeckLinkConsumer()
	{
		if ( m_deckLinkOutput )
			m_deckLinkOutput->Release();
		if ( m_deckLink )
			m_deckLink->Release();
		if ( m_videoFrameQ )
			mlt_deque_close( m_videoFrameQ );
	}
开发者ID:zaenalarifin,项目名称:mlt,代码行数:9,代码来源:consumer_decklink.cpp

示例12: StopRunning

void BMDOutputDelegate::StopRunning ()
{
	// Stop the audio and video output streams immediately
	m_deckLinkOutput->StopScheduledPlayback(0, NULL, 0);
	//
	//m_deckLinkOutput->DisableAudioOutput();
	m_deckLinkOutput->DisableVideoOutput();
	
	if (m_yuvFrame != NULL)
		m_yuvFrame->Release();
	m_yuvFrame = NULL;
	
	if (m_rgbFrame != NULL)
		m_rgbFrame->Release();
	m_rgbFrame = NULL;
	
	// Success; update the UI
	m_running = false;
}
开发者ID:TritonSailor,项目名称:livepro,代码行数:19,代码来源:BMDOutput.cpp

示例13: setup_audio

        void setup_audio( ) {
            IOAudioPacket preroll_audio(8008, n_channels);
            preroll_audio.zero( );

            audio_in_pipe = new Pipe<IOAudioPacket *>(OUT_PIPE_SIZE);
            audio_fifo = new AudioFIFO<int16_t>(n_channels);
            audio_fifo->add_packet(&preroll_audio);

            assert(deckLinkOutput != NULL);

            if (deckLinkOutput->SetAudioCallback(this) != S_OK) {
                throw std::runtime_error(
                    "Failed to set DeckLink audio callback"
                );
            }

            if (deckLinkOutput->EnableAudioOutput( 
                    bmdAudioSampleRate48kHz, bmdAudioSampleType16bitInteger, 
                    n_channels, bmdAudioOutputStreamContinuous) != S_OK) {
                throw std::runtime_error(
                    "Failed to enable DeckLink audio output"
                );
            }

            audio_preroll_done = 0;

            if (deckLinkOutput->BeginAudioPreroll( ) != S_OK) {
                throw std::runtime_error(
                    "Failed to begin DeckLink audio preroll"
                );
            }

            while (audio_preroll_done == 0) { 
                /* FIXME: busy wait */
            }

            if (deckLinkOutput->EndAudioPreroll( ) != S_OK) {
                throw std::runtime_error(
                    "Failed to end DeckLink audio preroll"
                );
            }
        }
开发者ID:DigiDaz,项目名称:exacore,代码行数:42,代码来源:decklink.cpp

示例14: try_finish_current_audio_packet

        /* 
         * Try sending some audio data to the Decklink.
         * Call only with current_audio_pkt != NULL.
         * Will set current_audio_pkt to NULL and delete the packet
         * if it is fully consumed.
         * Return number of samples consumed.
         */
        int try_finish_current_audio_packet( ) {
            uint32_t n_consumed;
            uint32_t n_left;
            
            uint32_t buffer;
            deckLinkOutput->GetBufferedAudioSampleFrameCount(&buffer);
            fprintf(stderr, "audio buffer = %u ", buffer);

            assert(current_audio_pkt != NULL);

            n_left = current_audio_pkt->n_frames( ) 
                    - samples_written_from_current_audio_pkt;

            if (n_left == 0) {
                fprintf(stderr, "Audio warning: This should not happen!\n");
                return 1;
            }

            if (deckLinkOutput->ScheduleAudioSamples(
                    current_audio_pkt->sample(
                        samples_written_from_current_audio_pkt
                    ), n_left, 0, 0, &n_consumed) != S_OK) {
                throw std::runtime_error(
                    "Failed to schedule audio samples"
                );
            }

            if (n_consumed == n_left) {
                delete current_audio_pkt;
                current_audio_pkt = NULL;
            } else if (n_consumed < n_left) {
                samples_written_from_current_audio_pkt += n_consumed;
            } else {
                throw std::runtime_error("This should not happen");
            }

            deckLinkOutput->GetBufferedAudioSampleFrameCount(&buffer);
            fprintf(stderr, "-> %u\n", buffer);

            return n_consumed;
        }
开发者ID:mikaelpfi,项目名称:exacore,代码行数:48,代码来源:decklink.cpp

示例15: preroll_video_frames

        void preroll_video_frames(unsigned int n_frames) {
            IDeckLinkMutableVideoFrame *frame;
            for (unsigned int i = 0; i < n_frames; i++) {
                if (deckLinkOutput->CreateVideoFrame(norms[norm].w, 
                        norms[norm].h, 2*norms[norm].w, bpf,
                        bmdFrameFlagDefault, &frame) != S_OK) {

                    throw std::runtime_error("Failed to create frame"); 
                }

                schedule_frame(frame);
            }
        }
开发者ID:mikaelpfi,项目名称:exacore,代码行数:13,代码来源:decklink.cpp


注:本文中的IDeckLinkOutput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。