]> granicus.if.org Git - rtmpdump/commitdiff
Discard old frames when doing pause/resume
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Tue, 10 Nov 2009 10:10:41 +0000 (10:10 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Tue, 10 Nov 2009 10:10:41 +0000 (10:10 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump@39 400ebc74-4327-4243-bc38-086b20814532

rtmp.cpp
rtmp.h

index 03efc813a99b1db4878c9673c66d3156321a5520..1342d7d6ac782941c1851ab98da00390a3213f69 100644 (file)
--- a/rtmp.cpp
+++ b/rtmp.cpp
@@ -420,6 +420,13 @@ int CRTMP::GetNextMediaPacket(RTMPPacket &packet)
     if (!bHasMediaPacket) { 
       packet.FreePacket();
     }
+    if (m_bPausing == 3) {
+      if (packet.m_nTimeStamp <= m_pauseStamp) {
+       bHasMediaPacket = false;
+       continue;
+      }
+      m_bPausing = 0;
+    }
   }
         
   if (bHasMediaPacket)
@@ -1309,7 +1316,6 @@ void CRTMP::HandleCtrl(const RTMPPacket &packet)
     case 0:
       tmp = ReadInt32(packet.m_body + 2);
       Log(LOGDEBUG, "%s, Stream Begin %d", __FUNCTION__, tmp);
-      m_bPausing = 0;
       break;
 
     case 1:
@@ -1339,10 +1345,11 @@ void CRTMP::HandleCtrl(const RTMPPacket &packet)
       tmp = ReadInt32(packet.m_body + 2);
       Log(LOGDEBUG, "%s, Stream BufferEmpty %d", __FUNCTION__, tmp);
       if (!m_bPausing) {
-        SendPause(true, m_channelTimestamp[m_mediaChannel]);
+       m_pauseStamp = m_channelTimestamp[m_mediaChannel];
+        SendPause(true, m_pauseStamp);
         m_bPausing = 1;
       } else if (m_bPausing == 2) {
-        SendPause(false, m_channelTimestamp[m_mediaChannel]);
+        SendPause(false, m_pauseStamp);
         m_bPausing = 3;
       }
       break;
diff --git a/rtmp.h b/rtmp.h
index 7c874ab9e2c43693674ce0f05ba9f70025aba22b..99dc50b72725cddcd62ec9ccbc2d373d39afafb1 100644 (file)
--- a/rtmp.h
+++ b/rtmp.h
@@ -217,6 +217,7 @@ class CRTMP
       int  m_nBufferMS;
       int  m_stream_id; // returned in _result from invoking createStream
       int  m_mediaChannel;
+      uint32_t  m_pauseStamp;
       bool m_bTimedout;
       int m_bPausing;
       int m_nClientBW;