diff --git a/plugins/channeltx/modatv/atvmod.cpp b/plugins/channeltx/modatv/atvmod.cpp index 09cda4e56..f0a4f1e44 100644 --- a/plugins/channeltx/modatv/atvmod.cpp +++ b/plugins/channeltx/modatv/atvmod.cpp @@ -23,6 +23,7 @@ MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureATVMod, Message) MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureImageFileName, Message) +MESSAGE_CLASS_DEFINITION(ATVMod::MsgConfigureVideoFileName, Message) const float ATVMod::m_blackLevel = 0.3f; const float ATVMod::m_spanLevel = 0.7f; @@ -251,8 +252,12 @@ bool ATVMod::handleMessage(const Message& cmd) { MsgConfigureImageFileName& conf = (MsgConfigureImageFileName&) cmd; openImage(conf.getFileName()); -// m_fileName = conf.getFileName(); // TODO -// openFileStream(); + return true; + } + else if (MsgConfigureVideoFileName::match(cmd)) + { + MsgConfigureVideoFileName& conf = (MsgConfigureVideoFileName&) cmd; + openVideo(conf.getFileName()); return true; } else @@ -343,6 +348,7 @@ void ATVMod::applyStandard() m_linesPerVBar = m_nbImageLines2 / m_nbBars; m_hBarIncrement = m_spanLevel / (float) m_nbBars; m_vBarIncrement = m_spanLevel / (float) m_nbBars; + m_fps = 30.0f; break; case ATVStdPAL625: // Follows PAL-B/G/H standard default: @@ -364,6 +370,7 @@ void ATVMod::applyStandard() m_linesPerVBar = m_nbImageLines2 / m_nbBars; m_hBarIncrement = m_spanLevel / (float) m_nbBars; m_vBarIncrement = m_spanLevel / (float) m_nbBars; + m_fps = 25.0f; } if (m_imageOK) @@ -383,6 +390,19 @@ void ATVMod::openImage(const QString& fileName) } } +void ATVMod::openVideo(const QString& fileName) +{ + m_videoOK = m_video.open(qPrintable(fileName)); + + if (m_videoOK) + { + m_videoFPS = m_video.get(CV_CAP_PROP_FPS); + m_videoWidth = (int) m_video.get(CV_CAP_PROP_FRAME_WIDTH); + m_videoHeight = (int) m_video.get(CV_CAP_PROP_FRAME_HEIGHT); + qDebug("ATVMod::openVideo(: FPS: %f size: %d x %d", m_videoFPS, m_videoWidth, m_videoHeight); + } +} + void ATVMod::resizeImage() { float fy = (m_nbImageLines - 2*m_nbBlankLines) / (float) m_imageOriginal.rows; diff --git a/plugins/channeltx/modatv/atvmod.h b/plugins/channeltx/modatv/atvmod.h index 78f9bf517..558e2bc3a 100644 --- a/plugins/channeltx/modatv/atvmod.h +++ b/plugins/channeltx/modatv/atvmod.h @@ -80,6 +80,27 @@ public: { } }; + class MsgConfigureVideoFileName : public Message + { + MESSAGE_CLASS_DECLARATION + + public: + const QString& getFileName() const { return m_fileName; } + + static MsgConfigureVideoFileName* create(const QString& fileName) + { + return new MsgConfigureVideoFileName(fileName); + } + + private: + QString m_fileName; + + MsgConfigureVideoFileName(const QString& fileName) : + Message(), + m_fileName(fileName) + { } + }; + ATVMod(); ~ATVMod(); @@ -207,6 +228,7 @@ private: QMutex m_settingsMutex; int m_horizontalCount; //!< current point index on line int m_lineCount; //!< current line index in frame + float m_fps; //!< resulting frames per second MovingAverage m_movingAverage; quint32 m_levelCalcCount; @@ -217,6 +239,13 @@ private: cv::Mat m_image; //!< resized image for transmission at given rate bool m_imageOK; + cv::VideoCapture m_video; //!< current video capture + cv::Mat m_frame; //!< current frame + float m_videoFPS; + int m_videoWidth; + int m_videoHeight; + bool m_videoOK; + static const float m_blackLevel; static const float m_spanLevel; static const int m_levelNbSamples; @@ -229,6 +258,7 @@ private: void modulateSample(); void applyStandard(); void openImage(const QString& fileName); + void openVideo(const QString& fileName); void resizeImage(); inline void pullImageLine(Real& sample) diff --git a/plugins/channeltx/modatv/atvmodgui.cpp b/plugins/channeltx/modatv/atvmodgui.cpp index 42b963d64..945a5b389 100644 --- a/plugins/channeltx/modatv/atvmodgui.cpp +++ b/plugins/channeltx/modatv/atvmodgui.cpp @@ -235,11 +235,24 @@ void ATVModGUI::on_imageFileDialog_clicked(bool checked) if (fileName != "") { m_imageFileName = fileName; - ui->recordFileText->setText(m_imageFileName); + ui->imageFileText->setText(m_imageFileName); configureImageFileName(); } } +void ATVModGUI::on_videoFileDialog_clicked(bool checked) +{ + QString fileName = QFileDialog::getOpenFileName(this, + tr("Open video file"), ".", tr("Video Files (*.avi *.mpg *.mp4 *.mov *.m4v)")); + + if (fileName != "") + { + m_videoFileName = fileName; + ui->videoFileText->setText(m_videoFileName); + configureVideoFileName(); + } +} + void ATVModGUI::configureImageFileName() { qDebug() << "ATVModGUI::configureImageFileName: " << m_imageFileName.toStdString().c_str(); @@ -247,6 +260,13 @@ void ATVModGUI::configureImageFileName() m_atvMod->getInputMessageQueue()->push(message); } +void ATVModGUI::configureVideoFileName() +{ + qDebug() << "ATVModGUI::configureVideoFileName: " << m_videoFileName.toStdString().c_str(); + ATVMod::MsgConfigureVideoFileName* message = ATVMod::MsgConfigureVideoFileName::create(m_videoFileName); + m_atvMod->getInputMessageQueue()->push(message); +} + void ATVModGUI::onWidgetRolled(QWidget* widget, bool rollDown) { } diff --git a/plugins/channeltx/modatv/atvmodgui.h b/plugins/channeltx/modatv/atvmodgui.h index 48138becc..61f1caa6b 100644 --- a/plugins/channeltx/modatv/atvmodgui.h +++ b/plugins/channeltx/modatv/atvmodgui.h @@ -67,11 +67,13 @@ private slots: void on_volume_valueChanged(int value); void on_channelMute_toggled(bool checked); void on_imageFileDialog_clicked(bool checked); + void on_videoFileDialog_clicked(bool checked); void onWidgetRolled(QWidget* widget, bool rollDown); void onMenuDoubleClicked(); void configureImageFileName(); + void configureVideoFileName(); void tick(); private: @@ -88,6 +90,7 @@ private: MovingAverage m_channelPowerDbAvg; QString m_imageFileName; + QString m_videoFileName; quint32 m_recordLength; int m_recordSampleRate; int m_samplesCount; diff --git a/plugins/channeltx/modatv/atvmodgui.ui b/plugins/channeltx/modatv/atvmodgui.ui index 32ec6d76b..06c6c157f 100644 --- a/plugins/channeltx/modatv/atvmodgui.ui +++ b/plugins/channeltx/modatv/atvmodgui.ui @@ -7,7 +7,7 @@ 0 0 342 - 363 + 366 @@ -466,18 +466,7 @@ - - - - - ... - - - - - - - + @@ -505,12 +494,23 @@ - - - Qt::Vertical + + + ... + + + + + + Qt::Horizontal + + + + + @@ -537,6 +537,17 @@ + + + + ... + + + + + + +