Fix SDP parsing for repeat time field with no offsets (#880)

Co-authored-by: Nicolas BRAINEZ <nicolas.brainez@ext.ec.europa.eu>
This commit is contained in:
nicoske
2025-09-05 23:04:30 +02:00
committed by GitHub
parent a8513af402
commit 1bc89661eb
2 changed files with 52 additions and 1 deletions

View File

@@ -393,7 +393,7 @@ func parseTimeUnits(value string) (int64, error) {
func (s *SessionDescription) unmarshalRepeatTimes(value string) error {
fields := strings.Fields(value)
if len(fields) < 3 {
if len(fields) < 2 {
return fmt.Errorf("%w `r=%v`", errSDPInvalidSyntax, value)
}

View File

@@ -3198,6 +3198,57 @@ var cases = []struct {
},
},
},
{
"AJA encoder with repeat time r=0 0",
[]byte("v=0\r\n" +
"o=VNSDK 0 0 IN IP4 10.0.8.133\r\n" +
"s=aja.sdp\r\n" +
"c=IN IP4 10.0.8.133\r\n" +
"t=0 0\r\n" +
"r=0 0\r\n" +
"m=video 0 RTP/AVP 96\r\n"),
[]byte("v=0\r\n" +
"o=VNSDK 0 0 IN IP4 10.0.8.133\r\n" +
"s=aja.sdp\r\n" +
"c=IN IP4 10.0.8.133\r\n" +
"t=0 0\r\n" +
"r=0 0\r\n" +
"m=video 0 RTP/AVP 96\r\n"),
SessionDescription{
Origin: psdp.Origin{
Username: "VNSDK",
SessionID: 0,
SessionVersion: 0,
NetworkType: "IN",
AddressType: "IP4",
UnicastAddress: "10.0.8.133",
},
SessionName: "aja.sdp",
ConnectionInformation: &psdp.ConnectionInformation{
NetworkType: "IN",
AddressType: "IP4",
Address: &psdp.Address{
Address: "10.0.8.133",
},
},
TimeDescriptions: []psdp.TimeDescription{
{
Timing: psdp.Timing{StartTime: 0, StopTime: 0},
RepeatTimes: []psdp.RepeatTime{{Interval: 0, Duration: 0, Offsets: nil}},
},
},
MediaDescriptions: []*psdp.MediaDescription{
{
MediaName: psdp.MediaName{
Media: "video",
Port: psdp.RangedPort{Value: 0},
Protos: []string{"RTP", "AVP"},
Formats: []string{"96"},
},
},
},
},
},
}
func TestUnmarshal(t *testing.T) {