Commit 63058103 by 景炳强

修改界面功能 修改一些输入输出bug

parent 457956c9
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>361</width> <width>361</width>
<height>541</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>361</width>
<height>289</height> <height>393</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>40</y>
<width>171</width> <width>171</width>
<height>20</height> <height>20</height>
</rect> </rect>
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>40</y> <y>50</y>
<width>87</width> <width>87</width>
<height>20</height> <height>20</height>
</rect> </rect>
...@@ -189,30 +189,118 @@ ...@@ -189,30 +189,118 @@
<string>Timecode</string> <string>Timecode</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="previewCheckBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>87</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>一键预览</string>
</property>
</widget>
<widget class="QComboBox" name="audioChannelCombo">
<property name="geometry">
<rect>
<x>100</x>
<y>190</y>
<width>100</width>
<height>22</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string/>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="maxVisibleItems">
<number>34</number>
</property>
</widget>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>70</y> <y>190</y>
<width>141</width> <width>90</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>延迟时间(单位:秒)</string> <string>音频通道</string>
</property> </property>
</widget> </widget>
<widget class="QLineEdit" name="deleyTimeEdit"> <widget class="Line" name="line">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>160</x> <x>10</x>
<y>70</y> <y>130</y>
<width>41</width> <width>360</width>
<height>21</height> <height>3</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>300</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
</property>
<property name="text">
<string>以下参数需要设置完成后需要重启程序才能生效</string>
</property>
</widget>
<widget class="QComboBox" name="outputModeCombo">
<property name="geometry">
<rect>
<x>100</x>
<y>150</y>
<width>100</width>
<height>22</height>
</rect>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string/>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="maxVisibleItems">
<number>34</number>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>90</width>
<height>16</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>5</string> <string>输出格式</string>
</property> </property>
</widget> </widget>
</widget> </widget>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -39,7 +39,9 @@ public slots: ...@@ -39,7 +39,9 @@ public slots:
void InputDeviceChanged(int selectedDeviceIndex); void InputDeviceChanged(int selectedDeviceIndex);
void InputConnectionChanged(int selectedConnectionIndex); void InputConnectionChanged(int selectedConnectionIndex);
void VideoFormatChanged(int selectedVideoFormatIndex); void VideoFormatChanged(int selectedVideoFormatIndex);
void AudioChannelChanged(int selectIndex);
void AutoDetectChanged(int autoDetectState); void AutoDetectChanged(int autoDetectState);
void PrewChanged(int state);
void RequestedDeviceGranted(ComPtr<IDeckLink>& device); void RequestedDeviceGranted(ComPtr<IDeckLink>& device);
signals: signals:
...@@ -68,8 +70,11 @@ private: ...@@ -68,8 +70,11 @@ private:
QComboBox* DeviceListCombo; QComboBox* DeviceListCombo;
QComboBox* InputConnectionCombo; QComboBox* InputConnectionCombo;
QComboBox* VideoFormatCombo; QComboBox* VideoFormatCombo;
QComboBox* AudioChannelCombo;
QCheckBox* AutoDetectCheckBox; QCheckBox* AutoDetectCheckBox;
QLabel* NDINameLabel; QLabel* NDINameLabel;
QCheckBox* PrewCheckBox;
int Index; int Index;
qint32 PrewState;
}; };
\ No newline at end of file
...@@ -15,14 +15,14 @@ class DeckLinkOpenGLWidget : public QOpenGLWidget ...@@ -15,14 +15,14 @@ class DeckLinkOpenGLWidget : public QOpenGLWidget
Q_OBJECT Q_OBJECT
public: public:
DeckLinkOpenGLWidget(QWidget* parent = nullptr); DeckLinkOpenGLWidget(qint32 prewState, QWidget* parent = nullptr);
virtual ~DeckLinkOpenGLWidget(); virtual ~DeckLinkOpenGLWidget();
IDeckLinkScreenPreviewCallback* GetDelegate(); IDeckLinkScreenPreviewCallback* GetDelegate();
DeckLinkPreviewOverlay* GetOverlay(); DeckLinkPreviewOverlay* GetOverlay();
void Clear(); void Clear();
void SetPrewState(qint32 state);
protected: protected:
// QOpenGLWidget // QOpenGLWidget
void initializeGL() override; void initializeGL() override;
...@@ -36,6 +36,8 @@ private: ...@@ -36,6 +36,8 @@ private:
ComPtr<ScreenPreviewCallback> Delegate; ComPtr<ScreenPreviewCallback> Delegate;
ComPtr<IDeckLinkGLScreenPreviewHelper> DeckLinkScreenPreviewHelper; ComPtr<IDeckLinkGLScreenPreviewHelper> DeckLinkScreenPreviewHelper;
DeckLinkOpenGLOverlayWidget* OverlayWidget; DeckLinkOpenGLOverlayWidget* OverlayWidget;
qint32 PrewState;
uint8_t* BlackBuffer;
}; };
class DeckLinkOpenGLOverlayWidget : public QWidget class DeckLinkOpenGLOverlayWidget : public QWidget
......
...@@ -29,7 +29,7 @@ class DeckLinkOutputDevice : public QObject, public IDeckLinkVideoOutputCallback ...@@ -29,7 +29,7 @@ class DeckLinkOutputDevice : public QObject, public IDeckLinkVideoOutputCallback
using ScheduledFramesList = std::list<ComPtr<DeckLinkOutputVideoFrame>>; using ScheduledFramesList = std::list<ComPtr<DeckLinkOutputVideoFrame>>;
public: public:
DeckLinkOutputDevice(ComPtr<IDeckLink>& decklink, int videoPrerollSize,int index); DeckLinkOutputDevice(ComPtr<IDeckLink>& decklink, int videoPrerollSize,int index,qint32 deleyTime);
virtual ~DeckLinkOutputDevice() = default; virtual ~DeckLinkOutputDevice() = default;
// IUnknown interface // IUnknown interface
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
ComPtr<IDeckLink> GetDeckLinkInstance(void) const { return deckLink; } ComPtr<IDeckLink> GetDeckLinkInstance(void) const { return deckLink; }
ComPtr<IDeckLinkOutput> getDeckLinkOutput(void) const { return deckLinkOutput; } ComPtr<IDeckLinkOutput> getDeckLinkOutput(void) const { return deckLinkOutput; }
void SetDeleyTime(qint32& deleyTime);
public slots: public slots:
void AddAudioFrame(std::shared_ptr<AudioPacket> audio_packet); void AddAudioFrame(std::shared_ptr<AudioPacket> audio_packet);
void AddFrame(std::shared_ptr<Image> image); void AddFrame(std::shared_ptr<Image> image);
...@@ -105,5 +105,6 @@ private: ...@@ -105,5 +105,6 @@ private:
qint32 Device_id; qint32 Device_id;
qint32 output_deley_ms;// qint32 output_deley_ms;//
qint32 audio_max_size; qint32 audio_max_size;
qint32 queue_max_size;
BMDDisplayMode outputDisplayMode; BMDDisplayMode outputDisplayMode;
}; };
...@@ -39,6 +39,8 @@ public: ...@@ -39,6 +39,8 @@ public:
BindingInputPage = inputPage; BindingInputPage = inputPage;
Process = process; Process = process;
Index = index; Index = index;
Process->SetOutputDeleyTime(DeleyTime);
Process->SetBlackBottomHeight(BlackBottomHeight);
} }
...@@ -50,7 +52,11 @@ public slots: ...@@ -50,7 +52,11 @@ public slots:
void ObjectNameChanged(const QString& newName); void ObjectNameChanged(const QString& newName);
void FormatChanged(BMDDisplayMode displayMode); void FormatChanged(BMDDisplayMode displayMode);
void DeleyTimeChanged(QString text);
void DeleyTimeFinish();
void BlackHeightFinish();
void VerifyClicked();
void PrewChanged(int state);
signals: signals:
void RequestDeckLink(ComPtr<IDeckLink>& device); void RequestDeckLink(ComPtr<IDeckLink>& device);
...@@ -75,4 +81,17 @@ private: ...@@ -75,4 +81,17 @@ private:
QComboBox* VideoFormatCombo; QComboBox* VideoFormatCombo;
QComboBox* VideoPixelFormatCombo; QComboBox* VideoPixelFormatCombo;
QLineEdit* PortNumLineEdit; QLineEdit* PortNumLineEdit;
QLineEdit* DeleyTimeEdit;
QLineEdit* BlackHeightEdit;
qint32 DeleyTime;//λms
qint32 BlackBottomHeight;
QCheckBox* PrewCheckBox;
QPushButton* VerifyBtn;
BMDDisplayMode DisplayMode;
BMDPixelFormat PixelFormat;
bool firstFmtChanged;
qint32 PrewState;
}; };
\ No newline at end of file
...@@ -18,8 +18,10 @@ public: ...@@ -18,8 +18,10 @@ public:
void Clear(); void Clear();
void SetDeviceLabel(const QString& label); void SetDeviceLabel(const QString& label);
void SetDeleyTime(const qint32& deleyTime);
void EnableTimeCode(bool enable); void EnableTimeCode(bool enable);
void EnableDeviceLabel(bool enable); void EnableDeviceLabel(bool enable);
void EnableDeleyTime(bool enable);
bool IsSignalValid(void); bool IsSignalValid(void);
void Paint(QPaintDevice* paintDevice); void Paint(QPaintDevice* paintDevice);
...@@ -35,4 +37,7 @@ private: ...@@ -35,4 +37,7 @@ private:
bool bEnableTimeCode; bool bEnableTimeCode;
bool bEnableDeviceLabel; bool bEnableDeviceLabel;
bool bEnableDeleyTime;
qint32 DeleyTime;
}; };
\ No newline at end of file
...@@ -55,6 +55,9 @@ private slots: ...@@ -55,6 +55,9 @@ private slots:
void DeviceLabelEnableChanged(bool enabled); void DeviceLabelEnableChanged(bool enabled);
void TimecodeEnableChanged(bool enabled); void TimecodeEnableChanged(bool enabled);
void DeleyTimeTextChanged(const QString&); void DeleyTimeTextChanged(const QString&);
void PrewEnableChanged(bool enabled);
void OutputModeChanged(int selectIndex);
void AudioChannelChanged(int selectIndex);
private: private:
void ReadSettings(); void ReadSettings();
private: private:
...@@ -66,7 +69,11 @@ private: ...@@ -66,7 +69,11 @@ private:
ProfileCallback* pProfileCallback; ProfileCallback* pProfileCallback;
QLineEdit* DeleyTimeEdit; QLineEdit* DeleyTimeEdit;
QComboBox* AudioChannelCombo;
QComboBox* OutputModeCombo;
QCheckBox* OutputModeCheck;
QCheckBox* TimecodeCheck;
QCheckBox* DeviceCheck;
std::array<DeckLinkInputPage*, kPreviewDevicesCount> InputDevicePages; std::array<DeckLinkInputPage*, kPreviewDevicesCount> InputDevicePages;
std::array<DeckLinkOutputPage*, kPreviewDevicesCount> OutputDevicePages; std::array<DeckLinkOutputPage*, kPreviewDevicesCount> OutputDevicePages;
std::array<std::shared_ptr<ProcessThread>, kPreviewDevicesCount> ProcessThreads; std::array<std::shared_ptr<ProcessThread>, kPreviewDevicesCount> ProcessThreads;
......
...@@ -171,7 +171,9 @@ public slots: ...@@ -171,7 +171,9 @@ public slots:
signals: signals:
void PushFrame(std::shared_ptr<Image> image); void PushFrame(std::shared_ptr<Image> image);
public:
void SetOutputDeleyTime(qint32 deleyTime) { output_deley_time = deleyTime; }
void SetBlackBottomHeight(qint32 blackHeight) { BlackBottomHeight = blackHeight; }
protected: protected:
void run() override; void run() override;
private: private:
...@@ -207,5 +209,6 @@ private: ...@@ -207,5 +209,6 @@ private:
int minTaskImageQueueSize; int minTaskImageQueueSize;
bool firstMinSize = false; bool firstMinSize = false;
qint32 BlackBottomHeight;
}; };
\ No newline at end of file
...@@ -87,7 +87,7 @@ HRESULT DeckLinkInputDevice::VideoInputFrameArrived(IDeckLinkVideoInputFrame* vi ...@@ -87,7 +87,7 @@ HRESULT DeckLinkInputDevice::VideoInputFrameArrived(IDeckLinkVideoInputFrame* vi
bool noInputSourceFlag = false; bool noInputSourceFlag = false;
if (flags & bmdFrameHasNoInputSource) if (flags & bmdFrameHasNoInputSource)
{ {
qDebug() << GetCurrDateTimeStr() << "index: " << Index << " DeckLinkInputDevice get video frame No input source " << hex << flags << " ------------ \n"; //qDebug() << GetCurrDateTimeStr() << "index: " << Index << " DeckLinkInputDevice get video frame No input source " << hex << flags << " ------------ \n";
noInputSourceFlag = true; noInputSourceFlag = true;
} }
bool restartStream = !noInputSourceFlag && PrevInputSignalAbsent; bool restartStream = !noInputSourceFlag && PrevInputSignalAbsent;
...@@ -146,7 +146,7 @@ HRESULT DeckLinkInputDevice::VideoInputFormatChanged(BMDVideoInputFormatChangedE ...@@ -146,7 +146,7 @@ HRESULT DeckLinkInputDevice::VideoInputFormatChanged(BMDVideoInputFormatChangedE
HRESULT result; HRESULT result;
BMDPixelFormat pixelFormat; BMDPixelFormat pixelFormat;
BMDDisplayMode displayMode = newDisplayMode->GetDisplayMode(); BMDDisplayMode displayMode = newDisplayMode->GetDisplayMode();
//if (Index != 1) return E_FAIL;
// Unexpected callback when auto-detect mode not enabled // Unexpected callback when auto-detect mode not enabled
if (!bApplyDetectedInputMode) if (!bApplyDetectedInputMode)
return E_FAIL; return E_FAIL;
...@@ -274,6 +274,8 @@ void DeckLinkInputDevice::StopCapture() ...@@ -274,6 +274,8 @@ void DeckLinkInputDevice::StopCapture()
DeckLinkInput->StopStreams(); DeckLinkInput->StopStreams();
DeckLinkInput->DisableVideoInput(); DeckLinkInput->DisableVideoInput();
DeckLinkInput->DisableAudioInput();
// Delete the callbacks // Delete the callbacks
DeckLinkInput->SetScreenPreviewCallback(nullptr); DeckLinkInput->SetScreenPreviewCallback(nullptr);
DeckLinkInput->SetCallback(nullptr); DeckLinkInput->SetCallback(nullptr);
......
...@@ -20,6 +20,8 @@ namespace ...@@ -20,6 +20,8 @@ namespace
std::make_pair(bmdVideoConnectionSVideo, QString("S-Video")), std::make_pair(bmdVideoConnectionSVideo, QString("S-Video")),
}; };
const std::vector<QString> AudioChannels = {"1","2","3","4","5","6","7","8"};
template<class T> template<class T>
T* findParent(QWidget* widget) T* findParent(QWidget* widget)
{ {
...@@ -53,6 +55,16 @@ DeckLinkInputPage::DeckLinkInputPage() : SelectedDevice(nullptr), NDIOutput(null ...@@ -53,6 +55,16 @@ DeckLinkInputPage::DeckLinkInputPage() : SelectedDevice(nullptr), NDIOutput(null
VideoFormatCombo->setEnabled(false); VideoFormatCombo->setEnabled(false);
FormLayout->addRow("Video Format:", VideoFormatCombo); FormLayout->addRow("Video Format:", VideoFormatCombo);
AudioChannelCombo = new QComboBox();
AudioChannelCombo->setMinimumWidth(kComboMinimumWidth);
AudioChannelCombo->setEnabled(true);
for(auto channel : AudioChannels)
{
AudioChannelCombo->addItem(channel);
}
AudioChannelCombo->setCurrentIndex(1);
//FormLayout->addRow("Audio Channel:", AudioChannelCombo);
AutoDetectCheckBox = new QCheckBox(); AutoDetectCheckBox = new QCheckBox();
AutoDetectCheckBox->setEnabled(false); AutoDetectCheckBox->setEnabled(false);
FormLayout->addRow("Auto-Detect Format:", AutoDetectCheckBox); FormLayout->addRow("Auto-Detect Format:", AutoDetectCheckBox);
...@@ -60,7 +72,13 @@ DeckLinkInputPage::DeckLinkInputPage() : SelectedDevice(nullptr), NDIOutput(null ...@@ -60,7 +72,13 @@ DeckLinkInputPage::DeckLinkInputPage() : SelectedDevice(nullptr), NDIOutput(null
NDINameLabel = new QLabel(); NDINameLabel = new QLabel();
FormLayout->addRow("NDIOutputLabel:", NDINameLabel); FormLayout->addRow("NDIOutputLabel:", NDINameLabel);
PreviewView = new DeckLinkOpenGLWidget(dynamic_cast<QWidget*>(this)); PrewCheckBox = new QCheckBox();
PrewCheckBox->setChecked(false);
PrewCheckBox->setMinimumWidth(kComboMinimumWidth);
FormLayout->addRow("Preview:", PrewCheckBox);
PrewState = PrewCheckBox->isChecked();
PreviewView = new DeckLinkOpenGLWidget(PrewState,dynamic_cast<QWidget*>(this));
PreviewView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); PreviewView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
NDIOutput = std::make_unique<NDIOutputThread>("NDIOutput", 1920, 1080); NDIOutput = std::make_unique<NDIOutputThread>("NDIOutput", 1920, 1080);
...@@ -72,6 +90,10 @@ DeckLinkInputPage::DeckLinkInputPage() : SelectedDevice(nullptr), NDIOutput(null ...@@ -72,6 +90,10 @@ DeckLinkInputPage::DeckLinkInputPage() : SelectedDevice(nullptr), NDIOutput(null
connect(VideoFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkInputPage::VideoFormatChanged); connect(VideoFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkInputPage::VideoFormatChanged);
connect(AutoDetectCheckBox, &QCheckBox::stateChanged, this, &DeckLinkInputPage::AutoDetectChanged); connect(AutoDetectCheckBox, &QCheckBox::stateChanged, this, &DeckLinkInputPage::AutoDetectChanged);
connect(this, &QObject::objectNameChanged, this, &DeckLinkInputPage::ObjectNameChanged); connect(this, &QObject::objectNameChanged, this, &DeckLinkInputPage::ObjectNameChanged);
connect(PrewCheckBox, &QCheckBox::stateChanged, this, &DeckLinkInputPage::PrewChanged);
connect(AudioChannelCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkInputPage::AudioChannelChanged);
AudioChannelCombo->setHidden(true);
} }
DeckLinkInputPage::~DeckLinkInputPage() DeckLinkInputPage::~DeckLinkInputPage()
...@@ -210,6 +232,19 @@ bool DeckLinkInputPage::ReleaseDeviceIfSelected(ComPtr<IDeckLink>& deckLink) ...@@ -210,6 +232,19 @@ bool DeckLinkInputPage::ReleaseDeviceIfSelected(ComPtr<IDeckLink>& deckLink)
return false; return false;
} }
void DeckLinkInputPage::AudioChannelChanged(int selectIndex)
{
if (selectIndex == -1) return;
auto value = AudioChannelCombo->currentText();
qDebug() << "audio channels select:" << value << "\n";
QString exe_dir = QCoreApplication::applicationDirPath();
QString ini_path = exe_dir + "/settings.ini";
QSettings settings(ini_path, QSettings::IniFormat);
settings.beginGroup("DELEYTIME");
settings.setValue("AUDIO_CHANNEL", value);
settings.endGroup();
}
void DeckLinkInputPage::InputDeviceChanged(int selectedDeviceIndex) void DeckLinkInputPage::InputDeviceChanged(int selectedDeviceIndex)
{ {
START_SLOT_TIME_COUNTER START_SLOT_TIME_COUNTER
...@@ -298,6 +333,12 @@ void DeckLinkInputPage::AutoDetectChanged(int autoDetectState) ...@@ -298,6 +333,12 @@ void DeckLinkInputPage::AutoDetectChanged(int autoDetectState)
END_SLOT_TIME_COUNTER END_SLOT_TIME_COUNTER
} }
void DeckLinkInputPage::PrewChanged(int state)
{
PrewState = state;
PreviewView->SetPrewState(PrewState);
}
void DeckLinkInputPage::DetectedVideoFormatChanged(BMDDisplayMode displayMode) void DeckLinkInputPage::DetectedVideoFormatChanged(BMDDisplayMode displayMode)
{ {
// Update videoFormatPopup with auto-detected display name // Update videoFormatPopup with auto-detected display name
......
...@@ -32,12 +32,12 @@ void DeckLinkOpenGLOverlayWidget::paintEvent(QPaintEvent* event) ...@@ -32,12 +32,12 @@ void DeckLinkOpenGLOverlayWidget::paintEvent(QPaintEvent* event)
/// DeckLinkOpenGLWidget /// DeckLinkOpenGLWidget
/// ///
DeckLinkOpenGLWidget::DeckLinkOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent) DeckLinkOpenGLWidget::DeckLinkOpenGLWidget(qint32 prewState,QWidget* parent) : PrewState(prewState),QOpenGLWidget(parent), BlackBuffer(NULL)
{ {
GetDeckLinkOpenGLScreenPreviewHelper(DeckLinkScreenPreviewHelper); GetDeckLinkOpenGLScreenPreviewHelper(DeckLinkScreenPreviewHelper);
Delegate = MakeComPtr<ScreenPreviewCallback>(); Delegate = MakeComPtr<ScreenPreviewCallback>();
if(PrvwFlag) connect(Delegate.Get(), &ScreenPreviewCallback::FrameArrived, this, &DeckLinkOpenGLWidget::SetFrame, Qt::QueuedConnection); connect(Delegate.Get(), &ScreenPreviewCallback::FrameArrived, this, &DeckLinkOpenGLWidget::SetFrame, Qt::QueuedConnection);
OverlayWidget = new DeckLinkOpenGLOverlayWidget(this); OverlayWidget = new DeckLinkOpenGLOverlayWidget(this);
} }
...@@ -60,7 +60,7 @@ void DeckLinkOpenGLWidget::initializeGL() ...@@ -60,7 +60,7 @@ void DeckLinkOpenGLWidget::initializeGL()
void DeckLinkOpenGLWidget::paintGL() void DeckLinkOpenGLWidget::paintGL()
{ {
START_GL_TIME_COUNTER START_GL_TIME_COUNTER
if(DeckLinkScreenPreviewHelper) if(DeckLinkScreenPreviewHelper && PrewState)
{ {
DeckLinkScreenPreviewHelper->PaintGL(); DeckLinkScreenPreviewHelper->PaintGL();
} }
...@@ -98,7 +98,8 @@ void DeckLinkOpenGLWidget::Clear() ...@@ -98,7 +98,8 @@ void DeckLinkOpenGLWidget::Clear()
void DeckLinkOpenGLWidget::SetFrame(ComPtr<IDeckLinkVideoFrame> frame) void DeckLinkOpenGLWidget::SetFrame(ComPtr<IDeckLinkVideoFrame> frame)
{ {
START_SLOT_TIME_COUNTER START_SLOT_TIME_COUNTER
if(DeckLinkScreenPreviewHelper)
if(DeckLinkScreenPreviewHelper && PrewState)
{ {
DeckLinkScreenPreviewHelper->SetFrame(frame.Get()); DeckLinkScreenPreviewHelper->SetFrame(frame.Get());
GetOverlay()->SetFrame(frame); GetOverlay()->SetFrame(frame);
...@@ -108,3 +109,15 @@ void DeckLinkOpenGLWidget::SetFrame(ComPtr<IDeckLinkVideoFrame> frame) ...@@ -108,3 +109,15 @@ void DeckLinkOpenGLWidget::SetFrame(ComPtr<IDeckLinkVideoFrame> frame)
} }
END_SLOT_TIME_COUNTER END_SLOT_TIME_COUNTER
} }
void DeckLinkOpenGLWidget::SetPrewState(qint32 state)
{
if (PrewState == state) return;
PrewState = state;
if (!PrewState)
{
DeckLinkScreenPreviewHelper->SetFrame(nullptr);
Clear();
update();
OverlayWidget->update();
}
}
...@@ -14,7 +14,7 @@ extern std::map<qint32, qint32> map_output_delay; ...@@ -14,7 +14,7 @@ extern std::map<qint32, qint32> map_output_delay;
#define AUDIOMAXSIZE (OutputDeleyTime + 3) * 50 #define AUDIOMAXSIZE (OutputDeleyTime + 3) * 50
DeckLinkOutputDevice::DeckLinkOutputDevice(ComPtr<IDeckLink>& decklink, int videoPrerollSize,int index) DeckLinkOutputDevice::DeckLinkOutputDevice(ComPtr<IDeckLink>& decklink, int videoPrerollSize,int index,qint32 deleyTime)
: RefCount(1), : RefCount(1),
state(PlaybackState::Idle), state(PlaybackState::Idle),
deckLink(decklink), deckLink(decklink),
...@@ -24,14 +24,15 @@ DeckLinkOutputDevice::DeckLinkOutputDevice(ComPtr<IDeckLink>& decklink, int vide ...@@ -24,14 +24,15 @@ DeckLinkOutputDevice::DeckLinkOutputDevice(ComPtr<IDeckLink>& decklink, int vide
startPlaybackTime(0), startPlaybackTime(0),
scheduledFrameCompletedCallback(nullptr), scheduledFrameCompletedCallback(nullptr),
first_sleep(false), first_sleep(false),
Index(index) Index(index),
output_deley_ms(deleyTime)
{ {
// Check that device has an output interface, this will throw an error if using a capture-only device such as DeckLink Mini Recorder // Check that device has an output interface, this will throw an error if using a capture-only device such as DeckLink Mini Recorder
if (!deckLinkOutput) if (!deckLinkOutput)
throw std::runtime_error("DeckLink device does not have an output interface."); throw std::runtime_error("DeckLink device does not have an output interface.");
//current_sleep_ms = OutputDeleyTime * 1000; //current_sleep_ms = OutputDeleyTime * 1000;
queue_max_size = (output_deley_ms / 1000 + 3) * 50;
InitResource(); //InitResource();
} }
// IUnknown methods // IUnknown methods
...@@ -336,13 +337,14 @@ bool DeckLinkOutputDevice::getReferenceSignalMode(BMDDisplayMode* mode) ...@@ -336,13 +337,14 @@ bool DeckLinkOutputDevice::getReferenceSignalMode(BMDDisplayMode* mode)
{ {
START_WAIT_TIME_COUNTER START_WAIT_TIME_COUNTER
if (state == PlaybackState::Stopping) break;
std::shared_ptr<Image> outputImage; std::shared_ptr<Image> outputImage;
if(outputVideoFrameQueue.WaitFor(outputImage)) if(outputVideoFrameQueue.WaitFor(outputImage))
{ {
auto now_time = QDateTime::currentMSecsSinceEpoch(); auto now_time = QDateTime::currentMSecsSinceEpoch();
auto dever_time = now_time - outputImage->getInputFrameCurTimeStamp(); auto dever_time = now_time - outputImage->getInputFrameCurTimeStamp();
//qDebug() << "index:"<<Index << "input frame cur time:" << outputImage->getInputFrameCurTimeStamp() << " now time:" << now_time << " dever time:" << dever_time << "\n"; qDebug() << "index:"<<Index << "deley_time:"<< output_deley_ms << ",input frame cur time:" << outputImage->getInputFrameCurTimeStamp() << " now time:" << now_time << " dever time:" << dever_time << "\n";
if (dever_time < output_deley_ms) if (dever_time < output_deley_ms)
{ {
current_sleep_ms = output_deley_ms - dever_time; current_sleep_ms = output_deley_ms - dever_time;
...@@ -411,6 +413,7 @@ bool DeckLinkOutputDevice::getReferenceSignalMode(BMDDisplayMode* mode) ...@@ -411,6 +413,7 @@ bool DeckLinkOutputDevice::getReferenceSignalMode(BMDDisplayMode* mode)
{ {
while (true) while (true)
{ {
if (state == PlaybackState::Stopping) break;
std::shared_ptr<AudioPacket> audio_packet; std::shared_ptr<AudioPacket> audio_packet;
if (outputAudioFrameQueue.WaitFor(audio_packet)) if (outputAudioFrameQueue.WaitFor(audio_packet))
{ {
...@@ -449,6 +452,7 @@ bool DeckLinkOutputDevice::getReferenceSignalMode(BMDDisplayMode* mode) ...@@ -449,6 +452,7 @@ bool DeckLinkOutputDevice::getReferenceSignalMode(BMDDisplayMode* mode)
{ {
while (true) while (true)
{ {
if (state == PlaybackState::Stopping) break;
std::shared_ptr<AudioPacket> audio_packet; std::shared_ptr<AudioPacket> audio_packet;
if (outputAudioFrameQueue.WaitFor(audio_packet)) if (outputAudioFrameQueue.WaitFor(audio_packet))
{ {
...@@ -538,7 +542,7 @@ void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image) ...@@ -538,7 +542,7 @@ void DeckLinkOutputDevice::AddFrame(std::shared_ptr<Image> image)
if (outputVideoFrameQueue.Size() >= 4) if (outputVideoFrameQueue.Size() >= 4)
qDebug() << "DeckLinkOutputDevice::AddFrame video---qsize:" << "\t" << outputVideoFrameQueue.Size() << "\n"; qDebug() << "DeckLinkOutputDevice::AddFrame video---qsize:" << "\t" << outputVideoFrameQueue.Size() << "\n";
if (outputVideoFrameQueue.Size() > audio_max_size) if (outputVideoFrameQueue.Size() > queue_max_size)
{ {
outputVideoFrameQueue.Reset(); outputVideoFrameQueue.Reset();
} }
...@@ -551,7 +555,7 @@ void DeckLinkOutputDevice::AddAudioFrame(std::shared_ptr<AudioPacket> audio_pack ...@@ -551,7 +555,7 @@ void DeckLinkOutputDevice::AddAudioFrame(std::shared_ptr<AudioPacket> audio_pack
if (outputAudioFrameQueue.Size() >= 4) if (outputAudioFrameQueue.Size() >= 4)
qDebug() << "index:" << Index << "DeckLinkOutputDevice::AddAudioFrame audio---qsize:" << "\t" << outputAudioFrameQueue.Size() << "\n"; qDebug() << "index:" << Index << "DeckLinkOutputDevice::AddAudioFrame audio---qsize:" << "\t" << outputAudioFrameQueue.Size() << "\n";
if (outputAudioFrameQueue.Size() > audio_max_size) if (outputAudioFrameQueue.Size() > queue_max_size)
{ {
outputAudioFrameQueue.Reset(); outputAudioFrameQueue.Reset();
} }
...@@ -595,3 +599,9 @@ void DeckLinkOutputDevice::InitResource() ...@@ -595,3 +599,9 @@ void DeckLinkOutputDevice::InitResource()
} }
} }
} }
void DeckLinkOutputDevice::SetDeleyTime(qint32& deleyTime)
{
output_deley_ms = deleyTime;
queue_max_size = (output_deley_ms / 1000 + 3) * 50;
}
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
#include <QToolBox> #include <QToolBox>
#include <QMessageBox> #include <QMessageBox>
#include <QLineEdit> #include <QLineEdit>
#include <qpushbutton.h>
#include "MomentaMedia.h" #include "MomentaMedia.h"
#include "BlackMagicDesign/DeckLinkOutputPage.h" #include "BlackMagicDesign/DeckLinkOutputPage.h"
#include "Utils/Platform.h" #include "Utils/Platform.h"
namespace namespace
{ {
const int kComboMinimumWidth = 185; const int kComboMinimumWidth = 180;
const std::vector<std::pair<BMDVideoConnection, QString>> kVideoOutputConnections = { const std::vector<std::pair<BMDVideoConnection, QString>> kVideoOutputConnections = {
std::make_pair(bmdVideoConnectionSDI, QString("SDI")), std::make_pair(bmdVideoConnectionSDI, QString("SDI")),
...@@ -46,7 +47,7 @@ namespace ...@@ -46,7 +47,7 @@ namespace
} }
DeckLinkOutputPage::DeckLinkOutputPage() : SelectedDevice(nullptr), Process(nullptr) DeckLinkOutputPage::DeckLinkOutputPage() : SelectedDevice(nullptr), Process(nullptr), firstFmtChanged(true)
{ {
FormLayout = new QFormLayout(this); FormLayout = new QFormLayout(this);
...@@ -65,17 +66,48 @@ DeckLinkOutputPage::DeckLinkOutputPage() : SelectedDevice(nullptr), Process(null ...@@ -65,17 +66,48 @@ DeckLinkOutputPage::DeckLinkOutputPage() : SelectedDevice(nullptr), Process(null
VideoPixelFormatCombo->setEnabled(false); VideoPixelFormatCombo->setEnabled(false);
FormLayout->addRow("Video Pixel Format:", VideoPixelFormatCombo); FormLayout->addRow("Video Pixel Format:", VideoPixelFormatCombo);
PreviewView = new DeckLinkOpenGLWidget(dynamic_cast<QWidget*>(this));
PreviewView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
PortNumLineEdit = new QLineEdit(); PortNumLineEdit = new QLineEdit();
PortNumLineEdit->setMinimumWidth(kComboMinimumWidth); PortNumLineEdit->setMinimumWidth(kComboMinimumWidth);
FormLayout->addRow("PortNum", PortNumLineEdit); FormLayout->addRow("PortNum", PortNumLineEdit);
DeleyTimeEdit = new QLineEdit();
DeleyTimeEdit->setMinimumWidth(kComboMinimumWidth);
DeleyTimeEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
DeleyTimeEdit->setText("3000");
FormLayout->addRow(QString::fromWCharArray(L"延迟时间(毫秒)"), DeleyTimeEdit);
BlackHeightEdit = new QLineEdit();
BlackHeightEdit->setMinimumWidth(kComboMinimumWidth);
BlackHeightEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
BlackHeightEdit->setText("0");
FormLayout->addRow(QString::fromWCharArray(L"黑边高度"), BlackHeightEdit);
PrewCheckBox = new QCheckBox();
PrewCheckBox->setChecked(false);
PrewCheckBox->setMinimumWidth(kComboMinimumWidth);
FormLayout->addRow(QString::fromWCharArray(L"预览"), PrewCheckBox);
PrewState = PrewCheckBox->isChecked();
PreviewView = new DeckLinkOpenGLWidget(PrewState, dynamic_cast<QWidget*>(this));
PreviewView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
VerifyBtn = new QPushButton(QString::fromWCharArray(L"确认"));
VerifyBtn->setMinimumWidth(kComboMinimumWidth);
FormLayout->addRow(VerifyBtn);
DeleyTime = DeleyTimeEdit->text().toInt();
BlackBottomHeight = BlackHeightEdit->text().toInt();
PreviewView->GetOverlay()->SetDeleyTime(DeleyTime);
connect(DeviceListCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkOutputPage::OutputDeviceChanged); connect(DeviceListCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkOutputPage::OutputDeviceChanged);
connect(VideoFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkOutputPage::VideoFormatChanged); connect(VideoFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkOutputPage::VideoFormatChanged);
connect(VideoPixelFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkOutputPage::VideoPixelFormatChanged); connect(VideoPixelFormatCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DeckLinkOutputPage::VideoPixelFormatChanged);
connect(this, &QObject::objectNameChanged, this, &DeckLinkOutputPage::ObjectNameChanged); connect(this, &QObject::objectNameChanged, this, &DeckLinkOutputPage::ObjectNameChanged);
connect(DeleyTimeEdit, &QLineEdit::editingFinished,this, &DeckLinkOutputPage::DeleyTimeFinish);
connect(BlackHeightEdit, &QLineEdit::editingFinished, this, &DeckLinkOutputPage::BlackHeightFinish);
connect(VerifyBtn, &QPushButton::clicked, this, &DeckLinkOutputPage::VerifyClicked);
connect(PrewCheckBox, &QCheckBox::stateChanged, this, &DeckLinkOutputPage::PrewChanged);
} }
DeckLinkOutputPage::~DeckLinkOutputPage() DeckLinkOutputPage::~DeckLinkOutputPage()
...@@ -113,6 +145,9 @@ void DeckLinkOutputPage::customEvent(QEvent* event) ...@@ -113,6 +145,9 @@ void DeckLinkOutputPage::customEvent(QEvent* event)
void DeckLinkOutputPage::StartOutput() void DeckLinkOutputPage::StartOutput()
{ {
if (!SelectedDevice || firstFmtChanged)
return;
FormatChanged(DisplayMode);
/* /*
if (!SelectedDevice) if (!SelectedDevice)
return; return;
...@@ -245,7 +280,7 @@ void DeckLinkOutputPage::RequestedDeviceGranted(ComPtr<IDeckLink>& device) ...@@ -245,7 +280,7 @@ void DeckLinkOutputPage::RequestedDeviceGranted(ComPtr<IDeckLink>& device)
{ {
START_SLOT_TIME_COUNTER START_SLOT_TIME_COUNTER
SelectedDevice = MakeComPtr<DeckLinkOutputDevice>(device, 1,Index); SelectedDevice = MakeComPtr<DeckLinkOutputDevice>(device, 1,Index,DeleyTime);
// Register profile callback with newly selected device`s profile manager // Register profile callback with newly selected device`s profile manager
...@@ -259,7 +294,8 @@ void DeckLinkOutputPage::RequestedDeviceGranted(ComPtr<IDeckLink>& device) ...@@ -259,7 +294,8 @@ void DeckLinkOutputPage::RequestedDeviceGranted(ComPtr<IDeckLink>& device)
if(Process->isRunning()) if(Process->isRunning())
Process->exit(); Process->exit();
Process->SetUpUDP("127.0.0.1", PortNumLineEdit->text()); //Process->SetUpUDP("127.0.0.1", PortNumLineEdit->text());
Process->SetUpUDP("0.0.0.0", PortNumLineEdit->text());
Process->start(); Process->start();
...@@ -271,13 +307,75 @@ void DeckLinkOutputPage::RequestedDeviceGranted(ComPtr<IDeckLink>& device) ...@@ -271,13 +307,75 @@ void DeckLinkOutputPage::RequestedDeviceGranted(ComPtr<IDeckLink>& device)
void DeckLinkOutputPage::FormatChanged(BMDDisplayMode displayMode) void DeckLinkOutputPage::FormatChanged(BMDDisplayMode displayMode)
{ {
BMDDisplayMode displayMode_ = displayMode; if (firstFmtChanged) firstFmtChanged = false;
DisplayMode = displayMode;
//BMDPixelFormat pixelFormat = bmdFormat10BitYUV; //BMDPixelFormat pixelFormat = bmdFormat10BitYUV;
BMDPixelFormat pixelFormat = bmdFormat8BitBGRA; PixelFormat = bmdFormat8BitBGRA;
SelectedDevice->StartPlayback(DisplayMode, false, PixelFormat, false, PreviewView->GetDelegate());
int indexToSelect = DeviceListCombo->findData(QVariant::fromValue((void*)SelectedDevice->GetDeckLinkInstance().Get()));
bool active = SelectedDevice->isPlaybackActive();
QToolBox* toolBox = findParent<QToolBox>(this);
int pageIndex = toolBox->indexOf(this);
QString title = QString("Output %1: %2%3").arg(pageIndex + 1).arg(DeviceListCombo->itemText(indexToSelect)).arg(active ? "" : " [inactive]");
toolBox->setItemText(pageIndex, title);
PreviewView->GetOverlay()->SetDeviceLabel(title);
}
void DeckLinkOutputPage::PrewChanged(int state)
{
PrewState = state;
PreviewView->SetPrewState(PrewState);
}
void DeckLinkOutputPage::VerifyClicked()
{
QString text = BlackHeightEdit->text();
auto height = text.toInt();
if (BlackBottomHeight != height)
{
BlackBottomHeight = height;
qDebug() << "index:" << Index << " BlackBottomHeight:" << BlackBottomHeight << "\n";
Process->SetBlackBottomHeight(BlackBottomHeight);
}
text = DeleyTimeEdit->text();
auto time = text.toInt();
if (DeleyTime != time)
{
DeleyTime = time;
qDebug() << "index:" << Index << " deley time:" << DeleyTime << "\n";
SelectedDevice->SetDeleyTime(DeleyTime);
Process->SetOutputDeleyTime(DeleyTime);
PreviewView->GetOverlay()->SetDeleyTime(DeleyTime);
}
SelectedDevice->StartPlayback(displayMode_, false, pixelFormat, false, PreviewView->GetDelegate());
} }
void DeckLinkOutputPage::BlackHeightFinish()
{
/*QString text = BlackHeightEdit->text();
BlackBottomHeight = text.toInt();
qDebug() << "index:" << Index << " BlackBottomHeight:" << BlackBottomHeight << "\n";
Process->SetBlackBottomHeight(BlackBottomHeight);*/
}
void DeckLinkOutputPage::DeleyTimeFinish()
{
/*QString text = DeleyTimeEdit->text();
DeleyTime = text.toInt();
qDebug() <<"index:"<< Index << " deley time:" << DeleyTime << "\n";
SelectedDevice->SetDeleyTime(DeleyTime);
Process->SetOutputDeleyTime(DeleyTime);*/
}
void DeckLinkOutputPage::DeleyTimeChanged(QString text)
{
qDebug() << "deley time:" << text << "\n";
}
void DeckLinkOutputPage::ObjectNameChanged(const QString& newName) void DeckLinkOutputPage::ObjectNameChanged(const QString& newName)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "BlackMagicDesign/DeckLinkPreviewVideoFrame.h" #include "BlackMagicDesign/DeckLinkPreviewVideoFrame.h"
#include "BlackMagicDesign/DeckLinkPreviewOverlay.h" #include "BlackMagicDesign/DeckLinkPreviewOverlay.h"
DeckLinkPreviewOverlay::DeckLinkPreviewOverlay(QObject* parent) : QObject(parent), bEnableTimeCode(false), bEnableDeviceLabel(false) DeckLinkPreviewOverlay::DeckLinkPreviewOverlay(QObject* parent) : QObject(parent), bEnableTimeCode(false), bEnableDeviceLabel(false),bEnableDeleyTime(false),DeleyTime(0)
{ {
} }
...@@ -69,6 +69,21 @@ void DeckLinkPreviewOverlay::SetDeviceLabel(const QString& label) ...@@ -69,6 +69,21 @@ void DeckLinkPreviewOverlay::SetDeviceLabel(const QString& label)
emit UpdatePreview(); emit UpdatePreview();
} }
void DeckLinkPreviewOverlay::SetDeleyTime(const qint32& deleyTime)
{
{
std::lock_guard<std::mutex> lock(Mutex);
if (DeleyTime != deleyTime)
{
DeleyTime = deleyTime;
emit UpdatePreview();
}
}
/*if (bEnableDeleyTime)
emit UpdatePreview();*/
}
void DeckLinkPreviewOverlay::EnableTimeCode(bool enable) void DeckLinkPreviewOverlay::EnableTimeCode(bool enable)
{ {
{ {
...@@ -89,6 +104,16 @@ void DeckLinkPreviewOverlay::EnableDeviceLabel(bool enable) ...@@ -89,6 +104,16 @@ void DeckLinkPreviewOverlay::EnableDeviceLabel(bool enable)
emit UpdatePreview(); emit UpdatePreview();
} }
void DeckLinkPreviewOverlay::EnableDeleyTime(bool enable)
{
{
std::lock_guard<std::mutex> lock(Mutex);
bEnableDeleyTime = enable;
}
emit UpdatePreview();
}
bool DeckLinkPreviewOverlay::IsSignalValid() bool DeckLinkPreviewOverlay::IsSignalValid()
{ {
std::lock_guard<std::mutex> lock(Mutex); std::lock_guard<std::mutex> lock(Mutex);
...@@ -118,14 +143,30 @@ void DeckLinkPreviewOverlay::Paint(QPaintDevice* paintDevice) ...@@ -118,14 +143,30 @@ void DeckLinkPreviewOverlay::Paint(QPaintDevice* paintDevice)
if(bEnableDeviceLabel) if(bEnableDeviceLabel)
{ {
font.setPixelSize(paintDevice->height() / 16); int size = paintDevice->height() / 16;
font.setPixelSize(15);
QFontMetrics metrics(font, paintDevice); QFontMetrics metrics(font, paintDevice);
QRect box(0, 0, paintDevice->width(), metrics.height() + 4); QRect box(0, 0, paintDevice->width(), metrics.height() + 4);
painter.fillRect(box, brush); painter.fillRect(box, brush);
painter.setPen(QColor(Qt::white)); painter.setPen(QColor(Qt::white));
painter.setFont(font); painter.setFont(font);
painter.drawText((paintDevice->width() - metrics.width(DeviceLabel)) / 2, box.top() + 2 + metrics.ascent(), DeviceLabel); //painter.setFont(QFont("Arial", 10));
int x = (paintDevice->width() - metrics.width(DeviceLabel)) / 2;
int y = box.top() + 2 + metrics.ascent();
painter.drawText(x, y, DeviceLabel);
if (DeleyTime)
{
QRect box(0, metrics.height() + 4, paintDevice->width(), metrics.height() + 4);
painter.fillRect(box, brush);
painter.setPen(QColor(Qt::white));
painter.setFont(font);
QString str = "DeleyTime:" + QString::number(DeleyTime);
int x = (paintDevice->width() - metrics.width(str)) / 2;
int y = box.top() + 2 + metrics.ascent();
painter.drawText(x, y, str);
}
} }
if(bEnableTimeCode) if(bEnableTimeCode)
......
...@@ -26,7 +26,12 @@ std::map<qint32, qint32> map_scale_mode; ...@@ -26,7 +26,12 @@ std::map<qint32, qint32> map_scale_mode;
int main_ver = 1; int main_ver = 1;
int mid_ver = 0; int mid_ver = 0;
int small_ver = 4; int small_ver = 5;
namespace
{
const std::vector<QString> AudioChannels = { "1","2","3","4","5","6","7","8" };
}
MomentaMedia::MomentaMedia(QWidget *parent) MomentaMedia::MomentaMedia(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
...@@ -53,12 +58,12 @@ MomentaMedia::MomentaMedia(QWidget *parent) ...@@ -53,12 +58,12 @@ MomentaMedia::MomentaMedia(QWidget *parent)
ProcessThreads[2] = std::make_shared<ProcessThread>(); ProcessThreads[2] = std::make_shared<ProcessThread>();
ProcessThreads[3] = std::make_shared<ProcessThread>(); ProcessThreads[3] = std::make_shared<ProcessThread>();
DeleyTimeEdit = ui.deleyTimeEdit; /*DeleyTimeEdit = ui.deleyTimeEdit;
QIntValidator* intValidator = new QIntValidator; QIntValidator* intValidator = new QIntValidator;
intValidator->setRange(0, 20); intValidator->setRange(0, 20);
DeleyTimeEdit->setValidator(intValidator); DeleyTimeEdit->setValidator(intValidator);
connect(DeleyTimeEdit,&QLineEdit::textChanged,this,&MomentaMedia::DeleyTimeTextChanged); connect(DeleyTimeEdit,&QLineEdit::textChanged,this,&MomentaMedia::DeleyTimeTextChanged);*/
...@@ -94,9 +99,41 @@ MomentaMedia::MomentaMedia(QWidget *parent) ...@@ -94,9 +99,41 @@ MomentaMedia::MomentaMedia(QWidget *parent)
connect(OutputDevicePages[i], &DeckLinkOutputPage::RequestDeckLinkIfAvailable, std::bind(&MomentaMedia::RequestOutputDeviceIfAvailable, this, OutputDevicePages[i], std::placeholders::_1)); connect(OutputDevicePages[i], &DeckLinkOutputPage::RequestDeckLinkIfAvailable, std::bind(&MomentaMedia::RequestOutputDeviceIfAvailable, this, OutputDevicePages[i], std::placeholders::_1));
connect(OutputDevicePages[i], &DeckLinkOutputPage::RelinquishDeckLink, this, &MomentaMedia::RelinquishOutputDevice); connect(OutputDevicePages[i], &DeckLinkOutputPage::RelinquishDeckLink, this, &MomentaMedia::RelinquishOutputDevice);
} }
OutputModeCombo = ui.outputModeCombo;
AudioChannelCombo = ui.audioChannelCombo;
DeviceCheck = ui.deviceLabelCheckBox;
TimecodeCheck = ui.timecodeCheckBox;
TimecodeCheck->setHidden(true);
DeviceCheck->setHidden(true);
connect(ui.deviceLabelCheckBox, &QCheckBox::stateChanged, this, &MomentaMedia::DeviceLabelEnableChanged); connect(ui.deviceLabelCheckBox, &QCheckBox::stateChanged, this, &MomentaMedia::DeviceLabelEnableChanged);
connect(ui.timecodeCheckBox, &QCheckBox::stateChanged, this, &MomentaMedia::TimecodeEnableChanged); connect(ui.timecodeCheckBox, &QCheckBox::stateChanged, this, &MomentaMedia::TimecodeEnableChanged);
connect(ui.previewCheckBox, &QCheckBox::stateChanged, this, &MomentaMedia::PrewEnableChanged);
QString exe_dir = QCoreApplication::applicationDirPath();
QString ini_path = exe_dir + "/settings.ini";
QSettings settings(ini_path, QSettings::IniFormat);
settings.beginGroup("DELEYTIME");
int mode = settings.value("OUTPUT_PLAY_MODE", "").toInt();
int channel = settings.value("AUDIO_CHANNEL").toInt();
settings.endGroup();
//OutputModeCheck->setChecked(mode);
for(auto channel : AudioChannels)
{
AudioChannelCombo->addItem(channel);
}
AudioChannelCombo->setCurrentIndex(channel - 1);
connect(AudioChannelCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MomentaMedia::AudioChannelChanged);
OutputModeCombo->addItem(QString::fromWCharArray(L"跟随输入格式"));
OutputModeCombo->addItem("1080 50I");
OutputModeCombo->setCurrentIndex(mode);
connect(OutputModeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &MomentaMedia::OutputModeChanged);
show(); show();
...@@ -494,6 +531,19 @@ void MomentaMedia::RelinquishOutputDevice(ComPtr<IDeckLink>& device) ...@@ -494,6 +531,19 @@ void MomentaMedia::RelinquishOutputDevice(ComPtr<IDeckLink>& device)
END_SLOT_TIME_COUNTER END_SLOT_TIME_COUNTER
} }
void MomentaMedia::AudioChannelChanged(int selectIndex)
{
if (selectIndex == -1) return;
auto value = AudioChannelCombo->currentText();
//qDebug() << "audio channels select:" << value << "\n";
QString exe_dir = QCoreApplication::applicationDirPath();
QString ini_path = exe_dir + "/settings.ini";
QSettings settings(ini_path, QSettings::IniFormat);
settings.beginGroup("DELEYTIME");
settings.setValue("AUDIO_CHANNEL", value);
settings.endGroup();
}
void MomentaMedia::DeviceLabelEnableChanged(bool enabled) void MomentaMedia::DeviceLabelEnableChanged(bool enabled)
{ {
START_SLOT_TIME_COUNTER START_SLOT_TIME_COUNTER
...@@ -506,6 +556,33 @@ void MomentaMedia::DeviceLabelEnableChanged(bool enabled) ...@@ -506,6 +556,33 @@ void MomentaMedia::DeviceLabelEnableChanged(bool enabled)
END_SLOT_TIME_COUNTER END_SLOT_TIME_COUNTER
} }
void MomentaMedia::OutputModeChanged(int selectIndex)
{
int value = selectIndex;
QString exe_dir = QCoreApplication::applicationDirPath();
QString ini_path = exe_dir + "/settings.ini";
QSettings settings(ini_path, QSettings::IniFormat);
settings.beginGroup("DELEYTIME");
settings.setValue("OUTPUT_PLAY_MODE", value);
settings.endGroup();
}
void MomentaMedia::PrewEnableChanged(bool enabled)
{
START_SLOT_TIME_COUNTER
DeviceCheck->setChecked(enabled);
for (int i = 0; i < PreviewLayout->count(); ++i)
{
DeckLinkOpenGLWidget* widget = qobject_cast<DeckLinkOpenGLWidget*>(PreviewLayout->itemAt(i)->widget());
if (widget)
widget->SetPrewState(enabled);
}
END_SLOT_TIME_COUNTER
}
void MomentaMedia::TimecodeEnableChanged(bool enabled) void MomentaMedia::TimecodeEnableChanged(bool enabled)
{ {
START_SLOT_TIME_COUNTER START_SLOT_TIME_COUNTER
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
#define CUTBUFFERMAXSIZE 125*2 #define CUTBUFFERMAXSIZE 125*2
int ProcessThread::s_count = 0; int ProcessThread::s_count = 0;
extern int OutputDeleyTime; //extern int OutputDeleyTime;
extern int FrameRate; extern int FrameRate;
extern int FrontDeleyTime; extern int FrontDeleyTime;
extern int BlackBottomHeight; //extern int BlackBottomHeight;
//extern int ScaleMode; //extern int ScaleMode;
extern std::map<qint32, qint32> map_output_delay; //extern std::map<qint32, qint32> map_output_delay;
extern std::map<qint32, qint32> map_scale_mode; extern std::map<qint32, qint32> map_scale_mode;
ProcessThread::ProcessThread() ProcessThread::ProcessThread()
...@@ -22,7 +22,7 @@ ProcessThread::ProcessThread() ...@@ -22,7 +22,7 @@ ProcessThread::ProcessThread()
{ {
idx = s_count++; idx = s_count++;
int key = idx + 1; int key = idx + 1;
output_deley_time = map_output_delay[key]; //output_deley_time = map_output_delay[key];
minTaskImageQueueSize = FrontDeleyTime * FrameRate; minTaskImageQueueSize = FrontDeleyTime * FrameRate;
} }
......
;BLACK_BOTTOM_HEIGHT 表示裁切后黑边距离底部的高度 取值范围为0到480
;DELEY_TIME 后延迟(输出延迟)最少2s 而且后延迟要大于前延迟至少1s
;FRONT_DELEY_TIME 前延迟
;PRVW_FLAG 0-表示关闭预览 1-表示打开预览
;FRAME_RATE 表示帧率 如1080p50 50帧率 1080i50 25帧率
;OUTPUT_PLAY_MODE 输出sdi模式 0-表示和输入格式一样 1-表示1080i输出
;AUDIO_CHANNEL音频通道数 默认是2
;DELEY_TIME_1/_2/_3/_4 对应绑卡的四路输入接口的延迟时间 单位是毫秒 最小2000ms
;SCALE_MODE 取值分别是0、1、2、3 其中缩放质量由低到高 0质量最低 3质量最高
[DELEYTIME] [DELEYTIME]
FRONT_DELEY_TIME=1 FRONT_DELEY_TIME=1
FRAME_RATE=25 FRAME_RATE=25
PRVW_FLAG=1 PRVW_FLAG=0
OUTPUT_PLAY_MODE=0 OUTPUT_PLAY_MODE=1
BLACK_BOTTOM_HEIGHT=0 BLACK_BOTTOM_HEIGHT=0
AUDIO_CHANNEL=2 AUDIO_CHANNEL=8
SCALE_MODE=0 SCALE_MODE=0
SCALE_MODE_1=0 SCALE_MODE_1=0
SCALE_MODE_2=1 SCALE_MODE_2=3
SCALE_MODE_3=2 SCALE_MODE_3=1
SCALE_MODE_4=3 SCALE_MODE_4=2
DELEY_TIME=2000 DELEY_TIME=2000
DELEY_TIME_1=2000 DELEY_TIME_1=3000
DELEY_TIME_2=3000 DELEY_TIME_2=3000
DELEY_TIME_3=4000 DELEY_TIME_3=3000
DELEY_TIME_4=5000 DELEY_TIME_4=3000
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