Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public DeserializationState ReadValue(ReadOnlySpan <byte> data, DeserializationSession session)
        {
            if (session.ParsedValue.MediaDescriptions != null && session.ParsedValue.MediaDescriptions.Any())
            {
                throw new DeserializationException("Email address MUST be specified before the first media field");
            }

            var remainingSlice = data;

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

            //uri
            var emailString =
                SerializationHelpers.ParseRequiredString("Email field",
                                                         SerializationHelpers.NextRequiredField("Email field", remainingSlice));

            session.ParsedValue.EmailNumbers = session.ParsedValue.EmailNumbers ?? new List <string>();
            session.ParsedValue.EmailNumbers.Add(emailString);
            return(OptionalValueDeSerializer.Instance.ReadValue);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }