-
Notifications
You must be signed in to change notification settings - Fork 10
/
app_window.cpp
62 lines (47 loc) · 1.85 KB
/
app_window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "app_window.h"
#include <iostream>
//const char * url = "rtsp://192.168.3.99:37441/h264";
const char * url = "rtsp://10.209.21.189:8554/txdx.mkv";
AppWindow::AppWindow(const char* progName, QWidget* parent)
: QMainWindow(parent),
_progName(progName){
this->setupUi();
this->_rtspSession = new RtspSession(1024, this->_progName.c_str(), url, this);
this->bindEvents();
}
void AppWindow::setupUi(){
QGridLayout *layout = new QGridLayout;
this->_cameraScreen = new QLabel("Video 0", this);
//this->_cameraScreen->setg
this->_cameraScreen->setStyleSheet("background:'black';color:'white'");
this->_startCaptureButton = new QPushButton(this);
this->_startCaptureButton->setText("Start");
this->_stopCaptureButton = new QPushButton(this);
this->_stopCaptureButton->setText("Stop");
layout->addWidget(this->_startCaptureButton, 0, 0);
layout->addWidget(this->_stopCaptureButton, 1, 0);
layout->addWidget(this->_cameraScreen, 2, 0);
QWidget * central = new QWidget(this);
setCentralWidget(central);
centralWidget()->setLayout(layout);
setWindowTitle("Camera Window");
setFixedSize(800, 600);
}
void AppWindow::bindEvents(){
connect(this->_startCaptureButton, SIGNAL(clicked()), this, SLOT(onStart()));
connect(this->_stopCaptureButton, SIGNAL(clicked()), this, SLOT(onStop()));
connect(this->_rtspSession, SIGNAL(gotFrame(QImage)), this, SLOT(updateFrame(QImage)));
}
void AppWindow::onStart(){
std::cout << "starting..." << std::endl;
this->_rtspSession->start();
}
void AppWindow::onStop(){
std::cout << "stoping..." << std::endl;
this->_rtspSession->stop();
}
void AppWindow::updateFrame(const QImage &image)
{
QPixmap pixmap = QPixmap::fromImage(image.scaled(this->_cameraScreen->size(), Qt::KeepAspectRatio) );
this->_cameraScreen->setPixmap(pixmap);
}