Browse Source

change driver_rtsp_client.

yuchuli 2 years ago
parent
commit
764f782eae

+ 3 - 0
src/driver/driver_h264_rtspclient/driver_h264_rtspclient.pro

@@ -49,6 +49,9 @@ INCLUDEPATH += /usr/include/x86_64-linux-gnu
 RESOURCES += \
     rtspclient.qrc
 
+
+DEFINES += SHOWINFO
+
 #DEFINES += SAVECODEPAR
 
 #DEFINES += TESTLATENCY

+ 13 - 3
src/driver/driver_h264_rtspclient/ffmpeg_outputer.h

@@ -36,6 +36,7 @@ class FfmpegOutputer {
     }
 
     int output_initialize(){
+        std::cout<<"init. "<<std::endl;
         int ret = 0;
         if (!(m_ofmt_ctx->oformat->flags & AVFMT_NOFILE)) {
             ret = avio_open(&m_ofmt_ctx->pb, m_url.c_str(), AVIO_FLAG_WRITE);
@@ -64,6 +65,8 @@ class FfmpegOutputer {
         }
 
         m_output_state = SERVICE;
+        std::cout<<"init "<<m_url<<" ok.service."<<std::endl;
+        m_list_packets.clear();
         return 0;
     }
 
@@ -71,7 +74,7 @@ class FfmpegOutputer {
         int ret = 0;
         if(m_list_packets.size() == 0)
         {
-            std::this_thread::sleep_for(std::chrono::microseconds(100));
+            std::this_thread::sleep_for(std::chrono::microseconds(3000));
             return;
         }
         while(m_list_packets.size() > 0) {
@@ -85,8 +88,14 @@ class FfmpegOutputer {
                 m_output_state = DOWN;
                 break;
             }
+            else
+            {
+#ifdef SHOWINFO
+                int64_t now = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
+                std::cout<<now<<" "<<m_url<<" up a frame. "<<std::endl;
+#endif
+            }
         }
-
     }
 
     void output_down() {
@@ -204,7 +213,8 @@ public:
     int InputPacket(AVPacket *pkt) {
         if(m_list_packets.size()>90)
         {
-            std::cout<<" ignore packete. buffer full."<<std::endl;
+            int64_t now = std::chrono::system_clock::now().time_since_epoch().count()/1000000;
+            std::cout<<now<<" ignore packete. buffer full."<<std::endl;
             return -1;
         }
         AVPacket *pkt1 = av_packet_alloc();