コード例 #1
0
        public ConnectionData ReadValue(ReadOnlySpan <byte> data)
        {
            var remainingSlice = data;

            // header
            SerializationHelpers.ParseRequiredHeader("Connection Data field", remainingSlice, HeaderBytes);
            remainingSlice = remainingSlice.Slice(HeaderBytes.Length);

            var connData = new ConnectionData();

            // nettype
            connData.Nettype =
                SerializationHelpers.ParseRequiredString("Connection Data field: nettype",
                                                         SerializationHelpers.NextRequiredDelimitedField("Connection Data field: nettype", SDPSerializer.ByteSpace, remainingSlice, out var consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // addrtype
            connData.AddrType =
                SerializationHelpers.ParseRequiredString("Connection Data field: addrtype",
                                                         SerializationHelpers.NextRequiredDelimitedField("Connection Data field: addrtype", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // connection-address
            connData.ConnectionAddress =
                SerializationHelpers.ParseRequiredString("Connection Data field: connection-address", remainingSlice);

            return(connData);
        }
コード例 #2
0
        public DeserializationState ReadValue(ReadOnlySpan <byte> data, DeserializationSession session)
        {
            var remainingSlice = data;

            //header
            SerializationHelpers.ParseRequiredHeader("Origin field", remainingSlice, HeaderBytes);
            remainingSlice = remainingSlice.Slice(HeaderBytes.Length);

            session.ParsedValue.Origin = new Origin();

            //username
            session.ParsedValue.Origin.UserName =
                SerializationHelpers.ParseRequiredString("Origin field: username",
                                                         SerializationHelpers.NextRequiredDelimitedField("Origin field: username", SDPSerializer.ByteSpace, remainingSlice, out var consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            //sess-id
            session.ParsedValue.Origin.SessionId = SerializationHelpers.ParseLong("Origin field: sess-id",
                                                                                  SerializationHelpers.NextRequiredDelimitedField("Origin field: sess-id", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            //sess-version
            session.ParsedValue.Origin.SessionVersion = SerializationHelpers.ParseLong("Origin field: sess-version",
                                                                                       SerializationHelpers.NextRequiredDelimitedField("Origin field: sess-version", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            //nettype
            session.ParsedValue.Origin.Nettype =
                SerializationHelpers.ParseRequiredString("Origin field: nettype",
                                                         SerializationHelpers.NextRequiredDelimitedField("Origin field: nettype", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            //addrtype
            session.ParsedValue.Origin.AddrType =
                SerializationHelpers.ParseRequiredString("Origin field: addrtype",
                                                         SerializationHelpers.NextRequiredDelimitedField("Origin field: addrtype", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // unicast-address
            session.ParsedValue.Origin.UnicastAddress =
                SerializationHelpers.ParseRequiredString("Origin field: unicast-address", remainingSlice);

            return(SessionNameSerializer.Instance.ReadValue);
        }
コード例 #3
0
        public RepeatTime ReadValue(ReadOnlySpan <byte> data)
        {
            var remainingSlice = data;

            //header
            SerializationHelpers.ParseRequiredHeader("Repeat Time field", remainingSlice, HeaderBytes);
            remainingSlice = remainingSlice.Slice(HeaderBytes.Length);

            var rt = new RepeatTime()
            {
                OffsetsFromStartTime = new List <TimeSpan>()
            };

            //repeat interval
            rt.RepeatInterval =
                SerializationHelpers.ParseRequiredTimespan("Repeat Time field: repeat interval",
                                                           SerializationHelpers.NextRequiredDelimitedField("Repeat Time field: repeat interval", SDPSerializer.ByteSpace, remainingSlice, out var consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            //active duration
            rt.ActiveDuration =
                SerializationHelpers.ParseRequiredTimespan("Repeat Time field: active duration",
                                                           SerializationHelpers.NextRequiredDelimitedField("Repeat Time field: active duration", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            //offsets from start-time
            ReadOnlySpan <byte> token;

            while ((token = SerializationHelpers.NextDelimitedField(SDPSerializer.ByteSpace, remainingSlice, out consumed)) != null)
            {
                rt.OffsetsFromStartTime.Add(SerializationHelpers.ParseRequiredTimespan("Repeat Time field: offsets from start-time are required", token));

                //There is no remaining peace left
                if (remainingSlice.Length <= consumed + 1)
                {
                    break;
                }

                remainingSlice = remainingSlice.Slice(consumed + 1);
            }

            return(rt);
        }
コード例 #4
0
        public MediaDescription ReadValue(ReadOnlySpan <byte> data)
        {
            var remainingSlice = data;

            //header
            SerializationHelpers.ParseRequiredHeader("Media field", remainingSlice, HeaderBytes);
            remainingSlice = remainingSlice.Slice(HeaderBytes.Length);

            var mDescr = new MediaDescription();

            // Media
            mDescr.Media =
                SerializationHelpers.ParseRequiredString("Media field: Media",
                                                         SerializationHelpers.NextRequiredDelimitedField("Media field: Media", SDPSerializer.ByteSpace, remainingSlice, out var consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // port
            mDescr.Port =
                SerializationHelpers.ParseRequiredString("Media field: Port",
                                                         SerializationHelpers.NextRequiredDelimitedField("Media field: Port", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // Proto
            mDescr.Proto =
                SerializationHelpers.ParseRequiredString("Media field: Proto",
                                                         SerializationHelpers.NextRequiredDelimitedField("Media field: Proto", SDPSerializer.ByteSpace, remainingSlice, out consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // fmt
            if (remainingSlice.Length == 0)
            {
                throw new DeserializationException("Invalid Media field: fmt, expected required values");
            }
            else
            {
                mDescr.Fmts = Encoding.UTF8.GetString(remainingSlice).Split((char)SDPSerializer.ByteSpace);
            }

            return(mDescr);
        }
コード例 #5
0
        public Bandwidth ReadValue(ReadOnlySpan <byte> data)
        {
            var remainingSlice = data;

            // header
            SerializationHelpers.ParseRequiredHeader("Bandwith field", remainingSlice, HeaderBytes);
            remainingSlice = remainingSlice.Slice(HeaderBytes.Length);

            var bandwith = new Bandwidth();

            // type
            bandwith.Type =
                SerializationHelpers.ParseRequiredString("Bandwith field: Type",
                                                         SerializationHelpers.NextRequiredDelimitedField("Bandwith field: Type", SDPSerializer.ByteColon, remainingSlice, out var consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // value
            bandwith.Value =
                SerializationHelpers.ParseRequiredString("Bandwith field: value", remainingSlice);

            return(bandwith);
        }
コード例 #6
0
        public TimingInfo ReadValue(ReadOnlySpan <byte> data)
        {
            var remainingSlice = data;

            //header
            SerializationHelpers.ParseRequiredHeader("Timing field", data, HeaderBytes);
            remainingSlice = remainingSlice.Slice(HeaderBytes.Length);

            var tim = new TimingInfo();

            // StartTime
            tim.StartTime =
                SerializationHelpers.ParseLong("Timing field: startTime",
                                               SerializationHelpers.NextRequiredDelimitedField("Timing field: startTime", SDPSerializer.ByteSpace, remainingSlice, out var consumed));
            remainingSlice = remainingSlice.Slice(consumed + 1);

            // StopTime
            tim.StopTime =
                SerializationHelpers.ParseLong("Timing field: stoptime",
                                               SerializationHelpers.NextRequiredField("StopTime field: stoptime", remainingSlice));

            return(tim);
        }