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; }
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" ); } }