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

List:       helix-server-cvs
Subject:    [Server-cvs] datatype/common/pktskim Umakefil, 1.4,
From:       jgordon () helixcommunity ! org
Date:       2009-03-31 19:05:10
Message-ID: 200903312007.n2VK72EI022175 () mailer ! progressive-comp ! com
[Download RAW message or body]

Update of /cvsroot/server/datatype/common/pktskim
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv25622

Modified Files:
      Tag: SERVER_12_1
	Umakefil h263skim.cpp h263skim.h h264skim.cpp h264skim.h 
	mp4skim.cpp mp4skim.h skimbase.cpp skimbase.h 
Log Message:
Synopsis
========
Numerous updates to handle legacy RTP live splitting.
I also reduced the default timeout from 25 secs to 10 secs.

Branches: SERVER_12_1, HEAD (SERVER_CURRENT)
Reviewer: jzeng


Description
===========
This diff involves lots of code being moved around. I have tried to
include diffs from the relevant original and also attaching the new
files where the diffs are confusing or impossible.

This is unfortunately not yet well tested, as I need to get it in
hopefully before I leave today. Also due the hasty nature, some of the
design may not be great. :)

qtbcplin:
packet and queue handling is split into reusable chunks, moved around
into more appropriate places.
* builds as a library as well as plugin.
* bitbucket is moved to server/common/struct (unmodified)
* a response interface (non-com) is added to RTPInfoSync to notify when
sync is complete
* QTStream is split apart into:
   - CLivePacketQueue (packet queue handling)
      server/common/util/livepacketqueue.cpp
   - RTPStream (general RTP/RTCP packet handling) - rtpstream.cpp
   - RTPLiveStream (subclass of RTPStream which handles the more specific
     stuff, like address resolution and receiver init, and timeout) -
     rtplivestream.cpp
   - moved packet skimmer creation from here to a static method in 
pktskim. (Also updated to use parsed RTPPacketBase.)
* PacketBufferManager is updated to use CLivePacketQueue, renamed
   SyncedQueueManager, and moved into server/common/util/pktqmgr.cpp
* Simple response interfaces (non-COM) created to for communication
   between queue, queue manager, and session handler (qtbcstreamsobj)
* handling of RTP vs RTCP moved to the receiver layer

common packet queue:
added the packet to the base CQueueEntry and got rid of the superfluous
subclass CInOrderPacketDeliveryQueue. Updated everything that uses the
subclass to just use CInorderPacketQueue.


Files Affected
==============
common/util/pub/tscalc.h
protocol/transport/rtp/rtpinfosync.cpp
protocol/transport/rtp/include/rtpinfosync.h
server/common/struct/Umakefil
server/common/struct/bitbucket.cpp [new]
server/common/struct/pub/bitbucket.h [new]
server/common/util/make_lib
server/common/util/packetreordershim.cpp
server/common/util/pub/pktreorderqueue.h
server/common/util/livepacketq.cpp [new]
server/common/util/pub/livepacketq.h [new]
server/common/util/pktqmgr.cpp [new]
server/common/util/pub/pktqmgr.h [new]
server/common/util/pub/packetreorderqueue.h [rem]
server/datatype/common/pktskim/Umakefil
server/datatype/common/pktskim/h263skim.cpp
server/datatype/common/pktskim/h263skim.h
server/datatype/common/pktskim/h264skim.cpp
server/datatype/common/pktskim/h264skim.h
server/datatype/common/pktskim/mp4skim.cpp
server/datatype/common/pktskim/mp4skim.h
server/datatype/common/pktskim/skimbase.cpp
server/datatype/common/pktskim/skimbase.h
server/engine/context/hxclfact.cpp
server/broadcast/transport/rtp/recv/libumakefil [new]
server/broadcast/transport/rtp/recv/dllumakefil [new]
server/broadcast/transport/rtp/recv/Umakefil
server/broadcast/transport/rtp/recv/qtbcobj.cpp
server/broadcast/transport/rtp/recv/qtbcobj.h
server/broadcast/transport/rtp/recv/qtbcplin.cpp
server/broadcast/transport/rtp/recv/qtbcplin.h
server/broadcast/transport/rtp/recv/qtreceiver.h [rem]
server/broadcast/transport/rtp/recv/qtreceiver.cpp [rem]
server/broadcast/transport/rtp/recv/pub/rtpreceiver.h [new]
server/broadcast/transport/rtp/recv/rtpreceiver.cpp [new]
server/broadcast/transport/rtp/recv/qtstream.h [rem]
server/broadcast/transport/rtp/recv/qtstream.cpp [rem]
server/broadcast/transport/rtp/recv/pub/rtpstream.h [new]
server/broadcast/transport/rtp/recv/rtpstream.cpp [new]
server/broadcast/transport/rtp/recv/pub/rtplivestream.h [new]
server/broadcast/transport/rtp/recv/rtplivestream.cpp [new]



Index: h264skim.cpp
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/h264skim.cpp,v
retrieving revision 1.5
retrieving revision 1.5.34.1
diff -u -d -r1.5 -r1.5.34.1
--- h264skim.cpp	15 Jul 2005 00:08:28 -0000	1.5
+++ h264skim.cpp	31 Mar 2009 19:05:08 -0000	1.5.34.1
@@ -39,6 +39,8 @@
 #include "hxengin.h"
 #include "hxassert.h"
 
+#include "rtppkt.h"
+
 #include "skimbase.h"
 #include "h264skim.h"
 
@@ -191,16 +193,14 @@
 }
 
 HX_RESULT
-H264PacketSkimmer::GetPacketInfo(IHXBuffer* pPacket, 
+H264PacketSkimmer::GetPacketInfo(RTPPacketBase* pPacket, 
                                  UINT32& ulPacketInfo)
 {
     HX_RESULT   hr = HXR_OK;
-    UINT32      uiPacketSize = 0;
     UINT32      uiPayloadSize = 0;
     BOOL        bKeyFrame = FALSE;
     BOOL        bValid = TRUE;
     BOOL        bAggregation = FALSE;
-    BYTE*       pRTPHdr  = NULL;
     BYTE*       pH264Payload = NULL;
     UINT8       uiZeroBit = 0;
     UINT8       uiNALUType = 0;
@@ -211,36 +211,14 @@
 
     ulPacketInfo = 0;
     
-    if (pPacket == NULL)
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-    uiPacketSize = pPacket->GetSize();
-
-    // Enforce minimum size: RTP hdr(12) + H264 hdr(1)
-    if (uiPacketSize < 13) 
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-
-    pRTPHdr = (BYTE*)pPacket->GetBuffer();
+    pH264Payload = (BYTE*)pPacket->data.data;
+    uiPayloadSize = pPacket->data.len;
 
-    if (pRTPHdr == NULL)
+    // Enforce minimum size: H264 hdr(1)
+    if (uiPayloadSize < 1) 
     {
         return HXR_INVALID_PARAMETER;
     }
-
-   
-    if (FAILED(hr = GetRTPPacketInfo(pRTPHdr, 
-                                     uiPacketSize,
-                                     ulPacketInfo,
-                                     pH264Payload)))
-    {
-        return hr;
-    }
-    
-    uiPayloadSize = uiPacketSize - (pH264Payload - pRTPHdr);
-    HX_ASSERT(uiPayloadSize >= 0 && uiPayloadSize <= uiPacketSize);
     
     uiZeroBit = (pH264Payload[0]  >> 7) & 1;
 

Index: h263skim.h
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/h263skim.h,v
retrieving revision 1.3
retrieving revision 1.3.34.1
diff -u -d -r1.3 -r1.3.34.1
--- h263skim.h	7 Jun 2005 03:06:37 -0000	1.3
+++ h263skim.h	31 Mar 2009 19:05:08 -0000	1.3.34.1
@@ -41,9 +41,8 @@
 
     H263PacketSkimmer();
 
-    virtual HX_RESULT GetPacketInfo(IHXBuffer* pPacket, 
+    virtual HX_RESULT GetPacketInfo(RTPPacketBase* pPacket, 
                                     UINT32& ulPacketInfo);
-
 private:
 
     void OutputPayloadInfo(UINT8 uiFrameType, 

Index: h264skim.h
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/h264skim.h,v
retrieving revision 1.3
retrieving revision 1.3.34.1
diff -u -d -r1.3 -r1.3.34.1
--- h264skim.h	7 Jun 2005 03:06:37 -0000	1.3
+++ h264skim.h	31 Mar 2009 19:05:08 -0000	1.3.34.1
@@ -43,7 +43,7 @@
 
     H264PacketSkimmer();
 
-    virtual HX_RESULT GetPacketInfo(IHXBuffer* pPacket, 
+    virtual HX_RESULT GetPacketInfo(RTPPacketBase* pPacket, 
                                     UINT32& ulPacketInfo);
 };
 #endif // _H264SKIM_H_

Index: skimbase.cpp
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/skimbase.cpp,v
retrieving revision 1.6.20.1
retrieving revision 1.6.20.1.6.1
diff -u -d -r1.6.20.1 -r1.6.20.1.6.1
--- skimbase.cpp	28 Nov 2007 11:04:18 -0000	1.6.20.1
+++ skimbase.cpp	31 Mar 2009 19:05:08 -0000	1.6.20.1.6.1
@@ -48,6 +48,40 @@
 
 #include "skimbase.h"
 
+#include "h263skim.h"
+#include "h264skim.h"
+#include "mp4skim.h"
+
+PacketSkimmer*
+PacketSkimmer::CreatePacketSkimmer(IHXBuffer* pMimeType)
+{
+    const char* szMimeType = (const char*)pMimeType->GetBuffer();
+
+    if (strncasecmp(szMimeType, "video/", 6))
+    {
+        return NULL;
+    }
+
+    PacketSkimmer* pPktSkimmer = NULL;
+    szMimeType += 6;
+    if (!strcasecmp(szMimeType, "H263-2000"))
+    {
+        pPktSkimmer = new H263PacketSkimmer;
+        pPktSkimmer->AddRef();
+    }
+    else if (!strcasecmp(szMimeType, "H264"))
+    { 
+        pPktSkimmer = new H264PacketSkimmer;
+        pPktSkimmer->AddRef();
+    }
+    else if (!strcasecmp(szMimeType, "MP4V-ES"))
+    {
+        pPktSkimmer = new MP4PacketSkimmer;
+        pPktSkimmer->AddRef();
+    }
+
+    return pPktSkimmer;
+}
 
 ///////////////////////////////////////////////////////////////////////////////
 // PacketSkimmer::PacketSkimmer()
@@ -113,112 +147,4 @@
     SKIM_DBGOUT(SKIM_DBG_CONFIG, ("PktSkimmer DbgLvl: %u\n", m_ulDebugLevel));
 }
 
-
-/////////////////////////////////////////////////////////////////////////////// 
-// PacketSkimmer::GetRTPSequence() - skim RTP header for relevant info // 
-// See RFC1889 for RTP packet format info.
-//
-// args: pRTPPkt - pointer to raw RTP packet buffer
-//       uRTPPT- [out] RTP Packet Type from RTP header
-//       uRTPSeqNo- [out] RTP sequence number from RTP header
-// returns: HXR_OK if valid packet, otherwise HXR_INVALID_PARAMETER 
-//////////////////////////////////////////////////////////////////////////////
-
-HX_RESULT
-PacketSkimmer::GetRTPSequence(BYTE* pRTPPkt,
-                               UINT32 ulPktLen,
-                               UINT8& uRTPPT,
-                               UINT16& uRTPSeqNo) {
-    UINT8 uiRTPVer    = (pRTPPkt[0] >> 6) & 0x03;
-
-    // Enforce supported RTP version and minimum pkt length
-
-    if (uiRTPVer != 2 || ulPktLen < 12)
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-
-    uRTPPT     = pRTPPkt[1] & 0x7F;
-
-    uRTPSeqNo = getshort( &(pRTPPkt[2]) );
-
-    return HXR_OK;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////
-// PacketSkimmer::GetRTPPacketInfo() - skim RTP header for relevant info
-//
-// See RFC1889 for RTP packet format info.
-//
-// args: pRTPPkt - pointer to raw RTP packet buffer
-//       ulPacketInfo - [out] packet info retrieved from RTP header
-//       pPayloadStart - [out] pointer to start of packet payload 
-// returns: HXR_OK if valid packet, otherwise HXR_INVALID_PARAMETER
-///////////////////////////////////////////////////////////////////////////////
-
-HX_RESULT 
-PacketSkimmer::GetRTPPacketInfo(BYTE* pRTPPkt,
-                                UINT32 ulPktLen,
-                                UINT32& ulPacketInfo,
-                                BYTE*& pPayloadStart)
-{
-    pPayloadStart = NULL;
-    UINT8 uiRTPVer    = (pRTPPkt[0] >> 6) & 0x03;
-
-    // Enforce supported RTP version and minimum pkt length
-
-    if (uiRTPVer != 2 || ulPktLen < 12)
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-
-    // Extension hdr length and CSRC count.
-    // These affect the total header length.
-
-    UINT8 uiRTPExt    = ((pRTPPkt[0] >> 4) & 1);
-    UINT8 uiRTPCC     = pRTPPkt[0] & 0x0F;
-
-    UINT8 uiRTPMarker = ((pRTPPkt[1] >> 7) & 1);
-
-    // Pkt type and seq no only used for debug output
-    UINT8 uiRTPPT     = pRTPPkt[1] & 0x7F;
-
-    UINT16 uiRTPSeqNo = getshort( &(pRTPPkt[2]) );
-
-
-    SKIM_DBGOUT(SKIM_DBG_RTP_VERBOSE, 
-                ("RTP: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", 
-                 pRTPPkt[0], pRTPPkt[1], pRTPPkt[2], pRTPPkt[3],
-                 pRTPPkt[4], pRTPPkt[5], pRTPPkt[6], pRTPPkt[7],
-                 pRTPPkt[8], pRTPPkt[9], pRTPPkt[10], pRTPPkt[11]));
-             
-    SKIM_DBGOUT((SKIM_DBG_RTP | SKIM_DBG_RTP_VERBOSE),
-                ("RTP: Ver=%u, Ext=%u, CC=%u, M=%u, PT=%u, Seq=%u\n", 
-                 uiRTPVer,
-                 uiRTPExt,
-                 uiRTPCC,
-                 uiRTPMarker,
-                 uiRTPPT,
-                 uiRTPSeqNo));
-
-    // Standard hdr len + CSRC headers (+ extension hdr stuff if any)
-    pPayloadStart = pRTPPkt + 12 + (uiRTPCC * 4);
-
-    if (uiRTPExt)
-    {
-        BYTE* pRTPExt = pPayloadStart; 
-
-        UINT16 uiRTPExtLen = getshort( &(pRTPExt[2]) );
-
-        SKIM_DBGOUT(SKIM_DBG_RTP_VERBOSE, ("RTPExt: Len: %u\n", uiRTPExtLen));
-
-        // Skip mandatory 32 bits (ext code/length) and extension words.
-        pPayloadStart += (uiRTPExtLen + 1) * 4; 
-    }
-
-
-    return HXR_OK;
-}
-
 ///////////////////////////////////////////////////////////////////////////////

Index: mp4skim.h
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/mp4skim.h,v
retrieving revision 1.3
retrieving revision 1.3.34.1
diff -u -d -r1.3 -r1.3.34.1
--- mp4skim.h	7 Jun 2005 03:06:37 -0000	1.3
+++ mp4skim.h	31 Mar 2009 19:05:08 -0000	1.3.34.1
@@ -43,7 +43,7 @@
 
     MP4PacketSkimmer();
 
-    virtual HX_RESULT GetPacketInfo(IHXBuffer* pPacket, 
+    virtual HX_RESULT GetPacketInfo(RTPPacketBase* pPacket, 
                                     UINT32& ulPacketInfo);
 };
 #endif // _MP4SKIM_H_

Index: skimbase.h
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/skimbase.h,v
retrieving revision 1.5
retrieving revision 1.5.28.1
diff -u -d -r1.5 -r1.5.28.1
--- skimbase.h	11 Jan 2007 02:33:51 -0000	1.5
+++ skimbase.h	31 Mar 2009 19:05:08 -0000	1.5.28.1
@@ -35,6 +35,9 @@
  *   
  * ***** END LICENSE BLOCK ***** */  
 
+#ifndef _SKIM_BASE_H_
+#define _SKIM_BASE_H_
+
 #include <stdio.h>
 #include <stdarg.h>
 
@@ -61,8 +64,11 @@
 // WARNING: Only for use within classes that derive from PacketSkimmer!
 #define SKIM_DBGOUT(ulMask, args) { if (ulMask & m_ulDebugLevel) DebugOut args; }
 
-// Base (abstract) packet skimmer class.
+// Forward Declarations
+class RTPPacketBase;
 
+
+// Base (abstract) packet skimmer class.
 class PacketSkimmer : public IUnknown
 {
 public:
@@ -78,24 +84,17 @@
                                          REFIID riid,
                                          void** ppvObj);
 
-    void SetDebugLevel(UINT32 ulDebugLevel);
+    static PacketSkimmer* CreatePacketSkimmer(IHXBuffer* pMimeType);
 
-    static HX_RESULT GetRTPSequence(BYTE* pRTPPkt,
-                                    UINT32 ulPktLen,
-                                    UINT8& uRTPPT,
-                                    UINT16& uRTPSeqNo);
+    void SetDebugLevel(UINT32 ulDebugLevel);
 
-    virtual HX_RESULT GetPacketInfo(IHXBuffer* pPacket, 
+    virtual HX_RESULT GetPacketInfo(RTPPacketBase* pPacket, 
                                     UINT32& ulPacketInfo) = 0;
 
 protected:
 
     void DebugOut(const char* szFormat...);
 
-    HX_RESULT GetRTPPacketInfo(BYTE* pRTPPkt,
-                               UINT32 ulPktLen,
-                               UINT32& ulPacketInfo,
-                               BYTE*& pPayloadStart);
     UINT32 m_ulRefCount;
     UINT32 m_ulDebugLevel;
 };
@@ -117,4 +116,5 @@
     va_end(args);
 }
 
+#endif /* _SKIM_BASE_H_ */
 

Index: mp4skim.cpp
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/mp4skim.cpp,v
retrieving revision 1.10.26.1
retrieving revision 1.10.26.1.6.1
diff -u -d -r1.10.26.1 -r1.10.26.1.6.1
--- mp4skim.cpp	28 Nov 2007 11:03:23 -0000	1.10.26.1
+++ mp4skim.cpp	31 Mar 2009 19:05:08 -0000	1.10.26.1.6.1
@@ -37,9 +37,12 @@
 
 #include "hxcom.h"
 #include "hxengin.h"
+#include "hxassert.h"
+
+#include "rtppkt.h"
+
 #include "skimbase.h"
 #include "mp4skim.h"
-#include "hxassert.h"
 
 HX_RESULT
 PrintStreamBits(BYTE* pBytes, int nCount, char* pszBits, int& nBitCount);
@@ -52,13 +55,11 @@
 }
 
 HX_RESULT
-MP4PacketSkimmer::GetPacketInfo(IHXBuffer* pPacket, 
+MP4PacketSkimmer::GetPacketInfo(RTPPacketBase* pPacket, 
                                  UINT32& ulPacketInfo)
 {
     HX_RESULT   hr = HXR_OK;
-    BYTE*       pRTPHdr = NULL;
     BYTE*       pMP4Payload = NULL;
-    UINT32      uiPacketSize = 0;
     UINT32      uiPayloadSize = 0;
     UINT32      nIndex = 0;
     BYTE*       pIndex = NULL;
@@ -66,47 +67,19 @@
     BOOL        bLoopDone = FALSE;
     UINT8       uiRTPMarker = 0;
 
-
     ulPacketInfo = 0;
 
-    if (pPacket == NULL) 
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-    
-    // Enforce minimum size: RTP hdr(12)
-    uiPacketSize = pPacket->GetSize();
-  
-    if (uiPacketSize < 12) 
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-    pRTPHdr = (BYTE*)pPacket->GetBuffer();
-    
+    uiPayloadSize = pPacket->data.len;
+    pMP4Payload = (BYTE*)pPacket->data.data;
 
-   
-    if (FAILED(hr = GetRTPPacketInfo(pRTPHdr, 
-                                     uiPacketSize,
-                                     ulPacketInfo,
-                                     pMP4Payload)))
-    {
-        goto done;
-    }
 
-    // rtp marker bit
-    uiRTPMarker = ((pRTPHdr[1] >> 7) & 0x01);
     /* If marker bit is set, there can be multiple VOPs in the RTP packet
     ** or this is the last RTP packet of a VOP */
-    if (uiRTPMarker)
+    if (pPacket->marker_flag)
     {
         ulPacketInfo |= SKIMINFO_PKT_FRAMEEND;
     }
 
-    // scan the mp4 data to find start code prefix (0x00, 0x00, 0x01)
-  
-    uiPayloadSize = uiPacketSize - (pMP4Payload - pRTPHdr);
-    HX_ASSERT(uiPayloadSize >= 0 && uiPayloadSize <= uiPacketSize);
-    
     if (m_ulDebugLevel & SKIM_DBG_PACKETIZER_VERBOSE && uiPayloadSize > 5)
     {
         char        pszBits[500];
@@ -124,11 +97,12 @@
               pszBits));
     }
 
+    // scan the mp4 data to find start code prefix (0x00, 0x00, 0x01)
     pIndex = pMP4Payload;
 
     // there needs to be at least 5 bytes of data in order to be a VOP 
     // (4 byte start code + 1 byte coding type)
-    while (!bLoopDone && !bKeyFrame && nIndex < uiPayloadSize - 5)
+    while (!bLoopDone && !bKeyFrame && uiPayloadSize > 5 && nIndex < uiPayloadSize - 5)
     {
         BYTE    codingType = 0;
         UINT32  uiSkipAhead = 1;
@@ -146,8 +120,8 @@
                 if (codingType == 0)
                 {
                     bKeyFrame = TRUE;
-                 }
-                 SKIM_DBGOUT((SKIM_DBG_PACKETIZER | SKIM_DBG_PACKETIZER_VERBOSE),
+                }
+                SKIM_DBGOUT((SKIM_DBG_PACKETIZER | SKIM_DBG_PACKETIZER_VERBOSE),
                     ("MP4: video object plane, vop coding type=%u, key frame=%s\n",
                      codingType,
                      codingType ? "No" : "Yes"));
@@ -214,8 +188,6 @@
     {
         ulPacketInfo |= SKIMINFO_PKT_KEYFRAME | SKIMINFO_PKT_FRAMESTART;
     }
-    
-done:
 
     return hr;
 }

Index: Umakefil
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/Umakefil,v
retrieving revision 1.4
retrieving revision 1.4.34.1
diff -u -d -r1.4 -r1.4.34.1
--- Umakefil	7 Jun 2005 03:06:37 -0000	1.4
+++ Umakefil	31 Mar 2009 19:05:08 -0000	1.4.34.1
@@ -42,6 +42,7 @@
                           "server/include",
                           "common/dbgtool/pub",
                           "common/util/pub",
+                          "protocol/transport/rtp/pub",
                           "server/common/util/pub")
 
 project.AddSources("skimbase.cpp", 

Index: h263skim.cpp
===================================================================
RCS file: /cvsroot/server/datatype/common/pktskim/h263skim.cpp,v
retrieving revision 1.6.26.1
retrieving revision 1.6.26.1.6.1
diff -u -d -r1.6.26.1 -r1.6.26.1.6.1
--- h263skim.cpp	28 Nov 2007 11:02:54 -0000	1.6.26.1
+++ h263skim.cpp	31 Mar 2009 19:05:08 -0000	1.6.26.1.6.1
@@ -44,6 +44,8 @@
 #include "hxcom.h"
 #include "hxengin.h"
 
+#include "rtppkt.h"
+
 #include "skimbase.h"
 #include "h263skim.h"
 #include "hxassert.h"
@@ -67,12 +69,13 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 HX_RESULT
-H263PacketSkimmer::GetPacketInfo(IHXBuffer* pPacket, 
+H263PacketSkimmer::GetPacketInfo(RTPPacketBase* pPacket, 
                                  UINT32& ulPacketInfo)
 {
     HX_RESULT hr = HXR_OK;
 
-    UINT32 ulReqdPktLen = 0;
+    UINT32 ulH263HeaderLen = 2;
+    UINT32 ulReqdPyldLen = 3;
 
     UINT8 uiH263PTypeFmt = 0;
     UINT8 uiFrameType = 0;
@@ -86,38 +89,14 @@
     UINT8 uiH263PLen  = 0;
     UINT8 uiH263PEBit = 0;
 
-    ulPacketInfo = 0;    
-
-    if (!pPacket)
-    {
-        return HXR_INVALID_PARAMETER;
-    }
-
-    BYTE* pRTPHdr = (BYTE*)pPacket->GetBuffer();
-    UINT32 ulPktLen = pPacket->GetSize();
-
-    BYTE* pH263Hdr = NULL;
+    BYTE* pH263Hdr = (BYTE*)pPacket->data.data;
     BYTE* pH263Payload = NULL;   
+    UINT32 ulPktLen = pPacket->data.len;
 
-    // Enforce minimum size: RTP hdr(12) + H263 hdr(2) + H263 payload(3).
-
-    if (FAILED(hr = GetRTPPacketInfo(pRTPHdr, 
-                                     ulPktLen,
-                                     ulPacketInfo,
-                                     pH263Hdr)))
-    {
-        return hr;
-    }
-
-    HX_ASSERT(pH263Hdr);
-
-    // min. len  =  rtp hdr len         + min. H263 hdr length                 
-    ulReqdPktLen = (pH263Hdr - pRTPHdr) + 2;
+    ulPacketInfo = 0;    
 
-    // Minimum req'd RTP hdr missing!
-    if (ulPktLen < ulReqdPktLen)
+    if (ulPktLen < ulH263HeaderLen)
     {
-        ulPacketInfo = 0;
         return HXR_INVALID_PARAMETER;
     }
 
@@ -146,7 +125,7 @@
     }
 
     /* If marker bit is set, it is end of frame */
-    if ((pRTPHdr[1] >> 7) & 1)
+    if (pPacket->marker_flag)
     {
         ulPacketInfo |= SKIMINFO_PKT_FRAMEEND;
     }
@@ -174,18 +153,18 @@
 
     ///// Scan H263 Payload
 
-    // reqd len  += 1 byte vrc hdr + extra picture hdr + minimum payload size
-    ulReqdPktLen += uiH263VBit + uiH263PLen + 3;
+    // header len  += 1 byte vrc hdr + extra picture hdr
+    ulH263HeaderLen += uiH263VBit + uiH263PLen;
 
     // Ensure that there's valid payload.
-    if (ulPktLen < ulReqdPktLen)
+    if (ulPktLen < ulH263HeaderLen + ulReqdPyldLen)
     {
         ulPacketInfo = 0;
         return HXR_INVALID_PARAMETER;        
     }
 
-    // 2 byte for minimum hdr + 1 byte VRC hdr + extra picture hdr
-    pH263Payload = pH263Hdr + 2 + uiH263VBit + uiH263PLen;
+    pH263Payload = pH263Hdr + ulH263HeaderLen;
+    ulPktLen -= ulH263HeaderLen;
 
     // Contents: 6-bit picture start code (PSC)
     //           8-bit temporal reference (TR)
@@ -218,7 +197,7 @@
         }
 
         // At least one more byte required for PLUSPTYPE info.
-        ulReqdPktLen++;
+        ulReqdPyldLen++;
 
         uiFrameType = 0;
 
@@ -232,10 +211,10 @@
 
         uiH263UFEP = ((pH263Payload[2] << 1) | pH263Payload[3] >> 7) & 0x07;
 
-        ulReqdPktLen += uiH263UFEP ? 1 : 0;
+        ulReqdPyldLen += uiH263UFEP ? 1 : 0;
 
         // Ensure that there's actually PLUSPTYPE information.
-        if (ulPktLen < ulReqdPktLen)
+        if (ulPktLen < ulReqdPyldLen)
         {
             ulPacketInfo = 0;
             return HXR_INVALID_PARAMETER;        
@@ -281,7 +260,6 @@
     return hr;
 }
 
-
 ///////////////////////////////////////////////////////////////////////////////
 // H263PacketSkimmer::OutputPayloadInfo() - output debugging info on payload
 //


_______________________________________________
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