pansen
2019-04-04 12879769af38a00425309e292b2c167afc6612c1
QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
@@ -5,6 +5,7 @@
#include <opencv2/imgproc.hpp>
#include <qt5/QtCore/QDateTime>
#include <basic/util/app/AppPreference.hpp>
#include <basic/util/app/AppConfig.h>
#include "VideoCaptureElementWithRtp.h"
#include <VideoToImageMulth/RtspAnalysManager.h>
@@ -35,7 +36,7 @@
bool BASICGB28181::VideoCaptureElementWithRtp::startRtpStream(int streamTransType) {
    if(!m_waitSignalrunning) {
    if (!m_waitSignalrunning) {
        DBG("std::thread waitSignalAndEmit create New!!");
        //等待下层ffmpeg将rtp包解码成为图片后触发信号,然后触发当前类的submit
        std::thread waitSignalAndEmit([&](BASICGB28181::VideoCaptureElementWithRtp *p_this) {
@@ -119,7 +120,7 @@
                usleep(1000000);
                //阻塞线程,等待外部触发关闭点播
                while (p_this->m_running) {
                    if(p_this->m_fFmpegDecoderJPG.getRunning()) {
                    if (p_this->m_fFmpegDecoderJPG.getRunning()) {
                        usleep(300000);
                    } else {
@@ -204,20 +205,20 @@
void BASICGB28181::VideoCaptureElementWithRtp::threadFunc() {
//    if ((!m_running) || (!m_waitSignal)) {
////        根据reopenTime判断是否需要重启
//        if (reopenTime < 0) {
//            stop();
//            INFO("grabFrame faild, element stopping");
//            return;
//        } else {
//            //todo 业务死锁
//            usleep(reopenTime * 1000);
//            INFO("grabFrame faild, try reopen video: ");
//            startRtpStream(m_streamTransType);
//            return;
//        }
//    }
    if (m_publishVideoRet) {
        if (videoPublishElement == nullptr) {
            string path = appConfig.getStringProperty("srsAddr") + "cam" + m_chanPubID + ".flv";
            cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height"));
            int gupIdx = appPref.getIntData("gpu.index");
            videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx);
        } else {
            videoPublishElement->stop();
            videoPublishElement->wait();
            delete videoPublishElement;
            videoPublishElement = nullptr;
        }
    }
    fireConnectors();
}
@@ -270,3 +271,11 @@
    return t_FilePath;
}
void BASICGB28181::VideoCaptureElementWithRtp::startPublishVideo() {
    m_publishVideoRet = true;
}
void BASICGB28181::VideoCaptureElementWithRtp::stopPublishVideo() {
    m_publishVideoRet = false;
}