private byte[] assembleSenderReportPacket(){
  final int FIXED_HEADER_SIZE=4;
  byte V_P_RC=(byte)((RtcpPacket.VERSION << 6) | (RtcpPacket.PADDING << 5) | (0x00));
  byte ss[]=RtcpPacketUtils.longToBytes(mRtcpSession.SSRC,4);
  byte PT[]=RtcpPacketUtils.longToBytes(RtcpPacket.RTCP_SR,1);
  byte NTP_Timestamp[]=RtcpPacketUtils.longToBytes(mRtcpSession.currentTime(),8);
  short randomOffset=(short)Math.abs(mRand.nextInt() & 0x000000FF);
  byte RTP_Timestamp[]=RtcpPacketUtils.longToBytes((long)mRtcpSession.tc + randomOffset,4);
  byte SenderPacketCount[]=RtcpPacketUtils.longToBytes(mRtcpSession.packetCount,4);
  byte SenderOctetCount[]=RtcpPacketUtils.longToBytes(mRtcpSession.octetCount,4);
  byte receptionReportBlocks[]=new byte[0];
  receptionReportBlocks=RtcpPacketUtils.append(receptionReportBlocks,assembleRTCPReceptionReport());
  byte receptionReports=(byte)(receptionReportBlocks.length / 24);
  V_P_RC=(byte)(V_P_RC | (byte)(receptionReports & 0x1F));
  byte length[]=RtcpPacketUtils.longToBytes((FIXED_HEADER_SIZE + ss.length + NTP_Timestamp.length+ RTP_Timestamp.length+ SenderPacketCount.length+ SenderOctetCount.length+ receptionReportBlocks.length) / 4 - 1,2);
  byte rtcpSRPacket[]=new byte[1];
  rtcpSRPacket[0]=V_P_RC;
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,PT);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,length);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,ss);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,NTP_Timestamp);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,RTP_Timestamp);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,SenderPacketCount);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,SenderOctetCount);
  rtcpSRPacket=RtcpPacketUtils.append(rtcpSRPacket,receptionReportBlocks);
  return rtcpSRPacket;
}

private byte [ ] assembleSenderReportPacket ( ) { final int FIXED_HEADER_SIZE = 4 ; byte V_P_RC = ( byte ) ( ( RtcpPacket . VERSION << 6 ) | ( RtcpPacket . PADDING << 5 ) | ( 0x00 ) ) ; byte ss [ ] = RtcpPacketUtils . longToBytes ( mRtcpSession . SSRC , 4 ) ; byte PT [ ] = RtcpPacketUtils . longToBytes ( RtcpPacket . RTCP_SR , 1 ) ; byte NTP_Timestamp [ ] = RtcpPacketUtils . longToBytes ( mRtcpSession . currentTime ( ) , 8 ) ; short randomOffset = ( short ) Math . abs ( mRand . nextInt ( ) & 0x000000FF ) ; byte RTP_Timestamp [ ] = RtcpPacketUtils . longToBytes ( ( long ) mRtcpSession . tc + randomOffset , 4 ) ; byte SenderPacketCount [ ] = RtcpPacketUtils . longToBytes ( mRtcpSession . packetCount , 4 ) ; byte SenderOctetCount [ ] = RtcpPacketUtils . longToBytes ( mRtcpSession . octetCount , 4 ) ; byte receptionReportBlocks [ ] = new byte [ 0 ] ; receptionReportBlocks = RtcpPacketUtils . append ( receptionReportBlocks , assembleRTCPReceptionReport ( ) ) ; byte receptionReports = ( byte ) ( receptionReportBlocks . length / 24 ) ; V_P_RC = ( byte ) ( V_P_RC | ( byte ) ( receptionReports & 0x1F ) ) ; byte length [ ] = RtcpPacketUtils . longToBytes ( ( FIXED_HEADER_SIZE + ss . length + NTP_Timestamp . length + RTP_Timestamp . length + SenderPacketCount . length + SenderOctetCount . length + receptionReportBlocks . length ) / 4 - 1 , 2 ) ; byte rtcpSRPacket [ ] = new byte [ 1 ] ; rtcpSRPacket [ 0 ] = V_P_RC ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , PT ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , length ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , ss ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , NTP_Timestamp ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , RTP_Timestamp ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , SenderPacketCount ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , SenderOctetCount ) ; rtcpSRPacket = RtcpPacketUtils . append ( rtcpSRPacket , receptionReportBlocks ) ; return rtcpSRPacket ; }
assemble rtcp sr packet
