decklink: reindent
This commit is contained in:
parent
ca8ea19cc3
commit
1e1c16150b
@ -35,7 +35,8 @@
|
|||||||
#define KDeckLinkPreviewAPI_Name "libDeckLinkPreviewAPI.so"
|
#define KDeckLinkPreviewAPI_Name "libDeckLinkPreviewAPI.so"
|
||||||
|
|
||||||
typedef IDeckLinkIterator *(*CreateIteratorFunc) (void);
|
typedef IDeckLinkIterator *(*CreateIteratorFunc) (void);
|
||||||
typedef IDeckLinkGLScreenPreviewHelper* (*CreateOpenGLScreenPreviewHelperFunc)(void);
|
typedef IDeckLinkGLScreenPreviewHelper
|
||||||
|
* (*CreateOpenGLScreenPreviewHelperFunc) (void);
|
||||||
typedef IDeckLinkVideoConversion *(*CreateVideoConversionInstanceFunc) (void);
|
typedef IDeckLinkVideoConversion *(*CreateVideoConversionInstanceFunc) (void);
|
||||||
|
|
||||||
static pthread_once_t gDeckLinkOnceControl = PTHREAD_ONCE_INIT;
|
static pthread_once_t gDeckLinkOnceControl = PTHREAD_ONCE_INIT;
|
||||||
@ -45,42 +46,47 @@ static CreateIteratorFunc gCreateIteratorFunc = NULL;
|
|||||||
static CreateOpenGLScreenPreviewHelperFunc gCreateOpenGLPreviewFunc = NULL;
|
static CreateOpenGLScreenPreviewHelperFunc gCreateOpenGLPreviewFunc = NULL;
|
||||||
static CreateVideoConversionInstanceFunc gCreateVideoConversionFunc = NULL;
|
static CreateVideoConversionInstanceFunc gCreateVideoConversionFunc = NULL;
|
||||||
|
|
||||||
static
|
static void
|
||||||
void InitDeckLinkAPI (void)
|
InitDeckLinkAPI (void)
|
||||||
{
|
{
|
||||||
void *libraryHandle;
|
void *libraryHandle;
|
||||||
|
|
||||||
libraryHandle = dlopen (kDeckLinkAPI_Name, RTLD_NOW | RTLD_GLOBAL);
|
libraryHandle = dlopen (kDeckLinkAPI_Name, RTLD_NOW | RTLD_GLOBAL);
|
||||||
if (!libraryHandle)
|
if (!libraryHandle) {
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", dlerror ());
|
fprintf (stderr, "%s\n", dlerror ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gCreateIteratorFunc = (CreateIteratorFunc)dlsym(libraryHandle, "CreateDeckLinkIteratorInstance_0001");
|
gCreateIteratorFunc =
|
||||||
|
(CreateIteratorFunc) dlsym (libraryHandle,
|
||||||
|
"CreateDeckLinkIteratorInstance_0001");
|
||||||
if (!gCreateIteratorFunc)
|
if (!gCreateIteratorFunc)
|
||||||
fprintf (stderr, "%s\n", dlerror ());
|
fprintf (stderr, "%s\n", dlerror ());
|
||||||
gCreateVideoConversionFunc = (CreateVideoConversionInstanceFunc)dlsym(libraryHandle, "CreateVideoConversionInstance_0001");
|
gCreateVideoConversionFunc =
|
||||||
|
(CreateVideoConversionInstanceFunc) dlsym (libraryHandle,
|
||||||
|
"CreateVideoConversionInstance_0001");
|
||||||
if (!gCreateVideoConversionFunc)
|
if (!gCreateVideoConversionFunc)
|
||||||
fprintf (stderr, "%s\n", dlerror ());
|
fprintf (stderr, "%s\n", dlerror ());
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static void
|
||||||
void InitDeckLinkPreviewAPI (void)
|
InitDeckLinkPreviewAPI (void)
|
||||||
{
|
{
|
||||||
void *libraryHandle;
|
void *libraryHandle;
|
||||||
|
|
||||||
libraryHandle = dlopen (KDeckLinkPreviewAPI_Name, RTLD_NOW | RTLD_GLOBAL);
|
libraryHandle = dlopen (KDeckLinkPreviewAPI_Name, RTLD_NOW | RTLD_GLOBAL);
|
||||||
if (!libraryHandle)
|
if (!libraryHandle) {
|
||||||
{
|
|
||||||
fprintf (stderr, "%s\n", dlerror ());
|
fprintf (stderr, "%s\n", dlerror ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gCreateOpenGLPreviewFunc = (CreateOpenGLScreenPreviewHelperFunc)dlsym(libraryHandle, "CreateOpenGLScreenPreviewHelper_0001");
|
gCreateOpenGLPreviewFunc =
|
||||||
|
(CreateOpenGLScreenPreviewHelperFunc) dlsym (libraryHandle,
|
||||||
|
"CreateOpenGLScreenPreviewHelper_0001");
|
||||||
if (!gCreateOpenGLPreviewFunc)
|
if (!gCreateOpenGLPreviewFunc)
|
||||||
fprintf (stderr, "%s\n", dlerror ());
|
fprintf (stderr, "%s\n", dlerror ());
|
||||||
}
|
}
|
||||||
|
|
||||||
IDeckLinkIterator* CreateDeckLinkIteratorInstance (void)
|
IDeckLinkIterator *
|
||||||
|
CreateDeckLinkIteratorInstance (void)
|
||||||
{
|
{
|
||||||
pthread_once (&gDeckLinkOnceControl, InitDeckLinkAPI);
|
pthread_once (&gDeckLinkOnceControl, InitDeckLinkAPI);
|
||||||
|
|
||||||
@ -89,7 +95,8 @@ IDeckLinkIterator* CreateDeckLinkIteratorInstance (void)
|
|||||||
return gCreateIteratorFunc ();
|
return gCreateIteratorFunc ();
|
||||||
}
|
}
|
||||||
|
|
||||||
IDeckLinkGLScreenPreviewHelper* CreateOpenGLScreenPreviewHelper (void)
|
IDeckLinkGLScreenPreviewHelper *
|
||||||
|
CreateOpenGLScreenPreviewHelper (void)
|
||||||
{
|
{
|
||||||
pthread_once (&gDeckLinkOnceControl, InitDeckLinkAPI);
|
pthread_once (&gDeckLinkOnceControl, InitDeckLinkAPI);
|
||||||
pthread_once (&gPreviewOnceControl, InitDeckLinkPreviewAPI);
|
pthread_once (&gPreviewOnceControl, InitDeckLinkPreviewAPI);
|
||||||
@ -99,7 +106,8 @@ IDeckLinkGLScreenPreviewHelper* CreateOpenGLScreenPreviewHelper (void)
|
|||||||
return gCreateOpenGLPreviewFunc ();
|
return gCreateOpenGLPreviewFunc ();
|
||||||
}
|
}
|
||||||
|
|
||||||
IDeckLinkVideoConversion* CreateVideoConversionInstance (void)
|
IDeckLinkVideoConversion *
|
||||||
|
CreateVideoConversionInstance (void)
|
||||||
{
|
{
|
||||||
pthread_once (&gDeckLinkOnceControl, InitDeckLinkAPI);
|
pthread_once (&gDeckLinkOnceControl, InitDeckLinkAPI);
|
||||||
|
|
||||||
@ -107,4 +115,3 @@ IDeckLinkVideoConversion* CreateVideoConversionInstance (void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
return gCreateVideoConversionFunc ();
|
return gCreateVideoConversionFunc ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,7 @@ DeckLinkCaptureDelegate::VideoInputFrameArrived (IDeckLinkVideoInputFrame *
|
|||||||
|
|
||||||
GST_DEBUG ("Frame received [%s] - %s - Size: %li bytes",
|
GST_DEBUG ("Frame received [%s] - %s - Size: %li bytes",
|
||||||
timecodeString != NULL ? timecodeString : "No timecode",
|
timecodeString != NULL ? timecodeString : "No timecode",
|
||||||
"Valid Frame",
|
"Valid Frame", videoFrame->GetRowBytes () * videoFrame->GetHeight ());
|
||||||
videoFrame->GetRowBytes () * videoFrame->GetHeight ());
|
|
||||||
|
|
||||||
if (timecodeString)
|
if (timecodeString)
|
||||||
free ((void *) timecodeString);
|
free ((void *) timecodeString);
|
||||||
@ -128,10 +127,9 @@ DeckLinkCaptureDelegate::VideoInputFrameArrived (IDeckLinkVideoInputFrame *
|
|||||||
}
|
}
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
DeckLinkCaptureDelegate::
|
DeckLinkCaptureDelegate::VideoInputFormatChanged
|
||||||
VideoInputFormatChanged (BMDVideoInputFormatChangedEvents events,
|
(BMDVideoInputFormatChangedEvents events, IDeckLinkDisplayMode * mode,
|
||||||
IDeckLinkDisplayMode * mode, BMDDetectedVideoInputFormatFlags)
|
BMDDetectedVideoInputFormatFlags) {
|
||||||
{
|
|
||||||
GST_ERROR ("moo");
|
GST_ERROR ("moo");
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@ -140,19 +138,25 @@ VideoInputFormatChanged (BMDVideoInputFormatChangedEvents events,
|
|||||||
int
|
int
|
||||||
usage (int status)
|
usage (int status)
|
||||||
{
|
{
|
||||||
HRESULT result;
|
HRESULT
|
||||||
IDeckLinkDisplayMode *displayMode;
|
result;
|
||||||
int displayModeCount = 0;
|
IDeckLinkDisplayMode *
|
||||||
|
displayMode;
|
||||||
|
int
|
||||||
|
displayModeCount = 0;
|
||||||
|
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Usage: Capture -m <mode id> [OPTIONS]\n" "\n" " -m <mode id>:\n");
|
"Usage: Capture -m <mode id> [OPTIONS]\n" "\n" " -m <mode id>:\n");
|
||||||
|
|
||||||
while (displayModeIterator->Next (&displayMode) == S_OK) {
|
while (displayModeIterator->Next (&displayMode) == S_OK) {
|
||||||
char *displayModeString = NULL;
|
char *
|
||||||
|
displayModeString = NULL;
|
||||||
|
|
||||||
result = displayMode->GetName ((const char **) &displayModeString);
|
result = displayMode->GetName ((const char **) &displayModeString);
|
||||||
if (result == S_OK) {
|
if (result == S_OK) {
|
||||||
BMDTimeValue frameRateDuration, frameRateScale;
|
BMDTimeValue
|
||||||
|
frameRateDuration,
|
||||||
|
frameRateScale;
|
||||||
displayMode->GetFrameRate (&frameRateDuration, &frameRateScale);
|
displayMode->GetFrameRate (&frameRateDuration, &frameRateScale);
|
||||||
|
|
||||||
fprintf (stderr, " %2d: %-20s \t %li x %li \t %g FPS\n",
|
fprintf (stderr, " %2d: %-20s \t %li x %li \t %g FPS\n",
|
||||||
@ -194,17 +198,28 @@ usage (int status)
|
|||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
IDeckLinkIterator *deckLinkIterator = CreateDeckLinkIteratorInstance ();
|
IDeckLinkIterator *
|
||||||
DeckLinkCaptureDelegate *delegate;
|
deckLinkIterator = CreateDeckLinkIteratorInstance ();
|
||||||
IDeckLinkDisplayMode *displayMode;
|
DeckLinkCaptureDelegate *
|
||||||
BMDVideoInputFlags inputFlags = 0;
|
delegate;
|
||||||
BMDDisplayMode selectedDisplayMode = bmdModeNTSC;
|
IDeckLinkDisplayMode *
|
||||||
BMDPixelFormat pixelFormat = bmdFormat8BitYUV;
|
displayMode;
|
||||||
int displayModeCount = 0;
|
BMDVideoInputFlags
|
||||||
int exitStatus = 1;
|
inputFlags = 0;
|
||||||
int ch;
|
BMDDisplayMode
|
||||||
bool foundDisplayMode = false;
|
selectedDisplayMode = bmdModeNTSC;
|
||||||
HRESULT result;
|
BMDPixelFormat
|
||||||
|
pixelFormat = bmdFormat8BitYUV;
|
||||||
|
int
|
||||||
|
displayModeCount = 0;
|
||||||
|
int
|
||||||
|
exitStatus = 1;
|
||||||
|
int
|
||||||
|
ch;
|
||||||
|
bool
|
||||||
|
foundDisplayMode = false;
|
||||||
|
HRESULT
|
||||||
|
result;
|
||||||
|
|
||||||
pthread_mutex_init (&sleepMutex, NULL);
|
pthread_mutex_init (&sleepMutex, NULL);
|
||||||
pthread_cond_init (&sleepCond, NULL);
|
pthread_cond_init (&sleepCond, NULL);
|
||||||
@ -334,8 +349,10 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
while (displayModeIterator->Next (&displayMode) == S_OK) {
|
while (displayModeIterator->Next (&displayMode) == S_OK) {
|
||||||
if (g_videoModeIndex == displayModeCount) {
|
if (g_videoModeIndex == displayModeCount) {
|
||||||
BMDDisplayModeSupport result;
|
BMDDisplayModeSupport
|
||||||
const char *displayModeName;
|
result;
|
||||||
|
const char *
|
||||||
|
displayModeName;
|
||||||
|
|
||||||
foundDisplayMode = true;
|
foundDisplayMode = true;
|
||||||
displayMode->GetName (&displayModeName);
|
displayMode->GetName (&displayModeName);
|
||||||
@ -427,4 +444,3 @@ bail:
|
|||||||
return exitStatus;
|
return exitStatus;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ static gboolean gst_decklink_sink_query (GstElement * element,
|
|||||||
GstQuery * query);
|
GstQuery * query);
|
||||||
|
|
||||||
static GstCaps *gst_decklink_sink_videosink_getcaps (GstPad * pad);
|
static GstCaps *gst_decklink_sink_videosink_getcaps (GstPad * pad);
|
||||||
static gboolean gst_decklink_sink_videosink_setcaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_decklink_sink_videosink_setcaps (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
static gboolean gst_decklink_sink_videosink_acceptcaps (GstPad * pad,
|
static gboolean gst_decklink_sink_videosink_acceptcaps (GstPad * pad,
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
static gboolean gst_decklink_sink_videosink_activate (GstPad * pad);
|
static gboolean gst_decklink_sink_videosink_activate (GstPad * pad);
|
||||||
@ -81,15 +82,18 @@ static GstFlowReturn gst_decklink_sink_videosink_chain (GstPad * pad,
|
|||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
static GstFlowReturn gst_decklink_sink_videosink_chainlist (GstPad * pad,
|
static GstFlowReturn gst_decklink_sink_videosink_chainlist (GstPad * pad,
|
||||||
GstBufferList * bufferlist);
|
GstBufferList * bufferlist);
|
||||||
static gboolean gst_decklink_sink_videosink_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_decklink_sink_videosink_event (GstPad * pad,
|
||||||
static gboolean gst_decklink_sink_videosink_query (GstPad * pad, GstQuery * query);
|
GstEvent * event);
|
||||||
|
static gboolean gst_decklink_sink_videosink_query (GstPad * pad,
|
||||||
|
GstQuery * query);
|
||||||
static GstFlowReturn gst_decklink_sink_videosink_bufferalloc (GstPad * pad,
|
static GstFlowReturn gst_decklink_sink_videosink_bufferalloc (GstPad * pad,
|
||||||
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
|
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
|
||||||
static GstIterator *gst_decklink_sink_videosink_iterintlink (GstPad * pad);
|
static GstIterator *gst_decklink_sink_videosink_iterintlink (GstPad * pad);
|
||||||
|
|
||||||
|
|
||||||
static GstCaps *gst_decklink_sink_audiosink_getcaps (GstPad * pad);
|
static GstCaps *gst_decklink_sink_audiosink_getcaps (GstPad * pad);
|
||||||
static gboolean gst_decklink_sink_audiosink_setcaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_decklink_sink_audiosink_setcaps (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
static gboolean gst_decklink_sink_audiosink_acceptcaps (GstPad * pad,
|
static gboolean gst_decklink_sink_audiosink_acceptcaps (GstPad * pad,
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
static gboolean gst_decklink_sink_audiosink_activate (GstPad * pad);
|
static gboolean gst_decklink_sink_audiosink_activate (GstPad * pad);
|
||||||
@ -103,8 +107,10 @@ static GstFlowReturn gst_decklink_sink_audiosink_chain (GstPad * pad,
|
|||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
static GstFlowReturn gst_decklink_sink_audiosink_chainlist (GstPad * pad,
|
static GstFlowReturn gst_decklink_sink_audiosink_chainlist (GstPad * pad,
|
||||||
GstBufferList * bufferlist);
|
GstBufferList * bufferlist);
|
||||||
static gboolean gst_decklink_sink_audiosink_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_decklink_sink_audiosink_event (GstPad * pad,
|
||||||
static gboolean gst_decklink_sink_audiosink_query (GstPad * pad, GstQuery * query);
|
GstEvent * event);
|
||||||
|
static gboolean gst_decklink_sink_audiosink_query (GstPad * pad,
|
||||||
|
GstQuery * query);
|
||||||
static GstFlowReturn gst_decklink_sink_audiosink_bufferalloc (GstPad * pad,
|
static GstFlowReturn gst_decklink_sink_audiosink_bufferalloc (GstPad * pad,
|
||||||
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
|
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
|
||||||
static GstIterator *gst_decklink_sink_audiosink_iterintlink (GstPad * pad);
|
static GstIterator *gst_decklink_sink_audiosink_iterintlink (GstPad * pad);
|
||||||
@ -125,25 +131,34 @@ static GstStaticPadTemplate gst_decklink_sink_videosink_template =
|
|||||||
GST_STATIC_PAD_TEMPLATE ("videosink",
|
GST_STATIC_PAD_TEMPLATE ("videosink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (
|
GST_STATIC_CAPS (MODE (720, 486, 30000, 1001, true)
|
||||||
MODE(720,486,30000,1001,true)
|
|
||||||
));
|
));
|
||||||
#if 0
|
#if 0
|
||||||
MODE (720, 486, 24000, 1001, true) ";"
|
MODE (720, 486, 24000, 1001, true) ";"
|
||||||
MODE(720,576,25,1,true) ";"
|
MODE (720, 576, 25, 1, true)
|
||||||
MODE(1920,1080,24000,1001,false) ";"
|
";"
|
||||||
MODE(1920,1080,24,1,false) ";"
|
MODE (1920, 1080, 24000, 1001, false)
|
||||||
MODE(1920,1080,25,1,false) ";"
|
";"
|
||||||
MODE(1920,1080,30000,1001,false) ";"
|
MODE (1920, 1080, 24, 1, false)
|
||||||
MODE(1920,1080,30,1,false) ";"
|
";"
|
||||||
MODE(1920,1080,25,1,true) ";"
|
MODE (1920, 1080, 25, 1, false)
|
||||||
MODE(1920,1080,30000,1001,true) ";"
|
";"
|
||||||
MODE(1920,1080,30,1,true) ";"
|
MODE (1920, 1080, 30000, 1001, false)
|
||||||
MODE(1280,720,50,1,true) ";"
|
";"
|
||||||
MODE(1280,720,60000,1001,true) ";"
|
MODE (1920, 1080, 30, 1, false)
|
||||||
|
";"
|
||||||
|
MODE (1920, 1080, 25, 1, true)
|
||||||
|
";"
|
||||||
|
MODE (1920, 1080, 30000, 1001, true)
|
||||||
|
";"
|
||||||
|
MODE (1920, 1080, 30, 1, true)
|
||||||
|
";"
|
||||||
|
MODE (1280, 720, 50, 1, true)
|
||||||
|
";"
|
||||||
|
MODE (1280, 720, 60000, 1001, true)
|
||||||
|
";"
|
||||||
MODE (1280, 720, 60, 1, true)
|
MODE (1280, 720, 60, 1, true)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_decklink_sink_audiosink_template =
|
static GstStaticPadTemplate gst_decklink_sink_audiosink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("audiosink",
|
GST_STATIC_PAD_TEMPLATE ("audiosink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
@ -152,7 +167,8 @@ GST_STATIC_PAD_TEMPLATE ("audiosink",
|
|||||||
);
|
);
|
||||||
|
|
||||||
typedef struct _DecklinkMode DecklinkMode;
|
typedef struct _DecklinkMode DecklinkMode;
|
||||||
struct _DecklinkMode {
|
struct _DecklinkMode
|
||||||
|
{
|
||||||
BMDDisplayMode mode;
|
BMDDisplayMode mode;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -424,7 +440,8 @@ gst_decklink_sink_start (GstDecklinkSink *decklinksink)
|
|||||||
}
|
}
|
||||||
//decklinksink->video_enabled = TRUE;
|
//decklinksink->video_enabled = TRUE;
|
||||||
|
|
||||||
decklinksink->output->SetScheduledFrameCompletionCallback (decklinksink->callback);
|
decklinksink->output->
|
||||||
|
SetScheduledFrameCompletionCallback (decklinksink->callback);
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
ret = decklinksink->output->EnableAudioOutput (bmdAudioSampleRate48kHz,
|
ret = decklinksink->output->EnableAudioOutput (bmdAudioSampleRate48kHz,
|
||||||
@ -773,8 +790,8 @@ gst_decklink_sink_videosink_query (GstPad * pad, GstQuery * query)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_decklink_sink_videosink_bufferalloc (GstPad * pad, guint64 offset, guint size,
|
gst_decklink_sink_videosink_bufferalloc (GstPad * pad, guint64 offset,
|
||||||
GstCaps * caps, GstBuffer ** buf)
|
guint size, GstCaps * caps, GstBuffer ** buf)
|
||||||
{
|
{
|
||||||
GstDecklinkSink *decklinksink;
|
GstDecklinkSink *decklinksink;
|
||||||
|
|
||||||
@ -984,8 +1001,8 @@ gst_decklink_sink_audiosink_query (GstPad * pad, GstQuery * query)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_decklink_sink_audiosink_bufferalloc (GstPad * pad, guint64 offset, guint size,
|
gst_decklink_sink_audiosink_bufferalloc (GstPad * pad, guint64 offset,
|
||||||
GstCaps * caps, GstBuffer ** buf)
|
guint size, GstCaps * caps, GstBuffer ** buf)
|
||||||
{
|
{
|
||||||
GstDecklinkSink *decklinksink;
|
GstDecklinkSink *decklinksink;
|
||||||
|
|
||||||
@ -1047,4 +1064,3 @@ Output::RenderAudioSamples (bool preroll)
|
|||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,36 +68,48 @@ static gboolean gst_decklink_src_send_event (GstElement * element,
|
|||||||
static gboolean gst_decklink_src_query (GstElement * element, GstQuery * query);
|
static gboolean gst_decklink_src_query (GstElement * element, GstQuery * query);
|
||||||
|
|
||||||
static GstCaps *gst_decklink_src_audio_src_getcaps (GstPad * pad);
|
static GstCaps *gst_decklink_src_audio_src_getcaps (GstPad * pad);
|
||||||
static gboolean gst_decklink_src_audio_src_setcaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_decklink_src_audio_src_setcaps (GstPad * pad,
|
||||||
static gboolean gst_decklink_src_audio_src_acceptcaps (GstPad * pad, GstCaps * caps);
|
GstCaps * caps);
|
||||||
static void gst_decklink_src_audio_src_fixatecaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_decklink_src_audio_src_acceptcaps (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
|
static void gst_decklink_src_audio_src_fixatecaps (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
static gboolean gst_decklink_src_audio_src_activate (GstPad * pad);
|
static gboolean gst_decklink_src_audio_src_activate (GstPad * pad);
|
||||||
static gboolean gst_decklink_src_audio_src_activatepush (GstPad * pad,
|
static gboolean gst_decklink_src_audio_src_activatepush (GstPad * pad,
|
||||||
gboolean active);
|
gboolean active);
|
||||||
static gboolean gst_decklink_src_audio_src_activatepull (GstPad * pad,
|
static gboolean gst_decklink_src_audio_src_activatepull (GstPad * pad,
|
||||||
gboolean active);
|
gboolean active);
|
||||||
static GstPadLinkReturn gst_decklink_src_audio_src_link (GstPad * pad, GstPad * peer);
|
static GstPadLinkReturn gst_decklink_src_audio_src_link (GstPad * pad,
|
||||||
|
GstPad * peer);
|
||||||
static GstFlowReturn gst_decklink_src_audio_src_getrange (GstPad * pad,
|
static GstFlowReturn gst_decklink_src_audio_src_getrange (GstPad * pad,
|
||||||
guint64 offset, guint length, GstBuffer ** buffer);
|
guint64 offset, guint length, GstBuffer ** buffer);
|
||||||
static gboolean gst_decklink_src_audio_src_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_decklink_src_audio_src_event (GstPad * pad,
|
||||||
static gboolean gst_decklink_src_audio_src_query (GstPad * pad, GstQuery * query);
|
GstEvent * event);
|
||||||
|
static gboolean gst_decklink_src_audio_src_query (GstPad * pad,
|
||||||
|
GstQuery * query);
|
||||||
static GstIterator *gst_decklink_src_audio_src_iterintlink (GstPad * pad);
|
static GstIterator *gst_decklink_src_audio_src_iterintlink (GstPad * pad);
|
||||||
|
|
||||||
|
|
||||||
static GstCaps *gst_decklink_src_video_src_getcaps (GstPad * pad);
|
static GstCaps *gst_decklink_src_video_src_getcaps (GstPad * pad);
|
||||||
static gboolean gst_decklink_src_video_src_setcaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_decklink_src_video_src_setcaps (GstPad * pad,
|
||||||
static gboolean gst_decklink_src_video_src_acceptcaps (GstPad * pad, GstCaps * caps);
|
GstCaps * caps);
|
||||||
static void gst_decklink_src_video_src_fixatecaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_decklink_src_video_src_acceptcaps (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
|
static void gst_decklink_src_video_src_fixatecaps (GstPad * pad,
|
||||||
|
GstCaps * caps);
|
||||||
static gboolean gst_decklink_src_video_src_activate (GstPad * pad);
|
static gboolean gst_decklink_src_video_src_activate (GstPad * pad);
|
||||||
static gboolean gst_decklink_src_video_src_activatepush (GstPad * pad,
|
static gboolean gst_decklink_src_video_src_activatepush (GstPad * pad,
|
||||||
gboolean active);
|
gboolean active);
|
||||||
static gboolean gst_decklink_src_video_src_activatepull (GstPad * pad,
|
static gboolean gst_decklink_src_video_src_activatepull (GstPad * pad,
|
||||||
gboolean active);
|
gboolean active);
|
||||||
static GstPadLinkReturn gst_decklink_src_video_src_link (GstPad * pad, GstPad * peer);
|
static GstPadLinkReturn gst_decklink_src_video_src_link (GstPad * pad,
|
||||||
|
GstPad * peer);
|
||||||
static GstFlowReturn gst_decklink_src_video_src_getrange (GstPad * pad,
|
static GstFlowReturn gst_decklink_src_video_src_getrange (GstPad * pad,
|
||||||
guint64 offset, guint length, GstBuffer ** buffer);
|
guint64 offset, guint length, GstBuffer ** buffer);
|
||||||
static gboolean gst_decklink_src_video_src_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_decklink_src_video_src_event (GstPad * pad,
|
||||||
static gboolean gst_decklink_src_video_src_query (GstPad * pad, GstQuery * query);
|
GstEvent * event);
|
||||||
|
static gboolean gst_decklink_src_video_src_query (GstPad * pad,
|
||||||
|
GstQuery * query);
|
||||||
static GstIterator *gst_decklink_src_video_src_iterintlink (GstPad * pad);
|
static GstIterator *gst_decklink_src_video_src_iterintlink (GstPad * pad);
|
||||||
|
|
||||||
static void gst_decklink_src_task (void *priv);
|
static void gst_decklink_src_task (void *priv);
|
||||||
@ -124,8 +136,7 @@ static GstStaticPadTemplate gst_decklink_src_video_src_template =
|
|||||||
GST_STATIC_PAD_TEMPLATE ("videosrc",
|
GST_STATIC_PAD_TEMPLATE ("videosrc",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (
|
GST_STATIC_CAPS (MODE (720, 486, 30000, 1001, true) ";"
|
||||||
MODE(720,486,30000,1001,true) ";"
|
|
||||||
MODE (720, 486, 24000, 1001, true) ";"
|
MODE (720, 486, 24000, 1001, true) ";"
|
||||||
MODE (720, 576, 25, 1, true) ";"
|
MODE (720, 576, 25, 1, true) ";"
|
||||||
MODE (1920, 1080, 24000, 1001, false) ";"
|
MODE (1920, 1080, 24000, 1001, false) ";"
|
||||||
@ -137,12 +148,12 @@ GST_STATIC_PAD_TEMPLATE ("videosrc",
|
|||||||
MODE (1920, 1080, 30000, 1001, true) ";"
|
MODE (1920, 1080, 30000, 1001, true) ";"
|
||||||
MODE (1920, 1080, 30, 1, true) ";"
|
MODE (1920, 1080, 30, 1, true) ";"
|
||||||
MODE (1280, 720, 50, 1, true) ";"
|
MODE (1280, 720, 50, 1, true) ";"
|
||||||
MODE(1280,720,60000,1001,true) ";"
|
MODE (1280, 720, 60000, 1001, true) ";" MODE (1280, 720, 60, 1, true)
|
||||||
MODE(1280,720,60,1,true)
|
|
||||||
));
|
));
|
||||||
|
|
||||||
typedef struct _DecklinkMode DecklinkMode;
|
typedef struct _DecklinkMode DecklinkMode;
|
||||||
struct _DecklinkMode {
|
struct _DecklinkMode
|
||||||
|
{
|
||||||
BMDDisplayMode mode;
|
BMDDisplayMode mode;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -226,7 +237,8 @@ gst_decklink_src_init (GstDecklinkSrc * decklinksrc,
|
|||||||
gst_task_set_lock (decklinksrc->task, &decklinksrc->task_mutex);
|
gst_task_set_lock (decklinksrc->task, &decklinksrc->task_mutex);
|
||||||
|
|
||||||
decklinksrc->audiosrcpad =
|
decklinksrc->audiosrcpad =
|
||||||
gst_pad_new_from_static_template (&gst_decklink_src_audio_src_template, "audiosrc");
|
gst_pad_new_from_static_template (&gst_decklink_src_audio_src_template,
|
||||||
|
"audiosrc");
|
||||||
gst_pad_set_getcaps_function (decklinksrc->audiosrcpad,
|
gst_pad_set_getcaps_function (decklinksrc->audiosrcpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_decklink_src_audio_src_getcaps));
|
GST_DEBUG_FUNCPTR (gst_decklink_src_audio_src_getcaps));
|
||||||
gst_pad_set_setcaps_function (decklinksrc->audiosrcpad,
|
gst_pad_set_setcaps_function (decklinksrc->audiosrcpad,
|
||||||
@ -256,7 +268,8 @@ gst_decklink_src_init (GstDecklinkSrc * decklinksrc,
|
|||||||
|
|
||||||
|
|
||||||
decklinksrc->videosrcpad =
|
decklinksrc->videosrcpad =
|
||||||
gst_pad_new_from_static_template (&gst_decklink_src_video_src_template, "videosrc");
|
gst_pad_new_from_static_template (&gst_decklink_src_video_src_template,
|
||||||
|
"videosrc");
|
||||||
gst_pad_set_getcaps_function (decklinksrc->videosrcpad,
|
gst_pad_set_getcaps_function (decklinksrc->videosrcpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_decklink_src_video_src_getcaps));
|
GST_DEBUG_FUNCPTR (gst_decklink_src_video_src_getcaps));
|
||||||
gst_pad_set_setcaps_function (decklinksrc->videosrcpad,
|
gst_pad_set_setcaps_function (decklinksrc->videosrcpad,
|
||||||
@ -446,8 +459,9 @@ gst_decklink_src_start (GstElement * element)
|
|||||||
|
|
||||||
sample_depth = 16;
|
sample_depth = 16;
|
||||||
channels = 2;
|
channels = 2;
|
||||||
ret = decklinksrc->input->EnableAudioInput (bmdAudioSampleRate48kHz, sample_depth,
|
ret =
|
||||||
channels);
|
decklinksrc->input->EnableAudioInput (bmdAudioSampleRate48kHz,
|
||||||
|
sample_depth, channels);
|
||||||
if (ret != S_OK) {
|
if (ret != S_OK) {
|
||||||
GST_ERROR ("enable video input failed");
|
GST_ERROR ("enable video input failed");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1004,9 +1018,11 @@ gst_decklink_src_task (void *priv)
|
|||||||
|
|
||||||
video_frame->GetBytes (&data);
|
video_frame->GetBytes (&data);
|
||||||
if (decklinksrc->copy_data) {
|
if (decklinksrc->copy_data) {
|
||||||
buffer = gst_buffer_new_and_alloc (decklinksrc->width * decklinksrc->height * 2);
|
buffer =
|
||||||
|
gst_buffer_new_and_alloc (decklinksrc->width * decklinksrc->height * 2);
|
||||||
|
|
||||||
memcpy (GST_BUFFER_DATA (buffer), data, decklinksrc->width * decklinksrc->height * 2);
|
memcpy (GST_BUFFER_DATA (buffer), data,
|
||||||
|
decklinksrc->width * decklinksrc->height * 2);
|
||||||
|
|
||||||
video_frame->Release ();
|
video_frame->Release ();
|
||||||
} else {
|
} else {
|
||||||
@ -1024,8 +1040,7 @@ gst_decklink_src_task (void *priv)
|
|||||||
decklinksrc->fps_d, decklinksrc->fps_n);
|
decklinksrc->fps_d, decklinksrc->fps_n);
|
||||||
GST_BUFFER_DURATION (buffer) =
|
GST_BUFFER_DURATION (buffer) =
|
||||||
gst_util_uint64_scale_int ((decklinksrc->num_frames + 1) * GST_SECOND,
|
gst_util_uint64_scale_int ((decklinksrc->num_frames + 1) * GST_SECOND,
|
||||||
decklinksrc->fps_d, decklinksrc->fps_n) -
|
decklinksrc->fps_d, decklinksrc->fps_n) - GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_BUFFER_TIMESTAMP (buffer);
|
|
||||||
GST_BUFFER_OFFSET (buffer) = decklinksrc->num_frames;
|
GST_BUFFER_OFFSET (buffer) = decklinksrc->num_frames;
|
||||||
if (decklinksrc->num_frames == 0) {
|
if (decklinksrc->num_frames == 0) {
|
||||||
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);
|
||||||
@ -1039,8 +1054,7 @@ gst_decklink_src_task (void *priv)
|
|||||||
"height", G_TYPE_INT, decklinksrc->height,
|
"height", G_TYPE_INT, decklinksrc->height,
|
||||||
"framerate", GST_TYPE_FRACTION,
|
"framerate", GST_TYPE_FRACTION,
|
||||||
decklinksrc->fps_n, decklinksrc->fps_d,
|
decklinksrc->fps_n, decklinksrc->fps_d,
|
||||||
"interlaced", G_TYPE_BOOLEAN, decklinksrc->interlaced,
|
"interlaced", G_TYPE_BOOLEAN, decklinksrc->interlaced, NULL);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
gst_buffer_set_caps (buffer, decklinksrc->video_caps);
|
gst_buffer_set_caps (buffer, decklinksrc->video_caps);
|
||||||
|
|
||||||
@ -1060,8 +1074,9 @@ gst_decklink_src_task (void *priv)
|
|||||||
gst_util_uint64_scale_int (decklinksrc->num_audio_samples * GST_SECOND,
|
gst_util_uint64_scale_int (decklinksrc->num_audio_samples * GST_SECOND,
|
||||||
1, 48000);
|
1, 48000);
|
||||||
GST_BUFFER_DURATION (audio_buffer) =
|
GST_BUFFER_DURATION (audio_buffer) =
|
||||||
gst_util_uint64_scale_int ((decklinksrc->num_audio_samples + n_samples) * GST_SECOND,
|
gst_util_uint64_scale_int ((decklinksrc->num_audio_samples +
|
||||||
1, 48000) - GST_BUFFER_TIMESTAMP (audio_buffer);
|
n_samples) * GST_SECOND, 1,
|
||||||
|
48000) - GST_BUFFER_TIMESTAMP (audio_buffer);
|
||||||
decklinksrc->num_audio_samples += n_samples;
|
decklinksrc->num_audio_samples += n_samples;
|
||||||
|
|
||||||
if (decklinksrc->audio_caps == NULL) {
|
if (decklinksrc->audio_caps == NULL) {
|
||||||
@ -1070,9 +1085,7 @@ gst_decklink_src_task (void *priv)
|
|||||||
"signed", G_TYPE_BOOLEAN, TRUE,
|
"signed", G_TYPE_BOOLEAN, TRUE,
|
||||||
"depth", G_TYPE_INT, 16,
|
"depth", G_TYPE_INT, 16,
|
||||||
"width", G_TYPE_INT, 16,
|
"width", G_TYPE_INT, 16,
|
||||||
"channels", G_TYPE_INT, 2,
|
"channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 48000, NULL);
|
||||||
"rate", G_TYPE_INT, 48000,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
gst_buffer_set_caps (audio_buffer, decklinksrc->audio_caps);
|
gst_buffer_set_caps (audio_buffer, decklinksrc->audio_caps);
|
||||||
|
|
||||||
@ -1081,5 +1094,3 @@ gst_decklink_src_task (void *priv)
|
|||||||
GST_ELEMENT_ERROR (decklinksrc, CORE, NEGOTIATION, (NULL), (NULL));
|
GST_ELEMENT_ERROR (decklinksrc, CORE, NEGOTIATION, (NULL), (NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user