| | |
| | | #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> |
| | | |
| | |
| | | |
| | | 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) { |
| | |
| | | usleep(1000000); |
| | | //阻塞线程,等待外部触发关闭点播 |
| | | while (p_this->m_running) { |
| | | if(p_this->m_fFmpegDecoderJPG.getRunning()) { |
| | | if (p_this->m_fFmpegDecoderJPG.getRunning()) { |
| | | usleep(300000); |
| | | } else { |
| | | |
| | |
| | | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | |
| | | return t_FilePath; |
| | | } |
| | | |
| | | void BASICGB28181::VideoCaptureElementWithRtp::startPublishVideo() { |
| | | m_publishVideoRet = true; |
| | | } |
| | | |
| | | void BASICGB28181::VideoCaptureElementWithRtp::stopPublishVideo() { |
| | | m_publishVideoRet = false; |
| | | } |