| | |
| | | private:
|
| | | /** 本地国标配置构造函数 */
|
| | | VssLocalSettingTblController() {}
|
| | |
|
| | | public:
|
| | | /** 本地国标配置单例模式 */
|
| | | static VssLocalSettingTblController* instance() {
|
| | | static VssLocalSettingTblController instance;
|
| | | return &instance;
|
| | | }
|
| | |
|
| | | public:
|
| | | /** 注册{label}http服务 */
|
| | | void registerHttpServices(HttpSrvRetRecieve& _HttpSrvRetRecieve) {
|
| | |
| | | std::placeholders::_3, std::placeholders::_4));
|
| | |
|
| | | }
|
| | |
|
| | | public:
|
| | | /** 添加本地国标配置 */
|
| | | std::string addVssLocalSettingTbl(std::string ip, unsigned int port, std::string content, PResponse &response) {
|
| | | DBG("ip:" << ip << "; port:" << port);
|
| | | DBG("content: " << content);
|
| | | Json::Reader requestJsonReader;
|
| | | Json::Value requestJsonValue;
|
| | | Json::Value responseJsonValue;
|
| | |
| | |
|
| | | /** 删除本地国标配置 */
|
| | | std::string delVssLocalSettingTbl(std::string ip, unsigned int port, std::string content, PResponse &response) {
|
| | | DBG("ip:" << ip << "; port:" << port);
|
| | | DBG("content: " << content);
|
| | | Json::Reader requestJsonReader;
|
| | | Json::Value requestJsonValue;
|
| | | Json::Value responseJsonValue;
|
| | |
| | |
|
| | | /** 更新本地国标配置 */
|
| | | std::string updateVssLocalSettingTbl(std::string ip, unsigned int port, std::string content, PResponse &response) {
|
| | | DBG("ip:" << ip << "; port:" << port);
|
| | | DBG("content: " << content);
|
| | | Json::Reader requestJsonReader;
|
| | | Json::Value requestJsonValue;
|
| | | Json::Value responseJsonValue;
|
| | |
| | | }
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | string iDValue = iDJsonValue.asString();
|
| | | responseJsonValue = VssLocalSettingTblSqliteDao::instance()->updateVssLocalSettingTbl(vssLocalSettingTblBuilder.buildVssLocalSettingTblMap(), "ID", iDValue);
|
| | | responseJsonValue = VssLocalSettingTblSqliteDao::instance()->updateVssLocalSettingTbl(
|
| | | vssLocalSettingTblBuilder.buildVssLocalSettingTblMap(), "ID", iDValue);
|
| | | }
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | |
| | |
|
| | | /** 查找单个本地国标配置 */
|
| | | std::string findVssLocalSettingTbl(std::string ip, unsigned int port, std::string content, PResponse &response) {
|
| | | DBG("ip:" << ip << "; port:" << port);
|
| | | DBG("content: " << content);
|
| | | Json::Reader requestJsonReader;
|
| | | Json::Value requestJsonValue;
|
| | | Json::Value responseJsonValue;
|
| | |
| | | }
|
| | | responseJsonValue["message"] = "查询成功!";
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue = VssLocalSettingTblSqliteDao::instance()->findVssLocalSettingTblList(vssLocalSettingTblBuilder.buildVssLocalSettingTblMap());
|
| | | responseJsonValue = VssLocalSettingTblSqliteDao::instance()->findVssLocalSettingTblList(
|
| | | vssLocalSettingTblBuilder.buildVssLocalSettingTblMap());
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | |
|
| | | /** 查找本地国标配置列表 */
|
| | | std::string findVssLocalSettingTblList(std::string ip, unsigned int port, std::string content, PResponse &response) {
|
| | | std::string
|
| | | findVssLocalSettingTblList(std::string ip, unsigned int port, std::string content, PResponse &response) {
|
| | | DBG("ip:" << ip << "; port:" << port);
|
| | | DBG("content: " << content);
|
| | | Json::Reader requestJsonReader;
|
| | | Json::Value requestJsonValue;
|
| | | Json::Value responseJsonValue;
|
| | |
| | | }
|
| | | responseJsonValue["message"] = "查询成功!";
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue = VssLocalSettingTblSqliteDao::instance()->findVssLocalSettingTblList(vssLocalSettingTblBuilder.buildVssLocalSettingTblMap());
|
| | | responseJsonValue = VssLocalSettingTblSqliteDao::instance()->findVssLocalSettingTblList(
|
| | | vssLocalSettingTblBuilder.buildVssLocalSettingTblMap());
|
| | |
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | | };
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | #endif //VSSLOCALSETTINGTBL_CONTROLLER_H
|
| | |
| | | using namespace std; |
| | | |
| | | static mysqlpp::Connection* conn; |
| | | |
| | | class BaseDao { |
| | | public: |
| | | static mysqlpp::SimpleResult add(std::map<std::string, std::string>& columns, string tableName) { |
| | |
| | | } |
| | | return simpleResult; |
| | | } |
| | | |
| | | static bool del(string tableName, std::map<std::string, std::string>& whereColumns) { |
| | | initConnection(); |
| | | string sql = "DELETE FROM " + tableName + " where 1=1 " + getWhereColumnNameValuePair(whereColumns); |
| | |
| | | } |
| | | return ret; |
| | | } |
| | | static bool update(std::map<std::string, std::string>& columns, string tableName, std::map<std::string, std::string>& whereColumns) { |
| | | |
| | | static bool update(std::map<std::string, std::string> &columns, string tableName, |
| | | std::map<std::string, std::string> &whereColumns) { |
| | | string updateSql = getUpdateSql(columns, tableName, whereColumns); |
| | | initConnection(); |
| | | mysqlpp::Query query = conn->query(updateSql); |
| | |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | | static string getInsertSql(std::map<std::string, std::string>& columns, string tableName) { |
| | | string insertSql = "INSERT INTO "+tableName+" (" |
| | | + getColumnNames(columns) + |
| | |
| | | cout << "insertSql " << insertSql << endl; |
| | | return insertSql; |
| | | } |
| | | static string getUpdateSql(std::map<std::string, std::string>& columns, string tableName, std::map<std::string, std::string>& whereColumns) { |
| | | |
| | | static string getUpdateSql(std::map<std::string, std::string> &columns, string tableName, |
| | | std::map<std::string, std::string> &whereColumns) { |
| | | string updateSql = "update "+tableName+" set " |
| | | + getColumnNameValuePair(columns) + |
| | | " where 1=1 "+ |
| | | getWhereColumnNameValuePair(whereColumns) |
| | | ; |
| | | getWhereColumnNameValuePair(whereColumns); |
| | | cout << "updateSql " << updateSql << endl; |
| | | return updateSql; |
| | | } |
| | | |
| | | static void doConnect() { |
| | | // if (conn->connect( |
| | | // appConfig.getStringProperty("database").c_str(), |
| | | // appConfig.getStringProperty("db_host").c_str(), |
| | | // appConfig.getStringProperty("db_user").c_str(), |
| | | // appConfig.getStringProperty("db_password").c_str(), |
| | | // appConfig.getIntProperty("db_port") |
| | | // )) { |
| | | if (conn->connect( |
| | | "EGEyesForVSS", |
| | | "127.0.0.1", |
| | | "root", |
| | | "123456", |
| | | 3306 |
| | | appConfig.getStringProperty("database").c_str(), |
| | | appConfig.getStringProperty("db_host").c_str(), |
| | | appConfig.getStringProperty("db_user").c_str(), |
| | | appConfig.getStringProperty("db_password").c_str(), |
| | | appConfig.getIntProperty("db_port") |
| | | )) { |
| | | // if (conn->connect( |
| | | // "EGEyesForVSS", |
| | | // "192.168.1.148", |
| | | // "root", |
| | | // "123456", |
| | | // 3306 |
| | | // )) { |
| | | cout << "connect success" << endl; |
| | | } else { |
| | | cout << "connect failed" << endl; |
| | | } |
| | | } |
| | | |
| | | static void initConnection() { |
| | | static bool inited = false; |
| | | if (!inited) { |
| | |
| | | doConnect(); |
| | | } |
| | | } |
| | | |
| | | static string getColumnNames(std::map<std::string, std::string>& columns) { |
| | | string columnNames; |
| | | auto size = columns.size(); |
| | |
| | | } |
| | | return columnNames; |
| | | } |
| | | |
| | | static string getColumnValues(std::map<std::string, std::string>& columns) { |
| | | string columnValues; |
| | | auto size = columns.size(); |
| | |
| | | } |
| | | return columnValues; |
| | | } |
| | | |
| | | static string getColumnNameValuePair(std::map<std::string, std::string>& columns) { |
| | | string columnNameValuePair; |
| | | auto size = columns.size(); |
| | |
| | | } |
| | | return columnNameValuePair; |
| | | } |
| | | |
| | | static string getWhereColumnNameValuePair(std::map<std::string, std::string>& columns) { |
| | | string columnNameValuePair; |
| | | auto size = columns.size(); |
| | |
| | | } |
| | | |
| | | BASICGB28181::FFmpegDecoderJPG::~FFmpegDecoderJPG() { |
| | | |
| | | while (m_rtpQueue.count_queue()) { |
| | | m_rtpQueue.popNotWait(); |
| | | } |
| | |
| | | info->buffLen = datalen; |
| | | info->camIdx = camIdx; |
| | | memcpy(info->buff, data, datalen); |
| | | { |
| | | // FILE *fp11 = NULL; |
| | | // if (!fp11) { |
| | | // fp11 = fopen(camIdx.c_str(), "a+"); |
| | | // } |
| | | // fwrite(data, sizeof(char), datalen, fp11); |
| | | // fclose(fp11); |
| | | } |
| | | |
| | | #ifdef TestCode |
| | | DBG(" m_rtpQueue.push before "); |
| | | #endif |
| | | m_rtpQueue.push(info); |
| | | m_rtpQueue. |
| | | push(info); |
| | | #ifdef TestCode |
| | | DBG(" m_rtpQueue.push after "); |
| | | #endif |
| | |
| | | p_this->frame_number++; |
| | | |
| | | int err6 = avcodec_send_packet(ctx, &pkt); |
| | | av_packet_unref(&pkt); |
| | | // av_packet_unref(&pkt); |
| | | int err7 = avcodec_receive_frame(ctx, frame); |
| | | if ((err7 == AVERROR(EAGAIN)) || (err5 < 0) || (err6 < 0)) { |
| | | ERR(" error << err7:" << err7 << " err5: " << err5 << " err6: " << err6); |
| | |
| | | m_frameIndex++; |
| | | m_packetsVec.push_back({m_frameIndex, newPacket}); |
| | | if (newPacket.flags & AV_PKT_FLAG_KEY) { |
| | | DBG("newPacket.flags & AV_PKT_FLAG_KEY "); |
| | | m_last_I_FrameId = m_frameIndex; |
| | | } |
| | | } |
| | |
| | | */ |
| | | m_pOutVideo_stream = avformat_new_stream(m_pOutFmtCtx, NULL); |
| | | { |
| | | // AVCodecContext *c; |
| | | // c = m_pOutVideo_stream->codec; |
| | | // c->bit_rate = 400000; |
| | | // c->codec_id = video_st->codec->codec_id; |
| | | // c->codec_type = video_st->codec->codec_type; |
| | | // c->time_base.num = video_st->time_base.num; |
| | | // c->time_base.den = video_st->time_base.den; |
| | | // fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den); |
| | | // c->width = video_st->codec->width; |
| | | // c->height = video_st->codec->height; |
| | | // c->pix_fmt = video_st->codec->pix_fmt; |
| | | // printf("%d %d %d", c->width, c->height, c->pix_fmt); |
| | | // c->flags = video_st->codec->flags; |
| | | // c->flags |= CODEC_FLAG_GLOBAL_HEADER; |
| | | // c->me_range = video_st->codec->me_range; |
| | | // c->max_qdiff = video_st->codec->max_qdiff; |
| | | // |
| | | // c->qmin = video_st->codec->qmin; |
| | | // c->qmax = video_st->codec->qmax; |
| | | // |
| | | // c->qcompress = video_st->codec->qcompress; |
| | | AVCodecContext *c; |
| | | c = m_pOutVideo_stream->codec; |
| | | c->bit_rate = 400000; |
| | | c->codec_id = video_st->codec->codec_id; |
| | | c->codec_type = video_st->codec->codec_type; |
| | | c->time_base.num = video_st->time_base.num; |
| | | c->time_base.den = video_st->time_base.den; |
| | | fprintf(stderr, "time_base.num = %d time_base.den = %d\n", c->time_base.num, c->time_base.den); |
| | | c->width = video_st->codec->width; |
| | | c->height = video_st->codec->height; |
| | | c->pix_fmt = video_st->codec->pix_fmt; |
| | | printf("%d %d %d", c->width, c->height, c->pix_fmt); |
| | | c->flags = video_st->codec->flags; |
| | | c->flags |= CODEC_FLAG_GLOBAL_HEADER; |
| | | c->me_range = video_st->codec->me_range; |
| | | c->max_qdiff = video_st->codec->max_qdiff; |
| | | |
| | | c->qmin = video_st->codec->qmin; |
| | | c->qmax = video_st->codec->qmax; |
| | | |
| | | c->qcompress = video_st->codec->qcompress; |
| | | } |
| | | ret = avio_open(&m_pOutFmtCtx->pb, filename, AVIO_FLAG_WRITE); |
| | | if (ret < 0) { |
| | |
| | | return -1; |
| | | } |
| | | |
| | | avformat_write_header(m_pOutFmtCtx, NULL); |
| | | DBG(" avformat_write_header " << avformat_write_header(m_pOutFmtCtx, NULL)); |
| | | |
| | | m_bstartWrite = true; |
| | | m_bFirstKeyFrame = true; |
| | |
| | | int arg1 = atoi(argv[1]); |
| | | |
| | | int gindx = abs(arg1) % 2; |
| | | int GB28181_Enable = arg1 < 0 ? gindx : -1; |
| | | int GB28181_Enable = arg1 < 0 ? 1 : -1; |
| | | DBG(gindx); |
| | | appPref.setIntData("GB28181_Enable", GB28181_Enable); |
| | | |
| | |
| | | ) |
| | | |
| | | add_executable(${PROJECT_NAME} |
| | | |
| | | ./pushStream/PushStreamAppPipeController.cpp |
| | | ../GB28181DecoderModel/FFmpegDecoderJPG.cpp |
| | | ../GB28181DecoderModel/GB28181Server.cpp |
| | | ../GB28181DecoderModel/VideoCaptureElementWithRtp.cpp |
| | | ../../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoChangeScore.cpp |
| | | # ../../../BasicPlatForm/basic/pipe_element/ffmpeg/VideoChangeScore.cpp |
| | | ../../../BasicPlatForm/basic/util/BASE64/Base64.cpp |
| | | # ../../../BasicPlatForm/basic/pipe_element/ffmpeg/FfmpegElement.cpp |
| | | ../VideoServer/QiaoJia/DB/LDBTool.cpp |
| | |
| | | m_imgRedisCRwLock.unlock(); |
| | | |
| | | //VideoCaptureElementWithRtp(std::string &chanPubID, int fps, int streamTransType, int gpuIdx = -1) |
| | | m_controllers_videoCapElem[index] = new BASICGB28181::VideoCaptureElementWithRtp( |
| | | const_cast<string &>(index), |
| | | // m_controllers_videoCapElem[index] = new BASICGB28181::VideoCaptureElementWithRtp( |
| | | // const_cast<string &>(index), |
| | | // 25, 0, 0, this); |
| | | |
| | | m_controllers_videoCapElem[index] = new PushStreamAppPipeController(const_cast<string &>(index), |
| | | 25, 0, 0, this); |
| | | m_controllers_videoCapElem[index]->SetVideoMinMaxSeconds(lst_dev.n_cut_min_duration, |
| | | lst_dev.n_cut_max_duration); |
| | |
| | | auto pCaptureElem = m_controllers_videoCapElem.find(nameSt.m_camId); |
| | | if (pCaptureElem != m_controllers_videoCapElem.end()) { |
| | | //#todo ~~~~~~!!!!!!! 这里有bug 需要放开调试 |
| | | // pCaptureElem->second->SaveVideo(name); |
| | | pCaptureElem->second->SaveVideo(name); |
| | | } else { |
| | | ERR("Can not Find CamId " << nameSt.m_camId); |
| | | } |
| | |
| | | #include <map> |
| | | #include "RtspCaptureElement.h" |
| | | #include "RtspImageRedis.h" |
| | | #include "../GB28181DecoderModel/VideoCaptureElementWithRtp.h" |
| | | //#include "../GB28181DecoderModel/VideoCaptureElementWithRtp.h" |
| | | #include "pushStream/PushStreamAppPipeController.h" |
| | | //#include <VideoCaptureElementWithRtp.h> |
| | | #include <QiaoJia/DB/LDBTool.h> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | |
| | | std::map<std::string, RtspCaptureElement *> m_controllers; |
| | | |
| | | //保存CamID和VideoCaptureElementWithRtp的映射关系 |
| | | std::map<std::string, BASICGB28181::VideoCaptureElementWithRtp *> m_controllers_videoCapElem; |
| | | // std::map<std::string, BASICGB28181::VideoCaptureElementWithRtp *> m_controllers_videoCapElem; |
| | | std::map<std::string, PushStreamAppPipeController *> m_controllers_videoCapElem; |
| | | |
| | | //保存CamID和RtspImageRedisElement的映射关系 |
| | | std::map<std::string, RtspImageRedisElement *> m_imgRedisControllers; |
| | |
| | | #include <basic/debug/Debug.h> |
| | | #include <opencv2/opencv.hpp> |
| | | #include <basic/timer_counter/Clocktimer.h> |
| | | #include <basic/pipe_element/ffmpeg/cap_ffmpeg_impl.hpp> |
| | | #include <thread> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <QString> |
| | | #include <QDateTime> |
| | | #include "RtspAnalysManager.h" |
| | | //#include <basic/pipe_element/ffmpeg/cap_ffmpeg_impl.hpp> |
| | | #include "../../../BasicPlatForm/basic/pipe_element/ffmpeg/FfmpegElement.cpp" |
| | | |
| | | RtspCaptureElement::RtspCaptureElement(const std::string &path, const std::string &camId, int fps, int reopenTime, |
| | | int gpuIndex, RtspAnalysManager *manager) : |
| | |
| | | if (argc < 4) { |
| | | assert("t_value.size()"); |
| | | } |
| | | |
| | | { |
| | | // std::string rtmpAddr = appConfig.getStringProperty("srsAddr"); |
| | | // std::string publish_basepath = rtmpAddr + "" ; |
| | | // appPref.setStringData("publish.basepath", publish_basepath); |
| | | appPref.setIntData("pulish.width", 640); |
| | | appPref.setIntData("pulish.height", 360); |
| | | } |
| | | int arg1 = atoi(argv[1]); |
| | | |
| | | int gindx = abs(arg1) % 2; |
| | | int GB28181_Enable = arg1 < 0 ? gindx : -1; |
| | | int GB28181_Enable = arg1 < 0 ? 1 : 0; |
| | | |
| | | DBG(gindx); |
| | | appPref.setIntData("GB28181_Enable", GB28181_Enable); |
New file |
| | |
| | | #include "PushStreamAppPipeController.h" |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <basic/util/app/AppUtil.h> |
| | | //#include <sstream> |
| | | #include <algorithm> |
| | | #include <basic/util/app/AppConfig.h> |
| | | |
| | | PushStreamAppPipeController::PushStreamAppPipeController(std::string &chanPubID, int fps, |
| | | int streamTransType, |
| | | int gpuIdx, RtspAnalysManager *manager) : |
| | | videoCaptureElement(chanPubID, fps, streamTransType, gpuIdx, manager), |
| | | index(chanPubID), |
| | | videoPublishElement(nullptr) { |
| | | |
| | | string path = appConfig.getStringProperty("srsAddr") + "cam" + chanPubID + ".flv"; |
| | | cv::Size size_(appPref.getIntData("pulish.width"), appPref.getIntData("pulish.height")); |
| | | int gupIdx = appPref.getLongData("gpu.index"); |
| | | videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx); |
| | | if (appPref.getIntData("pulish.width") < 0 || appPref.getIntData("pulish.height") < 0) { |
| | | ERR("pulish.width: " << appPref.getIntData("pulish.width") << " Height: " |
| | | << appPref.getIntData("pulish.height")); |
| | | } |
| | | videoCaptureElement.registerConnector([&] { |
| | | //if(!videoPublishElement.isBusy()){ |
| | | videoPublishElement->setImage(videoCaptureElement.getImage()); |
| | | //videoPublishElement.submit(); |
| | | //} |
| | | }); |
| | | |
| | | registerElement(videoCaptureElement); |
| | | registerElement(*videoPublishElement); |
| | | |
| | | // videoCaptureElement.setOutPutInterval(3); |
| | | } |
| | | |
| | | std::string PushStreamAppPipeController::getRtmp() { |
| | | std::string ret = videoPublishElement->getPath(); |
| | | size_t pos = ret.find(".flv"); |
| | | ret = ret.substr(0, pos); |
| | | INFO(ret); |
| | | return ret; |
| | | } |
| | | |
| | | void PushStreamAppPipeController::SaveVideo(const std::string &strImageName) { |
| | | videoCaptureElement.SaveVideo(strImageName); |
| | | } |
| | | |
| | | void PushStreamAppPipeController::SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds) { |
| | | videoCaptureElement.SetVideoMinMaxSeconds(minSeconds, maxSeconds); |
| | | } |
New file |
| | |
| | | #ifndef PUSHSTREAMAPPPIPECONTROLLER_H |
| | | #define PUSHSTREAMAPPPIPECONTROLLER_H |
| | | |
| | | #include <basic/pipe/PipeController.h> |
| | | #include <basic/pipe_element/ffmpeg/FfmpegElement.h> |
| | | #include <jsoncpp/json/json.h> |
| | | #include "../GB28181DecoderModel/VideoCaptureElementWithRtp.h" |
| | | |
| | | class PushStreamAppPipeController : public PipeController { |
| | | public: |
| | | PushStreamAppPipeController(std::string &chanPubID, int fps, |
| | | int streamTransType, |
| | | int gpuIdx, RtspAnalysManager *manager); |
| | | |
| | | std::string getRtmp(); |
| | | |
| | | |
| | | void SaveVideo(const std::string &strImageName); |
| | | |
| | | //设置保存视频的最小和最大长度,单位是秒,实际的运行情况有一些差距,需要完善 |
| | | void SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds); |
| | | |
| | | private: |
| | | BASICGB28181::VideoCaptureElementWithRtp videoCaptureElement; |
| | | ffmpeg::VideoPublishElement* videoPublishElement; |
| | | std::string index; |
| | | }; |
| | | |
| | | #endif // PUSHSTREAMAPPPIPECONTROLLER_H |