| | |
| | | #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")); |
| | | 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); |
| | |
| | | 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 |
| | | ) |
| | |
| | | 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; |
| | |
| | | } |
| | | 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 { |
| | | if (value_reader["id"].isNull()) { |
| | | //本地视频源 第一次测试连接 |
| | | //TODO |
| | | //调用rtsp流rtsp://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"; |
| | |
| | | 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\": \"内容有误,请检查!\"}"; |
| | | } |
| | | } else { |
| | | return "{\"ret_status\": \"内容有误,请检查!\"}"; |
| | | } |
| | | |
| | | return out; |
| | |
| | | if (!reader.parse(content, value_reader)) { |
| | | return "{\"ret_status\": \"传输错误,请检查!\"}"; |
| | | } |
| | | |
| | | Json::Value value; |
| | | 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流rtsp://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 end"); |
| | | |
| | | Json::Value value; |
| | | value["ret_status"] = "ok_ack"; |
| | | } |
| | | |
| | | |
| | | std::string out = value.toStyledString(); |
| | | |
| | |
| | | #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> |
| | | |
| | |
| | | |
| | | 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; |
| | | } |
| | |
| | | #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> |
| | | |
| | |
| | | //根据timeStamp创建路径 |
| | | std::string MakeDir(const std::string &timeStamp); |
| | | |
| | | void startPublishVideo(); |
| | | |
| | | void stopPublishVideo(); |
| | | |
| | | private: |
| | | int reopenTime{10}; |
| | | int m_gpuIdx; |
| | |
| | | |
| | | //用来保存录像视频的路径 |
| | | std::string m_cutPath; |
| | | std::atomic<bool> m_publishVideoRet{false}; |
| | | ffmpeg::VideoPublishElement * videoPublishElement; |
| | | private: |
| | | /*** |
| | | * 启动实时流接收数据线程 |
| | |
| | | } |
| | | } 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 { |
| | |
| | | #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) : |
| | |
| | | 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(); |
| | | } |
| | |
| | | m_capture->SetMinMaxVideoSeconds(minSeconds, maxSeconds); |
| | | } |
| | | |
| | | void RtspCaptureElement::startPublishVideo() { |
| | | m_publishVideoRet = true; |
| | | } |
| | | |
| | | void RtspCaptureElement::stopPublishVideo() { |
| | | m_publishVideoRet = false; |
| | | } |
| | | |
| | |
| | | #include <opencv2/opencv.hpp> |
| | | #include "../StructureApp/HiredisTool.h" |
| | | #include <atomic> |
| | | #include <basic/pipe_element/ffmpeg/FfmpegElement.h> |
| | | |
| | | class RtspAnalysManager; |
| | | |
| | |
| | | |
| | | //设置保存视频的最小和最大长度,单位是秒,实际的运行情况有一些差距,需要完善 |
| | | void SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds); |
| | | |
| | | void startPublishVideo(); |
| | | |
| | | void stopPublishVideo(); |
| | | |
| | | private: |
| | | //线程执行函数 |
| | |
| | | //保存视频流的路径,类似于rtsp://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; |
| | | |
| | |
| | | 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); |
| | |
| | | void PushStreamAppPipeController::SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds) { |
| | | videoCaptureElement.SetVideoMinMaxSeconds(minSeconds, maxSeconds); |
| | | } |
| | | |
| | | void PushStreamAppPipeController::startPublishVideo() { |
| | | videoCaptureElement.startPublishVideo(); |
| | | } |
| | | |
| | | void PushStreamAppPipeController::stopPublishVideo() { |
| | | |
| | | videoCaptureElement.stopPublishVideo(); |
| | | } |
| | |
| | | //设置保存视频的最小和最大长度,单位是秒,实际的运行情况有一些差距,需要完善 |
| | | void SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds); |
| | | |
| | | void startPublishVideo(); |
| | | |
| | | void stopPublishVideo(); |
| | | |
| | | private: |
| | | BASICGB28181::VideoCaptureElementWithRtp videoCaptureElement; |
| | | ffmpeg::VideoPublishElement* videoPublishElement; |