decklink: reindent

This commit is contained in:
David Schleef 2012-03-17 11:39:54 -07:00
parent e37ce96b2c
commit 83e2ca791c
4 changed files with 71 additions and 75 deletions

View file

@ -43,11 +43,11 @@ IDeckLink *deckLink;
IDeckLinkInput *deckLinkInput; IDeckLinkInput *deckLinkInput;
IDeckLinkDisplayModeIterator *displayModeIterator; IDeckLinkDisplayModeIterator *displayModeIterator;
static BMDTimecodeFormat g_timecodeFormat = (BMDTimecodeFormat)0; static BMDTimecodeFormat g_timecodeFormat = (BMDTimecodeFormat) 0;
DeckLinkCaptureDelegate::DeckLinkCaptureDelegate ():m_refCount (0) DeckLinkCaptureDelegate::DeckLinkCaptureDelegate ():m_refCount (0)
{ {
m_mutex = g_mutex_new(); m_mutex = g_mutex_new ();
} }
DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate () DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate ()
@ -55,8 +55,7 @@ DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate ()
g_mutex_free (m_mutex); g_mutex_free (m_mutex);
} }
ULONG ULONG DeckLinkCaptureDelegate::AddRef (void)
DeckLinkCaptureDelegate::AddRef (void)
{ {
g_mutex_lock (m_mutex); g_mutex_lock (m_mutex);
m_refCount++; m_refCount++;
@ -65,15 +64,15 @@ DeckLinkCaptureDelegate::AddRef (void)
return (ULONG) m_refCount; return (ULONG) m_refCount;
} }
ULONG ULONG DeckLinkCaptureDelegate::Release (void)
DeckLinkCaptureDelegate::Release (void)
{ {
g_mutex_lock (m_mutex); g_mutex_lock (m_mutex);
m_refCount--; m_refCount--;
g_mutex_unlock (m_mutex); g_mutex_unlock (m_mutex);
if (m_refCount == 0) { if (m_refCount == 0) {
delete this; delete
this;
return 0; return 0;
} }

View file

@ -94,7 +94,8 @@ gst_decklink_audio_connection_get_type (void)
if (!type) { if (!type) {
static const GEnumValue connections[] = { static const GEnumValue connections[] = {
{GST_DECKLINK_AUDIO_CONNECTION_AUTO, "auto", "Automatic"}, {GST_DECKLINK_AUDIO_CONNECTION_AUTO, "auto", "Automatic"},
{GST_DECKLINK_AUDIO_CONNECTION_EMBEDDED, "embedded", "SDI/HDMI embedded audio"}, {GST_DECKLINK_AUDIO_CONNECTION_EMBEDDED, "embedded",
"SDI/HDMI embedded audio"},
{GST_DECKLINK_AUDIO_CONNECTION_AES_EBU, "aes", "AES/EBU input"}, {GST_DECKLINK_AUDIO_CONNECTION_AES_EBU, "aes", "AES/EBU input"},
{GST_DECKLINK_AUDIO_CONNECTION_ANALOG, "analog", "Analog input"}, {GST_DECKLINK_AUDIO_CONNECTION_ANALOG, "analog", "Analog input"},
{0, NULL, NULL} {0, NULL, NULL}
@ -110,29 +111,29 @@ gst_decklink_audio_connection_get_type (void)
#define HD 1, 1, false, true #define HD 1, 1, false, true
static const GstDecklinkMode modes[] = { static const GstDecklinkMode modes[] = {
{bmdModeNTSC, 720, 486, 30000, 1001, true, NTSC }, {bmdModeNTSC, 720, 486, 30000, 1001, true, NTSC},
{bmdModeNTSC2398, 720, 486, 24000, 1001, true, NTSC }, {bmdModeNTSC2398, 720, 486, 24000, 1001, true, NTSC},
{bmdModePAL, 720, 576, 25, 1, true, PAL }, {bmdModePAL, 720, 576, 25, 1, true, PAL},
{bmdModeNTSCp, 720, 486, 30000, 1001, false, NTSC }, {bmdModeNTSCp, 720, 486, 30000, 1001, false, NTSC},
{bmdModePALp, 720, 576, 25, 1, false, PAL }, {bmdModePALp, 720, 576, 25, 1, false, PAL},
{bmdModeHD1080p2398, 1920, 1080, 24000, 1001, false, HD }, {bmdModeHD1080p2398, 1920, 1080, 24000, 1001, false, HD},
{bmdModeHD1080p24, 1920, 1080, 24, 1, false, HD }, {bmdModeHD1080p24, 1920, 1080, 24, 1, false, HD},
{bmdModeHD1080p25, 1920, 1080, 25, 1, false, HD }, {bmdModeHD1080p25, 1920, 1080, 25, 1, false, HD},
{bmdModeHD1080p2997, 1920, 1080, 30000, 1001, false, HD }, {bmdModeHD1080p2997, 1920, 1080, 30000, 1001, false, HD},
{bmdModeHD1080p30, 1920, 1080, 30, 1, false, HD }, {bmdModeHD1080p30, 1920, 1080, 30, 1, false, HD},
{bmdModeHD1080i50, 1920, 1080, 25, 1, true, HD }, {bmdModeHD1080i50, 1920, 1080, 25, 1, true, HD},
{bmdModeHD1080i5994, 1920, 1080, 30000, 1001, true, HD }, {bmdModeHD1080i5994, 1920, 1080, 30000, 1001, true, HD},
{bmdModeHD1080i6000, 1920, 1080, 30, 1, true, HD }, {bmdModeHD1080i6000, 1920, 1080, 30, 1, true, HD},
{bmdModeHD1080p50, 1920, 1080, 50, 1, false, HD }, {bmdModeHD1080p50, 1920, 1080, 50, 1, false, HD},
{bmdModeHD1080p5994, 1920, 1080, 30000, 1001, false, HD }, {bmdModeHD1080p5994, 1920, 1080, 30000, 1001, false, HD},
{bmdModeHD1080p6000, 1920, 1080, 60, 1, false, HD }, {bmdModeHD1080p6000, 1920, 1080, 60, 1, false, HD},
{bmdModeHD720p50, 1280, 720, 50, 1, false, HD }, {bmdModeHD720p50, 1280, 720, 50, 1, false, HD},
{bmdModeHD720p5994, 1280, 720, 60000, 1001, false, HD }, {bmdModeHD720p5994, 1280, 720, 60000, 1001, false, HD},
{bmdModeHD720p60, 1280, 720, 60, 1, false, HD } {bmdModeHD720p60, 1280, 720, 60, 1, false, HD}
}; };
@ -155,8 +156,7 @@ gst_decklink_mode_get_structure (GstDecklinkModeEnum e)
"interlaced", G_TYPE_BOOLEAN, mode->interlaced, "interlaced", G_TYPE_BOOLEAN, mode->interlaced,
"pixel-aspect-ratio", GST_TYPE_FRACTION, mode->par_n, mode->par_d, "pixel-aspect-ratio", GST_TYPE_FRACTION, mode->par_n, mode->par_d,
"color-matrix", G_TYPE_STRING, mode->is_hdtv ? "hdtv" : "sdtv", "color-matrix", G_TYPE_STRING, mode->is_hdtv ? "hdtv" : "sdtv",
"chroma-site", G_TYPE_STRING, "mpeg2", "chroma-site", G_TYPE_STRING, "mpeg2", NULL);
NULL);
} }
GstCaps * GstCaps *
@ -178,8 +178,8 @@ gst_decklink_mode_get_template_caps (void)
GstStructure *s; GstStructure *s;
caps = gst_caps_new_empty (); caps = gst_caps_new_empty ();
for(i=0;i<(int)G_N_ELEMENTS(modes);i++) { for (i = 0; i < (int) G_N_ELEMENTS (modes); i++) {
s = gst_decklink_mode_get_structure ((GstDecklinkModeEnum)i); s = gst_decklink_mode_get_structure ((GstDecklinkModeEnum) i);
gst_caps_append_structure (caps, s); gst_caps_append_structure (caps, s);
} }

View file

@ -277,16 +277,16 @@ gst_decklink_sink_init (GstDecklinkSink * decklinksink,
decklinksink->callback->decklinksink = decklinksink; decklinksink->callback->decklinksink = decklinksink;
#ifdef _MSC_VER #ifdef _MSC_VER
decklinksink->com_init_lock = g_mutex_new(); decklinksink->com_init_lock = g_mutex_new ();
decklinksink->com_deinit_lock = g_mutex_new(); decklinksink->com_deinit_lock = g_mutex_new ();
decklinksink->com_initialized = g_cond_new(); decklinksink->com_initialized = g_cond_new ();
decklinksink->com_uninitialize = g_cond_new(); decklinksink->com_uninitialize = g_cond_new ();
decklinksink->com_uninitialized = g_cond_new(); decklinksink->com_uninitialized = g_cond_new ();
g_mutex_lock (decklinksink->com_init_lock); g_mutex_lock (decklinksink->com_init_lock);
/* create the COM initialization thread */ /* create the COM initialization thread */
g_thread_create ((GThreadFunc)gst_decklink_sink_com_thread, g_thread_create ((GThreadFunc) gst_decklink_sink_com_thread,
decklinksink, FALSE, NULL); decklinksink, FALSE, NULL);
/* wait until the COM thread signals that COM has been initialized */ /* wait until the COM thread signals that COM has been initialized */
@ -347,7 +347,8 @@ gst_decklink_sink_com_thread (GstDecklinkSink * src)
res = CoInitializeEx (0, COINIT_MULTITHREADED); res = CoInitializeEx (0, COINIT_MULTITHREADED);
if (res == S_FALSE) if (res == S_FALSE)
GST_WARNING_OBJECT (src, "COM has been already initialized in the same process"); GST_WARNING_OBJECT (src,
"COM has been already initialized in the same process");
else if (res == RPC_E_CHANGED_MODE) else if (res == RPC_E_CHANGED_MODE)
GST_WARNING_OBJECT (src, "The concurrency model of COM has changed."); GST_WARNING_OBJECT (src, "The concurrency model of COM has changed.");
else else
@ -402,7 +403,8 @@ gst_decklink_sink_finalize (GObject * object)
if (decklinksink->comInitialized) { if (decklinksink->comInitialized) {
g_mutex_lock (decklinksink->com_deinit_lock); g_mutex_lock (decklinksink->com_deinit_lock);
g_cond_signal (decklinksink->com_uninitialize); g_cond_signal (decklinksink->com_uninitialize);
g_cond_wait (decklinksink->com_uninitialized, decklinksink->com_deinit_lock); g_cond_wait (decklinksink->com_uninitialized,
decklinksink->com_deinit_lock);
g_mutex_unlock (decklinksink->com_deinit_lock); g_mutex_unlock (decklinksink->com_deinit_lock);
} }
@ -455,8 +457,8 @@ gst_decklink_sink_start (GstDecklinkSink * decklinksink)
} }
//decklinksink->video_enabled = TRUE; //decklinksink->video_enabled = TRUE;
decklinksink->output-> decklinksink->output->SetScheduledFrameCompletionCallback (decklinksink->
SetScheduledFrameCompletionCallback (decklinksink->callback); callback);
sample_depth = bmdAudioSampleType16bitInteger; sample_depth = bmdAudioSampleType16bitInteger;
ret = decklinksink->output->EnableAudioOutput (bmdAudioSampleRate48kHz, ret = decklinksink->output->EnableAudioOutput (bmdAudioSampleRate48kHz,
@ -1089,16 +1091,18 @@ HRESULT
return S_OK; return S_OK;
} }
HRESULT Output::ScheduledPlaybackHasStopped () HRESULT
Output::ScheduledPlaybackHasStopped ()
{ {
GST_ERROR ("ScheduledPlaybackHasStopped"); GST_ERROR ("ScheduledPlaybackHasStopped");
return S_OK; return S_OK;
} }
HRESULT Output::RenderAudioSamples (bool preroll) HRESULT
Output::RenderAudioSamples (bool preroll)
{ {
uint32_t samplesWritten; uint32_t samplesWritten;
GstBuffer * buffer; GstBuffer *buffer;
// guint64 samplesToWrite; // guint64 samplesToWrite;
@ -1108,9 +1112,7 @@ HRESULT Output::RenderAudioSamples (bool preroll)
// running = true; // running = true;
} else { } else {
g_mutex_lock (decklinksink->audio_mutex); g_mutex_lock (decklinksink->audio_mutex);
decklinksink->output->ScheduleAudioSamples ( decklinksink->output->ScheduleAudioSamples (GST_BUFFER_DATA (decklinksink->audio_buffer), GST_BUFFER_SIZE (decklinksink->audio_buffer) / 4, // 2 bytes per sample, stereo
GST_BUFFER_DATA (decklinksink->audio_buffer),
GST_BUFFER_SIZE (decklinksink->audio_buffer) / 4, // 2 bytes per sample, stereo
0, 0, &samplesWritten); 0, 0, &samplesWritten);
buffer = buffer =

View file

@ -325,16 +325,16 @@ gst_decklink_src_init (GstDecklinkSrc * decklinksrc,
decklinksrc->frame_num = -1; /* -1 so will be 0 after incrementing */ decklinksrc->frame_num = -1; /* -1 so will be 0 after incrementing */
#ifdef _MSC_VER #ifdef _MSC_VER
decklinksrc->com_init_lock = g_mutex_new(); decklinksrc->com_init_lock = g_mutex_new ();
decklinksrc->com_deinit_lock = g_mutex_new(); decklinksrc->com_deinit_lock = g_mutex_new ();
decklinksrc->com_initialized = g_cond_new(); decklinksrc->com_initialized = g_cond_new ();
decklinksrc->com_uninitialize = g_cond_new(); decklinksrc->com_uninitialize = g_cond_new ();
decklinksrc->com_uninitialized = g_cond_new(); decklinksrc->com_uninitialized = g_cond_new ();
g_mutex_lock (decklinksrc->com_init_lock); g_mutex_lock (decklinksrc->com_init_lock);
/* create the COM initialization thread */ /* create the COM initialization thread */
g_thread_create ((GThreadFunc)gst_decklink_src_com_thread, g_thread_create ((GThreadFunc) gst_decklink_src_com_thread,
decklinksrc, FALSE, NULL); decklinksrc, FALSE, NULL);
/* wait until the COM thread signals that COM has been initialized */ /* wait until the COM thread signals that COM has been initialized */
@ -415,7 +415,8 @@ gst_decklink_src_com_thread (GstDecklinkSrc * src)
res = CoInitializeEx (0, COINIT_MULTITHREADED); res = CoInitializeEx (0, COINIT_MULTITHREADED);
if (res == S_FALSE) if (res == S_FALSE)
GST_WARNING_OBJECT (src, "COM has been already initialized in the same process"); GST_WARNING_OBJECT (src,
"COM has been already initialized in the same process");
else if (res == RPC_E_CHANGED_MODE) else if (res == RPC_E_CHANGED_MODE)
GST_WARNING_OBJECT (src, "The concurrency model of COM has changed."); GST_WARNING_OBJECT (src, "The concurrency model of COM has changed.");
else else
@ -470,7 +471,6 @@ gst_decklink_src_finalize (GObject * object)
if (decklinksrc->video_caps) { if (decklinksrc->video_caps) {
gst_caps_unref (decklinksrc->video_caps); gst_caps_unref (decklinksrc->video_caps);
} }
#ifdef _MSC_VER #ifdef _MSC_VER
/* signal the COM thread that it should uninitialize COM */ /* signal the COM thread that it should uninitialize COM */
if (decklinksrc->comInitialized) { if (decklinksrc->comInitialized) {
@ -1215,8 +1215,7 @@ gst_decklink_src_task (void *priv)
GST_ELEMENT_WARNING (decklinksrc, RESOURCE, READ, GST_ELEMENT_WARNING (decklinksrc, RESOURCE, READ,
("Dropped %d frame(s), for a total of %d frame(s)", ("Dropped %d frame(s), for a total of %d frame(s)",
decklinksrc->dropped_frames - decklinksrc->dropped_frames_old, decklinksrc->dropped_frames - decklinksrc->dropped_frames_old,
decklinksrc->dropped_frames), decklinksrc->dropped_frames), (NULL));
(NULL));
decklinksrc->dropped_frames_old = decklinksrc->dropped_frames; decklinksrc->dropped_frames_old = decklinksrc->dropped_frames;
} }
@ -1269,12 +1268,11 @@ gst_decklink_src_task (void *priv)
gst_buffer_set_caps (buffer, decklinksrc->video_caps); gst_buffer_set_caps (buffer, decklinksrc->video_caps);
ret = gst_pad_push (decklinksrc->videosrcpad, buffer); ret = gst_pad_push (decklinksrc->videosrcpad, buffer);
if (! (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED || if (!(ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED ||
ret == GST_FLOW_WRONG_STATE)) { ret == GST_FLOW_WRONG_STATE)) {
GST_ELEMENT_ERROR (decklinksrc, STREAM, FAILED, GST_ELEMENT_ERROR (decklinksrc, STREAM, FAILED,
("Internal data stream error."), ("Internal data stream error."),
("stream stopped, reason %s", ("stream stopped, reason %s", gst_flow_get_name (ret)));
gst_flow_get_name (ret)));
} }
if (gst_pad_is_linked (decklinksrc->audiosrcpad)) { if (gst_pad_is_linked (decklinksrc->audiosrcpad)) {
@ -1287,9 +1285,7 @@ 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 + gst_util_uint64_scale_int (n_samples * GST_SECOND, 1, 48000);
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) {
@ -1303,12 +1299,11 @@ gst_decklink_src_task (void *priv)
gst_buffer_set_caps (audio_buffer, decklinksrc->audio_caps); gst_buffer_set_caps (audio_buffer, decklinksrc->audio_caps);
ret = gst_pad_push (decklinksrc->audiosrcpad, audio_buffer); ret = gst_pad_push (decklinksrc->audiosrcpad, audio_buffer);
if (! (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED || if (!(ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED ||
ret == GST_FLOW_WRONG_STATE)) { ret == GST_FLOW_WRONG_STATE)) {
GST_ELEMENT_ERROR (decklinksrc, STREAM, FAILED, GST_ELEMENT_ERROR (decklinksrc, STREAM, FAILED,
("Internal data stream error."), ("Internal data stream error."),
("stream stopped, reason %s", ("stream stopped, reason %s", gst_flow_get_name (ret)));
gst_flow_get_name (ret)));
} }
} }
audio_frame->Release (); audio_frame->Release ();