private void extractExtensionHeader ( byte [ ] data , int length , int dataId , RtpPacket packet ) { byte [ ] extensionHeaderData = new byte [ length * 4 ] ; System . arraycopy ( data , ++ dataId , extensionHeaderData , 0 , extensionHeaderData . length ) ; packet . extensionHeader = new RtpExtensionHeader ( ) ; int i = 0 ; while ( packet . extensionHeader . elementsCount ( ) < length ) { byte idAndLength = extensionHeaderData [ i ] ; if ( idAndLength == 0x00 ) { i = i + 1 ; continue ; } int elementId = ( idAndLength & 0xf0 ) > > > 4 ; if ( elementId > 0 && elementId < 15 ) { int elementLength = ( idAndLength & 0x0f ) ; byte [ ] elementData = new byte [ elementLength + 1 ] ; System . arraycopy ( extensionHeaderData , i + 1 , elementData , 0 , elementData . length ) ; packet . extensionHeader . addElement ( elementId , elementData ) ; i = i + elementData . length + 1 ; } else { break ; } } }
Extract Extension Header