iOS Safari can't play stream properly
xpiaoyu opened this issue ยท 5 comments
Your environment.
- Version: v2.0.22
- Browser: iOS Safari 12.3
- Other Information - iOS Safari 12.3 do broadcast properly. However when I broadcast on Chrome or Firefox, the safari can't play the stream properly. It keeps loading.
What did you do?
Just use example sfu-minimal.
Chrome, Firefox on desktop can broadcast and play stream properly.
When I try to receive stream and play it on iOS Safari, it just keeps loading state.
Then I check the bandwith, it shows that the stream is transfering to Safari.(TX:~50KB/S RX:~50KB/S only one broadcaster, one receiver)
BTW, Chome on Android seems had the same problem.
What did you expect?
Safari on iOS and Chrome on Android can play stream properly.
What happened?
It keeps on loading.
Have you checked the SDP for each peer? It might be worth pasting the rtpmaps here so we can see if all peers are using the same payload type for each codec. sfuminimal is using the pion default payload type for VP8, which may not be compatible with Safari.
Thanks for replying.
Below is Safari on iOS 12.3 offer
a=sendrecv
a=msid:- 2f1544ed-c0d4-4da2-b159-af193d550b3a
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 H264/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=fmtp:96 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640c1f
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 H264/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 VP8/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:127 red/90000
a=rtpmap:125 rtx/90000
a=fmtp:125 apt=127
a=rtpmap:104 ulpfec/90000
a=ssrc-group:FID 2032056555 1854427595
a=ssrc:2032056555 cname:/DKepec8hbM0SBlw
a=ssrc:2032056555 msid:- 2f1544ed-c0d4-4da2-b159-af193d550b3a
a=ssrc:2032056555 mslabel:-
a=ssrc:2032056555 label:2f1544ed-c0d4-4da2-b159-af193d550b3a
a=ssrc:1854427595 cname:/DKepec8hbM0SBlw
a=ssrc:1854427595 msid:- 2f1544ed-c0d4-4da2-b159-af193d550b3a
a=ssrc:1854427595 mslabel:-
a=ssrc:1854427595 label:2f1544ed-c0d4-4da2-b159-af193d550b3a
m=audio 50596 UDP/TLS/RTP/SAVPF 111 103 9 102 0 8 105 13 110 113 126
c=IN IP4 172.27.0.17
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:2832760603 1 udp 33562367 172.27.0.17 50596 typ relay raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=candidate:842163049 1 udp 1677729535 112.25.149.138 60679 typ srflx raddr 0.0.0.0 rport 0 generation 0 network-cost 999
a=ice-ufrag:Wy0M
a=ice-pwd:h7Che4woBTsbM0LdJY4Cu6TM
a=ice-options:trickle
a=fingerprint:sha-256 A0:0A:0C:48:CB:D8:B7:20:20:71:44:E7:94:AE:7D:96:E6:89:18:3D:61:08:45:A8:A5:63:C0:2F:D5:D8:EB:77
a=setup:actpass
a=mid:1
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid
a=sendrecv
a=msid:- 76c04ab0-81fb-4dbb-a81a-8b8a73c99210
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:806797980 cname:/DKepec8hbM0SBlw
a=ssrc:806797980 msid:- 76c04ab0-81fb-4dbb-a81a-8b8a73c99210
a=ssrc:806797980 mslabel:-
a=ssrc:806797980 label:76c04ab0-81fb-4dbb-a81a-8b8a73c99210
Then this is the pion webrtc server answer
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=ssrc:504957125 cname:pion
a=ssrc:504957125 msid:pion video
a=ssrc:504957125 mslabel:pion
a=ssrc:504957125 label:video
a=sendrecv
a=candidate:foundation 1 udp 2130706431 192.168.1.96 58717 typ host generation 0
a=candidate:foundation 2 udp 2130706431 192.168.1.96 58717 typ host generation 0
a=candidate:foundation 1 udp 16777215 172.27.0.17 64021 typ relay raddr 192.168.1.96 rport 58718 generation 0
a=candidate:foundation 2 udp 16777215 172.27.0.17 64021 typ relay raddr 192.168.1.96 rport 58718 generation 0
a=end-of-candidates
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=setup:active
a=mid:1
a=ice-ufrag:xWRAvyHNoJFzSZuE
a=ice-pwd:xWRAvyHNoJFzSZuEtucticVoZjaqDKAC
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:111 opus/48000/2
a=fmtp:111 minptime=10;useinbandfec=1
a=ssrc:3037093397 cname:pion
a=ssrc:3037093397 msid:pion audio
a=ssrc:3037093397 mslabel:pion
a=ssrc:3037093397 label:audio
a=sendrecv
a=candidate:foundation 1 udp 2130706431 192.168.1.96 58717 typ host generation 0
a=candidate:foundation 2 udp 2130706431 192.168.1.96 58717 typ host generation 0
a=candidate:foundation 1 udp 16777215 172.27.0.17 64021 typ relay raddr 192.168.1.96 rport 58718 generation 0
a=candidate:foundation 2 udp 16777215 172.27.0.17 64021 typ relay raddr 192.168.1.96 rport 58718 generation 0
a=end-of-candidates
iOS 12.3 seems had supported VP8 codec
It looks like VP8 is mapped to payload type 100
in the offer:
a=rtpmap:100 VP8/90000
but Pion maps VP8 to 96
in the answer:
a=rtpmap:96 VP8/90000
Try re-testing with sfu-minimal
modified to map VP8 to 100
explicitly, i.e.:
// Setup the codecs you want to use.
// Only support VP8, this makes our proxying code simpler
- m.RegisterCodec(webrtc.NewRTPVP8Codec(webrtc.DefaultPayloadTypeVP8, 90000))
+ m.RegisterCodec(webrtc.NewRTPVP8Codec(100, 90000))
If this works for Safari it will probably break the other two. In that case you may have to dynamically determine the payload type when creating the media engine, so that the payload types match what is in the incoming offers from each peer.
Implementing payload type detection can be achieved by doing something similar to:
parsed := sdp.SessionDescription{}
if err := parsed.Unmarshal([]byte(offer.SDP)); err != nil {
return err
}
vp8 := sdp.Codec{
Name: "VP8",
}
payloadType, err := parsed.GetPayloadTypeForCodec(vp8)
if err != nil {
return err
}
m := webrtc.MediaEngine{}
m.RegisterCodec(webrtc.NewRTPVP8Codec(payloadType, 90000))