RtcpSdes extends RtcpHeader { protected int encode(byte[] rawData, int offSet) { int startPosition = offSet; offSet = super.encode(rawData, offSet); for (RtcpSdesChunk rtcpSdesChunk : sdesChunks) { if (rtcpSdesChunk != null) { offSet = rtcpSdesChunk.encode(rawData, offSet); } else { break; } } this.length = (offSet - startPosition - 4) / 4; rawData[startPosition + 2] = ((byte) ((this.length & 0xFF00) >> 8)); rawData[startPosition + 3] = ((byte) (this.length & 0x00FF)); return offSet; } protected  RtcpSdes();  RtcpSdes(boolean padding); void addRtcpSdesChunk(RtcpSdesChunk rtcpSdesChunk); RtcpSdesChunk[] getSdesChunks(); String getCname(); @Override String toString();  }
@Test public void testEncode() { RtcpSdes rtcpSdes = new RtcpSdes(false); RtcpSdesItem rtcpSdesItem = new RtcpSdesItem(RtcpSdesItem.RTCP_SDES_CNAME, "QTSS1262189851"); RtcpSdesChunk rtcpSdesChunk = new RtcpSdesChunk(1448293446); rtcpSdesChunk.addRtcpSdesItem(rtcpSdesItem); rtcpSdes.addRtcpSdesChunk(rtcpSdesChunk); byte[] rawData = new byte[256]; int length = rtcpSdes.encode(rawData, 0); assertEquals(p.length, length); for (int i = 0; i < p.length; i++) { assertEquals(p[i], rawData[i]); } }