public DeserializationState ReadValue(ReadOnlySpan <byte> data, DeserializationSession session) { if (session.ParsedValue.Uri != null) { throw new DeserializationException("No more than one URI field is allowed per session description"); } if (session.ParsedValue.MediaDescriptions != null && session.ParsedValue.MediaDescriptions.Any()) { throw new DeserializationException($"Uri MUST be specified before the first media field"); } var remainingSlice = data; //header SerializationHelpers.ParseRequiredHeader("Uri field", remainingSlice, HeaderBytes); remainingSlice = remainingSlice.Slice(HeaderBytes.Length); //uri var uriString = SerializationHelpers.ParseRequiredString("Uri field", SerializationHelpers.NextRequiredField("Uri field", remainingSlice)); if (Uri.TryCreate(uriString, UriKind.RelativeOrAbsolute, out var parsedUri)) { session.ParsedValue.Uri = parsedUri; } else { throw new DeserializationException($"Invalid Uri field value: {uriString}"); } return(OptionalValueDeSerializer.Instance.ReadValue); }
public byte[] ReadValue(ReadOnlySpan <byte> data) { var remainingSlice = data; //header SerializationHelpers.ParseRequiredHeader("Media title field", data, HeaderBytes); remainingSlice = remainingSlice.Slice(HeaderBytes.Length); //value return(SerializationHelpers.NextRequiredField("Media title", remainingSlice).ToArray()); }
public DeserializationState ReadValue(ReadOnlySpan <byte> data, DeserializationSession session) { var remainingSlice = data; //header SerializationHelpers.ParseRequiredHeader("Session name", data, HeaderBytes); remainingSlice = remainingSlice.Slice(HeaderBytes.Length); //value session.ParsedValue.SessionName = SerializationHelpers.NextRequiredField("Session name", remainingSlice).ToArray(); return(OptionalValueDeSerializer.Instance.ReadValue); }
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); }
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); }