RtcpBye extends RtcpHeader { protected int encode(byte[] rawData, int offSet) { int startPosition = offSet; offSet = super.encode(rawData, offSet); for (int i = 0; i < this.count; i++) { long ssrc = ssrcs[i]; rawData[offSet++] = ((byte) ((ssrc & 0xFF000000) >> 24)); rawData[offSet++] = ((byte) ((ssrc & 0x00FF0000) >> 16)); rawData[offSet++] = ((byte) ((ssrc & 0x0000FF00) >> 8)); rawData[offSet++] = ((byte) ((ssrc & 0x000000FF))); } this.length = (offSet - startPosition - 4) / 4; rawData[startPosition + 2] = ((byte) ((this.length & 0xFF00) >> 8)); rawData[startPosition + 3] = ((byte) (this.length & 0x00FF)); return offSet; } protected  RtcpBye();  RtcpBye(boolean padding); void addSsrc(long ssrc); long[] getSsrcs(); @Override String toString();  }
@Test public void testEncode() { RtcpBye rtcpBye = new RtcpBye(false); rtcpBye.addSsrc(1448293446); byte[] rawData = new byte[256]; int length = rtcpBye.encode(rawData, 0); assertEquals(p.length, length); for (int i = 0; i < p.length; i++) { assertEquals(p[i], rawData[i]); } }