[hxserver] CR: 3GPP Annex G QoS SDP attributes
Jamie Gordon jgordon at real.comSuggested Reviewers: Go and Kamlesh
Description:
Adds the Annex G video stream attributes to the SDP when applied.
Uses profile values (if existent) for PreDecBufSize and
InitPostDecBufPeriod, Preroll (converted to 90kHz) for
InitPreDecBufPeriod, and MaxBitRate (converted to Bytes/sec)
for DecByteRate.
Removed some unexercised code in CASMStreamFilter::StreamHeaderReady
and CASMStreamFilter::FileHeaderReady.
PR 107806
Branches: SERVER_CURRENT (HEAD) and SERVER_10_1_STABLE
Tested: win32
Built: win32, sunos5.8
Files:
server/engine/inputsource/stream_filter_asm.cpp
server/engine/inputsource/stream_filter_asm.h
server/engine/inputsource/pub/asmhandler.h
protocol/sdp/sdpmdgen.cpp
-------------- next part --------------
Index: stream_filter_asm.cpp
===================================================================
RCS file: /cvs/server/engine/inputsource/stream_filter_asm.cpp,v
retrieving revision 1.26
diff -u -w -r1.26 stream_filter_asm.cpp
--- stream_filter_asm.cpp 17 Sep 2003 21:08:01 -0000 1.26
+++ stream_filter_asm.cpp 19 Nov 2003 22:31:05 -0000
@@ -2173,11 +2173,11 @@
}
HX_RESULT
-ASMRuleHandler::ModifyHeaders(IHXValues* pHdr)
+ASMRuleHandler::ModifyHeaders(IHXValues* pHdr, BOOL bUseAnnexG)
{
HX_ASSERT(pHdr);
UINT32 ulStreamNo = 0;
- UINT32 ulAvgRate = 0;
+ UINT32 ulVal = 0;
IHXRateDescription* pRateDesc = NULL;
HX_RESULT theErr = pHdr->GetPropertyULONG32("StreamNumber", ulStreamNo);
@@ -2188,18 +2188,31 @@
}
if (HXR_OK == theErr)
{
- theErr = pRateDesc->GetAvgRate(ulAvgRate);
- pRateDesc->Release();
- pRateDesc = NULL;
+ if (SUCCEEDED(pRateDesc->GetAvgRate(ulVal)))
+ {
+ pHdr->SetPropertyULONG32("AvgBitRate", ulVal);
}
- if (HXR_OK == theErr)
+ if (bUseAnnexG)
+ {
+ if (SUCCEEDED(pRateDesc->GetMaxRate(ulVal)) && ulVal >= 8)
+ {
+ // Convert to bytes/sec, round up
+ pHdr->SetPropertyULONG32("DecByteRate", (ulVal + 7) >> 3);
+ }
+ if (SUCCEEDED(pRateDesc->GetPreroll(ulVal)) && ulVal)
{
- theErr = pHdr->SetPropertyULONG32("AvgBitRate", ulAvgRate);
+ // Convert to 90kHz
+ pHdr->SetPropertyULONG32("InitPreDecBufPeriod", ulVal * 90);
+ }
+ }
+
+ pRateDesc->Release();
}
// ok if this fails for now
return HXR_OK;
}
+
/*
HX_RESULT
ASMRuleHandler::GetStatsString(REF(IHXBuffer*)pStats)
@@ -2662,7 +2675,7 @@
}
if (HXR_OK == status)
{
- status = m_pRuleHandler->ModifyHeaders(pNewHdr);
+ status = ModifyStreamHeaders(pNewHdr);
}
status = m_pCtrlSink->StreamHeaderReady(status, pNewHdr);
HX_RELEASE(pNewHdr);
@@ -2924,6 +2937,7 @@
BOOL bConfigFound = TRUE;
UINT32 ulPreDecodeBufSize = 0; // profile
UINT32 ulDecodeByteRate = 0; // profile
+ UINT32 ulPostDecBufPeriod = 0; // profile
UINT32 ulMaxRateConfig = 0; // max rate from config file
if (m_pStats)
@@ -2937,14 +2951,16 @@
UINT32 attribtype = HX_CP_TYPE_INT;
profAttribute.ulInt = 0;
- if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_VPREDEC_BUF_SIZE, attribtype, profAttribute)))
+ if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_VPREDEC_BUF_SIZE,
+ attribtype, profAttribute)))
{
// better be >= preroll * avgbitrate
ulPreDecodeBufSize = profAttribute.ulInt;
}
profAttribute.ulInt = 0;
- if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_VDEC_BYTE_RATE, attribtype, profAttribute)))
+ if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_VDEC_BYTE_RATE,
+ attribtype, profAttribute)))
{
//Video Decoding Byte Rate is in Bytes/sec
ulDecodeByteRate = profAttribute.ulInt;
@@ -2952,14 +2968,22 @@
ulDecodeByteRate *= 8;
}
+ profAttribute.ulInt = 0;
+ if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_VPOSTDEC_BUF_PERIOD,
+ attribtype, profAttribute)))
+ {
+ ulPostDecBufPeriod = profAttribute.ulInt;
+ }
attribtype = HX_CP_TYPE_BOOL;
profAttribute.bBool = 0;
- if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_SOUND_CAP, attribtype, profAttribute)))
+ if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_SOUND_CAP, attribtype,
+ profAttribute)))
{
/* */
}
- if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_IMAGE_CAP, attribtype, profAttribute)))
+ if (SUCCEEDED(pProfile->GetAttribute(HX_CP_ATTR_IMAGE_CAP, attribtype,
+ profAttribute)))
{
/* */
}
@@ -3021,6 +3045,15 @@
m_selectionParam.m_ulMaxPreDecBufSize = MAX_UINT32;
}
+ if (ulPostDecBufPeriod)
+ {
+ m_selectionParam.m_ulPostDecBufPeriod = ulPostDecBufPeriod;
+ }
+ else
+ {
+ m_selectionParam.m_ulPostDecBufPeriod = 0;
+ }
+
/*
* Initial Target Rate -
*/
@@ -3343,42 +3376,48 @@
return theErr;
}
-STDMETHODIMP
-CASMStreamFilter::FileHeaderReady(HX_RESULT ulStatus, IHXValues* pHeader)
+HX_RESULT
+CASMStreamFilter::ModifyStreamHeaders(IHXValues* pHdr)
{
- return HandleFileHeader(ulStatus, pHeader);
+ HX_ASSERT(m_pRuleHandler);
+ HX_ASSERT(pHdr);
- HX_ASSERT(m_pCtrlSink);
- // XXXGo - Need to modify header according to the Stream Selection
- IHXValues* pNewHeader = NULL;
- if (HXR_OK == ulStatus)
+ IHXBuffer* pMimeType = NULL;
+
+ // Add the Annex G QoS SDP params if it's a video stream
+ // and QoS was applied
+ if (m_pQoSConfig &&
+ SUCCEEDED(pHdr->GetPropertyCString("MimeType", pMimeType)) &&
+ strncasecmp((const char*)pMimeType->GetBuffer(), "video", 5) == 0)
{
- ulStatus = CopyHeaders(pHeader, pNewHeader);
- }
- ulStatus = m_pCtrlSink->FileHeaderReady(ulStatus, pNewHeader);
- HX_RELEASE(pNewHeader);
- return ulStatus;
+ if (m_selectionParam.m_ulMaxPreDecBufSize &&
+ m_selectionParam.m_ulMaxPreDecBufSize < MAX_UINT32)
+ {
+ pHdr->SetPropertyULONG32("PreDecBufSize",
+ m_selectionParam.m_ulMaxPreDecBufSize);
}
-STDMETHODIMP
-CASMStreamFilter::StreamHeaderReady(HX_RESULT ulStatus, IHXValues* pHeader)
+ if (m_selectionParam.m_ulPostDecBufPeriod)
{
- return HandleStreamHeader(ulStatus, pHeader);
- HX_ASSERT(m_pCtrlSink);
+ // Convert to 90kHz
+ pHdr->SetPropertyULONG32("InitPostDecBufPeriod",
+ m_selectionParam.m_ulPostDecBufPeriod * 90);
+ }
- // XXXGo - Need to modify header according to the Stream Selection
- IHXValues* pNewHeader = NULL;
- if (HXR_OK == ulStatus)
- {
- ulStatus = CopyHeaders(pHeader, pNewHeader);
+ return m_pRuleHandler->ModifyHeaders(pHdr, TRUE);
}
- if (HXR_OK == ulStatus)
- {
- ulStatus = m_pRuleHandler->ModifyHeaders(pNewHeader);
+
+ return m_pRuleHandler->ModifyHeaders(pHdr, FALSE);
}
- ulStatus = m_pCtrlSink->StreamHeaderReady(ulStatus, pNewHeader);
- HX_RELEASE(pNewHeader);
- return ulStatus;
+STDMETHODIMP
+CASMStreamFilter::FileHeaderReady(HX_RESULT ulStatus, IHXValues* pHeader)
+{
+ return HandleFileHeader(ulStatus, pHeader);
+}
+STDMETHODIMP
+CASMStreamFilter::StreamHeaderReady(HX_RESULT ulStatus, IHXValues* pHeader)
+{
+ return HandleStreamHeader(ulStatus, pHeader);
}
Index: stream_filter_asm.h
===================================================================
RCS file: /cvs/server/engine/inputsource/stream_filter_asm.h,v
retrieving revision 1.1
diff -u -w -r1.1 stream_filter_asm.h
--- stream_filter_asm.h 20 Aug 2003 01:20:31 -0000 1.1
+++ stream_filter_asm.h 19 Nov 2003 22:31:05 -0000
@@ -135,6 +135,7 @@
HX_RESULT HandleFileHeader(HX_RESULT status, IHXValues* pHdr);
HX_RESULT HandleStreamHeader(HX_RESULT status, IHXValues* pHdr);
HX_RESULT CopyHeaders(IHXValues* pOldVal, REF(IHXValues*) pNewVal);
+ HX_RESULT ModifyStreamHeaders(IHXValues* pHdr);
UINT32 GetInitialMediaRate(void);
HX_RESULT _SetInitialRate(UINT32 ulRate);
@@ -196,6 +197,7 @@
UINT32 m_ulMaxTargetRate; // bits/sec
UINT32 m_ulMaxPreDecBufSize; // bytes
UINT32 m_ulInitTargetRate; // bits/serc
+ UINT32 m_ulPostDecBufPeriod; // 1/90000 sec
} m_selectionParam;
// debug
Index: pub/asmhandler.h
===================================================================
RCS file: /cvs/server/engine/inputsource/pub/asmhandler.h,v
retrieving revision 1.2
diff -u -w -r1.2 asmhandler.h
--- pub/asmhandler.h 12 Sep 2003 00:40:47 -0000 1.2
+++ pub/asmhandler.h 19 Nov 2003 22:31:05 -0000
@@ -191,7 +191,7 @@
void Dump(void);
void SetHeader(UINT32 ulStreamNo, IHXValues* pHdr);
- HX_RESULT ModifyHeaders(IHXValues* pHdr);
+ HX_RESULT ModifyHeaders(IHXValues* pHdr, BOOL bUseAnnexG);
/* Need to keep track of subscription state */
HX_RESULT HandlePacket(UINT32 ulStreamNo, UINT16 unRuleNum);
-------------- next part --------------
Index: sdpmdgen.cpp
===================================================================
RCS file: /cvs/protocol/sdp/sdpmdgen.cpp,v
retrieving revision 1.12
diff -u -w -r1.12 sdpmdgen.cpp
--- sdpmdgen.cpp 17 Sep 2003 21:13:51 -0000 1.12
+++ sdpmdgen.cpp 19 Nov 2003 22:33:58 -0000
@@ -736,6 +736,14 @@
UINT32 ulRTCPRR = 0;
BOOL bFoundRTCPSR = FALSE;
UINT32 ulRTCPSR = 0;
+ BOOL bFoundPreDecBufSize = FALSE;
+ UINT32 ulPreDecBufSize = 0;
+ BOOL bFoundPreDecBufPeriod = FALSE;
+ UINT32 ulPreDecBufPeriod = 0;
+ BOOL bFoundPostDecBufPeriod = FALSE;
+ UINT32 ulPostDecBufPeriod = 0;
+ BOOL bFoundDecByteRate = FALSE;
+ UINT32 ulDecByteRate = 0;
char* pszMimeType=NULL;
char* pszMimeFirst=NULL;
@@ -831,6 +839,27 @@
bFoundRTCPSR = TRUE;
ulRTCPSR = propValue;
}
+ else if(strcasecmp(pPropName, "PreDecBufSize") == 0)
+ {
+ bFoundPreDecBufSize = TRUE;
+ ulPreDecBufSize = propValue;
+ }
+ else if(strcasecmp(pPropName, "InitPreDecBufPeriod") == 0)
+ {
+ bFoundPreDecBufPeriod = TRUE;
+ ulPreDecBufPeriod = propValue;
+ }
+ else if(strcasecmp(pPropName, "InitPostDecBufPeriod") == 0)
+ {
+ bFoundPostDecBufPeriod = TRUE;
+ ulPostDecBufPeriod = propValue;
+ }
+ else if(strcasecmp(pPropName, "DecByteRate") == 0)
+ {
+ bFoundDecByteRate = TRUE;
+ ulDecByteRate = propValue;
+ }
+
else
{
bAddToHeader = TRUE;
@@ -1259,6 +1288,32 @@
HX_VECTOR_DELETE(pszMimeType);
}
+ // 3GPP AnnexG values
+ if (bFoundPreDecBufSize)
+ {
+ SafeSprintf(psz256, 256, "a=X-predecbufsize:%u%s",
+ ulPreDecBufSize, pszEOL);
+ mDesc += psz256;
+ }
+ if (bFoundPreDecBufPeriod)
+ {
+ SafeSprintf(psz256, 256, "a=X-initpredecbufperiod:%u%s",
+ ulPreDecBufPeriod, pszEOL);
+ mDesc += psz256;
+ }
+ if (bFoundPostDecBufPeriod)
+ {
+ SafeSprintf(psz256, 256, "a=X-initpostdecbufperiod:%u%s",
+ ulPostDecBufPeriod, pszEOL);
+ mDesc += psz256;
+ }
+ if (bFoundDecByteRate)
+ {
+ SafeSprintf(psz256, 256, "a=X-decbyterate:%u%s",
+ ulDecByteRate, pszEOL);
+ mDesc += psz256;
+ }
+
if (pszMimeFirst)
{
HX_VECTOR_DELETE(pszMimeFirst);
-------------- next part --------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe at helix-server.helixcommunity.org
For additional commands, e-mail: dev-help at helix-server.helixcommunity.org