mirror of
https://github.com/pion/webrtc.git
synced 2025-10-21 14:19:31 +08:00
Fix linter errors
golangci-lint upgrade to v1.56.2 added more checks Relates to pion/.goassets#201
This commit is contained in:
@@ -52,7 +52,7 @@ func TestDataChannel_EventHandlers(t *testing.T) {
|
|||||||
close(onOpenCalled)
|
close(onOpenCalled)
|
||||||
})
|
})
|
||||||
|
|
||||||
dc.OnMessage(func(p DataChannelMessage) {
|
dc.OnMessage(func(DataChannelMessage) {
|
||||||
close(onMessageCalled)
|
close(onMessageCalled)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
answerDC.OnMessage(func(msg DataChannelMessage) {
|
answerDC.OnMessage(func(DataChannelMessage) {
|
||||||
atomic.AddUint32(&nAnswerReceived, 1)
|
atomic.AddUint32(&nAnswerReceived, 1)
|
||||||
})
|
})
|
||||||
assert.True(t, answerDC.Ordered(), "Ordered should be set to true")
|
assert.True(t, answerDC.Ordered(), "Ordered should be set to true")
|
||||||
@@ -259,7 +259,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
offerDC.OnMessage(func(msg DataChannelMessage) {
|
offerDC.OnMessage(func(DataChannelMessage) {
|
||||||
atomic.AddUint32(&nOfferReceived, 1)
|
atomic.AddUint32(&nOfferReceived, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var nPacketsReceived int
|
var nPacketsReceived int
|
||||||
d.OnMessage(func(msg DataChannelMessage) {
|
d.OnMessage(func(DataChannelMessage) {
|
||||||
nPacketsReceived++
|
nPacketsReceived++
|
||||||
|
|
||||||
if nPacketsReceived == 10 {
|
if nPacketsReceived == 10 {
|
||||||
@@ -347,7 +347,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
dc.OnMessage(func(msg DataChannelMessage) {
|
dc.OnMessage(func(DataChannelMessage) {
|
||||||
})
|
})
|
||||||
|
|
||||||
err = signalPair(offerPC, answerPC)
|
err = signalPair(offerPC, answerPC)
|
||||||
|
@@ -135,7 +135,7 @@ func TestDataChannel_Open(t *testing.T) {
|
|||||||
d.OnOpen(func() {
|
d.OnOpen(func() {
|
||||||
openCalls <- true
|
openCalls <- true
|
||||||
})
|
})
|
||||||
d.OnMessage(func(msg DataChannelMessage) {
|
d.OnMessage(func(DataChannelMessage) {
|
||||||
go func() {
|
go func() {
|
||||||
// Wait a little bit to ensure all messages are processed.
|
// Wait a little bit to ensure all messages are processed.
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
@@ -191,7 +191,7 @@ func TestDataChannel_Open(t *testing.T) {
|
|||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
answerDC.OnMessage(func(msg DataChannelMessage) {
|
answerDC.OnMessage(func(DataChannelMessage) {
|
||||||
go func() {
|
go func() {
|
||||||
// Wait a little bit to ensure all messages are processed.
|
// Wait a little bit to ensure all messages are processed.
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
@@ -237,7 +237,7 @@ func TestDataChannel_Send(t *testing.T) {
|
|||||||
if d.Label() != expectedLabel {
|
if d.Label() != expectedLabel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
d.OnMessage(func(msg DataChannelMessage) {
|
d.OnMessage(func(DataChannelMessage) {
|
||||||
e := d.Send([]byte("Pong"))
|
e := d.Send([]byte("Pong"))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
t.Fatalf("Failed to send string on data channel")
|
t.Fatalf("Failed to send string on data channel")
|
||||||
@@ -259,7 +259,7 @@ func TestDataChannel_Send(t *testing.T) {
|
|||||||
t.Fatalf("Failed to send string on data channel")
|
t.Fatalf("Failed to send string on data channel")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
dc.OnMessage(func(msg DataChannelMessage) {
|
dc.OnMessage(func(DataChannelMessage) {
|
||||||
done <- true
|
done <- true
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ func TestDataChannel_Send(t *testing.T) {
|
|||||||
if d.Label() != expectedLabel {
|
if d.Label() != expectedLabel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
d.OnMessage(func(msg DataChannelMessage) {
|
d.OnMessage(func(DataChannelMessage) {
|
||||||
e := d.Send([]byte("Pong"))
|
e := d.Send([]byte("Pong"))
|
||||||
if e != nil {
|
if e != nil {
|
||||||
t.Fatalf("Failed to send string on data channel")
|
t.Fatalf("Failed to send string on data channel")
|
||||||
@@ -309,7 +309,7 @@ func TestDataChannel_Send(t *testing.T) {
|
|||||||
|
|
||||||
assert.True(t, dc.Ordered(), "Ordered should be set to true")
|
assert.True(t, dc.Ordered(), "Ordered should be set to true")
|
||||||
|
|
||||||
dc.OnMessage(func(msg DataChannelMessage) {
|
dc.OnMessage(func(DataChannelMessage) {
|
||||||
done <- true
|
done <- true
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ func TestDataChannelParameters(t *testing.T) {
|
|||||||
|
|
||||||
t.Fatal("OnDataChannel must not be fired when negotiated == true")
|
t.Fatal("OnDataChannel must not be fired when negotiated == true")
|
||||||
})
|
})
|
||||||
offerPC.OnDataChannel(func(d *DataChannel) {
|
offerPC.OnDataChannel(func(*DataChannel) {
|
||||||
t.Fatal("OnDataChannel must not be fired when negotiated == true")
|
t.Fatal("OnDataChannel must not be fired when negotiated == true")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -130,11 +130,11 @@ func TestPeerConnection_DTLSRoleSettingEngine(t *testing.T) {
|
|||||||
report := test.CheckRoutines(t)
|
report := test.CheckRoutines(t)
|
||||||
defer report()
|
defer report()
|
||||||
|
|
||||||
t.Run("Server", func(t *testing.T) {
|
t.Run("Server", func(*testing.T) {
|
||||||
runTest(DTLSRoleServer)
|
runTest(DTLSRoleServer)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Client", func(t *testing.T) {
|
t.Run("Client", func(*testing.T) {
|
||||||
runTest(DTLSRoleClient)
|
runTest(DTLSRoleClient)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -74,7 +74,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
estimatorChan := make(chan cc.BandwidthEstimator, 1)
|
estimatorChan := make(chan cc.BandwidthEstimator, 1)
|
||||||
congestionController.OnNewPeerConnection(func(id string, estimator cc.BandwidthEstimator) {
|
congestionController.OnNewPeerConnection(func(id string, estimator cc.BandwidthEstimator) { //nolint: revive
|
||||||
estimatorChan <- estimator
|
estimatorChan <- estimator
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ func main() { // nolint:gocognit
|
|||||||
localTrackChan := make(chan *webrtc.TrackLocalStaticRTP)
|
localTrackChan := make(chan *webrtc.TrackLocalStaticRTP)
|
||||||
// Set a handler for when a new remote track starts, this just distributes all our packets
|
// Set a handler for when a new remote track starts, this just distributes all our packets
|
||||||
// to connected peers
|
// to connected peers
|
||||||
peerConnection.OnTrack(func(remoteTrack *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(remoteTrack *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
// Create a local track, all our SFU clients will be fed via this track
|
// Create a local track, all our SFU clients will be fed via this track
|
||||||
localTrack, newTrackErr := webrtc.NewTrackLocalStaticRTP(remoteTrack.Codec().RTPCodecCapability, "video", "pion")
|
localTrack, newTrackErr := webrtc.NewTrackLocalStaticRTP(remoteTrack.Codec().RTPCodecCapability, "video", "pion")
|
||||||
if newTrackErr != nil {
|
if newTrackErr != nil {
|
||||||
|
@@ -80,7 +80,7 @@ func main() { // nolint:gocognit
|
|||||||
// A HTTP handler that allows the other Pion instance to send us ICE candidates
|
// A HTTP handler that allows the other Pion instance to send us ICE candidates
|
||||||
// This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN
|
// This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN
|
||||||
// candidates which may be slower
|
// candidates which may be slower
|
||||||
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { //nolint: revive
|
||||||
candidate, candidateErr := ioutil.ReadAll(r.Body)
|
candidate, candidateErr := ioutil.ReadAll(r.Body)
|
||||||
if candidateErr != nil {
|
if candidateErr != nil {
|
||||||
panic(candidateErr)
|
panic(candidateErr)
|
||||||
@@ -91,7 +91,7 @@ func main() { // nolint:gocognit
|
|||||||
})
|
})
|
||||||
|
|
||||||
// A HTTP handler that processes a SessionDescription given to us from the other Pion process
|
// A HTTP handler that processes a SessionDescription given to us from the other Pion process
|
||||||
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { // nolint: revive
|
||||||
sdp := webrtc.SessionDescription{}
|
sdp := webrtc.SessionDescription{}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&sdp); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&sdp); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@@ -80,7 +80,7 @@ func main() { //nolint:gocognit
|
|||||||
// A HTTP handler that allows the other Pion instance to send us ICE candidates
|
// A HTTP handler that allows the other Pion instance to send us ICE candidates
|
||||||
// This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN
|
// This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN
|
||||||
// candidates which may be slower
|
// candidates which may be slower
|
||||||
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { //nolint: revive
|
||||||
candidate, candidateErr := ioutil.ReadAll(r.Body)
|
candidate, candidateErr := ioutil.ReadAll(r.Body)
|
||||||
if candidateErr != nil {
|
if candidateErr != nil {
|
||||||
panic(candidateErr)
|
panic(candidateErr)
|
||||||
@@ -91,7 +91,7 @@ func main() { //nolint:gocognit
|
|||||||
})
|
})
|
||||||
|
|
||||||
// A HTTP handler that processes a SessionDescription given to us from the other Pion process
|
// A HTTP handler that processes a SessionDescription given to us from the other Pion process
|
||||||
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { //nolint: revive
|
||||||
sdp := webrtc.SessionDescription{}
|
sdp := webrtc.SessionDescription{}
|
||||||
if sdpErr := json.NewDecoder(r.Body).Decode(&sdp); sdpErr != nil {
|
if sdpErr := json.NewDecoder(r.Body).Decode(&sdp); sdpErr != nil {
|
||||||
panic(sdpErr)
|
panic(sdpErr)
|
||||||
|
@@ -112,7 +112,7 @@ func main() {
|
|||||||
|
|
||||||
// Set a handler for when a new remote track starts, this handler copies inbound RTP packets,
|
// Set a handler for when a new remote track starts, this handler copies inbound RTP packets,
|
||||||
// replaces the SSRC and sends them back
|
// replaces the SSRC and sends them back
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType)
|
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType)
|
||||||
for {
|
for {
|
||||||
// Read RTP packets being sent to Pion
|
// Read RTP packets being sent to Pion
|
||||||
|
@@ -131,7 +131,7 @@ func main() {
|
|||||||
// Set a handler for when a new remote track starts, this handler will forward data to
|
// Set a handler for when a new remote track starts, this handler will forward data to
|
||||||
// our UDP listeners.
|
// our UDP listeners.
|
||||||
// In your application this is where you would handle/process audio/video
|
// In your application this is where you would handle/process audio/video
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
// Retrieve udp connection
|
// Retrieve udp connection
|
||||||
c, ok := udpConns[track.Kind().String()]
|
c, ok := udpConns[track.Kind().String()]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@@ -101,7 +101,7 @@ func main() {
|
|||||||
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
|
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
|
||||||
// an ivf file, since we could have multiple video tracks we provide a counter.
|
// an ivf file, since we could have multiple video tracks we provide a counter.
|
||||||
// In your application this is where you would handle/process video
|
// In your application this is where you would handle/process video
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
if strings.EqualFold(track.Codec().MimeType, webrtc.MimeTypeAV1) {
|
if strings.EqualFold(track.Codec().MimeType, webrtc.MimeTypeAV1) {
|
||||||
fmt.Println("Got AV1 track, saving to disk as output.ivf")
|
fmt.Println("Got AV1 track, saving to disk as output.ivf")
|
||||||
saveToDisk(ivfFile, track)
|
saveToDisk(ivfFile, track)
|
||||||
|
@@ -121,7 +121,7 @@ func main() {
|
|||||||
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
|
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
|
||||||
// an ivf file, since we could have multiple video tracks we provide a counter.
|
// an ivf file, since we could have multiple video tracks we provide a counter.
|
||||||
// In your application this is where you would handle/process video
|
// In your application this is where you would handle/process video
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
codec := track.Codec()
|
codec := track.Codec()
|
||||||
if strings.EqualFold(codec.MimeType, webrtc.MimeTypeOpus) {
|
if strings.EqualFold(codec.MimeType, webrtc.MimeTypeOpus) {
|
||||||
fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)")
|
fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)")
|
||||||
|
@@ -99,7 +99,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set a handler for when a new remote track starts
|
// Set a handler for when a new remote track starts
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
fmt.Println("Track has started")
|
fmt.Println("Track has started")
|
||||||
|
|
||||||
// Start reading from all the streams and sending them to the related output track
|
// Start reading from all the streams and sending them to the related output track
|
||||||
|
@@ -77,7 +77,7 @@ func main() {
|
|||||||
|
|
||||||
// Set a handler for when a new remote track starts. We read the incoming packets, but then
|
// Set a handler for when a new remote track starts. We read the incoming packets, but then
|
||||||
// immediately discard them
|
// immediately discard them
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
fmt.Printf("New incoming track with codec: %s\n", track.Codec().MimeType)
|
fmt.Printf("New incoming track with codec: %s\n", track.Codec().MimeType)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@@ -84,7 +84,7 @@ func main() { // nolint:gocognit
|
|||||||
packets := make(chan *rtp.Packet, 60)
|
packets := make(chan *rtp.Packet, 60)
|
||||||
|
|
||||||
// Set a handler for when a new remote track starts
|
// Set a handler for when a new remote track starts
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
|
||||||
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType)
|
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType)
|
||||||
trackNum := trackCount
|
trackNum := trackCount
|
||||||
trackCount++
|
trackCount++
|
||||||
|
@@ -75,7 +75,7 @@ func TestICETransport_OnSelectedCandidatePairChange(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
senderCalledCandidateChange := int32(0)
|
senderCalledCandidateChange := int32(0)
|
||||||
pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(pair *ICECandidatePair) {
|
pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(*ICECandidatePair) {
|
||||||
atomic.StoreInt32(&senderCalledCandidateChange, 1)
|
atomic.StoreInt32(&senderCalledCandidateChange, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ func TestPeerConnection_Interceptor(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
seenRTP, seenRTPCancel := context.WithCancel(context.Background())
|
seenRTP, seenRTPCancel := context.WithCancel(context.Background())
|
||||||
answerer.OnTrack(func(track *TrackRemote, receiver *RTPReceiver) {
|
answerer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
p, attributes, readErr := track.ReadRTP()
|
p, attributes, readErr := track.ReadRTP()
|
||||||
assert.NoError(t, readErr)
|
assert.NoError(t, readErr)
|
||||||
|
|
||||||
@@ -136,18 +136,18 @@ func Test_Interceptor_BindUnbind(t *testing.T) {
|
|||||||
atomic.AddUint32(&cntBindRTCPWriter, 1)
|
atomic.AddUint32(&cntBindRTCPWriter, 1)
|
||||||
return writer
|
return writer
|
||||||
},
|
},
|
||||||
BindLocalStreamFn: func(i *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
|
BindLocalStreamFn: func(_ *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
|
||||||
atomic.AddUint32(&cntBindLocalStream, 1)
|
atomic.AddUint32(&cntBindLocalStream, 1)
|
||||||
return writer
|
return writer
|
||||||
},
|
},
|
||||||
UnbindLocalStreamFn: func(i *interceptor.StreamInfo) {
|
UnbindLocalStreamFn: func(*interceptor.StreamInfo) {
|
||||||
atomic.AddUint32(&cntUnbindLocalStream, 1)
|
atomic.AddUint32(&cntUnbindLocalStream, 1)
|
||||||
},
|
},
|
||||||
BindRemoteStreamFn: func(i *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader {
|
BindRemoteStreamFn: func(_ *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader {
|
||||||
atomic.AddUint32(&cntBindRemoteStream, 1)
|
atomic.AddUint32(&cntBindRemoteStream, 1)
|
||||||
return reader
|
return reader
|
||||||
},
|
},
|
||||||
UnbindRemoteStreamFn: func(i *interceptor.StreamInfo) {
|
UnbindRemoteStreamFn: func(_ *interceptor.StreamInfo) {
|
||||||
atomic.AddUint32(&cntUnbindRemoteStream, 1)
|
atomic.AddUint32(&cntUnbindRemoteStream, 1)
|
||||||
},
|
},
|
||||||
CloseFn: func() error {
|
CloseFn: func() error {
|
||||||
|
@@ -306,11 +306,11 @@ func TestPeerConnection_EventHandlers_Go(t *testing.T) {
|
|||||||
assert.NotPanics(t, func() { pc.onTrack(nil, nil) })
|
assert.NotPanics(t, func() { pc.onTrack(nil, nil) })
|
||||||
assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ICEConnectionStateNew) })
|
assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ICEConnectionStateNew) })
|
||||||
|
|
||||||
pc.OnTrack(func(t *TrackRemote, r *RTPReceiver) {
|
pc.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
close(onTrackCalled)
|
close(onTrackCalled)
|
||||||
})
|
})
|
||||||
|
|
||||||
pc.OnICEConnectionStateChange(func(cs ICEConnectionState) {
|
pc.OnICEConnectionStateChange(func(ICEConnectionState) {
|
||||||
close(onICEConnectionStateChangeCalled)
|
close(onICEConnectionStateChangeCalled)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -601,15 +601,15 @@ func TestPeerConnection_IceLite(t *testing.T) {
|
|||||||
closePairNow(t, offerPC, answerPC)
|
closePairNow(t, offerPC, answerPC)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("Offerer", func(t *testing.T) {
|
t.Run("Offerer", func(*testing.T) {
|
||||||
connectTwoAgents(true, false)
|
connectTwoAgents(true, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Answerer", func(t *testing.T) {
|
t.Run("Answerer", func(*testing.T) {
|
||||||
connectTwoAgents(false, true)
|
connectTwoAgents(false, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Both", func(t *testing.T) {
|
t.Run("Both", func(*testing.T) {
|
||||||
connectTwoAgents(true, true)
|
connectTwoAgents(true, true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ func TestMulticastDNSCandidates(t *testing.T) {
|
|||||||
assert.NoError(t, signalPair(pcOffer, pcAnswer))
|
assert.NoError(t, signalPair(pcOffer, pcAnswer))
|
||||||
|
|
||||||
onDataChannel, onDataChannelCancel := context.WithCancel(context.Background())
|
onDataChannel, onDataChannelCancel := context.WithCancel(context.Background())
|
||||||
pcAnswer.OnDataChannel(func(d *DataChannel) {
|
pcAnswer.OnDataChannel(func(*DataChannel) {
|
||||||
onDataChannelCancel()
|
onDataChannelCancel()
|
||||||
})
|
})
|
||||||
<-onDataChannel.Done()
|
<-onDataChannel.Done()
|
||||||
@@ -941,7 +941,7 @@ func TestICERestart_Error_Handling(t *testing.T) {
|
|||||||
keepPackets.set(true)
|
keepPackets.set(true)
|
||||||
|
|
||||||
// Add a filter that monitors the traffic on the router
|
// Add a filter that monitors the traffic on the router
|
||||||
wan.AddChunkFilter(func(c vnet.Chunk) bool {
|
wan.AddChunkFilter(func(vnet.Chunk) bool {
|
||||||
return keepPackets.get()
|
return keepPackets.get()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1361,21 +1361,21 @@ func TestPeerConnectionNilCallback(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
pc.onSignalingStateChange(SignalingStateStable)
|
pc.onSignalingStateChange(SignalingStateStable)
|
||||||
pc.OnSignalingStateChange(func(ss SignalingState) {
|
pc.OnSignalingStateChange(func(SignalingState) {
|
||||||
t.Error("OnSignalingStateChange called")
|
t.Error("OnSignalingStateChange called")
|
||||||
})
|
})
|
||||||
pc.OnSignalingStateChange(nil)
|
pc.OnSignalingStateChange(nil)
|
||||||
pc.onSignalingStateChange(SignalingStateStable)
|
pc.onSignalingStateChange(SignalingStateStable)
|
||||||
|
|
||||||
pc.onConnectionStateChange(PeerConnectionStateNew)
|
pc.onConnectionStateChange(PeerConnectionStateNew)
|
||||||
pc.OnConnectionStateChange(func(pcs PeerConnectionState) {
|
pc.OnConnectionStateChange(func(PeerConnectionState) {
|
||||||
t.Error("OnConnectionStateChange called")
|
t.Error("OnConnectionStateChange called")
|
||||||
})
|
})
|
||||||
pc.OnConnectionStateChange(nil)
|
pc.OnConnectionStateChange(nil)
|
||||||
pc.onConnectionStateChange(PeerConnectionStateNew)
|
pc.onConnectionStateChange(PeerConnectionStateNew)
|
||||||
|
|
||||||
pc.onICEConnectionStateChange(ICEConnectionStateNew)
|
pc.onICEConnectionStateChange(ICEConnectionStateNew)
|
||||||
pc.OnICEConnectionStateChange(func(ics ICEConnectionState) {
|
pc.OnICEConnectionStateChange(func(ICEConnectionState) {
|
||||||
t.Error("OnConnectionStateChange called")
|
t.Error("OnConnectionStateChange called")
|
||||||
})
|
})
|
||||||
pc.OnICEConnectionStateChange(nil)
|
pc.OnICEConnectionStateChange(nil)
|
||||||
|
@@ -252,7 +252,7 @@ func TestPeerConnection_Media_Shutdown(t *testing.T) {
|
|||||||
var onTrackFiredLock sync.Mutex
|
var onTrackFiredLock sync.Mutex
|
||||||
onTrackFired := false
|
onTrackFired := false
|
||||||
|
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, receiver *RTPReceiver) {
|
pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
onTrackFiredLock.Lock()
|
onTrackFiredLock.Lock()
|
||||||
defer onTrackFiredLock.Unlock()
|
defer onTrackFiredLock.Unlock()
|
||||||
onTrackFired = true
|
onTrackFired = true
|
||||||
@@ -327,7 +327,7 @@ func TestPeerConnection_Media_Disconnected(t *testing.T) {
|
|||||||
keepPackets.set(true)
|
keepPackets.set(true)
|
||||||
|
|
||||||
// Add a filter that monitors the traffic on the router
|
// Add a filter that monitors the traffic on the router
|
||||||
wan.AddChunkFilter(func(c vnet.Chunk) bool {
|
wan.AddChunkFilter(func(vnet.Chunk) bool {
|
||||||
return keepPackets.get()
|
return keepPackets.get()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -438,7 +438,7 @@ func TestUndeclaredSSRC(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
onTrackFired := make(chan struct{})
|
onTrackFired := make(chan struct{})
|
||||||
pcAnswer.OnTrack(func(trackRemote *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(trackRemote *TrackRemote, _ *RTPReceiver) {
|
||||||
assert.Equal(t, trackRemote.StreamID(), vp8Writer.StreamID())
|
assert.Equal(t, trackRemote.StreamID(), vp8Writer.StreamID())
|
||||||
assert.Equal(t, trackRemote.ID(), vp8Writer.ID())
|
assert.Equal(t, trackRemote.ID(), vp8Writer.ID())
|
||||||
close(onTrackFired)
|
close(onTrackFired)
|
||||||
@@ -793,7 +793,7 @@ func TestPlanBMediaExchange(t *testing.T) {
|
|||||||
|
|
||||||
var onTrackWaitGroup sync.WaitGroup
|
var onTrackWaitGroup sync.WaitGroup
|
||||||
onTrackWaitGroup.Add(trackCount)
|
onTrackWaitGroup.Add(trackCount)
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
onTrackWaitGroup.Done()
|
onTrackWaitGroup.Done()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1422,7 +1422,7 @@ func TestPeerConnection_Simulcast_NoDataChannel(t *testing.T) {
|
|||||||
pcSender.OnConnectionStateChange(connectionStateChangeHandler)
|
pcSender.OnConnectionStateChange(connectionStateChangeHandler)
|
||||||
pcReceiver.OnConnectionStateChange(connectionStateChangeHandler)
|
pcReceiver.OnConnectionStateChange(connectionStateChangeHandler)
|
||||||
|
|
||||||
pcReceiver.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
pcReceiver.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -128,12 +128,12 @@ func TestPeerConnection_Renegotiation_AddRecvonlyTransceiver(t *testing.T) {
|
|||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
|
|
||||||
if tc.answererSends {
|
if tc.answererSends {
|
||||||
pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcOffer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
onTrackFiredFunc()
|
onTrackFiredFunc()
|
||||||
})
|
})
|
||||||
assert.NoError(t, signalPair(pcAnswer, pcOffer))
|
assert.NoError(t, signalPair(pcAnswer, pcOffer))
|
||||||
} else {
|
} else {
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
onTrackFiredFunc()
|
onTrackFiredFunc()
|
||||||
})
|
})
|
||||||
assert.NoError(t, signalPair(pcOffer, pcAnswer))
|
assert.NoError(t, signalPair(pcOffer, pcAnswer))
|
||||||
@@ -166,7 +166,7 @@ func TestPeerConnection_Renegotiation_AddTrack(t *testing.T) {
|
|||||||
|
|
||||||
haveRenegotiated := &atomicBool{}
|
haveRenegotiated := &atomicBool{}
|
||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
if !haveRenegotiated.get() {
|
if !haveRenegotiated.get() {
|
||||||
t.Fatal("OnTrack was called before renegotiation")
|
t.Fatal("OnTrack was called before renegotiation")
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ func TestPeerConnection_Renegotiation_AddTrack_Multiple(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
onTrackCount[track.ID()]++
|
onTrackCount[track.ID()]++
|
||||||
onTrackChan <- struct{}{}
|
onTrackChan <- struct{}{}
|
||||||
})
|
})
|
||||||
@@ -288,7 +288,7 @@ func TestPeerConnection_Renegotiation_AddTrack_Rename(t *testing.T) {
|
|||||||
haveRenegotiated := &atomicBool{}
|
haveRenegotiated := &atomicBool{}
|
||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
var atomicRemoteTrack atomic.Value
|
var atomicRemoteTrack atomic.Value
|
||||||
pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcOffer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
if !haveRenegotiated.get() {
|
if !haveRenegotiated.get() {
|
||||||
t.Fatal("OnTrack was called before renegotiation")
|
t.Fatal("OnTrack was called before renegotiation")
|
||||||
}
|
}
|
||||||
@@ -445,7 +445,7 @@ func TestPeerConnection_Renegotiation_CodecChange(t *testing.T) {
|
|||||||
|
|
||||||
tracksCh := make(chan *TrackRemote)
|
tracksCh := make(chan *TrackRemote)
|
||||||
tracksClosed := make(chan struct{})
|
tracksClosed := make(chan struct{})
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
tracksCh <- track
|
tracksCh <- track
|
||||||
for {
|
for {
|
||||||
if _, _, readErr := track.ReadRTP(); errors.Is(readErr, io.EOF) {
|
if _, _, readErr := track.ReadRTP(); errors.Is(readErr, io.EOF) {
|
||||||
@@ -533,7 +533,7 @@ func TestPeerConnection_Renegotiation_RemoveTrack(t *testing.T) {
|
|||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
trackClosed, trackClosedFunc := context.WithCancel(context.Background())
|
trackClosed, trackClosedFunc := context.WithCancel(context.Background())
|
||||||
|
|
||||||
pcAnswer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcAnswer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
onTrackFiredFunc()
|
onTrackFiredFunc()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@@ -567,7 +567,7 @@ func TestPeerConnection_RoleSwitch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
pcFirstOfferer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcFirstOfferer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
onTrackFiredFunc()
|
onTrackFiredFunc()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ func TestPeerConnection_Renegotiation_SetLocalDescription(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcOffer.OnTrack(func(*TrackRemote, *RTPReceiver) {
|
||||||
onTrackFiredFunc()
|
onTrackFiredFunc()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1244,7 +1244,7 @@ func TestPeerConnection_Regegotiation_AnswerAddsTrack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracksCh := make(chan *TrackRemote)
|
tracksCh := make(chan *TrackRemote)
|
||||||
pcOffer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
pcOffer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
tracksCh <- track
|
tracksCh <- track
|
||||||
for {
|
for {
|
||||||
if _, _, readErr := track.ReadRTP(); errors.Is(readErr, io.EOF) {
|
if _, _, readErr := track.ReadRTP(); errors.Is(readErr, io.EOF) {
|
||||||
@@ -1309,7 +1309,7 @@ func TestNegotiationNeededWithRecvonlyTrack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDataChannel, onDataChannelCancel := context.WithCancel(context.Background())
|
onDataChannel, onDataChannelCancel := context.WithCancel(context.Background())
|
||||||
pcAnswer.OnDataChannel(func(d *DataChannel) {
|
pcAnswer.OnDataChannel(func(*DataChannel) {
|
||||||
onDataChannelCancel()
|
onDataChannelCancel()
|
||||||
})
|
})
|
||||||
<-onDataChannel.Done()
|
<-onDataChannel.Done()
|
||||||
|
@@ -470,7 +470,7 @@ func TestMultipleOfferAnswer(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("New PeerConnection: got error: %v", err)
|
t.Errorf("New PeerConnection: got error: %v", err)
|
||||||
}
|
}
|
||||||
secondPeerConn.OnICECandidate(func(i *ICECandidate) {
|
secondPeerConn.OnICECandidate(func(*ICECandidate) {
|
||||||
})
|
})
|
||||||
|
|
||||||
if _, err = secondPeerConn.CreateOffer(nil); err != nil {
|
if _, err = secondPeerConn.CreateOffer(nil); err != nil {
|
||||||
@@ -566,7 +566,7 @@ func TestMultipleCreateChannel(t *testing.T) {
|
|||||||
pcOffer, _ := NewPeerConnection(Configuration{})
|
pcOffer, _ := NewPeerConnection(Configuration{})
|
||||||
pcAnswer, _ := NewPeerConnection(Configuration{})
|
pcAnswer, _ := NewPeerConnection(Configuration{})
|
||||||
|
|
||||||
pcAnswer.OnDataChannel(func(d *DataChannel) {
|
pcAnswer.OnDataChannel(func(*DataChannel) {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -473,7 +473,7 @@ func TestSampleBuilderWithPacketHeadHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
headCount := 0
|
headCount := 0
|
||||||
s := New(10, &fakeDepacketizer{}, 1, WithPacketHeadHandler(func(headPacket interface{}) interface{} {
|
s := New(10, &fakeDepacketizer{}, 1, WithPacketHeadHandler(func(interface{}) interface{} {
|
||||||
headCount++
|
headCount++
|
||||||
return true
|
return true
|
||||||
}))
|
}))
|
||||||
|
@@ -42,7 +42,7 @@ func TestSetRTPParameters(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
seenPacket, seenPacketCancel := context.WithCancel(context.Background())
|
seenPacket, seenPacketCancel := context.WithCancel(context.Background())
|
||||||
receiver.OnTrack(func(trackRemote *TrackRemote, r *RTPReceiver) {
|
receiver.OnTrack(func(_ *TrackRemote, r *RTPReceiver) {
|
||||||
r.SetRTPParameters(p)
|
r.SetRTPParameters(p)
|
||||||
|
|
||||||
incomingTrackCodecs := r.Track().Codec()
|
incomingTrackCodecs := r.Track().Codec()
|
||||||
|
@@ -333,7 +333,7 @@ func (r *RTPSender) Send(parameters RTPSendParameters) error {
|
|||||||
|
|
||||||
rtpInterceptor := r.api.interceptor.BindLocalStream(
|
rtpInterceptor := r.api.interceptor.BindLocalStream(
|
||||||
&trackEncoding.streamInfo,
|
&trackEncoding.streamInfo,
|
||||||
interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
|
interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, _ interceptor.Attributes) (int, error) {
|
||||||
return srtpStream.WriteRTP(header, payload)
|
return srtpStream.WriteRTP(header, payload)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
2
sdp.go
2
sdp.go
@@ -541,7 +541,7 @@ type mediaSection struct {
|
|||||||
|
|
||||||
func bundleMatchFromRemote(matchBundleGroup *string) func(mid string) bool {
|
func bundleMatchFromRemote(matchBundleGroup *string) func(mid string) bool {
|
||||||
if matchBundleGroup == nil {
|
if matchBundleGroup == nil {
|
||||||
return func(midValue string) bool {
|
return func(string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1241,7 +1241,7 @@ func TestPeerConnection_GetStats(t *testing.T) {
|
|||||||
d.OnOpen(func() {
|
d.OnOpen(func() {
|
||||||
answerDCChan <- d
|
answerDCChan <- d
|
||||||
})
|
})
|
||||||
d.OnMessage(func(m DataChannelMessage) {
|
d.OnMessage(func(DataChannelMessage) {
|
||||||
dcWait.Done()
|
dcWait.Done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@@ -149,7 +149,7 @@ func Test_TrackLocalStatic_PayloadType(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
onTrackFired, onTrackFiredFunc := context.WithCancel(context.Background())
|
||||||
offerer.OnTrack(func(track *TrackRemote, r *RTPReceiver) {
|
offerer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
|
||||||
assert.Equal(t, track.PayloadType(), PayloadType(100))
|
assert.Equal(t, track.PayloadType(), PayloadType(100))
|
||||||
assert.Equal(t, track.Codec().RTPCodecCapability.MimeType, "video/VP8")
|
assert.Equal(t, track.Codec().RTPCodecCapability.MimeType, "video/VP8")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user