From 0ad1516d29d13796ae2355d83b04cbc9a23cbc7d Mon Sep 17 00:00:00 2001
From: xuxiuxi <554325746@qq.com>
Date: 星期五, 15 三月 2019 09:49:32 +0800
Subject: [PATCH] Merge branch 'yw.1.2.fixbug' of http://192.168.1.226:10010/r/development/c++ into yw.1.2.fixbug

---
 /dev/null                                                        |    4 
 QiaoJiaSystem/FaceSearchServer/main.cpp                          |    5 
 QiaoJiaSystem/DataManagerServer/http_configserver.cpp            |    2 
 QiaoJiaSystem/FaceSearchServer/CMakeLists.txt                    |    1 
 QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp |    7 +
 QiaoJiaSystem/FaceSearchServer/AlarmServer.hpp                   |   23 +++
 QiaoJiaSystem/FaceSearchServer/FaceDBCompareServer.h             |    3 
 QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp           |  308 +++++++++++++++++++++++++++------------------------
 8 files changed, 198 insertions(+), 155 deletions(-)

diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
index b391e8d..5193036 100644
--- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
+++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -2449,7 +2449,7 @@
             if (TableName.find("lt_") != 0) {
                 TableName.insert(0, "lt_");
             }
-            fieldValues.insert(std::make_pair("tableName", TableName));
+            fieldValues["tableName"] = TableName;
 
             ret = m_SqliteFaceEncap.updateTable("sys_o_tables", fieldValues);
         }
diff --git a/QiaoJiaSystem/FaceSearchServer/AlarmServer.hpp b/QiaoJiaSystem/FaceSearchServer/AlarmServer.hpp
index 1fe1b9c..811f78a 100644
--- a/QiaoJiaSystem/FaceSearchServer/AlarmServer.hpp
+++ b/QiaoJiaSystem/FaceSearchServer/AlarmServer.hpp
@@ -1,4 +1,5 @@
 //
+// 瀵规瘮鎶ヨ鐨勫熀绫�
 // Created by ps on 2/26/18.
 //
 
@@ -13,6 +14,9 @@
 #include <basic/util/thread/MultiThread.h>
 #include <basic/util/BASE64/Base64.h>
 
+/***
+ * 闇�瑕佸姣旂殑涓�鏉¤褰�
+ */
 struct AlarmData {
     int num;
     std::string tableName;
@@ -20,6 +24,9 @@
     float threshold;
 };
 
+/***
+ * 鏁版嵁搴撲腑鏌ヨ鐨勪竴鏉¤褰�
+ */
 struct FeatureData {
     long face_id;
     std::string uuid;
@@ -29,6 +36,11 @@
     std::string idcard;
 };
 
+/***
+ * 瀛楃涓叉牴鎹鍙峰垎鍓插苟杩斿洖鏁版嵁
+ * @param str_list
+ * @return
+ */
 static std::vector<std::string> AlarmServerPropertyAnalyseByComma(std::string str_list) {
     std::vector<std::string> result;
     char *property_list = const_cast<char *>(str_list.c_str());
@@ -60,6 +72,9 @@
     CPU_Number = 1
 };
 
+/***
+ * 鎶ヨ鏈嶅姟鍩虹被
+ */
 class AlarmServer {
 
 public:
@@ -77,11 +92,19 @@
         dataRemoveBuffer.clear();
     }
 
+    /***
+     * 鍒濆鍖栨椂浣跨敤绾跨▼鍔犺浇鏁版嵁搴�
+     * @param str_config
+     */
     void initDB(std::string str_config) {
         std::thread thd(loadDBCahce, this, str_config);
         thd.detach();
     }
 
+    /***
+     * 绉婚櫎鏁版嵁
+     * @param key
+     */
     void removeData(std::string key) {
         std::lock_guard<std::mutex> guard(dataRemoveBufferMtx);
         dataRemoveBuffer.insert(key);
diff --git a/QiaoJiaSystem/FaceSearchServer/CMakeLists.txt b/QiaoJiaSystem/FaceSearchServer/CMakeLists.txt
index 26f313c..5860601 100644
--- a/QiaoJiaSystem/FaceSearchServer/CMakeLists.txt
+++ b/QiaoJiaSystem/FaceSearchServer/CMakeLists.txt
@@ -89,7 +89,6 @@
 add_executable(${PROJECT_NAME}
     main.cpp
     rpc/FaceSearchServer.cpp
-    FaceSearchServerResources.cpp
     FaceFeatureSearchServerI.cpp
     FaceFeatureSearchServerI.h
     CasiaFaceWrapper/CasiaFaceWrapperN.cpp
diff --git a/QiaoJiaSystem/FaceSearchServer/FaceDBCompareServer.h b/QiaoJiaSystem/FaceSearchServer/FaceDBCompareServer.h
index 7940970..da4bb96 100644
--- a/QiaoJiaSystem/FaceSearchServer/FaceDBCompareServer.h
+++ b/QiaoJiaSystem/FaceSearchServer/FaceDBCompareServer.h
@@ -54,11 +54,10 @@
 static bool getRet(std::string startTime, std::string endTime) {
     auto crrentTime = AppUtil::getTimeSecString();
 
-    if (crrentTime.compare(startTime) > 0 && crrentTime.compare(endTime) < 0) {
+    if (crrentTime.compare(startTime) > 0 && (crrentTime.compare(endTime) < 0 || endTime == "0000-00-00 00:00:00")) {
         return true;
     }
     return false;
-
 }
 
 #endif //COMPARETEST_FACEDBCOMPARESERVER_H
diff --git a/QiaoJiaSystem/FaceSearchServer/FaceSearchServerResources.cpp b/QiaoJiaSystem/FaceSearchServer/FaceSearchServerResources.cpp
deleted file mode 100644
index b82cdeb..0000000
--- a/QiaoJiaSystem/FaceSearchServer/FaceSearchServerResources.cpp
+++ /dev/null
@@ -1,4 +0,0 @@
-//
-// Created by pans on 4/27/18.
-//
-
diff --git a/QiaoJiaSystem/FaceSearchServer/main.cpp b/QiaoJiaSystem/FaceSearchServer/main.cpp
index fa14be5..08ca7be 100644
--- a/QiaoJiaSystem/FaceSearchServer/main.cpp
+++ b/QiaoJiaSystem/FaceSearchServer/main.cpp
@@ -1,4 +1,5 @@
 //
+// 浜鸿劯瀵规瘮涓昏繘绋嬪叆鍙�
 // Created by pans on 4/27/18.
 //
 #include <iostream>
@@ -14,7 +15,7 @@
 using namespace std;
 
 int main(int argc, char **argv) {
-    std::cout<<__DATE__<<" "<<__TIME__<<std::endl;
+    std::cout << __DATE__ << " " << __TIME__ << std::endl;
     SAVE_APP_ARGS;
     ENABLEGLOG(GET_STR_CONFIG("logPath").c_str());
     auto ich = Ice::initialize(argc, argv);
@@ -26,6 +27,8 @@
 
 //    appPref.setStringData("ipAdd", "192.168.1.185");
 //    appPref.setIntData("ipPort", 9200);
+
+    //璁剧疆es涓婁紶ip鍜岀鍙�
     appPref.setStringData("ipAdd", appConfig.getStringProperty("ES_IP"));
     appPref.setIntData("ipPort", appConfig.getIntProperty("ES_PORT"));
 
diff --git a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
index 2d5455d..9e8fd7e 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/FFmpegDecoderJPG.cpp
@@ -143,148 +143,186 @@
  */
 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;
+    while(!p_this->m_running) {
+
+        p_this->m_running = true;
 //    av_register_all();
 //    avformat_network_init();
-    p_this->ic = avformat_alloc_context();
+        p_this->ic = avformat_alloc_context();
 
-    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(p_this->ic->pb, &p_this->ic->iformat, nullptr, nullptr, 0, p_this->m_buf_size);
-    if(err){
-        ERR("av_probe_input_buffer" << err);
-    }
-    err = avformat_open_input(&p_this->ic, "", NULL, NULL);
-    if(err){
-        ERR("avformat_open_input" << err);
-    }
-//    int err2 = avformat_find_stream_info(ic, nullptr);
-    err = avformat_find_stream_info(p_this->ic, NULL);
-    if(err){
-        ERR("avformat_find_stream_info" << err);
-    }
-    int vi = -1;
-    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;
+        p_this->iobuffer = (unsigned char *) av_malloc(p_this->m_buf_size);
+        if (!p_this->iobuffer) {
+            ERR("av_malloc: err======" << p_this->m_camIdx);
+            p_this->m_running = false;
+            continue;
         }
-    }
-    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);
+        p_this->avio = avio_alloc_context(p_this->iobuffer, p_this->m_buf_size, 0, p_this, p_this->read_data, NULL,
+                                          NULL);
+        if (!p_this->avio) {
+            ERR("avio_alloc_context: err======" << p_this->m_camIdx);
+            p_this->m_running = false;
+            continue;
+        }
+        p_this->ic->pb = p_this->avio;
 
-    p_this->codec = avcodec_find_decoder(p_this->ctx->codec_id);
-    //鏄惁鍚敤GPU
-    if (p_this->m_gpuIdx >= 0) {
-        if (p_this->codec != NULL) {
-            char cuvidName[40] = {0};
-            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 {
+        int err = av_probe_input_buffer(p_this->ic->pb, &p_this->ic->iformat, nullptr, nullptr, 0, p_this->m_buf_size);
+        if (err) {
+            ERR("av_probe_input_buffer: err======" << err  << p_this->m_camIdx);
+            p_this->m_running = false;
+            continue;
+        }
+        err = avformat_open_input(&p_this->ic, "", NULL, NULL);
+        if (err) {
+            ERR("avformat_open_input: err======" << err  << p_this->m_camIdx);
+            p_this->m_running = false;
+            continue;
+        }
+//    int err2 = avformat_find_stream_info(ic, nullptr);
+        err = avformat_find_stream_info(p_this->ic, NULL);
+        if (err) {
+            ERR("avformat_find_stream_info: err======" << err  << p_this->m_camIdx);
+//        avformat_close_input(&p_this->ic);
+//        DBG("avformat_close_input(&p_this->ic);");
+            p_this->m_running = false;
+            continue;
+        }
+        int vi = -1;
+        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;
+            }
+        }
+        p_this->stream = p_this->ic->streams[vi];
+        p_this->video_st = p_this->stream;
+        p_this->ctx = avcodec_alloc_context3(nullptr);
+        err = avcodec_parameters_to_context(p_this->ctx, p_this->stream->codecpar);
+        if (err) {
+            ERR("avcodec_parameters_to_context: err======" << err  << p_this->m_camIdx);
+//        avformat_close_input(&p_this->ic);
+//        DBG("avformat_close_input(&p_this->ic);");
+            p_this->m_running = false;
+            continue;
+        }
+
+        p_this->codec = avcodec_find_decoder(p_this->ctx->codec_id);
+        //鏄惁鍚敤GPU
+        if (p_this->m_gpuIdx >= 0) {
+            if (p_this->codec != NULL) {
+                char cuvidName[40] = {0};
+                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");
+                        ERR("codec_cuvid is NULL"  << p_this->m_camIdx);
+                    }
                 }
             }
         }
-    }
-    int err4 = avcodec_open2(p_this->ctx, p_this->codec, nullptr);
-
-    av_init_packet(&p_this->pkt);
-
-    p_this->frame = av_frame_alloc();
-    unsigned int usleepTime = (1000 / p_this->m_fps) - 12;
-    usleepTime *= 1000;
-    DBG(" before while <<usleepTime is " << usleepTime);
-    while (p_this->m_running) {
-#ifdef TestCode
-        ClockTimer Test("while time");
-#endif
-        av_packet_unref(&p_this->pkt);
-        p_this->pkt.data = NULL;
-        p_this->pkt.size = 0;
-
-        int err5 = av_read_frame(p_this->ic, &p_this->pkt);
-        //# todo save package
-        p_this->frame_number++;
-
-        int err6 = avcodec_send_packet(p_this->ctx, &p_this->pkt);
-        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);
+        err = avcodec_open2(p_this->ctx, p_this->codec, nullptr);
+        if (err) {
+            ERR("avcodec_open2: err======" << err  << p_this->m_camIdx);
+//        avformat_close_input(&p_this->ic);
+//        DBG("avformat_close_input(&p_this->ic);");
+//        avcodec_free_context(&p_this->ctx);
+//        DBG("avcodec_free_context(&p_this->ctx);");
+            p_this->m_running = false;
             continue;
         }
-        //DBG("GotPicture "<<m_camId<<":"<<frame_number);
-        //鏀惧湪姝ゅ鏄洜涓轰箣鍓嶆斁鍦ㄥ墠闈�,鏀跺埌鐨勫抚涓嶅畬鎴�
-        p_this->SaveToPacketVector(p_this->pkt);
-        p_this->CheckSave();
+
+        av_init_packet(&p_this->pkt);
+
+        p_this->frame = av_frame_alloc();
+        unsigned int usleepTime = (1000 / p_this->m_fps) - 12;
+        usleepTime *= 1000;
+        DBG("===open ok, camid: " << p_this->m_camIdx );
+        while (p_this->m_running) {
+#ifdef TestCode
+            ClockTimer Test("while time");
+#endif
+            av_packet_unref(&p_this->pkt);
+            p_this->pkt.data = NULL;
+            p_this->pkt.size = 0;
+
+            int err5 = av_read_frame(p_this->ic, &p_this->pkt);
+            //# todo save package
+            p_this->frame_number++;
+
+            int err6 = avcodec_send_packet(p_this->ctx, &p_this->pkt);
+            int err7 = avcodec_receive_frame(p_this->ctx, p_this->frame);
+            if ((err7 == AVERROR(EAGAIN)) || (err5 < 0) || (err6 < 0)) {
+                ERR("  err======: err7" << err7 << "  err5: " << err5 << " err6: " << err6  << p_this->m_camIdx);
+                usleep(40000);
+                continue;
+            }
+            //DBG("GotPicture "<<m_camId<<":"<<frame_number);
+            //鏀惧湪姝ゅ鏄洜涓轰箣鍓嶆斁鍦ㄥ墠闈�,鏀跺埌鐨勫抚涓嶅畬鎴�
+            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(p_this->frame));
+            p_this->m_image = std::move(BASICGB28181::avframe_to_cvmat(p_this->frame));
 
 #ifdef TestCode
-        {
-//            TestCode 娴嬭瘯浠g爜淇濆瓨鍥剧墖鍒版湰鍦�
-            ClockTimer cl("TestCode");
-            std::string strNewTime2 = AppUtil::getTimeUSecString();
-            cv::putText(p_this->m_image, strNewTime2, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN,
-                        5, cv::Scalar(255, 255, 0), 2);
-            std::thread test([&](cv::Mat img, std::string strThing) {
-                try {
-                    std::string strNewTime = "tmpDec/";
-                    strNewTime.append(p_this->m_camIdx + "_").append(strThing).append(".jpg");
-//                    cv::imwrite(strNewTime, p_this->m_image);
-                } catch (std::exception ex) {
-                    ERR(ex.what());
-                }
-            }, p_this->m_image, strNewTime2);
-            test.detach();
-        }
+            {
+    //            TestCode 娴嬭瘯浠g爜淇濆瓨鍥剧墖鍒版湰鍦�
+                ClockTimer cl("TestCode");
+                std::string strNewTime2 = AppUtil::getTimeUSecString();
+                cv::putText(p_this->m_image, strNewTime2, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN,
+                            5, cv::Scalar(255, 255, 0), 2);
+                std::thread test([&](cv::Mat img, std::string strThing) {
+                    try {
+                        std::string strNewTime = "tmpDec/";
+                        strNewTime.append(p_this->m_camIdx + "_").append(strThing).append(".jpg");
+    //                    cv::imwrite(strNewTime, p_this->m_image);
+                    } catch (std::exception ex) {
+                        ERR(ex.what());
+                    }
+                }, p_this->m_image, strNewTime2);
+                test.detach();
+            }
 #endif
 
-        //#todo send to other thd
+            //#todo send to other thd
 #ifdef TestCode
-        DBG("emitSigal(\"DecoderImageOK\") begin");
+            DBG("emitSigal(\"DecoderImageOK\") begin");
 #endif
-        //瑙﹀彂淇″彿
-        gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK");
+            //瑙﹀彂淇″彿
+            gSignalLock.emitSigal(p_this->m_camIdx + "DecoderImageOK");
 //#ifdef TestCode
 //        DBG("emitSigal(\"DecoderImageOK\") after");
 //#endif
 
-        DBG("emitSigal(\"DecoderImageOK\") after");
-        DBG("p_this->m_camIdx is " << p_this->m_camIdx << " queue size is " << p_this->m_rtpQueue.count_queue());
+            DBG("emitSigal(\"DecoderImageOK\") after");
+            DBG("p_this->m_camIdx is " << p_this->m_camIdx << " queue size is " << p_this->m_rtpQueue.count_queue());
 
 #ifdef TestCode
-        {
-            ClockTimer cl("waitTime");
-            int loop = 0;
-            //#TODO
-//            while ((loop++ < 3000) && !(p_this->m_readData)) {
-//                usleep(10);
-//            }
+            {
+                ClockTimer cl("waitTime");
+                int loop = 0;
+                //#TODO
+    //            while ((loop++ < 3000) && !(p_this->m_readData)) {
+    //                usleep(10);
+    //            }
 
-            usleep(30000);
-            DBG("p_this->m_readData is " << p_this->m_readData << "  loop is " << loop << " queue size is "
-                                         << p_this->m_rtpQueue.count_queue());
-            p_this->m_readData = false;
-//        usleep(12000);
-        }
+                usleep(30000);
+                DBG("p_this->m_readData is " << p_this->m_readData << "  loop is " << loop << " queue size is "
+                                             << p_this->m_rtpQueue.count_queue());
+                p_this->m_readData = false;
+    //        usleep(12000);
+            }
 #else
-        usleep(usleepTime);
+//            usleep(usleepTime);
 #endif
 
+        }
+        DBG(" after while ");
+        av_frame_free(&p_this->frame);
     }
-    DBG(" after while ");
-    av_frame_free(&p_this->frame);
 }
 
 bool BASICGB28181::FFmpegDecoderJPG::startThd(const std::string &camIdx, const int &fps, const int &gpuIdx) {
@@ -296,6 +334,7 @@
             setenv("CUDA_VISIBLE_DEVICES", std::to_string(gpuIdx).c_str(), 0);
         }
         m_camIdx = camIdx;
+        DBG("BareFlowDecoderThd camIdx : " << camIdx);
         std::thread t_BareFlowDecoder(BareFlowDecoderThd, this);
         t_BareFlowDecoder.detach();
     );
@@ -550,40 +589,19 @@
     if ((packet != nullptr) && (inVideoStream != nullptr)) {
         AVStream *inStream = (AVStream *) inVideoStream;
         AVPacket *pkg = static_cast<AVPacket *>(packet);
-//        static unsigned  long int frame_index = 0
-//            pkg->dts = ++frame_index;
-//            pkg->pts = frame_index;
 
-            //todo
-//        if(pkg->pts==AV_NOPTS_VALUE){
-            DBG("frame_index==%d\n" << frame_index);
-            //Write PTS
-            AVRational time_base1=inStream->time_base;
-            //Duration between 2 frames (us)
-            int64_t calc_duration=(double)AV_TIME_BASE/av_q2d(inStream->r_frame_rate);
-            //Parameters
-            pkg->pts=(double)(frame_index*calc_duration)/(double)(av_q2d(time_base1)*AV_TIME_BASE);
-            pkg->dts=pkg->pts;
-            pkg->duration=(double)calc_duration/(double)(av_q2d(time_base1)*AV_TIME_BASE);
-//            frame_index++;
-//        }
-//        else{
-//            DBG("pts" << pkg->pts << "firstKeyPts" << firstKeyPts);
-//            DBG("dts" << pkg->dts << "firstKeyDts" << firstKeyDts);
-//            pkg->pts -= firstKeyPts;
-//            pkg->dts -= firstKeyDts;
-//            pkg->pts = av_rescale_q_rnd(pkg->pts, inStream->time_base,
-//                                        m_pOutVideo_stream->time_base,
-//                                        (AVRounding) (AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
-//            pkg->dts = av_rescale_q_rnd(pkg->dts, inStream->time_base,
-//                                        m_pOutVideo_stream->time_base,
-//                                        (AVRounding) (AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX));
-//            pkg->duration = av_rescale_q(pkg->duration, inStream->time_base,
-//                                         m_pOutVideo_stream->time_base);
-//            pkg->pos = -1;
-//        }
 
-        DBG("pts:" << pkg->pts);
-        DBG("dts:" << pkg->dts);
+        DBG("frame_index==%d\n" << frame_index);
+        //Write PTS
+        AVRational time_base1=inStream->time_base;
+        //Duration between 2 frames (us)
+        int64_t calc_duration=(double)AV_TIME_BASE/av_q2d(inStream->r_frame_rate);
+        //Parameters
+        pkg->pts=(double)(frame_index*calc_duration)/(double)(av_q2d(time_base1)*AV_TIME_BASE);
+        pkg->dts=pkg->pts;
+        pkg->duration=(double)calc_duration/(double)(av_q2d(time_base1)*AV_TIME_BASE);
+
+//        DBG("pts:" << pkg->pts);
+//        DBG("dts:" << pkg->dts);
     }
 }
\ No newline at end of file
diff --git a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
index 3efd923..8a1d652 100644
--- a/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
+++ b/QiaoJiaSystem/GB28181DecoderModel/VideoCaptureElementWithRtp.cpp
@@ -101,7 +101,12 @@
                 p_this->m_running = true;
                 p_this->m_fFmpegDecoderJPG.startThd(p_this->m_chanPubID, p_this->m_fps, p_this->m_gpuIdx);
                 while (p_this->m_running) {
-                    usleep(300000);
+//                    if(p_this->m_fFmpegDecoderJPG.getRunning()) {
+                        usleep(300000);
+//                    }else{
+//                        p_this->m_running = false;
+//                        break;
+//                    }
                 }
                 DBG("videoCaptureElementThd stop ...");
                 C_RealVideoStop(lrealhandle);

--
Gitblit v1.8.0