[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-cvs
Subject:    [Datatype-cvs] mpeg2ts/stream tsstreamff.cpp,1.10.2.3,1.10.2.4
From:       packard () helixcommunity ! org
Date:       2012-08-09 12:18:39
[Download RAW message or body]

Update of /cvsroot/datatype/mpeg2ts/stream
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv12204

Modified Files:
      Tag: SERVER_15_0
	tsstreamff.cpp 
Log Message:
Synopsis:
=========
fix for Bug 270511:For MPEG2-TS ingress, stop the encoder then re-start again, Play \
this stream has error

Branch: SERVER_15_0_RN, HEAD

Suggested Reviewers:  Xiaocheng Li, Richard, Anyone

Description:
============
<Version>
Verified pass on version: Helix Universal Media Server (RealNetworks) (15.0.0.48) \
Build  (233380/18190) 

<Step>
1. Setup a mptslive source
2. In MPEG2-TS live stream, set the time out = 30
    <Var StreamTimeout="30"/> 
3. Use FFMPEG stream a mpts live to server
4. Use the RealPlayer to check this stream, it's OK
5. Stop the FFMPEG, then re-start it with 10 seconds
6. Use the RealPlayer to check this stream again

<Result>
1. In step6, in RealPlayer, only has sound but no video.

Solution
============
Timeout setting is not supposed to be used in this test case.
As encoder disconnect then re-connect, it is taken as a new live feed, whose \
timestamp is reset. But unfortunately, server listens on UDP port which is \
connectless. When server receives new live feed packet whose timestamp is reset, it \
is confused and could only send audio packet.

The solution is not make server takes the re-connect live feed as the same as the old \
one. It just disconnect from the live feed and release those related classes if it \
detect a reconnection.

File Affected
============
datatype/mpeg2ts/stream/tsstreamff.cpp
datatype/mpeg2ts/stream/pub/tsstreamff.h

Testing Performed:
================
1. send a live feed to server
2. play it with RN player
3. disconnect and reconnect within the timeout value
4. play it again. (After a while, player start to play)
5. loop step 3-4, it is OK.
 

Index: tsstreamff.cpp
===================================================================
RCS file: /cvsroot/datatype/mpeg2ts/stream/tsstreamff.cpp,v
retrieving revision 1.10.2.3
retrieving revision 1.10.2.4
diff -u -d -r1.10.2.3 -r1.10.2.4
--- tsstreamff.cpp	6 Aug 2012 23:10:34 -0000	1.10.2.3
+++ tsstreamff.cpp	9 Aug 2012 12:17:42 -0000	1.10.2.4
@@ -88,6 +88,7 @@
 #endif
 
 #define DEFAULT_TS_CALLBACK_INTERVAL 1000
+#define TS_RECONNECT_INTERVAL 10000
 
 const char* const CTSStreamFF::zm_szDescription      = "Helix MPEG Transport Stream \
Plugin";  const char* const CTSStreamFF::zm_pCopyright        = HXVER_COPYRIGHT;
@@ -1352,6 +1353,18 @@
                     if (m_pStreamInfo[i].m_pNextPacket)
                     {
                         ulDTS = m_pStreamInfo[i].m_pNextPacket->GetTime();
+                        if( m_pStreamInfo[i].m_uPreviousUsedTs > \
TS_RECONNECT_INTERVAL && +                            ulDTS < \
m_pStreamInfo[i].m_uPreviousUsedTs - TS_RECONNECT_INTERVAL && +                       \
m_pStreamInfo[i].m_uPreviousUsedTs < MAX_UINT32 - TS_RECONNECT_INTERVAL) +            \
{ +                            //m_pStreamInfo[i].m_uPreviousUsedTs > \
TS_RECONNECT_INTERVAL means we can't detect the case at the beginning of a live feed \
+                            //ulDTS < m_pStreamInfo[i].m_uPreviousUsedTs - \
TS_RECONNECT_INTERVAL means we need to deal disorder packets +                        \
//m_pStreamInfo[i].m_uPreviousUsedTs < MAX_UINT32 - TS_RECONNECT_INTERVAL means we \
need to deal roll over +     
+                            ActiveStop();
+                            return HXR_OK;
+                            
+                        }
                         if (uNextStream == HX_INVALID_STREAM || 
                             IsEarlier(ulDTS, ulNextDTS))
                         {
@@ -1369,6 +1382,7 @@
                 if (bReady)
                 {
                     m_usNextPacketStream = uNextStream;
+                    m_pStreamInfo[uNextStream].m_uPreviousUsedTs = \
m_pStreamInfo[uNextStream].m_pNextPacket->GetTime();  SendPendingPackets();
                 }
 
@@ -1755,7 +1769,10 @@
             break;
         }
     }
-
+    if( HX_INVALID_STREAM != usNextStream)
+    {
+        m_pStreamInfo[usNextStream].m_uPreviousUsedTs = \
m_pStreamInfo[usNextStream].m_pNextPacket->GetTime(); +    }
     return usNextStream;
 }
 
@@ -1824,7 +1841,6 @@
     UINT16 usStreamNo = 0;
     UINT32 ulDTS = 0;
     UINT32 ulNextDTS = MAX_UINT32;
-
     for (UINT16 i=0; i<(UINT16)m_ulStreamCount; i++)
     {
         if (!m_pStreamInfo[i].m_pNextPacket)
@@ -1883,7 +1899,6 @@
             m_pFFResponse->StreamDone(usStreamNo);
         }
     }
-
 #ifdef HELIX_FEATURE_SERVER
     TSDPRINTF(B_ENTRY,
         ("%p: CTSStreamFF::SendPacketsEOS() - Exit\n", this));
@@ -1927,6 +1942,8 @@
     }
 }
 
+// There is another way to close the CTSStreamFF.
+// Using ActiveStop
 void
 CTSStreamFF::HandleTimeout(HXBOOL bStreamInfo)
 {
@@ -2090,3 +2107,41 @@
         m_pSocket = NULL;
     }
 }
+
+// here we don't use HandleTimeout to close CTSStreamFF
+// As we don't need to call the SendPacketsEOS.
+// We just call StreamDone directly and remove callback
+void 
+CTSStreamFF::ActiveStop()
+{
+    if (m_ulTimeOutCB && m_pScheduler)
+    {
+        m_pScheduler->Remove(m_ulTimeOutCB);
+        m_ulTimeOutCB = 0;
+    }
+    
+    for (UINT16 i=0; i<(UINT16)m_ulStreamCount; i++)
+    {
+        if (!m_pStreamInfo[i].m_bStreamDone)
+        {
+            // This stream is done now.
+            m_pStreamInfo[i].m_bStreamDone = TRUE;
+            m_pStreamInfo[i].m_bPacketRequested = FALSE;
+            m_pFFResponse->StreamDone(i);
+        }
+    }
+
+
+    if (m_pMCastSocket)
+    {
+        m_pMCastSocket->LeaveGroup(m_pAddress, m_pLocalAddr);
+        m_pMCastSocket->Release();
+        m_pMCastSocket = NULL;
+    }
+    if (m_pSocket)
+    {
+        m_pSocket->Close();
+        m_pSocket->Release();
+        m_pSocket = NULL;
+    }
+}
\ No newline at end of file


_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic