Package rtpi.packets

Examples of rtpi.packets.RtcpiPacket


  int currentStart=0;
  byte[] data = packet.getData();
  int length = packet.getLength();
  LinkedList rtcpiPackets = new LinkedList();
  RtcpiPacket rtcpiPacket=null;
 
  try {
      while(currentStart<length) {
    switch (RtcpiPacket.inspectPayloadType(data,currentStart)) {
    case RtcpiSourceDescriptionPacket.SDES:
        rtcpiPacket = new RtcpiSourceDescriptionPacket(data, currentStart);
        rtcpiPacket.parse();
        rtcpiPackets.add(rtcpiPacket);
        break;
    case RtcpiByePacket.BYE:
        rtcpiPacket = new RtcpiByePacket(data, currentStart);
        rtcpiPacket.parse();
        rtcpiPackets.add(rtcpiPacket);
        break;
    case RtcpiSubcomponentReportPacket.SUBREP:
        rtcpiPacket = new RtcpiSubcomponentReportPacket(data, currentStart);
        rtcpiPacket.parse();
        rtcpiPackets.add(rtcpiPacket);
        break;
    default:
        System.err.println("Rtpi: Unknown Rtcpi packet received -ignored! Type was "+RtcpiPacket.inspectPayloadType(data,currentStart));
    }
    currentStart+=RtcpiPacket.inspectLength(data,currentStart);
      }
  } catch (Exception ex) {     
      System.err.println("Rtpi: invalid RTCP/I compound packet received - ignored! Error was: "+ex);
      return;
  }
 
  if(!(rtcpiPackets.getFirst() instanceof RtcpiSourceDescriptionPacket)) {
      System.err.println("Rtpi: Received invalid RTCP/I compound packet. It did not start with an SDES packet!");
      return;
  }

  RtcpiSourceDescriptionPacket sdesPacket=(RtcpiSourceDescriptionPacket) rtcpiPackets.getFirst();
  LinkedList items = sdesPacket.getSourceDescriptionItems();
  if (((SourceDescriptionItem) items.getFirst()).getType()!=SourceDescriptionItem.CNAME) {
      System.err.println("Rtpi: Received invalid RTCP/I compound packet. SDES packet did not start with a CNAME item!");
      return;
  }
 
  // now we are sure that we have received a valid RTCPI packet!

  avg_rtcpi_size=(int) (avg_rtcpi_size*OLD_FACTOR+(packet.getLength()+rtcpiTransport.getHeaderSize())*NEW_FACTOR);

  RtpiSourceInfo info = (RtpiSourceInfo) remoteParticipants.get(new Integer(sdesPacket.getParticipantID()));

  if (info!=null) {
      info.heardFrom();
      //System.out.println("calling heardFrom for source info: " + sdesPacket.getParticipantID());
  }

  for (ListIterator iter=rtcpiPackets.listIterator();iter.hasNext();) {
      rtcpiPacket = (RtcpiPacket) iter.next();
      switch (rtcpiPacket.getPayloadType()) {
      case RtcpiSourceDescriptionPacket.SDES:
    handleSdesPacket((RtcpiSourceDescriptionPacket) rtcpiPacket);
    break;
      case RtcpiByePacket.BYE:
    handleByePacket((RtcpiByePacket) rtcpiPacket);
    break;
      case RtcpiSubcomponentReportPacket.SUBREP:
    handleSubcomponentReportPacket((RtcpiSubcomponentReportPacket) rtcpiPacket);
    break;
      default:
    System.err.println("Rtpi: Could not handle RTCP/I packet, unknown type: "+rtcpiPacket.getPayloadType());
    break;
      }
  }
    }
View Full Code Here

TOP

Related Classes of rtpi.packets.RtcpiPacket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.