mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
decklink: reindent
This commit is contained in:
parent
e37ce96b2c
commit
83e2ca791c
4 changed files with 71 additions and 75 deletions
|
@ -43,11 +43,11 @@ IDeckLink *deckLink;
|
|||
IDeckLinkInput *deckLinkInput;
|
||||
IDeckLinkDisplayModeIterator *displayModeIterator;
|
||||
|
||||
static BMDTimecodeFormat g_timecodeFormat = (BMDTimecodeFormat)0;
|
||||
static BMDTimecodeFormat g_timecodeFormat = (BMDTimecodeFormat) 0;
|
||||
|
||||
DeckLinkCaptureDelegate::DeckLinkCaptureDelegate ():m_refCount (0)
|
||||
{
|
||||
m_mutex = g_mutex_new();
|
||||
m_mutex = g_mutex_new ();
|
||||
}
|
||||
|
||||
DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate ()
|
||||
|
@ -55,8 +55,7 @@ DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate ()
|
|||
g_mutex_free (m_mutex);
|
||||
}
|
||||
|
||||
ULONG
|
||||
DeckLinkCaptureDelegate::AddRef (void)
|
||||
ULONG DeckLinkCaptureDelegate::AddRef (void)
|
||||
{
|
||||
g_mutex_lock (m_mutex);
|
||||
m_refCount++;
|
||||
|
@ -65,15 +64,15 @@ DeckLinkCaptureDelegate::AddRef (void)
|
|||
return (ULONG) m_refCount;
|
||||
}
|
||||
|
||||
ULONG
|
||||
DeckLinkCaptureDelegate::Release (void)
|
||||
ULONG DeckLinkCaptureDelegate::Release (void)
|
||||
{
|
||||
g_mutex_lock (m_mutex);
|
||||
m_refCount--;
|
||||
g_mutex_unlock (m_mutex);
|
||||
|
||||
if (m_refCount == 0) {
|
||||
delete this;
|
||||
delete
|
||||
this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,8 @@ gst_decklink_audio_connection_get_type (void)
|
|||
if (!type) {
|
||||
static const GEnumValue connections[] = {
|
||||
{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_ANALOG, "analog", "Analog input"},
|
||||
{0, NULL, NULL}
|
||||
|
@ -110,29 +111,29 @@ gst_decklink_audio_connection_get_type (void)
|
|||
#define HD 1, 1, false, true
|
||||
|
||||
static const GstDecklinkMode modes[] = {
|
||||
{bmdModeNTSC, 720, 486, 30000, 1001, true, NTSC },
|
||||
{bmdModeNTSC2398, 720, 486, 24000, 1001, true, NTSC },
|
||||
{bmdModePAL, 720, 576, 25, 1, true, PAL },
|
||||
{bmdModeNTSCp, 720, 486, 30000, 1001, false, NTSC },
|
||||
{bmdModePALp, 720, 576, 25, 1, false, PAL },
|
||||
{bmdModeNTSC, 720, 486, 30000, 1001, true, NTSC},
|
||||
{bmdModeNTSC2398, 720, 486, 24000, 1001, true, NTSC},
|
||||
{bmdModePAL, 720, 576, 25, 1, true, PAL},
|
||||
{bmdModeNTSCp, 720, 486, 30000, 1001, false, NTSC},
|
||||
{bmdModePALp, 720, 576, 25, 1, false, PAL},
|
||||
|
||||
{bmdModeHD1080p2398, 1920, 1080, 24000, 1001, false, HD },
|
||||
{bmdModeHD1080p24, 1920, 1080, 24, 1, false, HD },
|
||||
{bmdModeHD1080p25, 1920, 1080, 25, 1, false, HD },
|
||||
{bmdModeHD1080p2997, 1920, 1080, 30000, 1001, false, HD },
|
||||
{bmdModeHD1080p30, 1920, 1080, 30, 1, false, HD },
|
||||
{bmdModeHD1080p2398, 1920, 1080, 24000, 1001, false, HD},
|
||||
{bmdModeHD1080p24, 1920, 1080, 24, 1, false, HD},
|
||||
{bmdModeHD1080p25, 1920, 1080, 25, 1, false, HD},
|
||||
{bmdModeHD1080p2997, 1920, 1080, 30000, 1001, false, HD},
|
||||
{bmdModeHD1080p30, 1920, 1080, 30, 1, false, HD},
|
||||
|
||||
{bmdModeHD1080i50, 1920, 1080, 25, 1, true, HD },
|
||||
{bmdModeHD1080i5994, 1920, 1080, 30000, 1001, true, HD },
|
||||
{bmdModeHD1080i6000, 1920, 1080, 30, 1, true, HD },
|
||||
{bmdModeHD1080i50, 1920, 1080, 25, 1, true, HD},
|
||||
{bmdModeHD1080i5994, 1920, 1080, 30000, 1001, true, HD},
|
||||
{bmdModeHD1080i6000, 1920, 1080, 30, 1, true, HD},
|
||||
|
||||
{bmdModeHD1080p50, 1920, 1080, 50, 1, false, HD },
|
||||
{bmdModeHD1080p5994, 1920, 1080, 30000, 1001, false, HD },
|
||||
{bmdModeHD1080p6000, 1920, 1080, 60, 1, false, HD },
|
||||
{bmdModeHD1080p50, 1920, 1080, 50, 1, false, HD},
|
||||
{bmdModeHD1080p5994, 1920, 1080, 30000, 1001, false, HD},
|
||||
{bmdModeHD1080p6000, 1920, 1080, 60, 1, false, HD},
|
||||
|
||||
{bmdModeHD720p50, 1280, 720, 50, 1, false, HD },
|
||||
{bmdModeHD720p5994, 1280, 720, 60000, 1001, false, HD },
|
||||
{bmdModeHD720p60, 1280, 720, 60, 1, false, HD }
|
||||
{bmdModeHD720p50, 1280, 720, 50, 1, false, HD},
|
||||
{bmdModeHD720p5994, 1280, 720, 60000, 1001, 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,
|
||||
"pixel-aspect-ratio", GST_TYPE_FRACTION, mode->par_n, mode->par_d,
|
||||
"color-matrix", G_TYPE_STRING, mode->is_hdtv ? "hdtv" : "sdtv",
|
||||
"chroma-site", G_TYPE_STRING, "mpeg2",
|
||||
NULL);
|
||||
"chroma-site", G_TYPE_STRING, "mpeg2", NULL);
|
||||
}
|
||||
|
||||
GstCaps *
|
||||
|
@ -178,8 +178,8 @@ gst_decklink_mode_get_template_caps (void)
|
|||
GstStructure *s;
|
||||
|
||||
caps = gst_caps_new_empty ();
|
||||
for(i=0;i<(int)G_N_ELEMENTS(modes);i++) {
|
||||
s = gst_decklink_mode_get_structure ((GstDecklinkModeEnum)i);
|
||||
for (i = 0; i < (int) G_N_ELEMENTS (modes); i++) {
|
||||
s = gst_decklink_mode_get_structure ((GstDecklinkModeEnum) i);
|
||||
gst_caps_append_structure (caps, s);
|
||||
}
|
||||
|
||||
|
|
|
@ -277,17 +277,17 @@ gst_decklink_sink_init (GstDecklinkSink * decklinksink,
|
|||
decklinksink->callback->decklinksink = decklinksink;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
decklinksink->com_init_lock = g_mutex_new();
|
||||
decklinksink->com_deinit_lock = g_mutex_new();
|
||||
decklinksink->com_initialized = g_cond_new();
|
||||
decklinksink->com_uninitialize = g_cond_new();
|
||||
decklinksink->com_uninitialized = g_cond_new();
|
||||
decklinksink->com_init_lock = g_mutex_new ();
|
||||
decklinksink->com_deinit_lock = g_mutex_new ();
|
||||
decklinksink->com_initialized = g_cond_new ();
|
||||
decklinksink->com_uninitialize = g_cond_new ();
|
||||
decklinksink->com_uninitialized = g_cond_new ();
|
||||
|
||||
g_mutex_lock (decklinksink->com_init_lock);
|
||||
|
||||
/* create the COM initialization thread */
|
||||
g_thread_create ((GThreadFunc)gst_decklink_sink_com_thread,
|
||||
decklinksink, FALSE, NULL);
|
||||
g_thread_create ((GThreadFunc) gst_decklink_sink_com_thread,
|
||||
decklinksink, FALSE, NULL);
|
||||
|
||||
/* wait until the COM thread signals that COM has been initialized */
|
||||
g_cond_wait (decklinksink->com_initialized, decklinksink->com_init_lock);
|
||||
|
@ -347,7 +347,8 @@ gst_decklink_sink_com_thread (GstDecklinkSink * src)
|
|||
|
||||
res = CoInitializeEx (0, COINIT_MULTITHREADED);
|
||||
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)
|
||||
GST_WARNING_OBJECT (src, "The concurrency model of COM has changed.");
|
||||
else
|
||||
|
@ -402,7 +403,8 @@ gst_decklink_sink_finalize (GObject * object)
|
|||
if (decklinksink->comInitialized) {
|
||||
g_mutex_lock (decklinksink->com_deinit_lock);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -455,8 +457,8 @@ gst_decklink_sink_start (GstDecklinkSink * decklinksink)
|
|||
}
|
||||
//decklinksink->video_enabled = TRUE;
|
||||
|
||||
decklinksink->output->
|
||||
SetScheduledFrameCompletionCallback (decklinksink->callback);
|
||||
decklinksink->output->SetScheduledFrameCompletionCallback (decklinksink->
|
||||
callback);
|
||||
|
||||
sample_depth = bmdAudioSampleType16bitInteger;
|
||||
ret = decklinksink->output->EnableAudioOutput (bmdAudioSampleRate48kHz,
|
||||
|
@ -1089,16 +1091,18 @@ HRESULT
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Output::ScheduledPlaybackHasStopped ()
|
||||
HRESULT
|
||||
Output::ScheduledPlaybackHasStopped ()
|
||||
{
|
||||
GST_ERROR ("ScheduledPlaybackHasStopped");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Output::RenderAudioSamples (bool preroll)
|
||||
HRESULT
|
||||
Output::RenderAudioSamples (bool preroll)
|
||||
{
|
||||
uint32_t samplesWritten;
|
||||
GstBuffer * buffer;
|
||||
GstBuffer *buffer;
|
||||
|
||||
// guint64 samplesToWrite;
|
||||
|
||||
|
@ -1108,9 +1112,7 @@ HRESULT Output::RenderAudioSamples (bool preroll)
|
|||
// running = true;
|
||||
} else {
|
||||
g_mutex_lock (decklinksink->audio_mutex);
|
||||
decklinksink->output->ScheduleAudioSamples (
|
||||
GST_BUFFER_DATA (decklinksink->audio_buffer),
|
||||
GST_BUFFER_SIZE (decklinksink->audio_buffer) / 4, // 2 bytes per sample, stereo
|
||||
decklinksink->output->ScheduleAudioSamples (GST_BUFFER_DATA (decklinksink->audio_buffer), GST_BUFFER_SIZE (decklinksink->audio_buffer) / 4, // 2 bytes per sample, stereo
|
||||
0, 0, &samplesWritten);
|
||||
|
||||
buffer =
|
||||
|
|
|
@ -322,20 +322,20 @@ gst_decklink_src_init (GstDecklinkSrc * decklinksrc,
|
|||
decklinksrc->stop = FALSE;
|
||||
decklinksrc->dropped_frames = 0;
|
||||
decklinksrc->dropped_frames_old = 0;
|
||||
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
|
||||
decklinksrc->com_init_lock = g_mutex_new();
|
||||
decklinksrc->com_deinit_lock = g_mutex_new();
|
||||
decklinksrc->com_initialized = g_cond_new();
|
||||
decklinksrc->com_uninitialize = g_cond_new();
|
||||
decklinksrc->com_uninitialized = g_cond_new();
|
||||
decklinksrc->com_init_lock = g_mutex_new ();
|
||||
decklinksrc->com_deinit_lock = g_mutex_new ();
|
||||
decklinksrc->com_initialized = g_cond_new ();
|
||||
decklinksrc->com_uninitialize = g_cond_new ();
|
||||
decklinksrc->com_uninitialized = g_cond_new ();
|
||||
|
||||
g_mutex_lock (decklinksrc->com_init_lock);
|
||||
|
||||
/* create the COM initialization thread */
|
||||
g_thread_create ((GThreadFunc)gst_decklink_src_com_thread,
|
||||
decklinksrc, FALSE, NULL);
|
||||
g_thread_create ((GThreadFunc) gst_decklink_src_com_thread,
|
||||
decklinksrc, FALSE, NULL);
|
||||
|
||||
/* wait until the COM thread signals that COM has been initialized */
|
||||
g_cond_wait (decklinksrc->com_initialized, decklinksrc->com_init_lock);
|
||||
|
@ -415,7 +415,8 @@ gst_decklink_src_com_thread (GstDecklinkSrc * src)
|
|||
|
||||
res = CoInitializeEx (0, COINIT_MULTITHREADED);
|
||||
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)
|
||||
GST_WARNING_OBJECT (src, "The concurrency model of COM has changed.");
|
||||
else
|
||||
|
@ -470,7 +471,6 @@ gst_decklink_src_finalize (GObject * object)
|
|||
if (decklinksrc->video_caps) {
|
||||
gst_caps_unref (decklinksrc->video_caps);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* signal the COM thread that it should uninitialize COM */
|
||||
if (decklinksrc->comInitialized) {
|
||||
|
@ -1213,10 +1213,9 @@ gst_decklink_src_task (void *priv)
|
|||
/* warning on dropped frames */
|
||||
if (decklinksrc->dropped_frames - decklinksrc->dropped_frames_old > 0) {
|
||||
GST_ELEMENT_WARNING (decklinksrc, RESOURCE, READ,
|
||||
("Dropped %d frame(s), for a total of %d frame(s)",
|
||||
decklinksrc->dropped_frames - decklinksrc->dropped_frames_old,
|
||||
decklinksrc->dropped_frames),
|
||||
(NULL));
|
||||
("Dropped %d frame(s), for a total of %d frame(s)",
|
||||
decklinksrc->dropped_frames - decklinksrc->dropped_frames_old,
|
||||
decklinksrc->dropped_frames), (NULL));
|
||||
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);
|
||||
|
||||
ret = gst_pad_push (decklinksrc->videosrcpad, buffer);
|
||||
if (! (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED ||
|
||||
ret == GST_FLOW_WRONG_STATE)) {
|
||||
if (!(ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED ||
|
||||
ret == GST_FLOW_WRONG_STATE)) {
|
||||
GST_ELEMENT_ERROR (decklinksrc, STREAM, FAILED,
|
||||
("Internal data stream error."),
|
||||
("stream stopped, reason %s",
|
||||
gst_flow_get_name (ret)));
|
||||
("Internal data stream error."),
|
||||
("stream stopped, reason %s", gst_flow_get_name (ret)));
|
||||
}
|
||||
|
||||
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,
|
||||
1, 48000);
|
||||
GST_BUFFER_DURATION (audio_buffer) =
|
||||
gst_util_uint64_scale_int ((decklinksrc->num_audio_samples +
|
||||
n_samples) * GST_SECOND, 1,
|
||||
48000) - GST_BUFFER_TIMESTAMP (audio_buffer);
|
||||
gst_util_uint64_scale_int (n_samples * GST_SECOND, 1, 48000);
|
||||
decklinksrc->num_audio_samples += n_samples;
|
||||
|
||||
if (decklinksrc->audio_caps == NULL) {
|
||||
|
@ -1303,12 +1299,11 @@ gst_decklink_src_task (void *priv)
|
|||
gst_buffer_set_caps (audio_buffer, decklinksrc->audio_caps);
|
||||
|
||||
ret = gst_pad_push (decklinksrc->audiosrcpad, audio_buffer);
|
||||
if (! (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED ||
|
||||
ret == GST_FLOW_WRONG_STATE)) {
|
||||
if (!(ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED ||
|
||||
ret == GST_FLOW_WRONG_STATE)) {
|
||||
GST_ELEMENT_ERROR (decklinksrc, STREAM, FAILED,
|
||||
("Internal data stream error."),
|
||||
("stream stopped, reason %s",
|
||||
gst_flow_get_name (ret)));
|
||||
("Internal data stream error."),
|
||||
("stream stopped, reason %s", gst_flow_get_name (ret)));
|
||||
}
|
||||
}
|
||||
audio_frame->Release ();
|
||||
|
|
Loading…
Reference in a new issue