Commit cd017574 authored by Rafaël Carré's avatar Rafaël Carré

decklink: cosmetics (1tbs)

parent d270debb
...@@ -183,10 +183,8 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame ...@@ -183,10 +183,8 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
{ {
demux_sys_t *sys = demux_->p_sys; demux_sys_t *sys = demux_->p_sys;
if (videoFrame) if (videoFrame) {
{ if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
if (videoFrame->GetFlags() & bmdFrameHasNoInputSource)
{
msg_Warn(demux_, "No input signal detected"); msg_Warn(demux_, "No input signal detected");
return S_OK; return S_OK;
} }
...@@ -202,8 +200,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame ...@@ -202,8 +200,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
void *frame_bytes; void *frame_bytes;
videoFrame->GetBytes(&frame_bytes); videoFrame->GetBytes(&frame_bytes);
for (int y = 0; y < height; ++y) for (int y = 0; y < height; ++y) {
{
const uint8_t *src = (const uint8_t *)frame_bytes + stride * y; const uint8_t *src = (const uint8_t *)frame_bytes + stride * y;
uint8_t *dst = video_frame->p_buffer + width * bpp * y; uint8_t *dst = video_frame->p_buffer + width * bpp * y;
memcpy(dst, src, width * bpp); memcpy(dst, src, width * bpp);
...@@ -223,8 +220,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame ...@@ -223,8 +220,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
es_out_Send(demux_->out, sys->video_es, video_frame); es_out_Send(demux_->out, sys->video_es, video_frame);
} }
if (audioFrame) if (audioFrame) {
{
const int bytes = audioFrame->GetSampleFrameCount() * sizeof(int16_t) * sys->channels; const int bytes = audioFrame->GetSampleFrameCount() * sizeof(int16_t) * sys->channels;
block_t *audio_frame = block_New(demux_, bytes); block_t *audio_frame = block_New(demux_, bytes);
...@@ -268,15 +264,13 @@ static int GetAudioConn(demux_t *demux) ...@@ -268,15 +264,13 @@ static int GetAudioConn(demux_t *demux)
c = bmdAudioConnectionAESEBU; c = bmdAudioConnectionAESEBU;
else if (!strcmp(opt, "analog")) else if (!strcmp(opt, "analog"))
c = bmdAudioConnectionAnalog; c = bmdAudioConnectionAnalog;
else else {
{
msg_Err(demux, "Invalid audio-connection: `%s\' specified", opt); msg_Err(demux, "Invalid audio-connection: `%s\' specified", opt);
free(opt); free(opt);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if (sys->config->SetInt(bmdDeckLinkConfigAudioInputConnection, c) != S_OK) if (sys->config->SetInt(bmdDeckLinkConfigAudioInputConnection, c) != S_OK) {
{
msg_Err(demux, "Failed to set audio input connection"); msg_Err(demux, "Failed to set audio input connection");
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -305,16 +299,14 @@ static int GetVideoConn(demux_t *demux) ...@@ -305,16 +299,14 @@ static int GetVideoConn(demux_t *demux)
c = bmdVideoConnectionComposite; c = bmdVideoConnectionComposite;
else if (!strcmp(opt, "svideo")) else if (!strcmp(opt, "svideo"))
c = bmdVideoConnectionSVideo; c = bmdVideoConnectionSVideo;
else else {
{
msg_Err(demux, "Invalid video-connection: `%s\' specified", opt); msg_Err(demux, "Invalid video-connection: `%s\' specified", opt);
free(opt); free(opt);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
free(opt); free(opt);
if (sys->config->SetInt(bmdDeckLinkConfigVideoInputConnection, c) != S_OK) if (sys->config->SetInt(bmdDeckLinkConfigVideoInputConnection, c) != S_OK) {
{
msg_Err(demux, "Failed to set video input connection"); msg_Err(demux, "Failed to set video input connection");
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -354,48 +346,41 @@ static int Open(vlc_object_t *p_this) ...@@ -354,48 +346,41 @@ static int Open(vlc_object_t *p_this)
IDeckLinkDisplayModeIterator *display_iterator = NULL; IDeckLinkDisplayModeIterator *display_iterator = NULL;
IDeckLinkIterator *decklink_iterator = CreateDeckLinkIteratorInstance(); IDeckLinkIterator *decklink_iterator = CreateDeckLinkIteratorInstance();
if (!decklink_iterator) if (!decklink_iterator) {
{
msg_Err(demux, "DeckLink drivers not found."); msg_Err(demux, "DeckLink drivers not found.");
goto finish; goto finish;
} }
card_index = var_InheritInteger(demux, "decklink-card-index"); card_index = var_InheritInteger(demux, "decklink-card-index");
if (card_index < 0) if (card_index < 0) {
{
msg_Err(demux, "Invalid card index %d", card_index); msg_Err(demux, "Invalid card index %d", card_index);
goto finish; goto finish;
} }
for (int i = 0; i <= card_index; i++) for (int i = 0; i <= card_index; i++) {
{
if (sys->card) if (sys->card)
sys->card->Release(); sys->card->Release();
if (decklink_iterator->Next(&sys->card) != S_OK) if (decklink_iterator->Next(&sys->card) != S_OK) {
{
msg_Err(demux, "DeckLink PCI card %d not found", card_index); msg_Err(demux, "DeckLink PCI card %d not found", card_index);
goto finish; goto finish;
} }
} }
const char *model_name; const char *model_name;
if (sys->card->GetModelName(&model_name) != S_OK) if (sys->card->GetModelName(&model_name) != S_OK) {
{
msg_Err(demux, "Could not get model name"); msg_Err(demux, "Could not get model name");
goto finish; goto finish;
} }
msg_Dbg(demux, "Opened DeckLink PCI card %d (%s)", card_index, model_name); msg_Dbg(demux, "Opened DeckLink PCI card %d (%s)", card_index, model_name);
if (sys->card->QueryInterface(IID_IDeckLinkInput, (void**)&sys->input) != S_OK) if (sys->card->QueryInterface(IID_IDeckLinkInput, (void**)&sys->input) != S_OK) {
{
msg_Err(demux, "Card has no inputs"); msg_Err(demux, "Card has no inputs");
goto finish; goto finish;
} }
/* Set up the video and audio sources. */ /* Set up the video and audio sources. */
if (sys->card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&sys->config) != S_OK) if (sys->card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&sys->config) != S_OK) {
{
msg_Err(demux, "Failed to get configuration interface"); msg_Err(demux, "Failed to get configuration interface");
goto finish; goto finish;
} }
...@@ -404,8 +389,7 @@ static int Open(vlc_object_t *p_this) ...@@ -404,8 +389,7 @@ static int Open(vlc_object_t *p_this)
goto finish; goto finish;
/* Get the list of display modes. */ /* Get the list of display modes. */
if (sys->input->GetDisplayModeIterator(&display_iterator) != S_OK) if (sys->input->GetDisplayModeIterator(&display_iterator) != S_OK) {
{
msg_Err(demux, "Failed to enumerate display modes"); msg_Err(demux, "Failed to enumerate display modes");
goto finish; goto finish;
} }
...@@ -430,8 +414,7 @@ static int Open(vlc_object_t *p_this) ...@@ -430,8 +414,7 @@ static int Open(vlc_object_t *p_this)
b_found_mode = false; b_found_mode = false;
for (;;) for (;;) {
{
IDeckLinkDisplayMode *display_mode; IDeckLinkDisplayMode *display_mode;
if ((display_iterator->Next(&display_mode) != S_OK) || !display_mode) if ((display_iterator->Next(&display_mode) != S_OK) || !display_mode)
break; break;
...@@ -441,16 +424,14 @@ static int Open(vlc_object_t *p_this) ...@@ -441,16 +424,14 @@ static int Open(vlc_object_t *p_this)
memcpy(sz_mode_id_text, &mode_id, sizeof(mode_id)); memcpy(sz_mode_id_text, &mode_id, sizeof(mode_id));
const char *mode_name; const char *mode_name;
if (display_mode->GetName(&mode_name) != S_OK) if (display_mode->GetName(&mode_name) != S_OK) {
{
msg_Err(demux, "Failed to get display mode name"); msg_Err(demux, "Failed to get display mode name");
display_mode->Release(); display_mode->Release();
goto finish; goto finish;
} }
BMDTimeValue frame_duration, time_scale; BMDTimeValue frame_duration, time_scale;
if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) if (display_mode->GetFrameRate(&frame_duration, &time_scale) != S_OK) {
{
msg_Err(demux, "Failed to get frame rate"); msg_Err(demux, "Failed to get frame rate");
display_mode->Release(); display_mode->Release();
goto finish; goto finish;
...@@ -485,8 +466,7 @@ static int Open(vlc_object_t *p_this) ...@@ -485,8 +466,7 @@ static int Open(vlc_object_t *p_this)
(int)display_mode->GetWidth(), (int)display_mode->GetHeight(), (int)display_mode->GetWidth(), (int)display_mode->GetHeight(),
double(time_scale) / frame_duration, field_dominance); double(time_scale) / frame_duration, field_dominance);
if (wanted_mode_id == mode_id) if (wanted_mode_id == mode_id) {
{
b_found_mode = true; b_found_mode = true;
width = display_mode->GetWidth(); width = display_mode->GetWidth();
height = display_mode->GetHeight(); height = display_mode->GetHeight();
...@@ -498,15 +478,13 @@ static int Open(vlc_object_t *p_this) ...@@ -498,15 +478,13 @@ static int Open(vlc_object_t *p_this)
display_mode->Release(); display_mode->Release();
} }
if (!b_found_mode) if (!b_found_mode) {
{
msg_Err(demux, "Unknown video mode specified. " msg_Err(demux, "Unknown video mode specified. "
"Run VLC with -vv to get a list of supported modes."); "Run VLC with -vv to get a list of supported modes.");
goto finish; goto finish;
} }
if (sys->input->EnableVideoInput(htonl(wanted_mode_id), bmdFormat8BitYUV, 0) != S_OK) if (sys->input->EnableVideoInput(htonl(wanted_mode_id), bmdFormat8BitYUV, 0) != S_OK) {
{
msg_Err(demux, "Failed to enable video input"); msg_Err(demux, "Failed to enable video input");
goto finish; goto finish;
} }
...@@ -514,10 +492,8 @@ static int Open(vlc_object_t *p_this) ...@@ -514,10 +492,8 @@ static int Open(vlc_object_t *p_this)
/* Set up audio. */ /* Set up audio. */
sys->channels = var_InheritInteger(demux, "decklink-audio-channels"); sys->channels = var_InheritInteger(demux, "decklink-audio-channels");
rate = var_InheritInteger(demux, "decklink-audio-rate"); rate = var_InheritInteger(demux, "decklink-audio-rate");
if (rate > 0 && sys->channels > 0) if (rate > 0 && sys->channels > 0) {
{ if (sys->input->EnableAudioInput(rate, bmdAudioSampleType16bitInteger, sys->channels) != S_OK) {
if (sys->input->EnableAudioInput(rate, bmdAudioSampleType16bitInteger, sys->channels) != S_OK)
{
msg_Err(demux, "Failed to enable audio input"); msg_Err(demux, "Failed to enable audio input");
goto finish; goto finish;
} }
...@@ -526,8 +502,7 @@ static int Open(vlc_object_t *p_this) ...@@ -526,8 +502,7 @@ static int Open(vlc_object_t *p_this)
sys->delegate = new DeckLinkCaptureDelegate(demux); sys->delegate = new DeckLinkCaptureDelegate(demux);
sys->input->SetCallback(sys->delegate); sys->input->SetCallback(sys->delegate);
if (sys->input->StartStreams() != S_OK) if (sys->input->StartStreams() != S_OK) {
{
msg_Err(demux, "Could not start streaming from SDI card. This could be caused " msg_Err(demux, "Could not start streaming from SDI card. This could be caused "
"by invalid video mode or flags, access denied, or card already in use."); "by invalid video mode or flags, access denied, or card already in use.");
goto finish; goto finish;
...@@ -591,8 +566,7 @@ static void Close(vlc_object_t *p_this) ...@@ -591,8 +566,7 @@ static void Close(vlc_object_t *p_this)
if (sys->config) if (sys->config)
sys->config->Release(); sys->config->Release();
if (sys->input) if (sys->input) {
{
sys->input->StopStreams(); sys->input->StopStreams();
sys->input->Release(); sys->input->Release();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment