RtcpSdesChunk { protected int encode(byte[] rawData, int offSet) { int temp = offSet; rawData[offSet++] = ((byte) ((this.ssrc & 0xFF000000) >> 24)); rawData[offSet++] = ((byte) ((this.ssrc & 0x00FF0000) >> 16)); rawData[offSet++] = ((byte) ((this.ssrc & 0x0000FF00) >> 8)); rawData[offSet++] = ((byte) ((this.ssrc & 0x000000FF))); for (RtcpSdesItem rtcpSdesItem : rtcpSdesItems) { if (rtcpSdesItem != null) { offSet = rtcpSdesItem.encode(rawData, offSet); } else { break; } } rawData[offSet++] = 0x00; int remainder = (offSet - temp) % 4; if (remainder != 0) { int pad = 4 - remainder; for (int i = 0; i < pad; i++) { rawData[offSet++] = 0x00; } } return offSet; } RtcpSdesChunk(long ssrc); protected  RtcpSdesChunk(); void addRtcpSdesItem(RtcpSdesItem rtcpSdesItem); long getSsrc(); String getCname(); RtcpSdesItem[] getRtcpSdesItems(); int getItemCount(); @Override String toString(); static final int MAX_ITEMS; }
@Test public void testEncode() { RtcpSdesItem rtcpSdesItem = new RtcpSdesItem(RtcpSdesItem.RTCP_SDES_CNAME, "abhayani@abhayani-laptop"); RtcpSdesChunk rtcpSdesChunk = new RtcpSdesChunk(233393951); rtcpSdesChunk.addRtcpSdesItem(rtcpSdesItem); byte[] rawData = new byte[256]; int length = rtcpSdesChunk.encode(rawData, 0); assertEquals(p.length, length); for(int i=0;i<p.length;i++){ assertEquals(p[i], rawData[i]); } }