mirror of
https://github.com/jech/galene.git
synced 2024-12-23 15:55:47 +01:00
36 lines
1 KiB
Go
36 lines
1 KiB
Go
|
package webserver
|
||
|
|
||
|
import (
|
||
|
"strings"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/pion/webrtc/v3"
|
||
|
)
|
||
|
|
||
|
func TestParseSDPFrag(t *testing.T) {
|
||
|
sdp := `a=ice-ufrag:FZ0m
|
||
|
a=ice-pwd:NRT+gj1EhsEwMm9MA7ljzBRy
|
||
|
m=audio 9 UDP/TLS/RTP/SAVPF 0
|
||
|
a=mid:0
|
||
|
a=candidate:2930517337 1 udp 2113937151 1eaafdf1-4127-499f-90d4-8c35ea49d5e6.local 44360 typ host generation 0 ufrag FZ0m network-cost 999
|
||
|
2024/09/30 00:07:41 {candidate:2930517337 1 udp 2113937151 1eaafdf1-4127-499f-90d4-8c35ea49d5e6.local 44360 typ host generation 0 ufrag FZ0m network-cost 999 0xc00062a580 0xc000620288 0xc00062a590}
|
||
|
a=end-of-candidates`
|
||
|
r := strings.NewReader(sdp)
|
||
|
candidates := []webrtc.ICECandidateInit(nil)
|
||
|
err := parseSDPFrag(r, func(c webrtc.ICECandidateInit) error {
|
||
|
candidates = append(candidates, c)
|
||
|
return nil
|
||
|
})
|
||
|
if err != nil {
|
||
|
t.Errorf("parseSDPFrag: %v", err)
|
||
|
}
|
||
|
if len(candidates) != 1 {
|
||
|
t.Errorf("Expected 1, got %v", candidates)
|
||
|
}
|
||
|
if *candidates[0].SDPMLineIndex != 0 ||
|
||
|
*candidates[0].SDPMid != "0" ||
|
||
|
*candidates[0].UsernameFragment != "FZ0m" {
|
||
|
t.Errorf("Got %v", candidates[0])
|
||
|
}
|
||
|
}
|