finsh basic functions
This commit is contained in:
parent
ab606d358a
commit
9bac1f9232
61
Channel.cpp
61
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
|
||||
|
15
Menu.cpp
15
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()
|
||||
|
11
Menu.ui
11
Menu.ui
@ -14,19 +14,18 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget#Menu{
|
||||
|
||||
}
|
||||
<string notr="true">/*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);
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
|
11
Widget.cpp
11
Widget.cpp
@ -213,9 +213,9 @@ void Widget::onReadyRead()
|
||||
curChannelName = menu->getCurChannel();
|
||||
menu->hide();
|
||||
showPlayList();
|
||||
}
|
||||
// if menu hide, then current channel playback and other channel play live
|
||||
else {
|
||||
} 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++) {
|
||||
@ -226,10 +226,13 @@ void Widget::onReadyRead()
|
||||
channelList.at(i)->startPlayLive();
|
||||
}
|
||||
}
|
||||
if (channel)
|
||||
if (channel) {
|
||||
channel->startPlayback(fileName);
|
||||
isPlayback = true;
|
||||
}
|
||||
ui->listWidget->hide();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Return:
|
||||
if (menu->isVisible()) {
|
||||
|
Loading…
Reference in New Issue
Block a user