[rtmpdump] r47 - rtmp.cpp rtmp.h

hyc subversion at mplayerhq.hu
Thu Nov 12 12:45:40 CET 2009


Author: hyc
Date: Thu Nov 12 12:45:40 2009
New Revision: 47

Log:
Fixed pause/resume synch

Modified:
   rtmp.cpp
   rtmp.h

Modified: rtmp.cpp
==============================================================================
--- rtmp.cpp	Wed Nov 11 11:24:55 2009	(r46)
+++ rtmp.cpp	Thu Nov 12 12:45:40 2009	(r47)
@@ -426,10 +426,12 @@ int CRTMP::GetNextMediaPacket(RTMPPacket
 
     if (!bHasMediaPacket) { 
       packet.FreePacket();
-    }
-    if (m_bPausing == 3) {
-      if (packet.m_nTimeStamp <= m_pauseStamp) {
-	bHasMediaPacket = false;
+    } else if (m_bPausing == 3) {
+      if (packet.m_nTimeStamp <= m_mediaStamp) {
+	bHasMediaPacket = 0;
+#ifdef _DEBUG
+	Log(LOGDEBUG, "Skipped type: %02X, size: %d, TS: %d ms, abs TS: %d, pause: %d ms", packet.m_packetType, packet.m_nBodySize, packet.m_nTimeStamp, packet.m_hasAbsTimestamp, m_mediaStamp);
+#endif
 	continue;
       }
       m_bPausing = 0;
@@ -438,11 +440,6 @@ int CRTMP::GetNextMediaPacket(RTMPPacket
         
   if (bHasMediaPacket)
     m_bPlaying = true;
-/*
-  else if (m_bTimedout) {
-    m_pauseStamp = m_channelTimestamp[m_mediaChannel];
-    m_bPausing = 3;
-  } */
 
   return bHasMediaPacket;
 }
@@ -483,6 +480,8 @@ int CRTMP::HandlePacket(RTMPPacket &pack
         bHasMediaPacket = 1;
 	if (!m_mediaChannel)
 	  m_mediaChannel = packet.m_nChannel;
+	if (!m_bPausing)
+	  m_mediaStamp = packet.m_nTimeStamp;
         break;
 
       case 0x09:
@@ -492,6 +491,8 @@ int CRTMP::HandlePacket(RTMPPacket &pack
         bHasMediaPacket = 1;
 	if (!m_mediaChannel)
 	  m_mediaChannel = packet.m_nChannel;
+	if (!m_bPausing)
+	  m_mediaStamp = packet.m_nTimeStamp;
         break;
 
       case 0x0F: // flex stream send
@@ -545,6 +546,7 @@ int CRTMP::HandlePacket(RTMPPacket &pack
       {
 	// go through FLV packets and handle metadata packets
         unsigned int pos=0;
+	uint32_t nTimeStamp = packet.m_nTimeStamp;
 
         while(pos+11 < packet.m_nBodySize) {
 		uint32_t dataSize = CRTMP::ReadInt24(packet.m_body+pos+1); // size without header (11) and prevTagSize (4)
@@ -555,10 +557,15 @@ int CRTMP::HandlePacket(RTMPPacket &pack
                 }
 		if(packet.m_body[pos] == 0x12) {
 			HandleMetadata(packet.m_body+pos+11, dataSize);
+		} else if (packet.m_body[pos] == 8 || packet.m_body[pos] == 9) {
+			nTimeStamp = CRTMP::ReadInt24(packet.m_body+pos+4);
+			nTimeStamp |= (packet.m_body[pos+7]<<24);
 		}
                 pos += (11+dataSize+4);
 	}
-	
+	if (!m_bPausing)
+	  m_mediaStamp = nTimeStamp;
+
         // FLV tag(s)
         //Log(LOGDEBUG, "%s, received: FLV tag(s) %lu bytes", __FUNCTION__, packet.m_nBodySize);
         bHasMediaPacket = 1;

Modified: rtmp.h
==============================================================================
--- rtmp.h	Wed Nov 11 11:24:55 2009	(r46)
+++ rtmp.h	Thu Nov 12 12:45:40 2009	(r47)
@@ -213,16 +213,17 @@ class CRTMP
       int  m_nBWCheckCounter;
       int  m_nBytesIn;
       int  m_nBytesInSent;
-      bool m_bPlaying;
       int  m_nBufferMS;
       int  m_stream_id; // returned in _result from invoking createStream
       int  m_mediaChannel;
+      uint32_t  m_mediaStamp;
       uint32_t  m_pauseStamp;
-      bool m_bTimedout;
       int m_bPausing;
+      int m_nServerBW;
       int m_nClientBW;
       uint8_t m_nClientBW2;
-      int m_nServerBW;
+      bool m_bPlaying;
+      bool m_bTimedout;
 
       //std::string m_strPlayer;
       //std::string m_strPageUrl;


More information about the rtmpdump mailing list