[hxprotocol] CR: Remove extraneous b=AS line in SDP generation

[hxprotocol] CR: Remove extraneous b=AS line in SDP generation

Damon Lanphear damonlan at real.com
Mon Dec 1 18:37:21 PST 2003


Done.  New diff attached.  The difference rests in the fact that CRLF is
not assumed when stepping over the EOL.

On Mon, 2003-12-01 at 16:29, Aaron Colwell wrote:
> This looks good except for one thing. I know the SDP spec says that all 
> SDP lines will end with a '\r\n', but in practice that is not always the 
> case. Even RealNetworks is guilty of violating this in the past. You 
> should change the code so that it also handles cases where the line is 
> terminated with only '\r' or '\n'.
> 
> Aaron
> 
> On Mon, 1 Dec 2003, Damon Lanphear wrote:
> 
> > Description:
> > 
> > Some encoders provide an additional stream header field: SDPData, which
> > is SDP formatted header information that is placed inline into the
> > generated SDP file.
> > 
> > These encoders may also include a b=AS line that conflicts with existing
> > b=AS lines written in all outbound SDP files.
> > 
> > This conflicting b=AS line causes unpredictable behavior in RTSP/RTP
> > clients.
> > 
> > Solution:
> > 
> > If b=AS lines are present in the SDPData field, remove the extraneous
> > b=AS line.
> > 
> 
-- 
Damon Lanphear <damonlan at real.com>
-------------- next part --------------
? Makefile
? Umakefil.upp
? dbg
? hxsdp.exp
? rel
? sdplib.mak
? sdplib.upp
? sdpplin.mak
? sdpplin.upp
Index: sdpmdgen.cpp
===================================================================
RCS file: /cvs/protocol/sdp/sdpmdgen.cpp,v
retrieving revision 1.12.10.1
diff -u -w -r1.12.10.1 sdpmdgen.cpp
--- sdpmdgen.cpp	20 Nov 2003 01:13:35 -0000	1.12.10.1
+++ sdpmdgen.cpp	2 Dec 2003 01:32:46 -0000
@@ -533,6 +533,7 @@
                 pszSDPData = new char [ dataSize + 1 ];
                 memcpy(pszSDPData, (const char*)pPropBuffer->GetBuffer(), dataSize); /* Flawfinder: ignore */
                 pszSDPData[dataSize] = '\0';
+		RemoveASLine(pszSDPData, dataSize);
             }   
             else if(strcasecmp(pPropName, "Information") == 0)
             {
@@ -960,6 +961,7 @@
                     pszSDPData = new char [ len + 1 ];
                     memcpy(pszSDPData, (const char*)pPropBuffer->GetBuffer(), len); /* Flawfinder: ignore */
                     pszSDPData[len] = '\0';
+		    RemoveASLine(pszSDPData, len);
                 }
                 else if(strcasecmp(pPropName, "Information") == 0)
                 {
@@ -1487,6 +1489,57 @@
      * Set the buffer and return.
      */
     return (char*)newbuf;
+}
+
+void
+SDPMediaDescGenerator::RemoveASLine(char* pSDPData, UINT32 len)
+{
+    /* 
+     * This method removes an extraneous b=AS line in place.
+     */
+
+    if (!pSDPData)
+    {
+	return;
+    }
+
+    char* pWriteCursor = strstr((const char*)pSDPData, "b=AS");
+
+    if (!pWriteCursor)
+    {
+	return;
+    }
+
+    char* pReadCursor = pWriteCursor;
+    UINT32 ulLength = (len - (pSDPData - pWriteCursor));
+
+    //Find the end of the field
+    while((ulLength != 0) &&
+	  (*pReadCursor != 0x0a) &&
+	  (*pReadCursor != 0x0d) &&
+          (*pReadCursor != ' '))
+    {
+        pReadCursor++;
+        ulLength--;
+    }
+
+    //Skip over the end of the field
+    while((ulLength > 0) &&
+          ((*pReadCursor == 0x0a) ||
+           (*pReadCursor == 0x0d) ||
+           (*pReadCursor == ' ')))
+    {
+        pReadCursor++;
+        ulLength--;
+    } 
+
+    if ((!ulLength) ||
+	(!pReadCursor))
+    {
+	return;
+    }
+    
+    memmove(pWriteCursor, pReadCursor, len - (pSDPData - pReadCursor));
 }
 
 BOOL SDPMediaDescGenerator::GetUseSessionGUID() const
Index: pub/sdpmdgen.h
===================================================================
RCS file: /cvs/protocol/sdp/pub/sdpmdgen.h,v
retrieving revision 1.2
diff -u -w -r1.2 sdpmdgen.h
--- pub/sdpmdgen.h	2 Jan 2003 22:02:02 -0000	1.2
+++ pub/sdpmdgen.h	2 Dec 2003 01:32:46 -0000
@@ -63,6 +63,7 @@
 private:
     HX_RESULT SpecComplianceCheck(UINT16 nValues, IHXValues** ppValueArray);
     char* EscapeBuffer(const char* pBuffer, UINT32 len);
+    void  RemoveASLine(char* pSDPData, UINT32 len);
 
     IUnknown* m_pContext;
     IHXCommonClassFactory* m_pCCF;

-------------- next part --------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe at protocol.helixcommunity.org
For additional commands, e-mail: dev-help at protocol.helixcommunity.org


More information about the Protocol-dev mailing list
 

Site Map   |   Terms of Use   |   Privacy Policy   |   Contact Us

Copyright © 1995-2007 RealNetworks, Inc. All rights reserved. RealNetworks and Helix are trademarks of RealNetworks.
All other trademarks or registered trademarks are the property of their respective holders.