Beispiel #1
0
        protected void Parse2(byte[] bytes, ref int startIndex, int length)
        {
            Version = (bytes[startIndex] & 0xb0) >> 6;
            if (Version != 2)
            {
                throw new ParseException(@"Version != 2");
            }

            Padding = (bytes[startIndex] & 0x20) != 0;
            Count   = bytes[startIndex] & 0x1f;

            startIndex++;

            if (Enum.IsDefined(typeof(RtcpMessageType), (int)bytes[startIndex]) == false)
            {
                throw new ParseException(@"Invalid RtcpMessageType");
            }
            MessageType = (RtcpMessageType)bytes[startIndex++];

            Length = (bytes.BigendianToUInt16(ref startIndex) + 1) * 4;
            if (Length > length - startIndex + HeaderLength)
            {
                throw new ParseException(@"Invalid Length");
            }
            int packetDataLength = startIndex + Length - HeaderLength;

            switch (MessageType)
            {
            case RtcpMessageType.SenderReport:
                SenderReport = new SenderReportPacket();
                SenderReport.Parse(bytes, ref startIndex, packetDataLength, Count);
                break;

            case RtcpMessageType.ReceiverReport:
                ReceiverReport = new ReceiverReportPacket();
                ReceiverReport.Parse(bytes, ref startIndex, packetDataLength, Count);
                break;

            case RtcpMessageType.SourceDescription:
                SourceDescription = new SourceDescriptionPacket();
                SourceDescription.Parse(bytes, ref startIndex, packetDataLength, Count);
                break;

            case RtcpMessageType.Goodbye:
                Goodbye = new GoodbyePacket();
                Goodbye.Parse(bytes, ref startIndex, packetDataLength, Count);
                break;

            case RtcpMessageType.ApplicationDefined:
                ApplicationDefined = new ApplicationDefinedPacket();
                ApplicationDefined.Parse(bytes, ref startIndex, packetDataLength, Count);
                break;

            default:
                throw new Exception();
            }
        }
Beispiel #2
0
		protected void Parse2(byte[] bytes, ref int startIndex, int length)
		{
			Version = (bytes[startIndex] & 0xb0) >> 6;
			if (Version != 2)
				throw new ParseException(@"Version != 2");

			Padding = (bytes[startIndex] & 0x20) != 0;
			Count = bytes[startIndex] & 0x1f;

			startIndex++;

			if (Enum.IsDefined(typeof(RtcpMessageType), (int)bytes[startIndex]) == false)
				throw new ParseException(@"Invalid RtcpMessageType");
			MessageType = (RtcpMessageType)bytes[startIndex++];

			Length = (bytes.BigendianToUInt16(ref startIndex) + 1) * 4;
			if (Length > length - startIndex + HeaderLength)
				throw new ParseException(@"Invalid Length");
			int packetDataLength = startIndex + Length - HeaderLength;

			switch (MessageType)
			{
				case RtcpMessageType.SenderReport:
					SenderReport = new SenderReportPacket();
					SenderReport.Parse(bytes, ref startIndex, packetDataLength, Count);
					break;

				case RtcpMessageType.ReceiverReport:
					ReceiverReport = new ReceiverReportPacket();
					ReceiverReport.Parse(bytes, ref startIndex, packetDataLength, Count);
					break;

				case RtcpMessageType.SourceDescription:
					SourceDescription = new SourceDescriptionPacket();
					SourceDescription.Parse(bytes, ref startIndex, packetDataLength, Count);
					break;

				case RtcpMessageType.Goodbye:
					Goodbye = new GoodbyePacket();
					Goodbye.Parse(bytes, ref startIndex, packetDataLength, Count);
					break;

				case RtcpMessageType.ApplicationDefined:
					ApplicationDefined = new ApplicationDefinedPacket();
					ApplicationDefined.Parse(bytes, ref startIndex, packetDataLength, Count);
					break;

				default:
					throw new Exception();
			}
		}