[datatype-dev] CR: Sequence number wrap around fix for Symbian XPSFF
Eric Hyche ehyche at real.comLooks good. ============================================= Eric Hyche (ehyche at real.com) Technical Lead RealNetworks, Inc. > -----Original Message----- > From: datatype-dev-bounces at helixcommunity.org > [mailto:datatype-dev-bounces at helixcommunity.org] On Behalf Of > rajesh.rathinasamy at nokia.com > Sent: Wednesday, November 15, 2006 7:24 PM > To: datatype-dev at helixcommunity.org > Subject: [datatype-dev] CR: Sequence number wrap around fix > for Symbian XPSFF > > "Nokia submits this code under the terms of a > commercial contribution agreement with RealNetworks, and I am > authorized to contribute this code under said agreement." > > Modified by: rajesh.rathinasamy at nokia.com > > Reviewed by: > > Date: 15-Nov-2006. > > Project: SymbianMmf > > ErrorId: EJZG-6VJV8Z > > Synopsis: CR: Sequence number wrap around fix > > While playing a 2hr clip, there was a > sequence number wrap around and all the packets after that > were dropped. This would result in app being in bufferring > state for a while and then the clip will end. > > Handled the sequence number wrapping. > Introduced a wrap sequence number gap tolerance value ( Will > be hit in packet loss close to seq wrap). > > > Files Modified: > ========= > Datatype/xps/fileformat/CXPSFileformat.cpp > > Image Size and Heap Use impact: no major impact > > Platforms and Profiles Build Verified: > helix-client-s60-32-mmf-mdf-arm > > Platforms and Profiles Functionality verified: > armv5, winscw > > Branch: Head & 210CayS > > > Index: CXPSFileformat.cpp > > =================================================================== > RCS file: /cvsroot/datatype/xps/fileformat/CXPSFileformat.cpp,v > retrieving revision 1.1.1.1.2.2 > diff -w -u -b -r1.1.1.1.2.2 CXPSFileformat.cpp > --- CXPSFileformat.cpp 3 Nov 2006 22:36:09 -0000 > 1.1.1.1.2.2 > +++ CXPSFileformat.cpp 15 Nov 2006 19:44:51 -0000 > @@ -73,6 +73,7 @@ > > #define MEDIASTREAM_Q_SIZE 100 > #define WRAP_SEQ_NO 0x10000 > +#define WRAP_SEQ_DIFF_TOLERANCE 10 > > const char* const CXPSFileFormat::zm_pDescription = > "External Packet Source File Format Plugin"; > const char* const CXPSFileFormat::zm_pCopyright = > "Copyrights Reserved"; > @@ -841,19 +842,34 @@ > // > HX_RESULT CMediaStream::AddPacket(UINT32 ulSeqNo, > IHXRTPPacket* pRTPPacket) > { > - HX_RESULT rv = HXR_OUTOFMEMORY; > + HX_RESULT rv = HXR_OK; > > HX_ASSERT(m_pQue); > - // Drop late packets > + > if((m_ulLastPktSeqNoDispatched != MAX_UINT32) && > (ulSeqNo <= m_ulLastPktSeqNoDispatched) ) > { > - HXLOGL2(HXLOG_SXPS, > "CMediaStream[%d]::AddPacket late pkt. LastSeq:%lu > CurrSeq:%lu - Dropping", > + // Check whether incoming pkt is late > + if((m_ulLastPktSeqNoDispatched > (WRAP_SEQ_NO > - WRAP_SEQ_DIFF_TOLERANCE)) > + && (ulSeqNo < WRAP_SEQ_DIFF_TOLERANCE) ) > + { > + // Could be wrap around. So consider > inserting into Q > + HXLOGL2(HXLOG_SXPS, > "CMediaStream[%d]::AddPacket LastSeq:%lu CurrSeq:%lu ", > m_ulStreamId, m_ulLastPktSeqNoDispatched, > ulSeqNo); > - rv = HXR_FAIL; > } > else > { > + // Late packet or the gap is beyond wrap > seq tolerance > + HXLOGL2(HXLOG_SXPS, > "CMediaStream[%d]::AddPacket late pkt. LastSeq:%lu > CurrSeq:%lu - Dropping", > + m_ulStreamId, > m_ulLastPktSeqNoDispatched, ulSeqNo); > + rv = HXR_FAILED; > + } > + } > + > + > + if(SUCCEEDED(rv)) > + { > + rv = HXR_OUTOFMEMORY; > CMediaStreamElem* pElem = new CMediaStreamElem(); > if(pElem != NULL) > { > @@ -915,7 +931,7 @@ > > } // End of if(pElem != NULL) > > - } // End of if(m_pQue != NULL) > + } // End of if(SUCCEEDED(rv)) > > > return rv; > @@ -953,9 +969,6 @@ > { > // Peek the packet on front and chk for missing pkt > pElem = (CMediaStreamElem*)m_pQue->front(); > - if((m_ulLastPktSeqNoDispatched == MAX_UINT32) || > - (pElem->SeqNo() == > (m_ulLastPktSeqNoDispatched + 1)) ) > - { > // Pkt() call does a AddRef > pRTPPacket = pElem->Pkt(); > > @@ -965,17 +978,11 @@ > m_ulLastPktSeqNoDispatched = pElem->SeqNo(); > delete pElem; > > - } > - else > + if(m_ulLastPktSeqNoDispatched == > (WRAP_SEQ_NO - 1)) > { > - HXLOGL2(HXLOG_SXPS, > "CMediaStream[%d]::GetNextPacket Packet Lost LstSeqNo:%lu > CurrPkt:%lu", > - m_ulStreamId, > m_ulLastPktSeqNoDispatched, pElem->SeqNo()); > - // packet missing, generate Lost pkt > - GenerateLostPacket(pRTPPacket); > - m_ulLastPktSeqNoDispatched++; > + HXLOGL2(HXLOG_SXPS, > "CMediaStream[%d]::GetNextPacket WRAPPING SEQ NO",m_ulStreamId); > + m_ulLastPktSeqNoDispatched = MAX_UINT32; > } > - > - > } // End of if(m_pQue->size() > 0) > } > > @@ -1093,6 +1100,10 @@ > if( (pRTPPacket != NULL) && (pFillerElem != NULL) ) > { > ulTailSeqNo++; > + if(ulTailSeqNo == WRAP_SEQ_NO) > + { > + ulTailSeqNo = 0; > + } > pFillerElem->Set(ulTailSeqNo, pRTPPacket); > m_pQue->push_back((void*)pFillerElem); > HX_RELEASE(pRTPPacket); > > > > >