代码拉取完成,页面将自动刷新
#include "networkcamerachannel2.h"
#include "ui_networkcamerachannel2.h"
#define RTSP_URL_HEAD tr("rtsp://")
#define INFO_WIDTH (150)
#define INFO_HEIGHT (40)
//static networkCameraChannel2 *m_networkCameraChannel2 = nullptr;
networkCameraChannel2::networkCameraChannel2(QWidget *parent) :
QWidget(parent),
ui(new Ui::networkCameraChannel2)
{
ui->setupUi(this);
// m_InfoShowLabel = new InfoShowLabel(this);
// m_InfoShowLabel->resize(INFO_WIDTH,INFO_HEIGHT);
// m_FullScreenButton = new FullScreenButton(this);
// m_FullScreenButton->hide();
// m_DataDictionary = DataDictionary::GetInstance();
// m_DataDictionary->SetMisData(MIS_CAMERA_STA2,CAMERA_OFFLINE);
// m_Url.clear();
// m_MyFFmpeg = new MyFFmpeg;
// //m_MyFFmpeg->SetShowLabel(ui->DisplayLabel,ui->DisplayLabel->width(),ui->DisplayLabel->height());
// m_Player = new QTimer();
// m_Player->setInterval(1000);
// m_RtspPlayer = new RTSP_Player(m_MyFFmpeg);
// m_playThread = new QThread();
// m_RtspPlayer->moveToThread(m_playThread);
// m_playThread->start();
// m_RepaintTimer = new QTimer;
// m_RepaintTimer->setInterval(1000);
// m_RepaintTimer->start();
// m_DisconnectTimer = new QTimer;
// m_DisconnectTimer->setInterval(1000 * 15);
// HideCentre();
// m_Shoting = false;
// m_DisplayInterval = m_DataDictionary->GetMisData(MIS_DISPLAY_INTERVAL2).toInt();
// BuildUrl();
// connect(m_MyFFmpeg,SIGNAL(MyFFmpegSigGetOneFrame(QImage)),this,SLOT(NetCameraShow(QImage)));
// connect(m_Player,SIGNAL(timeout()),m_RtspPlayer,SLOT(PlayerStart()));
// connect(m_DisconnectTimer,SIGNAL(timeout()),this,SLOT(DisconnectDisplay()));
// //connect(m_Player,SIGNAL(timeout()),m_RTSPDeCode,SLOT(DeCodeStart()));
// //connect(m_Player,SIGNAL(timeout()),m_Player,SLOT(stop()));
// connect(m_RtspPlayer,SIGNAL(SigOpenUrlResult(int)),this,SLOT(PlayerStatus(int)));
// connect(m_DataDictionary,SIGNAL(SystemDataChange(SystemDataIndex_t)),this,SLOT(SystemDataChangeProcess(SystemDataIndex_t)));
//// connect(m_RepaintTimer,SIGNAL(timeout()),this,SLOT(PicLabelRepaint()));
// connect(m_FullScreenButton,SIGNAL(Clicked()),this,SIGNAL(Clicked()));
// connect(m_DataDictionary,SIGNAL(MisDataChange(MisDataIndex_t)),this,SLOT(MisDataChange(MisDataIndex_t)));
}
networkCameraChannel2::~networkCameraChannel2()
{
delete ui;
}
QString networkCameraChannel2::UrlGetIp(QString Str)
{
QRegExp regEx("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
QString Ip ;
regEx.indexIn(Str,0);
Ip = regEx.cap(0);
return Ip;
}
void networkCameraChannel2::BuildUrl()
{
// if(!m_DataDictionary)
// return ;
// //m_RtspPlayer->PlayerStop();
// QString passWord = m_DataDictionary->GetSystemData(SYS_CAMERA_PASSWORD2);
// QString userName = m_DataDictionary->GetSystemData(SYS_CAMERA_USERNAME2);
// QString ip = m_DataDictionary->GetSystemData(SYS_CAMERA_IP2);
// QString port = m_DataDictionary->GetSystemData(SYS_CAMERA_PORT2);
// QString path = m_DataDictionary->GetSystemData(SYS_CAMERA_PATH);
// QString url = m_DataDictionary->GetSystemData(SYS_CAMERA_URL2);
// if(url.isEmpty())
// m_Url = RTSP_URL_HEAD + userName + ":" + passWord + "@" + ip + ":" + port + path;
// else
// m_Url = url;
// qDebug() << m_Url;
// m_MyFFmpeg->MyFFmpegSetUrl(m_Url);
// m_RtspPlayer->Play();
// ip = UrlGetIp(m_Url);
// m_InfoShowLabel->SetInfo(ip);
}
//networkCameraChannel2 *networkCameraChannel2::GetInstance()
//{
// if(m_networkCameraChannel2 == nullptr){
// m_networkCameraChannel2 = new networkCameraChannel2;
// }
// return m_networkCameraChannel2;
//}
void networkCameraChannel2::resizeEvent(QResizeEvent *event)
{
// qDebug() << "aaaaaaaaaaaaa" << event->size();
// this->resize(event->size());
// ui->DisplayLabel->resize(event->size());
// m_InfoShowLabel->move(event->size().width()-INFO_WIDTH - 30,event->size().height()-INFO_HEIGHT-20);
// m_FullScreenButton->move(event->size().width() - m_FullScreenButton->width() - 20,40);
}
//void networkCameraChannel2::NetCameraShow(QImage Img)
//{
// //QImage newImage = Img.scaled(ui->DisplayLabel->width(), ui->DisplayLabel->height(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
// static int cnt = 0;
// cnt++;
// if(cnt <= m_DisplayInterval)
// {
// return;
// }
// cnt = 0;
// //ui->DisplayLabel->setStyleSheet("QLabel{border-radius: 20px;}");
// ui->DisplayLabel->setPixmap(QPixmap::fromImage(Img));
// if(m_Shoting){
// m_DataDictionary->SetMisData(MIS_SHOT_NET_CAM2_RES,Img);
// m_Shoting = false;
// }
//}
//void networkCameraChannel2::PlayerStatus(int Sta)
//{
// qDebug() << __FUNCTION__ << Sta;
// switch(Sta)
// {
// case RTSP_Player::FFmpegInitFail:
// BuildUrl();
// if(!m_DisconnectTimer->isActive())
// m_DisconnectTimer->start();
// m_DataDictionary->SetMisData(MIS_CAMERA_STA2,CAMERA_OFFLINE);
// break;
// case RTSP_Player::FFmpegInitSucc:
// qDebug() << __FUNCTION__ << Sta;
// m_DisconnectTimer->stop();
// m_DataDictionary->SetMisData(MIS_CAMERA_STA2,CAMERA_ONLINE);
// break;
// case RTSP_Player::FFmpegStoped:
// BuildUrl();
// //m_RtspPlayer->PlayerStart();
// //m_playThread->start();
// m_DisconnectTimer->stop();
// m_DataDictionary->SetMisData(MIS_CAMERA_STA2,CAMERA_OFFLINE);
// break;
// }
//}
//void networkCameraChannel2::PicLabelRepaint()
//{
// ui->DisplayLabel->repaint();
//}
//void networkCameraChannel2::SystemDataChangeProcess(SystemDataIndex_t Index)
//{
// switch(Index)
// {
// case SYS_CAMERA_PASSWORD2:
// case SYS_CAMERA_USERNAME2:
// case SYS_CAMERA_IP2:
// case SYS_CAMERA_PORT2:
// case SYS_CAMERA_PATH:
// case SYS_CAMERA_URL2:
// m_RtspPlayer->PlayerStop();
// break;
// default:
// break;
// }
//}
//void networkCameraChannel2::MisDataChange(MisDataIndex_t Index)
//{
// switch (Index) {
// case MIS_DISPLAY_INTERVAL2:
// m_DisplayInterval = m_DataDictionary->GetMisData(MIS_DISPLAY_INTERVAL2).toInt();
// break;
// case MIS_SHOT_NET_CAM2:
// if(m_DataDictionary->GetMisData(MIS_CAMERA_STA2).toUInt() == CAMERA_OFFLINE){
// m_DataDictionary->SetMisData(MIS_SHOT_NET_CAM2_RES,QImage());
// }else {
// m_Shoting = true;
// }
// break;
// default:
// break;
// }
//}
//void networkCameraChannel2::DisconnectDisplay()
//{
// ui->DisplayLabel->clear();
// ui->DisplayLabel->setText("摄像头连接失败,请检测网络或登录信息\n重连中… …");
// m_DisconnectTimer->stop();
//}
void networkCameraChannel2::Show(QWidget *parent,int ax, int ay)
{
this->setParent(parent);
this->move(ax,ay);
this->show();
// //m_RtspPlayer->PlayerStart();
// ui->DisplayLabel->resize(parent->size());
// m_Player->start();
}
void networkCameraChannel2::ShowCentre()
{
// ui->CentreA->show();
// ui->CentreB->show();
}
void networkCameraChannel2::HideCentre()
{
// ui->CentreA->hide();
// ui->CentreB->hide();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。