RtcpAppDefined extends RtcpHeader { protected int encode(byte[] rawData, int offSet) { int startPosition = offSet; offSet = super.encode(rawData, 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))); byte[] nameBytes = this.name.getBytes(); for (int i = 0; i < 4; i++) { rawData[offSet++] = nameBytes[i]; } System.arraycopy(data, 0, rawData, offSet, data.length); offSet += data.length; this.length = (offSet - startPosition - 4) / 4; rawData[startPosition + 2] = ((byte) ((this.length & 0xFF00) >> 8)); rawData[startPosition + 3] = ((byte) (this.length & 0x00FF)); return offSet; } RtcpAppDefined(); protected  RtcpAppDefined(boolean padding, int subType, long ssrc, String name, byte[] data); byte[] getData(); String getName(); long getSsrc(); int getSubType();  }
@Test public void testEncode() { byte[] appData = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x61, 0x74, 0x00, 0x04, 0x00, 0x00, 0x00, 0x14 }; RtcpAppDefined rtcpAppDefined = new RtcpAppDefined(false, 1, 266283887, "qtsi", appData); byte[] rawData = new byte[256]; int length = rtcpAppDefined.encode(rawData, 0); assertEquals(p.length, length); for (int i = 0; i < p.length; i++) { assertEquals(p[i], rawData[i]); } }