新增视频监控内核mpv
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
#include "vlc.h"
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
|
||||
#define STRDATETIME qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss"))
|
||||
|
||||
VlcThread::VlcThread(QObject *parent) : QThread(parent)
|
||||
{
|
||||
setObjectName("VlcThread");
|
||||
@@ -34,7 +30,7 @@ void VlcThread::run()
|
||||
free();
|
||||
stopped = false;
|
||||
isPlay = false;
|
||||
//qDebug() << TIMEMS << "stop vlc thread";
|
||||
//qDebug() << TIMEMS << "stop vlc1 thread";
|
||||
}
|
||||
|
||||
void VlcThread::setUrl(const QString &url)
|
||||
@@ -136,7 +132,7 @@ void VlcThread::stop()
|
||||
//实时视频显示窗体类
|
||||
VlcWidget::VlcWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
vlc = new VlcThread(this);
|
||||
thread = new VlcThread(this);
|
||||
}
|
||||
|
||||
VlcWidget::~VlcWidget()
|
||||
@@ -146,7 +142,7 @@ VlcWidget::~VlcWidget()
|
||||
|
||||
void VlcWidget::setUrl(const QString &url)
|
||||
{
|
||||
vlc->setUrl(url);
|
||||
thread->setUrl(url);
|
||||
}
|
||||
|
||||
void VlcWidget::open()
|
||||
@@ -154,27 +150,27 @@ void VlcWidget::open()
|
||||
//qDebug() << TIMEMS << "open video" << objectName();
|
||||
clear();
|
||||
|
||||
vlc->play();
|
||||
vlc->start();
|
||||
thread->play();
|
||||
thread->start();
|
||||
}
|
||||
|
||||
void VlcWidget::pause()
|
||||
{
|
||||
vlc->pause();
|
||||
thread->pause();
|
||||
}
|
||||
|
||||
void VlcWidget::next()
|
||||
{
|
||||
vlc->next();
|
||||
thread->next();
|
||||
}
|
||||
|
||||
void VlcWidget::close()
|
||||
{
|
||||
//qDebug() << TIMEMS << "close video" << objectName();
|
||||
if (vlc->isRunning()) {
|
||||
vlc->stop();
|
||||
vlc->quit();
|
||||
vlc->wait(3000);
|
||||
if (thread->isRunning()) {
|
||||
thread->stop();
|
||||
thread->quit();
|
||||
thread->wait(3000);
|
||||
}
|
||||
|
||||
QTimer::singleShot(5, this, SLOT(clear()));
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#endif
|
||||
|
||||
#include "vlchead.h"
|
||||
class VlcWidget;
|
||||
|
||||
class VlcThread : public QThread
|
||||
{
|
||||
@@ -23,7 +22,6 @@ private:
|
||||
volatile bool isPlay; //播放视频标志位
|
||||
|
||||
QString url; //视频流地址
|
||||
|
||||
libvlc_instance_t *vlcInst; //载体对象
|
||||
libvlc_media_t *vlcMedia; //媒体对象
|
||||
libvlc_media_player_t *vlcPlayer; //播放对象
|
||||
@@ -60,7 +58,7 @@ public:
|
||||
~VlcWidget();
|
||||
|
||||
private:
|
||||
VlcThread *vlc; //实时视频采集对象
|
||||
VlcThread *thread;
|
||||
|
||||
public slots:
|
||||
//设置视频流地址
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
HEADERS += $$PWD/vlchead.h
|
||||
HEADERS += $$PWD/vlc.h
|
||||
SOURCES += $$PWD/vlc.cpp
|
||||
HEADERS += $$PWD/vlchead.h
|
||||
HEADERS += $$PWD/vlc.h
|
||||
SOURCES += $$PWD/vlc.cpp
|
||||
|
||||
#如果用的是vlc3内核请将vlc2改成vlc3,两种内核不兼容,头文件也不一样,建议用vlc2
|
||||
DEFINES += vlc2
|
||||
|
||||
@@ -1,37 +1,5 @@
|
||||
/*****************************************************************************
|
||||
* vlc.h: global header for libvlc
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1998-2008 VLC authors and VideoLAN
|
||||
* $Id: 8f39094bd4b15c99288cecd001f76fcc10565daa $
|
||||
*
|
||||
* Authors: Vincent Seguin <seguin@via.ecp.fr>
|
||||
* Samuel Hocevar <sam@zoy.org>
|
||||
* Gildas Bazin <gbazin@netcourrier.com>
|
||||
* Derk-Jan Hartman <hartman at videolan dot org>
|
||||
* Pierre d'Herbemont <pdherbemont@videolan.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef VLC_VLC_H
|
||||
#define VLC_VLC_H 1
|
||||
|
||||
/**
|
||||
* \file
|
||||
* This file defines libvlc new external API
|
||||
*/
|
||||
#ifndef VLCHEAD_H
|
||||
#define VLCHEAD_H 1
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -68,4 +36,15 @@ extern "C" {
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* _VLC_VLC_H */
|
||||
#include "qdatetime.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz"))
|
||||
#define TIME qPrintable(QTime::currentTime().toString("HH:mm:ss"))
|
||||
#define QDATE qPrintable(QDate::currentDate().toString("yyyy-MM-dd"))
|
||||
#define QTIME qPrintable(QTime::currentTime().toString("HH-mm-ss"))
|
||||
#define DATETIME qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"))
|
||||
#define STRDATETIME qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss"))
|
||||
#define STRDATETIMEMS qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss-zzz"))
|
||||
|
||||
#endif // VLCHEAD_H
|
||||
|
||||
Reference in New Issue
Block a user