diff --git a/Channel.cpp b/Channel.cpp
index 4256958..15cf24b 100644
--- a/Channel.cpp
+++ b/Channel.cpp
@@ -23,15 +23,11 @@ Channel::Channel(QObject* parent)
timer->stop();
videoInput = nullptr;
- videoEncoder = nullptr;
videoOutput = nullptr;
+ videoEncoder = nullptr;
audioEncoder = nullptr;
record = nullptr;
- // file = nullptr;
- // videoDecoder = nullptr;
- // audioDecoder = nullptr;
rtsp = nullptr;
-
snap = Link::create("EncodeV");
overLay = Link::create("Overlay");
@@ -39,7 +35,7 @@ Channel::Channel(QObject* parent)
audioInput = Link::create("InputAlsa");
QVariantMap dataIn;
dataIn["path"] = "hw:0,0";
- dataIn["channels"] = 2;
+
audioInput->start(dataIn);
}
if (audioOutput == nullptr) {
@@ -54,7 +50,6 @@ Channel::Channel(QObject* parent)
}
if (file == nullptr) {
file = Link::create("InputFile");
- file->start();
// one video playback end
connect(file, &LinkObject::newEvent, [=](QString type, QVariant) {
@@ -99,10 +94,10 @@ void Channel::init()
videoInput->start(dataVi);
// start water mask
- overLay->start();
+ // overLay->start();
// link video input and output, and add water mask
- videoInput->linkV(overLay)->linkV(videoOutput);
+ videoInput->linkV(videoOutput);
// capture picture from video
QVariantMap dataSnap;
@@ -139,18 +134,6 @@ void Channel::init()
rtsp->start(dataRtsp);
videoInput->linkV(videoEncoder)->linkV(rtsp)->linkV(rtspServer);
audioInput->linkA(audioEncoder)->linkA(rtsp)->linkA(rtspServer);
-
- // init file and decoder
- // file = Link::create("InputFile");
- // file->start();
-
- // videoDecoder = Link::create("DecodeV");
- // videoDecoder->start();
- // audioDecoder = Link::create("DecodeA");
- // audioDecoder->start();
-
- // file->linkV(videoDecoder)->linkV(videoOutput);
- // file->linkA(audioDecoder)->linkA(audioOutput);
}
/**
@@ -188,7 +171,7 @@ void Channel::startRecord()
dataRecord["path"] = QString("%1/%2/%3.mp4").arg(VideoPath).arg(channelName).arg(curTime);
record->setData(dataRecord);
record->start();
- setOverlay("Record");
+ // setOverlay("Record");
timer->start();
snap->invoke("snapSync", QString("%1/%2/%3.jpg").arg(SnapPath).arg(channelName).arg(curTime));
@@ -200,7 +183,7 @@ void Channel::startRecord()
void Channel::stopRecord()
{
record->stop(true);
- setOverlay("No Record");
+ // setOverlay("No Record");
timer->stop();
}
@@ -210,22 +193,32 @@ void Channel::stopRecord()
*/
void Channel::startPlayback(QString fileName)
{
- qDebug() << channelName << "start play back, file name:" << fileName;
QString path = QString("%1/%2/%3").arg(VideoPath).arg(channelName).arg(fileName);
// break video input and output
videoInput->unLinkV(videoOutput);
- file->linkV(videoDecoder)->linkV(videoOutput);
+ videoDecoder->linkV(videoOutput);
QVariantMap dataFile;
dataFile["path"] = path;
- file->setData(dataFile);
- // file->start();
+ file->start(dataFile);
isPlayback = true;
}
+/**
+ * @brief play live
+ */
+void Channel::startPlayLive()
+{
+ videoDecoder->unLinkV(videoOutput);
+ file->stop(true);
+
+ videoInput->linkV(videoOutput);
+ isPlayback = false;
+}
+
/**
* @brief playback -10s
*/
@@ -257,20 +250,6 @@ void Channel::togglePause()
file->invoke("pause", isPause);
}
-/**
- * @brief play live
- */
-void Channel::startPlayLive()
-{
- // stop playback
- videoDecoder->unLinkV(videoOutput);
-
- file->stop(true);
- isPlayback = false;
-
- videoInput->linkV(videoOutput);
-}
-
/**
* @brief open console process, and use it by command
* @param com
diff --git a/Menu.cpp b/Menu.cpp
index b86a5e3..26dc1c3 100644
--- a/Menu.cpp
+++ b/Menu.cpp
@@ -8,16 +8,11 @@ Menu::Menu(QWidget* parent)
ui->setupUi(this);
ui->btnChannelA->setChecked(true);
- // set window background transparent
- // QPalette pal = palette();
- // pal.setBrush(QPalette::Base, Qt::transparent);
- // setPalette(pal);
- // setAttribute(Qt::WA_TranslucentBackground, true);
-
- QPoint globalPos = parent->mapToGlobal(QPoint(0, 0)); //父窗口绝对坐标
- int x = globalPos.x() + (parent->width() - this->width()) / 2; //x坐标
- int y = globalPos.y() + (parent->height() - this->height()) / 2; //y坐标
- this->move(x, y); //窗口移动
+ // move to center
+ QPoint globalPos = parent->mapToGlobal(QPoint(0, 0));
+ int x = globalPos.x() + (parent->width() - this->width()) / 2;
+ int y = globalPos.y() + (parent->height() - this->height()) / 2;
+ this->move(x, y);
}
Menu::~Menu()
diff --git a/Menu.ui b/Menu.ui
index a6f8ff6..17e7269 100644
--- a/Menu.ui
+++ b/Menu.ui
@@ -14,19 +14,18 @@
Form
- QWidget#Menu{
-
-}
+ /*QWidget#Menu{
+ background: rgba(0, 0, 0, 0.5);
+}*/
QPushButton {
border: none;
- background: rbga(0, 0, 0, 0.5);
+ background: rgba(0, 0, 0, 0.7);
color: #ffffff;
}
QPushButton::checked{
- color: #0082E5;
- background: rgba(0, 130, 229, 0.5);
+ background: rgba(0, 0, 255, 0.7);
}
diff --git a/Widget.cpp b/Widget.cpp
index 7079552..5f97d87 100644
--- a/Widget.cpp
+++ b/Widget.cpp
@@ -213,22 +213,25 @@ void Widget::onReadyRead()
curChannelName = menu->getCurChannel();
menu->hide();
showPlayList();
- }
- // if menu hide, then current channel playback and other channel play live
- else {
- QString fileName = ui->listWidget->currentItem()->text();
- Channel* channel = nullptr;
- for (int i = 0; i < channelList.count(); i++) {
- if (channelList.at(i)->channelName == curChannelName) {
- channel = channelList.at(i);
+ } else {
+ // if list widget show, then current channel playback and other channel play live
+ if (ui->listWidget->isVisible()) {
+ QString fileName = ui->listWidget->currentItem()->text();
+ Channel* channel = nullptr;
+ for (int i = 0; i < channelList.count(); i++) {
+ if (channelList.at(i)->channelName == curChannelName) {
+ channel = channelList.at(i);
+ }
+ if (channelList.at(i)->isPlayback) {
+ channelList.at(i)->startPlayLive();
+ }
}
- if (channelList.at(i)->isPlayback) {
- channelList.at(i)->startPlayLive();
+ if (channel) {
+ channel->startPlayback(fileName);
+ isPlayback = true;
}
+ ui->listWidget->hide();
}
- if (channel)
- channel->startPlayback(fileName);
- ui->listWidget->hide();
}
break;
case Return:
diff --git a/Widget.ui b/Widget.ui
index 0860f80..229b17c 100644
--- a/Widget.ui
+++ b/Widget.ui
@@ -18,6 +18,9 @@
Widget
+
+
+
0