mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 23:26:58 +08:00
Bump SRTP/RTCP and update RTCP API
Reading/Writing RTCP packets now return a slice Relates to pion/srtp#29
This commit is contained in:
@@ -85,7 +85,7 @@ func main() {
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second * 3)
|
||||
for range ticker.C {
|
||||
errSend := peerConnection.WriteRTCP(&rtcp.PictureLossIndication{MediaSSRC: track.SSRC()})
|
||||
errSend := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: track.SSRC()}})
|
||||
if errSend != nil {
|
||||
fmt.Println(errSend)
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ func main() {
|
||||
go func() {
|
||||
ticker := time.NewTicker(rtcpPLIInterval)
|
||||
for range ticker.C {
|
||||
if rtcpSendErr := peerConnection.WriteRTCP(&rtcp.PictureLossIndication{MediaSSRC: remoteTrack.SSRC()}); rtcpSendErr != nil {
|
||||
if rtcpSendErr := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: remoteTrack.SSRC()}}); rtcpSendErr != nil {
|
||||
fmt.Println(rtcpSendErr)
|
||||
}
|
||||
}
|
||||
|
4
go.mod
4
go.mod
@@ -8,11 +8,11 @@ require (
|
||||
github.com/pion/ice v0.2.1
|
||||
github.com/pion/logging v0.2.1
|
||||
github.com/pion/quic v0.1.1
|
||||
github.com/pion/rtcp v1.1.5
|
||||
github.com/pion/rtcp v1.2.0
|
||||
github.com/pion/rtp v1.1.1
|
||||
github.com/pion/sctp v1.5.0
|
||||
github.com/pion/sdp/v2 v2.1.1
|
||||
github.com/pion/srtp v1.2.1
|
||||
github.com/pion/srtp v1.2.3
|
||||
github.com/pion/transport v0.6.0
|
||||
github.com/stretchr/testify v1.3.0
|
||||
)
|
||||
|
8
go.sum
8
go.sum
@@ -31,16 +31,16 @@ github.com/pion/logging v0.2.1 h1:LwASkBKZ+2ysGJ+jLv1E/9H1ge0k1nTfi1X+5zirkDk=
|
||||
github.com/pion/logging v0.2.1/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
||||
github.com/pion/quic v0.1.1 h1:D951FV+TOqI9A0rTF7tHx0Loooqz+nyzjEyj8o3PuMA=
|
||||
github.com/pion/quic v0.1.1/go.mod h1:zEU51v7ru8Mp4AUBJvj6psrSth5eEFNnVQK5K48oV3k=
|
||||
github.com/pion/rtcp v1.1.5 h1:UO4u+U3IYVzA1tWCNrR+hUo02tpOrn4elwZ9pQzBVKo=
|
||||
github.com/pion/rtcp v1.1.5/go.mod h1:a5dj2d6BKIKHl43EnAOIrCczcjESrtPuMgfmL6/K6QM=
|
||||
github.com/pion/rtcp v1.2.0 h1:rT2FptW5YHIern+4XlbGYnnsT26XGxurnkNLnzhtDXg=
|
||||
github.com/pion/rtcp v1.2.0/go.mod h1:a5dj2d6BKIKHl43EnAOIrCczcjESrtPuMgfmL6/K6QM=
|
||||
github.com/pion/rtp v1.1.1 h1:lag+9/lSOLBEYeYB/28KXm/ka1H++4wkmSj/WkttV6Y=
|
||||
github.com/pion/rtp v1.1.1/go.mod h1:/l4cvcKd0D3u9JLs2xSVI95YkfXW87a3br3nqmVtSlE=
|
||||
github.com/pion/sctp v1.5.0 h1:VcixluIP/XBKL3wRRYIzpvbkFQFVs2yUWJo1NUivy7k=
|
||||
github.com/pion/sctp v1.5.0/go.mod h1:btfZTRxsoVwp7PfvorgOKqkxV/BKHGGrNf1YUKnMGRQ=
|
||||
github.com/pion/sdp/v2 v2.1.1 h1:i3fAyjiLuQseYNo0BtCOPfzp91Ppb7vasRGmUUTog28=
|
||||
github.com/pion/sdp/v2 v2.1.1/go.mod h1:idSlWxhfWQDtTy9J05cgxpHBu/POwXN2VDRGYxT/EjU=
|
||||
github.com/pion/srtp v1.2.1 h1:t31SdcMM22MI1Slu591uhX/aVrvNSPpO0XnR62v9x7k=
|
||||
github.com/pion/srtp v1.2.1/go.mod h1:clAbcxURqAYE9KrsByaBCPK7vUC553yKJ99oHnso5YY=
|
||||
github.com/pion/srtp v1.2.3 h1:apLkkpGRr4DLX5w9ouE7pQR0cXyj8L27I35Cxzk0RGs=
|
||||
github.com/pion/srtp v1.2.3/go.mod h1:17CD1YQ0gb5UtcQnwUKhS8gIKHBMlyNQcxtXZ99xhEA=
|
||||
github.com/pion/stun v0.2.1 h1:rSKJ0ynYkRalRD8BifmkaGLeepCFuGTwG6FxPsrPK8o=
|
||||
github.com/pion/stun v0.2.1/go.mod h1:TChCNKgwnFiFG/c9K+zqEdd6pO6tlODb9yN1W/zVfsE=
|
||||
github.com/pion/transport v0.6.0 h1:WAoyJg/6OI8dhCVFl/0JHTMd1iu2iHgGUXevptMtJ3U=
|
||||
|
@@ -1523,8 +1523,8 @@ func (pc *PeerConnection) SetIdentityProvider(provider string) error {
|
||||
|
||||
// WriteRTCP sends a user provided RTCP packet to the connected peer
|
||||
// If no peer is connected the packet is discarded
|
||||
func (pc *PeerConnection) WriteRTCP(pkt rtcp.Packet) error {
|
||||
raw, err := pkt.Marshal()
|
||||
func (pc *PeerConnection) WriteRTCP(pkts []rtcp.Packet) error {
|
||||
raw, err := rtcp.Marshal(pkts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1638,7 +1638,7 @@ func (pc *PeerConnection) addTransceiverSDP(d *sdp.SessionDescription, midValue
|
||||
WithValueAttribute(sdp.AttrKeyMID, midValue).
|
||||
WithICECredentials(iceParams.UsernameFragment, iceParams.Password).
|
||||
WithPropertyAttribute(sdp.AttrKeyRTCPMux). // TODO: support RTCP fallback
|
||||
WithPropertyAttribute(sdp.AttrKeyRTCPRsize) // TODO: Support Reduced-Size RTCP?
|
||||
WithPropertyAttribute(sdp.AttrKeyRTCPRsize)
|
||||
|
||||
codecs := pc.api.mediaEngine.getCodecsByKind(t.kind)
|
||||
for _, codec := range codecs {
|
||||
|
@@ -58,7 +58,7 @@ func TestPeerConnection_Media_Sample(t *testing.T) {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
if routineErr := pcAnswer.WriteRTCP(&rtcp.RapidResynchronizationRequest{SenderSSRC: track.SSRC(), MediaSSRC: track.SSRC()}); routineErr != nil {
|
||||
if routineErr := pcAnswer.WriteRTCP([]rtcp.Packet{&rtcp.RapidResynchronizationRequest{SenderSSRC: track.SSRC(), MediaSSRC: track.SSRC()}}); routineErr != nil {
|
||||
awaitRTCPRecieverSend <- routineErr
|
||||
return
|
||||
}
|
||||
@@ -122,7 +122,7 @@ func TestPeerConnection_Media_Sample(t *testing.T) {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
if routineErr := pcOffer.WriteRTCP(&rtcp.PictureLossIndication{SenderSSRC: vp8Track.SSRC(), MediaSSRC: vp8Track.SSRC()}); routineErr != nil {
|
||||
if routineErr := pcOffer.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{SenderSSRC: vp8Track.SSRC(), MediaSSRC: vp8Track.SSRC()}}); routineErr != nil {
|
||||
awaitRTCPSenderSend <- routineErr
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ func TestPeerConnection_Media_Disconnected(t *testing.T) {
|
||||
for i := 0; i <= 5; i++ {
|
||||
if rtpErr := vp8Track.WriteSample(media.Sample{Data: []byte{0x00}, Samples: 1}); rtpErr != nil {
|
||||
t.Fatal(rtpErr)
|
||||
} else if rtcpErr := pcOffer.WriteRTCP(&rtcp.PictureLossIndication{MediaSSRC: 0}); rtcpErr != nil {
|
||||
} else if rtcpErr := pcOffer.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: 0}}); rtcpErr != nil {
|
||||
t.Fatal(rtcpErr)
|
||||
}
|
||||
}
|
||||
@@ -440,7 +440,7 @@ func TestPeerConnection_Media_Closed(t *testing.T) {
|
||||
t.Fatal("Write to Track with no RTPSenders did not return io.ErrClosedPipe")
|
||||
}
|
||||
|
||||
if err = pcAnswer.WriteRTCP(&rtcp.RapidResynchronizationRequest{SenderSSRC: 0, MediaSSRC: 0}); err != io.ErrClosedPipe {
|
||||
if err = pcAnswer.WriteRTCP([]rtcp.Packet{&rtcp.RapidResynchronizationRequest{SenderSSRC: 0, MediaSSRC: 0}}); err != io.ErrClosedPipe {
|
||||
t.Fatal("WriteRTCP to closed PeerConnection did not return io.ErrClosedPipe")
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ func (r *RTPReceiver) Read(b []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
// ReadRTCP is a convenience method that wraps Read and unmarshals for you
|
||||
func (r *RTPReceiver) ReadRTCP() (rtcp.Packet, error) {
|
||||
func (r *RTPReceiver) ReadRTCP() ([]rtcp.Packet, error) {
|
||||
b := make([]byte, receiveMTU)
|
||||
i, err := r.Read(b)
|
||||
if err != nil {
|
||||
|
@@ -123,7 +123,7 @@ func (r *RTPSender) Read(b []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
// ReadRTCP is a convenience method that wraps Read and unmarshals for you
|
||||
func (r *RTPSender) ReadRTCP() (rtcp.Packet, error) {
|
||||
func (r *RTPSender) ReadRTCP() ([]rtcp.Packet, error) {
|
||||
b := make([]byte, receiveMTU)
|
||||
i, err := r.Read(b)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user