#include <sys/time.h>
#include <limits.h>
#include <pthread.h>
-#ifdef WIN32
-#include <objbase.h>
-#include "DeckLinkAPI_h.h"
-#else
-#include "DeckLinkAPI.h"
-typedef const char* BSTR;
-#endif
-
-#define SAFE_RELEASE(V) if (V) { V->Release(); V = NULL; }
+#include "common.h"
static const unsigned PREROLL_MINIMUM = 3;
IDeckLinkDisplayModeIterator* iter = NULL;
IDeckLinkDisplayMode* mode = NULL;
IDeckLinkDisplayMode* result = 0;
-
+
if ( m_deckLinkOutput->GetDisplayModeIterator( &iter ) == S_OK )
{
while ( !result && iter->Next( &mode ) == S_OK )
m_fps = (double) m_timescale / m_duration;
int p = mode->GetFieldDominance() == bmdProgressiveFrame;
mlt_log_verbose( getConsumer(), "BMD mode %dx%d %.3f fps prog %d\n", m_width, m_height, m_fps, p );
-
+
if ( m_width == profile->width && p == profile->progressive
&& m_fps == mlt_profile_fps( profile )
&& ( m_height == profile->height || ( m_height == 486 && profile->height == 480 ) ) )
}
SAFE_RELEASE( iter );
}
-
+
return result;
}
-
+
public:
mlt_consumer getConsumer()
{ return &m_consumer; }
m_deckLinkKeyer = NULL;
m_deckLinkOutput = NULL;
m_deckLink = NULL;
+ m_decklinkFrame = NULL;
}
~DeckLinkConsumer()
SAFE_RELEASE( m_deckLinkOutput );
SAFE_RELEASE( m_deckLink );
}
-
+
bool open( unsigned card = 0 )
{
unsigned i = 0;
}
#else
IDeckLinkIterator* deckLinkIterator = CreateDeckLinkIteratorInstance();
-
+
if ( !deckLinkIterator )
{
mlt_log_error( getConsumer(), "The DeckLink drivers not installed.\n" );
SAFE_RELEASE( m_deckLink );
return false;
}
-
+
// Get the keyer interface
IDeckLinkAttributes *deckLinkAttributes = 0;
if ( m_deckLink->QueryInterface( IID_IDeckLinkAttributes, (void**) &deckLinkAttributes ) == S_OK )
// Provide this class as a delegate to the audio and video output interfaces
m_deckLinkOutput->SetScheduledFrameCompletionCallback( this );
-
+
return true;
}
mlt_log_error( getConsumer(), "Profile is not compatible with decklink.\n" );
return false;
}
-
+
// Set the keyer
if ( m_deckLinkKeyer && ( m_isKeyer = mlt_properties_get_int( properties, "keyer" ) ) )
{
return true;
}
-
+
bool stop()
{
mlt_properties properties = MLT_CONSUMER_PROPERTIES( getConsumer() );
stop();
return false;
}
-
+
// Make the first line black for field order correction.
if ( S_OK == frame->GetBytes( (void**) &buffer ) && buffer )
{
return result;
}
-
+
// *** DeckLink API implementation of IDeckLinkVideoOutputCallback IDeckLinkAudioOutputCallback *** //
// IUnknown needs only a dummy implementation
{ return 1; }
virtual ULONG STDMETHODCALLTYPE Release()
{ return 1; }
-
+
/************************* DeckLink API Delegate Methods *****************************/
-
+
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted( IDeckLinkVideoFrame* completedFrame, BMDOutputFrameCompletionResult completed )
{
if( !m_reprio )
{
return mlt_consumer_is_stopped( getConsumer() ) ? S_FALSE : S_OK;
}
-
+
void ScheduleNextFrame( bool preroll )
{
{
if ( decklink->QueryInterface( IID_IDeckLinkOutput, (void**) &decklinkOutput ) == S_OK )
{
- char *name = NULL;
- if ( decklink->GetModelName( (BSTR*) &name ) == S_OK )
+ DLString name = NULL;
+ if ( decklink->GetModelName( &name ) == S_OK )
{
+ char *name_cstr = getCString( name );
const char *format = "device.%d";
char *key = (char*) calloc( 1, strlen( format ) + 1 );
sprintf( key, format, i );
- mlt_properties_set( properties, key, name );
+ mlt_properties_set( properties, key, name_cstr );
free( key );
- free( name );
+ freeDLString( name );
+ freeCString( name_cstr );
}
SAFE_RELEASE( decklinkOutput );
}