From 12879769af38a00425309e292b2c167afc6612c1 Mon Sep 17 00:00:00 2001 From: pansen <pansen626@sina.com> Date: 星期四, 04 四月 2019 11:27:38 +0800 Subject: [PATCH] 增加点播功能 --- QiaoJiaSystem/DataManagerServer/demo.cpp | 44 ++-- QiaoJiaSystem/DataManagerServer/http_configserver.cpp | 83 ++++++--- QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.h | 8 + QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.h | 6 QiaoJiaSystem/DataManagerServer/CMakeLists.txt | 109 +++++++------ QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h | 7 QiaoJiaSystem/DataManagerServer/AppPipeController.cpp | 37 ++-- QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp | 41 +++-- QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp | 42 +++-- QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp | 30 +++ QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp | 23 ++ 11 files changed, 275 insertions(+), 155 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp b/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp index 13df05b..30e114b 100644 --- a/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp +++ b/QiaoJiaSystem/DataManagerServer/AppPipeController.cpp @@ -4,35 +4,34 @@ #include <basic/util/app/AppUtil.h> //#include <sstream> #include <algorithm> -AppPipeController::AppPipeController(int index, const Json::Value &json): - videoCaptureElement(json["rtsp"].asString(), 25,3000,appPref.getIntData("gpu.index")), - index(index), videoPublishElement(appPref.getStringData("publish.basepath")+".flv", - cv::Size(appConfig.getIntProperty("pulish.width"),appConfig.getIntProperty("pulish.height")), - "flv", 25, appPref.getIntData("gpu.index")) -{ - if(appConfig.getIntProperty("pulish.width") < 0 || appConfig.getIntProperty("pulish.height") < 0) - { - ERR("pulish.width: "<<appConfig.getIntProperty("pulish.width") <<" Height: "<< appConfig.getIntProperty("pulish.height")); - } - videoCaptureElement.registerConnector([&]{ - //if(!videoPublishElement.isBusy()){ - videoPublishElement.setImage(videoCaptureElement.getImage()); - //videoPublishElement.submit(); - //} +AppPipeController::AppPipeController(int index, const Json::Value &json) : + videoCaptureElement(json["rtsp"].asString(), 25, 3000, appPref.getIntData("gpu.index")), + index(index), videoPublishElement(appPref.getStringData("publish.basepath") + ".flv", + cv::Size(appConfig.getIntProperty("pulish.width"), + appConfig.getIntProperty("pulish.height")), + "flv", 25, appPref.getIntData("gpu.index")) { + if (appConfig.getIntProperty("pulish.width") < 0 || appConfig.getIntProperty("pulish.height") < 0) { + ERR("pulish.width: " << appConfig.getIntProperty("pulish.width") << " Height: " + << appConfig.getIntProperty("pulish.height")); + } + videoCaptureElement.registerConnector([&] { + //if(!videoPublishElement.isBusy()){ + videoPublishElement.setImage(videoCaptureElement.getImage()); +// videoPublishElement.submit(); + //} }); registerElement(videoCaptureElement); - registerElement(videoPublishElement); +// registerElement(videoPublishElement); //videoCaptureElement.setOutPutInterval(3); } -std::string AppPipeController::getRtmp() -{ +std::string AppPipeController::getRtmp() { std::string ret = videoPublishElement.getPath(); size_t pos = ret.find(".flv"); - ret = ret.substr(0,pos); + ret = ret.substr(0, pos); INFO(ret); return ret; } diff --git a/QiaoJiaSystem/DataManagerServer/CMakeLists.txt b/QiaoJiaSystem/DataManagerServer/CMakeLists.txt index e2339d3..77fd0e8 100644 --- a/QiaoJiaSystem/DataManagerServer/CMakeLists.txt +++ b/QiaoJiaSystem/DataManagerServer/CMakeLists.txt @@ -174,53 +174,64 @@ evpp_concurrentqueue ) -#add_executable(Apptest -# demo.cpp -# ./AppPipeController.cpp -# ./AppPipeController.h -# -# ../../BasicPlatForm/basic/util/opencv/CvUtil.cpp -# ../../BasicPlatForm/basic/util/BASE64/Base64.cpp -# ../../BasicPlatForm/basic/util/fastdfs/FastdfsClient.cpp -# ../FaceSearchServer/CasiaFaceWrapper/CasiaFaceWrapperN.cpp -# ../FaceSearchServer/CasiaFaceWrapper/CasiaFaceWrapperN.h -# ../../BasicPlatForm/basic/pipe_element/ffmpeg/FfmpegElement.cpp -# ../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoChangeScore.cpp -# ) -# -#target_link_libraries(Apptest -# boost_system -# boost_thread -# boost_filesystem -# ei -# erl_interface_st -# ei_st -# erl_interface -# # uuid -# rt -# pthread -# avformat -# avcodec -# swresample -# swscale -# avutil -# bz2 dl z -# -# opencv_world -# THFaceImage -# THFeature -# THFaceProperty -# -# curl -# fastcommon -# fdfsclient -# -# Qt5Core -# Qt5Sql -# -# jsoncpp -# -# HCCore -# hcnetsdk -# ) +add_executable(demo + demo.cpp + ./AppPipeController.cpp + ./AppPipeController.h + ../../../BasicPlatForm/basic/util/opencv/CvUtil.cpp + ../../../BasicPlatForm/basic/pipe_element/ffmpeg/FfmpegElement.cpp + ../../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoChangeScore.cpp + ../../../BasicPlatForm/basic/timer_counter/Clocktimer.cpp + ) + +target_link_libraries(demo + glog + boost_system + boost_thread + boost_filesystem + ei + erl_interface_st + ei_st + erl_interface + uuid + rt + avformat + avcodec + swresample + swscale + avutil + bz2 dl z + + opencv_world + THFaceImage + THFeature + THFaceProperty + + curl + fastcommon + fdfsclient + + Qt5Core + Qt5Sql + sqlite3 + + jsoncpp + + imos_mw_sdk + mw_sdk_player + mw_sdk_ipc + mw_sdk_bp + mw_sdk_rm + + HCCore + hcnetsdk + pthread + mysqlpp + mysqlclient + + #mq + event + evnsq + evpp_concurrentqueue + ) diff --git a/QiaoJiaSystem/DataManagerServer/demo.cpp b/QiaoJiaSystem/DataManagerServer/demo.cpp index 4217194..6a83272 100644 --- a/QiaoJiaSystem/DataManagerServer/demo.cpp +++ b/QiaoJiaSystem/DataManagerServer/demo.cpp @@ -8,30 +8,30 @@ using namespace std; int main() { -// Json::Value json; -// json["rtsp"] = "rtsp://admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream"; -// -// std::string publish_basepath = "rtmp://localhost:1934/live/cam" + std::to_string(554); -// appPref.setIntData("gpu.index", 0); -// appPref.setStringData("publish.basepath", publish_basepath); -// appPref.setIntData("pulish.width", 640); -// appPref.setIntData("pulish.height", 360); -// -// AppPipeController a(0, json); -// a.start(); -// -// getchar(); -// -// a.stop(); -// a.wait(); - std::cout<<__DATE__<<" "<<__TIME__<<std::endl; - string img = "http://192.168.1.182:8080/ManCarAnaly/group2/M00/02/B5/wKgBnFw3TB-AfsrIAAah4WWyHJ0555.jpg"; + Json::Value json; + json["rtsp"] = "rtsp://admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream"; - auto pos = img.find("group"); + std::string publish_basepath = "rtmp://localhost:1934/live/cam" + std::to_string(554); + appPref.setIntData("gpu.index", 0); + appPref.setStringData("publish.basepath", publish_basepath); + appPref.setIntData("pulish.width", 640); + appPref.setIntData("pulish.height", 360); - auto img_url = img.substr(pos); - std::string img_str = "http://"; - img_str.append(""); + AppPipeController a(0, json); + a.start(); + + getchar(); + + a.stop(); + a.wait(); +// std::cout<<__DATE__<<" "<<__TIME__<<std::endl; +// string img = "http://192.168.1.182:8080/ManCarAnaly/group2/M00/02/B5/wKgBnFw3TB-AfsrIAAah4WWyHJ0555.jpg"; +// +// auto pos = img.find("group"); +// +// auto img_url = img.substr(pos); +// std::string img_str = "http://"; +// img_str.append(""); return 0; diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp index 494356c..9296951 100644 --- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp +++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp @@ -1318,28 +1318,41 @@ } Json::Value value; if (value_reader.isMember("id")) { - if (value_reader["id"].isNull()) return "{\"ret_status\": \"id鍐呭鏈夎锛岃妫�鏌ワ紒\"}"; - value["connect_status"] = "True"; - std::string rtmp_url = appConfig.getStringProperty("srsAddr"); - rtmp_url.append("cam").append(value_reader["id"].asCString()); - value["video_url"] = rtmp_url; - out = value.toStyledString(); - - } else { - //TODO - //璋冪敤rtsp娴乺tsp://admin:a1234567@192.168.1.215:554/h264/ch1/main/av_stream + if (value_reader["id"].isNull()) { + //鏈湴瑙嗛婧� 绗竴娆℃祴璇曡繛鎺� + //TODO + //璋冪敤rtsp娴乺tsp://admin:a1234567@192.168.1.215:554/h264/ch1/main/av_stream // std::string rtsp_url = "rtsp://" + username + ":" + passwd + "@" + ip + ":" + std::to_string(port) + "/h264/ch1/main/av_stream"; - bool ret = cam_connect_video_start(value_reader["str_ip"].asString(), value_reader["n_port"].asInt(), \ + bool ret = cam_connect_video_start(value_reader["str_ip"].asString(), value_reader["n_port"].asInt(), \ value_reader["str_username"].asString(), value_reader["str_password"].asString(), \ value_reader["str_brand"].asString()); - if (!ret) { + if (!ret) { + return "{\"ret_status\": \"鍐呭鏈夎锛岃妫�鏌ワ紒\"}"; + } + std::string rtmp_url = m_rtmp[value_reader["str_ip"].asCString()].appPC->getRtmp(); + value["connect_status"] = "True"; + value["video_url"] = rtmp_url; + out = value.toStyledString(); + } else if (!value_reader["type"].isNull()) { + + value["connect_status"] = "True"; + std::string rtmp_url = appConfig.getStringProperty("srsAddr"); + rtmp_url.append("cam").append(value_reader["id"].asCString()); + value["video_url"] = rtmp_url; + out = value.toStyledString(); + { + std::string topic = "VideoToImageMulth"; + Json::Value json_cfg; + json_cfg["cam_startPublish"] = content; + std::string msg = json_cfg.toStyledString(); + DBG("msg:" << msg); + nsqMsgProducer->Publish(topic, (void *) (&msg)); + } + } else { return "{\"ret_status\": \"鍐呭鏈夎锛岃妫�鏌ワ紒\"}"; } - - std::string rtmp_url = m_rtmp[value_reader["str_ip"].asCString()].appPC->getRtmp(); - value["connect_status"] = "True"; - value["video_url"] = rtmp_url; - out = value.toStyledString(); + } else { + return "{\"ret_status\": \"鍐呭鏈夎锛岃妫�鏌ワ紒\"}"; } return out; @@ -1357,19 +1370,31 @@ if (!reader.parse(content, value_reader)) { return "{\"ret_status\": \"浼犺緭閿欒锛岃妫�鏌ワ紒\"}"; } - - //TODO - //璋冪敤rtsp娴乺tsp://admin:a1234567@192.168.1.215:554/h264/ch1/main/av_stream -// std::string rtsp_url = "rtsp://" + username + ":" + passwd + "@" + ip + ":" + std::to_string(port) + "/h264/ch1/main/av_stream"; - DBG("cam_connect_video_stop begin"); - bool ret = cam_connect_video_stop(value_reader["str_ip"].asString()); - if (!ret) { - return "{\"ret_status\": \"浼犺緭閿欒锛岃妫�鏌ワ紒\"}"; - } - DBG("cam_connect_video_stop end"); - Json::Value value; - value["ret_status"] = "ok_ack"; + if (value_reader.isMember("id")) { + value["ret_status"] = "ok_ack"; + { + std::string topic = "VideoToImageMulth"; + Json::Value json_cfg; + json_cfg["cam_stopPublish"] = content; + std::string msg = json_cfg.toStyledString(); + DBG("msg:" << msg); + nsqMsgProducer->Publish(topic, (void *) (&msg)); + } + } else { + //TODO + //璋冪敤rtsp娴乺tsp://admin:a1234567@192.168.1.215:554/h264/ch1/main/av_stream +// std::string rtsp_url = "rtsp://" + username + ":" + passwd + "@" + ip + ":" + std::to_string(port) + "/h264/ch1/main/av_stream"; + DBG("cam_connect_video_stop begin"); + bool ret = cam_connect_video_stop(value_reader["str_ip"].asString()); + if (!ret) { + return "{\"ret_status\": \"浼犺緭閿欒锛岃妫�鏌ワ紒\"}"; + } + DBG("cam_connect_video_stop end"); + + value["ret_status"] = "ok_ack"; + } + std::string out = value.toStyledString(); diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp index 2f7010f..9b7b775 100644 --- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp +++ b/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灏唕tp鍖呰В鐮佹垚涓哄浘鐗囧悗瑙﹀彂淇″彿,鐒跺悗瑙﹀彂褰撳墠绫荤殑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; +} diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h index f2915cc..0ca39eb 100644 --- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h +++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.h @@ -8,6 +8,7 @@ #include "FFmpegDecoderJPG.h" #include "28181SDK.h" #include <basic/pipe/PipeElement.h> +#include <basic/pipe_element/ffmpeg/FfmpegElement.h> //#include <RtspAnalysManager.h> //#include <VideoToImageMulth/RtspAnalysManager.h> @@ -52,6 +53,10 @@ //鏍规嵁timeStamp鍒涘缓璺緞 std::string MakeDir(const std::string &timeStamp); + void startPublishVideo(); + + void stopPublishVideo(); + private: int reopenTime{10}; int m_gpuIdx; @@ -72,6 +77,8 @@ //鐢ㄦ潵淇濆瓨褰曞儚瑙嗛鐨勮矾寰� std::string m_cutPath; + std::atomic<bool> m_publishVideoRet{false}; + ffmpeg::VideoPublishElement * videoPublishElement; private: /*** * 鍚姩瀹炴椂娴佹帴鏀舵暟鎹嚎绋� diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp index 746b804..ce34ed9 100644 --- a/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp +++ b/QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp @@ -78,7 +78,7 @@ item.second->SetVideoMinMaxSeconds(cut_min_duration, cut_max_duration); } } - } else if (itor_json.name() == "cam_edit" ) { + } else if (itor_json.name() == "cam_edit") { string cam_idx = cfg_val["str_cam_dev_id"].asString(); if (pthis->m_GB28181_Enable) { if (pthis->m_controllers_videoCapElem.find(cam_idx) != @@ -98,10 +98,34 @@ } } else if (itor_json.name() == "cam_del") { string cam_idx = cfg_val["str_cam_dev_id"].asString(); + pthis->removeCamera(cam_idx); + } else if (itor_json.name() == "cam_startPublish") { + string cam_idx = cfg_val["str_cam_dev_id"].asString(); if (pthis->m_GB28181_Enable) { - pthis->removeCamera(cam_idx); + if (pthis->m_controllers_videoCapElem.find(cam_idx) != + pthis->m_controllers_videoCapElem.end()) { + INFO("cam add is " << cfg_val["str_addr"].asString()); + pthis->m_controllers_videoCapElem[cam_idx]->startPublishVideo(); + } } else { - pthis->removeCamera(cam_idx); + if (pthis->m_controllers.find(cam_idx) != pthis->m_controllers.end()) { + INFO("cam add is " << cfg_val["str_addr"].asString()); + pthis->m_controllers[cam_idx]->startPublishVideo(); + } + } + } else if (itor_json.name() == "cam_stopPublish") { + string cam_idx = cfg_val["str_cam_dev_id"].asString(); + if (pthis->m_GB28181_Enable) { + if (pthis->m_controllers_videoCapElem.find(cam_idx) != + pthis->m_controllers_videoCapElem.end()) { + INFO("cam add is " << cfg_val["str_addr"].asString()); + pthis->m_controllers_videoCapElem[cam_idx]->stopPublishVideo(); + } + } else { + if (pthis->m_controllers.find(cam_idx) != pthis->m_controllers.end()) { + INFO("cam add is " << cfg_val["str_addr"].asString()); + pthis->m_controllers[cam_idx]->stopPublishVideo(); + } } } } else { diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp b/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp index b8d983d..374529b 100644 --- a/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp +++ b/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.cpp @@ -9,6 +9,7 @@ #include "RtspAnalysManager.h" //#include <basic/pipe_element/ffmpeg/cap_ffmpeg_impl.hpp> #include "../../../BasicPlatForm/basic/pipe_element/ffmpeg/FfmpegElement.cpp" +#include <basic/util/app/AppConfig.h> RtspCaptureElement::RtspCaptureElement(const std::string &path, const std::string &camId, int fps, int reopenTime, int gpuIndex, RtspAnalysManager *manager) : @@ -56,6 +57,20 @@ img.copyTo(copyMat); std::string imageName = m_capture->GetImageName(); m_pManager->SaveImageToRedis(m_camId, imageName, copyMat); + } + //#todo publish Video + if (m_publishVideoRet) { + if (videoPublishElement == nullptr) { + string path = appConfig.getStringProperty("srsAddr") + "cam" + m_camId + ".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(); } @@ -114,3 +129,11 @@ m_capture->SetMinMaxVideoSeconds(minSeconds, maxSeconds); } +void RtspCaptureElement::startPublishVideo() { + m_publishVideoRet = true; +} + +void RtspCaptureElement::stopPublishVideo() { + m_publishVideoRet = false; +} + diff --git a/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.h b/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.h index 51c5a86..36fa3ea 100644 --- a/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.h +++ b/QiaoJiaSystem/VideoToImageMulth/RtspCaptureElement.h @@ -5,6 +5,7 @@ #include <opencv2/opencv.hpp> #include "../StructureApp/HiredisTool.h" #include <atomic> +#include <basic/pipe_element/ffmpeg/FfmpegElement.h> class RtspAnalysManager; @@ -26,6 +27,10 @@ //璁剧疆淇濆瓨瑙嗛鐨勬渶灏忓拰鏈�澶ч暱搴�,鍗曚綅鏄,瀹為檯鐨勮繍琛屾儏鍐垫湁涓�浜涘樊璺濓紝闇�瑕佸畬鍠� void SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds); + + void startPublishVideo(); + + void stopPublishVideo(); private: //绾跨▼鎵ц鍑芥暟 @@ -49,6 +54,9 @@ //淇濆瓨瑙嗛娴佺殑璺緞,绫讳技浜巖tsp://admin:a1234567@192.168.1.201:554/h264/ch2/main/av_stream std::string m_path; + + std::atomic<bool> m_publishVideoRet{false}; + ffmpeg::VideoPublishElement *videoPublishElement; // Redis鐨勫伐鍏风被 // HiredisTool m_redisTool; diff --git a/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp b/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp index 2bf9968..1c01b86 100644 --- a/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp +++ b/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.cpp @@ -12,29 +12,30 @@ index(chanPubID), videoPublishElement(nullptr) { - string path = appConfig.getStringProperty("srsAddr") + "cam" + 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); - if (appConfig.getIntProperty("pulish.width") < 0 || appConfig.getIntProperty("pulish.height") < 0) { - ERR("pulish.width: " << appConfig.getIntProperty("pulish.width") << " Height: " - << appConfig.getIntProperty("pulish.height")); - } - videoCaptureElement.registerConnector([&] { - //if(!videoPublishElement.isBusy()){ - videoPublishElement->setImage(videoCaptureElement.getImage()); - //videoPublishElement.submit(); - //} - }); +// string path = appConfig.getStringProperty("srsAddr") + "cam" + 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); +// if (appConfig.getIntProperty("pulish.width") < 0 || appConfig.getIntProperty("pulish.height") < 0) { +// ERR("pulish.width: " << appConfig.getIntProperty("pulish.width") << " Height: " +// << appConfig.getIntProperty("pulish.height")); +// } +// videoCaptureElement.registerConnector([&] { +// //if(!videoPublishElement.isBusy()){ +// videoPublishElement->setImage(videoCaptureElement.getImage()); +// //videoPublishElement.submit(); +// //} +// }); registerElement(videoCaptureElement); - registerElement(*videoPublishElement); +// registerElement(*videoPublishElement); // videoCaptureElement.setOutPutInterval(3); } std::string PushStreamAppPipeController::getRtmp() { - std::string ret = videoPublishElement->getPath(); + //#todo videoPublishElement is nullptr + std::string ret = "";// videoPublishElement->getPath(); size_t pos = ret.find(".flv"); ret = ret.substr(0, pos); INFO(ret); @@ -48,3 +49,12 @@ void PushStreamAppPipeController::SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds) { videoCaptureElement.SetVideoMinMaxSeconds(minSeconds, maxSeconds); } + +void PushStreamAppPipeController::startPublishVideo() { + videoCaptureElement.startPublishVideo(); +} + +void PushStreamAppPipeController::stopPublishVideo() { + + videoCaptureElement.stopPublishVideo(); +} diff --git a/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.h b/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.h index ea0085f..ac8a21c 100644 --- a/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.h +++ b/QiaoJiaSystem/VideoToImageMulth/pushStream/PushStreamAppPipeController.h @@ -20,9 +20,13 @@ //璁剧疆淇濆瓨瑙嗛鐨勬渶灏忓拰鏈�澶ч暱搴�,鍗曚綅鏄,瀹為檯鐨勮繍琛屾儏鍐垫湁涓�浜涘樊璺濓紝闇�瑕佸畬鍠� void SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds); + void startPublishVideo(); + + void stopPublishVideo(); + private: BASICGB28181::VideoCaptureElementWithRtp videoCaptureElement; - ffmpeg::VideoPublishElement* videoPublishElement; + ffmpeg::VideoPublishElement *videoPublishElement; std::string index; }; -- Gitblit v1.8.0