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

List:       helix-server-cvs
Subject:    [Server-cvs] engine/inputsource ppmstaticshim.cpp,1.8,1.9
From:       dsingh () helixcommunity ! org
Date:       2007-09-27 10:43:06
Message-ID: 200709271043.l8RAhHZH004594 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/server/engine/inputsource
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv9489

Modified Files:
	ppmstaticshim.cpp 
Log Message:
Synopsis
========

Addition of RealMedia stream switching capability under FCS. 
Branches: HEAD
Suggested Reviewer: Jamie Gordon, JJ Zeng , Anyone.


Description
===========
Currently server is having capability of switching RealAudio only clips. With this \
feature addition, server can switch clips which have either realVideo only stream or \
RealAudio and RealVideo streams. The ppmstaticshim.cpp file has major changes because \
the current implementation has only single stream handling, which will now be changed \
to any number of streams in the clip.

This CR also addressing one issue related to call stack problem which causes ceasing \
of getpacket packetready sequence. In current implementation when  switch occurs the \
function call sequence for switching the packet source is like this: the function \
CPPMStaticShim::PacketReady() calls CPPMStaticShim::SwitchSource() calls \
ClientSession::SwitchDone(). The function ClientSession::SwitchDone() cleans up the \
older packet source and file format objects. This cleanup done by \
ClientSession::SwitchDone is potentially creating problem because we are in context \
of GetPacket/PacketReady of all those objects which are cleaned up by \
ClientSession::SwitchDone(). So to eliminate this problem I moved the call to \
CPPMStaticShim::SwitchSource()
> From  CPPMStaticShim::PacketReady()   To   CPPMStaticShim::GetPacket().

Some points to note here are:
[] The code is functionally completed but the switch is taking too long to occur \
which needs to be tuned up. After the switch, audio of new clip starts from the \
beginning but some starting video frames are not displayed. [] Also I am not sure \
about the behavior of the server in case of client subscribe to a new stream or \
un-subscribe a stream while playback. This     implementation is considering only \
those streams for which setup is done. And GetPacket for only those streams will be \
called in case of queued switch.        [] In the current implementation I observed \
that when we play the clip using fcs URL the clip doesnt played to the end, it stops \
some 3-4 seconds before. But stops successfully no problem observed on player and \
server. This problem persists in this code addition also but, in case of queued \
switch the old clip played to the end(no truncation) and then new clip starts.


Files Affected
==============
server/engine/session/clientsession.cpp
server/engine/session/pub/clientsession.h
server/engine/inputsource/ppmstaticshim.cpp
server/engine/inputsource/pub/ppmstaticshim.h
server-restricted/datatype/switch/switchverifier.cpp

Testing Performed
=================

Unit Tests:
- None

Integration Tests:
- Tested switching of realmedia clips(realvideo10.rm and locally generated using HMP) \
as:  a) Using FCS URL, clip played to the end without switch any switch request.
 b) Successfull immediate switching to new matching clip, and new clip played to the \
end(truncated but not due to my changes).  c) Successfull switching to new queued \
clip and new clip played to the end.

Leak Tests:
- No extra leaks observed.

Performance Tests:
- None

Platforms Tested: win32-i386-vc7 
Build verified: win32-i386-vc7, linux-rhel4-i686.

QA Hints
===============
-None




Index: ppmstaticshim.cpp
===================================================================
RCS file: /cvsroot/server/engine/inputsource/ppmstaticshim.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ppmstaticshim.cpp	26 Sep 2007 21:19:37 -0000	1.8
+++ ppmstaticshim.cpp	27 Sep 2007 10:43:03 -0000	1.9
@@ -36,6 +36,7 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "hxcom.h"
+#include "clientsession.h"
 #include "ppmstaticshim.h"
 #include "proc.h"
 
@@ -59,7 +60,8 @@
 #include "ratedescmgr.h"
 
 
-CPPMStaticShim::CPPMStaticShim(IHXPSourcePackets* pSourcePackets, IHXSwitchResponse* \
pResp, IHXCommonClassFactory* pCCF) \
+CPPMStaticShim::CPPMStaticShim(IHXPSourcePackets* pSourcePackets, IHXSwitchResponse* \
pResp, IHXCommonClassFactory* pCCF, +        ClientSession::StreamInfo** ppStrmInfo, \
UINT16 num_streams, HXBOOL bIsRTP)  :m_ulRefCount(0)
      ,m_pPacketSource(pSourcePackets)
      ,m_pPacketSink(NULL)
@@ -74,6 +76,9 @@
      ,m_bSwitch(FALSE)
      ,m_uNewclip(0)
      ,m_ulLastGetPacketStream((UINT16)-1)
+    ,m_bSwitchSource(FALSE)
+    ,m_uNumOfStreams(num_streams)
+    ,m_bIsRTP(bIsRTP)
 {
      if(m_pPacketSource)
      {
@@ -84,6 +89,14 @@
          m_pCCF = pCCF;
          m_pCCF->AddRef();
      }
+    m_pStreamInfo = new StreamData[num_streams];
+    HX_ASSERT(m_pStreamInfo);
+    memset(m_pStreamInfo , 0 , (sizeof(StreamData) * num_streams));
+    for(UINT16 i = 0; i < num_streams; i++)
+    {
+        m_pStreamInfo[i].bSetupReceived = ppStrmInfo[i]->m_bSetupReceived;
+    }
+
 }
 
 CPPMStaticShim::~CPPMStaticShim()
@@ -97,6 +110,7 @@
     HX_RELEASE(m_pPacketSink);
     HX_RELEASE(m_pSwitchPacketSource);
     HX_RELEASE(m_pCCF);
+    HX_VECTOR_DELETE(m_pStreamInfo);
 }
 
 
@@ -120,10 +134,19 @@
 STDMETHODIMP
 CPPMStaticShim::GetPacket(UINT16 unStreamNumber)
 {
+    HX_RESULT retVal = HXR_OK;
      if(m_pPacketSource)
      {
-         m_ulLastGetPacketStream = unStreamNumber;
-         return m_pPacketSource->GetPacket(unStreamNumber);
+
+         retVal = m_pPacketSource->GetPacket(unStreamNumber);
+
+        if(m_bSwitchSource)
+        {
+            SwitchSource();
+            m_bSwitchSource = FALSE;
+        }
+
+        return retVal;
      }
      else
      {
@@ -148,18 +171,24 @@
     {
 
         SwitchSource();
-        // if m_ulLastGetPacketStream is not -1, the last Getpacket had resulted in
-        // StreamDone, and we need to jump start the new source now.
-        if(m_ulLastGetPacketStream != (UINT16)-1)
+
+        /* jump start the new source now */
+        for(UINT16 i = 0; i < m_uNumOfStreams; i++)
         {
-            GetPacket(m_ulLastGetPacketStream);
+            if(m_pStreamInfo[i].bSetupReceived)
+            {
+                GetPacket(i);
+            }
         }
     }
 }
 void 
 CPPMStaticShim::SwitchSource()
 {
-    m_uNewclip = 1;
+    for(UINT16 i=0; i<m_uNumOfStreams;i++)
+    {
+        m_pStreamInfo[i].uNewclip = 1;
+    }
     HX_RELEASE(m_pPacketSource);
     m_pSwitchResponse->SwitchDone(HXR_OK);
     m_pPacketSource = m_pSwitchPacketSource;
@@ -170,73 +199,70 @@
 UINT32
 CPPMStaticShim::GetClipEndTime()
 {
-    return (m_ulLastPacketTS + m_uDiff);
+    /* Assuming 0th stream is the deciding stream for clip end time */
+    return (m_pStreamInfo[0].ulLastPacketTS + m_pStreamInfo[0].uDiff);
 }
 
-STDMETHODIMP
- CPPMStaticShim::PacketReady(HX_RESULT ulStatus, IHXPacket*pPacket)
- {
-     INT32 ulCurTS = 0;
-     INT32 ulRTPCurTS = 0;
-     IHXPacket* pNewPacket = NULL;
-     HX_RESULT ulRet = HXR_OK;
-     IHXRTPPacket* pRTPPacket = NULL;
-
-    m_ulLastGetPacketStream = (UINT16)-1;
-
-     pPacket->QueryInterface(IID_IHXRTPPacket,(void**)&pRTPPacket);
-     ulCurTS = pPacket->GetTime();
-     if(pRTPPacket)
-     {
-         ulRTPCurTS = pRTPPacket->GetRTPTime();
-     }
-     else
-     {
-         ulRTPCurTS = ulCurTS;
-     }
+    STDMETHODIMP
+CPPMStaticShim::PacketReady(HX_RESULT ulStatus, IHXPacket*pPacket)
+{
+    INT32 ulCurTS = 0;
+    INT32 ulRTPCurTS = 0;
+    IHXPacket* pNewPacket = NULL;
+    HX_RESULT ulRet = HXR_OK;
+    IHXRTPPacket* pRTPPacket = NULL;
+    UINT16 unStreamNumber = 0;
 
-     if(m_uNewclip == 1)
-     {
-         if(!(pPacket->GetASMFlags() & HX_ASM_SWITCH_ON))
-               return HXR_UNEXPECTED;
-         m_uDiff += m_ulLastPacketTS - ulCurTS + m_uPacketDiff;
-         m_uRTPDiff += m_ulRTPLastPacketTS - ulRTPCurTS + m_uRTPPacketDiff;
-         
-         m_uNewclip = 0;
-     }
-     else
-     {
+    pPacket->QueryInterface(IID_IHXRTPPacket,(void**)&pRTPPacket);
+    ulCurTS = pPacket->GetTime();
+    if(pRTPPacket)
+    {
+        ulRTPCurTS = pRTPPacket->GetRTPTime();
+    }
+    else
+    {
+        ulRTPCurTS = ulCurTS;
+    }
+    unStreamNumber = pPacket->GetStreamNumber();
+    if(m_pStreamInfo[unStreamNumber].uNewclip)
+    {
+        if(!(pPacket->GetASMFlags() & HX_ASM_SWITCH_ON))
+            return HXR_UNEXPECTED;
+        m_pStreamInfo[unStreamNumber].uDiff += 
+            (m_pStreamInfo[unStreamNumber].ulLastPacketTS - ulCurTS + \
m_pStreamInfo[unStreamNumber].uPacketDiff); +        \
m_pStreamInfo[unStreamNumber].uRTPDiff +=  +                \
(m_pStreamInfo[unStreamNumber].ulRTPLastPacketTS - ulRTPCurTS + \
m_pStreamInfo[unStreamNumber].uRTPPacketDiff); +        \
m_pStreamInfo[unStreamNumber].uNewclip = 0; +    }
+    else
+    {
         /* The first packet of the new clip should not have the same timestamp
            as the timestamp of the last packet of the old clip.So I store the 
            timestamp difference between 2 consecutive packets of the old clips
            so that the 1st packet of the new clip will differ by the same from
            the last packet of the old clip                    */
+         m_pStreamInfo[unStreamNumber].uPacketDiff = (ulCurTS - \
m_pStreamInfo[unStreamNumber].ulLastPacketTS); +         \
m_pStreamInfo[unStreamNumber].uRTPPacketDiff = (ulRTPCurTS - \
m_pStreamInfo[unStreamNumber].ulRTPLastPacketTS); +    }
+    m_bSwitchSource = (m_bSwitch == TRUE && (pPacket->GetASMFlags() & \
HX_ASM_SWITCH_OFF));  
-         m_uPacketDiff = ulCurTS - m_ulLastPacketTS;
-         m_uRTPPacketDiff = ulRTPCurTS - m_ulRTPLastPacketTS;
-     }
-     if(m_bSwitch == TRUE && (pPacket->GetASMFlags() & HX_ASM_SWITCH_OFF))
-     {
-         SwitchSource();
-     }
-      
-     if(m_pPacketSink)
-     {
-         m_ulLastPacketTS = ulCurTS;
-         m_ulRTPLastPacketTS = ulRTPCurTS;
-         
-         pNewPacket = CreateNewPacket(pPacket);
-         ulRet = m_pPacketSink->PacketReady(ulStatus, pNewPacket);
-         HX_RELEASE(pRTPPacket);
-         HX_RELEASE(pNewPacket);
-         return ulRet;
-     }
-     else
-     {
-         HX_ASSERT(!"missing m_pPacketSink");
-         return HXR_UNEXPECTED;
-     }
- }
+    if(m_pPacketSink)
+    {
+        m_pStreamInfo[unStreamNumber].ulLastPacketTS = ulCurTS;
+        m_pStreamInfo[unStreamNumber].ulRTPLastPacketTS = ulRTPCurTS;
+
+        pNewPacket = CreateNewPacket(pPacket);
+        ulRet = m_pPacketSink->PacketReady(ulStatus, pNewPacket);
+        HX_RELEASE(pRTPPacket);
+        HX_RELEASE(pNewPacket);
+        return ulRet;
+    }
+    else
+    {
+        HX_ASSERT(!"missing m_pPacketSink");
+        return HXR_UNEXPECTED;
+    }
+}
 
  IHXPacket*
  CPPMStaticShim::CreateNewPacket(IHXPacket* pPacket)
@@ -261,8 +287,9 @@
      {
          pRTPPacket->GetRTP(pBuffer, ulTime, ulRTPTime, unStreamNumber, unASMFlags, \
unASMRuleNumber);  }
-     ((IHXRTPPacket*)pNewPacket)->SetRTP(pBuffer, ulTime + m_uDiff, 
-                ulRTPTime + m_uRTPDiff, unStreamNumber, unASMFlags, \
unASMRuleNumber); +     ((IHXRTPPacket*)pNewPacket)->SetRTP(pBuffer, (ulTime + \
m_pStreamInfo[unStreamNumber].uDiff),  +                                        \
(ulRTPTime + m_pStreamInfo[unStreamNumber].uRTPDiff), +                               \
unStreamNumber, unASMFlags, unASMRuleNumber);  HX_RELEASE(pBuffer);
      HX_RELEASE(pRTPPacket);
      return pNewPacket;


_______________________________________________
Server-cvs mailing list
Server-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/server-cvs


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

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