[rtmpdump] r50 - rtmp.cpp rtmp.h rtmpdump.cpp

hyc subversion at mplayerhq.hu
Thu Nov 12 15:58:53 CET 2009


Author: hyc
Date: Thu Nov 12 15:58:52 2009
New Revision: 50

Log:
Use pause/unpause for FMS 3.0 as well

Modified:
   rtmp.cpp
   rtmp.h
   rtmpdump.cpp

Modified: rtmp.cpp
==============================================================================
--- rtmp.cpp	Thu Nov 12 14:01:40 2009	(r49)
+++ rtmp.cpp	Thu Nov 12 15:58:52 2009	(r50)
@@ -122,12 +122,6 @@ double CRTMP::GetDuration() { return m_f
 bool CRTMP::IsConnected() { return m_socket != 0; }
 bool CRTMP::IsTimedout() { return m_bTimedout; }
 
-void CRTMP::GetPauseStamps(uint32_t *pause, uint32_t *resume)
-{
-  *pause = m_pauseStamp;
-  *resume = m_mediaStamp;
-}
-
 void CRTMP::SetBufferMS(int size)
 {
   m_nBufferMS = size;
@@ -403,6 +397,20 @@ bool CRTMP::ReconnectStream(int bufferTi
   return ConnectStream(seekTime, dLength);
 }
 
+bool CRTMP::ToggleStream()
+{
+  bool res;
+
+  res = SendPause(true, m_pauseStamp);
+  if (!res) return res;
+
+  m_bPausing = 1;
+  sleep(1);
+  res = SendPause(false, m_pauseStamp);
+  m_bPausing = 3;
+  return res;
+}
+
 void CRTMP::DeleteStream() {
   if (m_stream_id < 0)
     return;
@@ -446,10 +454,8 @@ int CRTMP::GetNextMediaPacket(RTMPPacket
         
   if (bHasMediaPacket)
     m_bPlaying = true;
-  else if (m_bTimedout) {
+  else if (m_bTimedout)
     m_pauseStamp = m_channelTimestamp[m_mediaChannel];
-    m_bPausing = 3;
-  }
 
   return bHasMediaPacket;
 }

Modified: rtmp.h
==============================================================================
--- rtmp.h	Thu Nov 12 14:01:40 2009	(r49)
+++ rtmp.h	Thu Nov 12 15:58:52 2009	(r50)
@@ -141,7 +141,7 @@ class CRTMP
       bool IsConnected(); 
       bool IsTimedout(); 
       double GetDuration();
-      void GetPauseStamps(uint32_t *pause, uint32_t *resume);
+      bool ToggleStream();
 
       bool ConnectStream(double seekTime=-10.0, uint32_t dLength=0);
       bool ReconnectStream(int bufferTime, double seekTime=-10.0, uint32_t dLength=0);

Modified: rtmpdump.cpp
==============================================================================
--- rtmpdump.cpp	Thu Nov 12 14:01:40 2009	(r49)
+++ rtmpdump.cpp	Thu Nov 12 15:58:52 2009	(r50)
@@ -1345,22 +1345,8 @@ int main(int argc, char **argv)
 			nInitialFrameSize = 0;
 			uint32_t lastOff;
 
-			Log(LOGINFO, "Connection timed out, trying to reconnect.\n\n");
-			rtmp->GetPauseStamps(&lastOff, &dSeek);
-
-			// Calculate the length of the stream to still play
-			if (dStopOffset > 0) {
-				dLength = dStopOffset - lastOff;
-
-				// Quit if start seek is past required stop offset
-				if(dLength <= 0) {
-					LogPrintf("Already Completed\n");
-					nStatus = RD_SUCCESS;
-					break;
-				}
-			}
-
-			if (!rtmp->ReconnectStream(bufferTime, lastOff, dLength)) {
+			Log(LOGINFO, "Connection timed out, trying to resume.\n\n");
+			if (!rtmp->ToggleStream()) {
 				Log(LOGERROR, "Failed to resume the stream\n\n");
 				if (!rtmp->IsTimedout())
 				  nStatus = RD_FAILED;


More information about the rtmpdump mailing list