pansen
2019-03-09 d6496edbb01f7b24c01615b111595a08d0fb8487
修复代码被覆盖的问题
5个文件已修改
102 ■■■■■ 已修改文件
QiaoJiaSystem/DataManagerServer/http_configserver.cpp 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.h 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -1934,6 +1934,7 @@
                ret = erlangDbTool->createDatabase(Uuid, fieldValues);
            } else if (SyncType == 0) {
                TableName.insert(0, "lt_");
                fieldValues.insert(std::make_pair("tableName", TableName));
                //本地库
                ret = m_SqliteFaceEncap.createTable(TableName, fieldValues);
            }
@@ -2408,26 +2409,27 @@
        std::string BwType = value["BwType"].asString();
        std::string StartTime = value["StartTime"].asString();
        std::string EndTime = value["EndTime"].asString();
        //#更新底库管理表
        FieldValues fieldValues;
        fieldValues.insert(std::make_pair("uuid", Uuid));
        fieldValues.insert(std::make_pair("tableName", TableName));
//            fieldValues.insert(std::make_pair("tableDesc", "ceshi2"));
        fieldValues.insert(std::make_pair("tableType", TableType));
        fieldValues.insert(std::make_pair("bwType", BwType));
        fieldValues.insert(std::make_pair("startTime", StartTime));
        fieldValues.insert(std::make_pair("endTime", EndTime));
//            fieldValues.insert(std::make_pair("create_by", "who"));
        bool ret = false;
        if (SyncType == 1) {
            //同步库
            ret = erlangDbTool->updateDatabase(Uuid, TableType, TableName, SyncType, BwType, StartTime, EndTime);
            ret = erlangDbTool->updateDatabase("sys_o_tables", fieldValues);
        } else if (SyncType == 0) {
            //本地库
            //#更新底库管理表
            FieldValues fieldValues;
            fieldValues.insert(std::make_pair("uuid", Uuid));
            if (TableName.find("lt_") != 0) {
                TableName.insert(0, "lt_");
            }
            fieldValues.insert(std::make_pair("tableName", TableName));
//            fieldValues.insert(std::make_pair("tableDesc", "ceshi2"));
            fieldValues.insert(std::make_pair("tableType", TableType));
            fieldValues.insert(std::make_pair("bwType", BwType));
            fieldValues.insert(std::make_pair("startTime", StartTime));
            fieldValues.insert(std::make_pair("endTime", EndTime));
//            fieldValues.insert(std::make_pair("create_by", "who"));
            ret = m_SqliteFaceEncap.updateTable("sys_o_tables", fieldValues);
        }
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -144,39 +144,41 @@
void BASICGB28181::FFmpegDecoderJPG::BareFlowDecoderThd(FFmpegDecoderJPG *p_this) {
    DBG(p_this->m_camIdx << "  BareFlowDecoderThd ok ... gpuIdx is " << p_this->m_gpuIdx);
    p_this->m_running = true;
    av_register_all();
    avformat_network_init();
    AVFormatContext *ic = avformat_alloc_context();
//    av_register_all();
//    avformat_network_init();
    p_this->ic = avformat_alloc_context();
    unsigned char *iobuffer = (unsigned char *) av_malloc(p_this->m_buf_size);
    AVIOContext *avio = avio_alloc_context(iobuffer, p_this->m_buf_size, 0, p_this, p_this->read_data, NULL, NULL);
    ic->pb = avio;
    p_this->iobuffer = (unsigned char *) av_malloc(p_this->m_buf_size);
    p_this->avio = avio_alloc_context(p_this->iobuffer, p_this->m_buf_size, 0, p_this, p_this->read_data, NULL, NULL);
    p_this->ic->pb = p_this->avio;
    int err = av_probe_input_buffer(ic->pb, &ic->iformat, nullptr, nullptr, 0, p_this->m_buf_size);
    int err1 = avformat_open_input(&ic, "", NULL, NULL);
    int err2 = avformat_find_stream_info(ic, nullptr);
    int err = av_probe_input_buffer(p_this->ic->pb, &p_this->ic->iformat, nullptr, nullptr, 0, p_this->m_buf_size);
    int err1 = avformat_open_input(&p_this->ic, "", NULL, NULL);
//    int err2 = avformat_find_stream_info(ic, nullptr);
    int err2 = avformat_find_stream_info(p_this->ic, NULL);
    int vi = -1;
    for (int i = 0; i < ic->nb_streams; ++i) {
        if (ic->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
    for (int i = 0; i < p_this->ic->nb_streams; ++i) {
        if (p_this->ic->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
            vi = i;
            break;
        }
    }
    AVStream *stream = ic->streams[vi];
    p_this->video_st = stream;
    AVCodecContext *ctx = avcodec_alloc_context3(nullptr);
    int err3 = avcodec_parameters_to_context(ctx, stream->codecpar);
    p_this->stream = p_this->ic->streams[vi];
    p_this->video_st = p_this->stream;
    p_this->ctx = avcodec_alloc_context3(nullptr);
    int err3 = avcodec_parameters_to_context(p_this->ctx, p_this->stream->codecpar);
    AVCodec *codec = avcodec_find_decoder(ctx->codec_id);
    p_this->codec = avcodec_find_decoder(p_this->ctx->codec_id);
    //是否启用GPU
    if (p_this->m_gpuIdx >= 0) {
        if (codec != NULL) {
        if (p_this->codec != NULL) {
            char cuvidName[40] = {0};
            sprintf(cuvidName, "%s_cuvid", codec->name);
            if (!strcmp(codec->name, "h264") || !strcmp(codec->name, "h265") || !strcmp(codec->name, "hevc")) {
                AVCodec *codec_cuvid = avcodec_find_decoder_by_name(cuvidName);
                if (codec_cuvid != NULL) {
                    codec = codec_cuvid;
            sprintf(cuvidName, "%s_cuvid", p_this->codec->name);
            if (!strcmp(p_this->codec->name, "h264") || !strcmp(p_this->codec->name, "h265") ||
                !strcmp(p_this->codec->name, "hevc")) {
                p_this->codec_cuvid = avcodec_find_decoder_by_name(cuvidName);
                if (p_this->codec_cuvid != NULL) {
                    p_this->codec = p_this->codec_cuvid;
                } else {
//                    return false;
                    ERR("codec_cuvid is NULL");
@@ -184,12 +186,11 @@
            }
        }
    }
    int err4 = avcodec_open2(ctx, codec, nullptr);
    int err4 = avcodec_open2(p_this->ctx, p_this->codec, nullptr);
    AVPacket pkt;
    av_init_packet(&pkt);
    av_init_packet(&p_this->pkt);
    AVFrame *frame = av_frame_alloc();
    p_this->frame = av_frame_alloc();
    unsigned int usleepTime = (1000 / p_this->m_fps) - 12;
    usleepTime *= 1000;
    DBG(" before while <<usleepTime is " << usleepTime);
@@ -197,13 +198,13 @@
#ifdef TestCode
        ClockTimer Test("while time");
#endif
        int err5 = av_read_frame(ic, &pkt);
        int err5 = av_read_frame(p_this->ic, &p_this->pkt);
        //# todo save package
        p_this->frame_number++;
        int err6 = avcodec_send_packet(ctx, &pkt);
        int err6 = avcodec_send_packet(p_this->ctx, &p_this->pkt);
//        av_packet_unref(&pkt);
        int err7 = avcodec_receive_frame(ctx, frame);
        int err7 = avcodec_receive_frame(p_this->ctx, p_this->frame);
        if ((err7 == AVERROR(EAGAIN)) || (err5 < 0) || (err6 < 0)) {
            ERR(" error << err7:" << err7 << "  err5: " << err5 << " err6: " << err6);
            usleep(40000);
@@ -211,11 +212,11 @@
        }
        //DBG("GotPicture "<<m_camId<<":"<<frame_number);
        //放在此处是因为之前放在前面,收到的帧不完成
        p_this->SaveToPacketVector(pkt);
        p_this->SaveToPacketVector(p_this->pkt);
        p_this->CheckSave();
//        BASICGB28181::avframe_to_cvmat(frame).copyTo(p_this->m_image);
        p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(frame));
        p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(p_this->frame));
#ifdef TestCode
        {
@@ -271,7 +272,7 @@
    }
    DBG(" after while ");
    av_frame_free(&frame);
    av_frame_free(&p_this->frame);
}
bool BASICGB28181::FFmpegDecoderJPG::startThd(const std::string &camIdx, const int &fps, const int &gpuIdx) {
QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.h
@@ -166,7 +166,18 @@
        //对收到的帧进行计数
        int64_t m_frameIndex = 0;
//*******************************************
        AVFormatContext *ic;
        unsigned char *iobuffer;
        AVIOContext *avio;
        AVStream *stream;
        AVCodecContext *ctx;
        AVCodec *codec;
        AVCodec *codec_cuvid;
        AVPacket pkt;
        AVFrame *frame;
        //*******************************************
        //将帧保存到帧数组
        void SaveToPacketVector(AVPacket &packet);
QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp
@@ -332,6 +332,7 @@
    rec.setValue("password", channelRec.str_password);
    rec.setValue("brand", channelRec.str_brand);
    rec.setValue("reserved", channelRec.str_reserved);
    rec.setValue("type", channelRec.type);
    pModel.insertRecord(-1, rec);//TODO
QiaoJiaSystem/VideoToImageMulth/RtspAnalysManager.cpp
@@ -58,6 +58,7 @@
//                                                 item.str_password.toStdString(), item.str_brand.toStdString());
                INFO("cam add is " << item.str_addr.toStdString());
                addCamera(t_camIdex, rtsp_url);
                sleep(1);
            }
        } else {
            ERR("searchCamDevTableAll size is 0");