@@ -36,7 +36,7 @@ const (
36
36
// peer-to-peer communications with another RTCPeerConnection instance in a
37
37
// browser, or to another endpoint implementing the required protocols.
38
38
type RTCPeerConnection struct {
39
- sync.RWMutex
39
+ mu sync.RWMutex
40
40
41
41
configuration RTCConfiguration
42
42
@@ -237,15 +237,15 @@ func (pc *RTCPeerConnection) initConfiguration(configuration RTCConfiguration) e
237
237
// OnSignalingStateChange sets an event handler which is invoked when the
238
238
// peer connection's signaling state changes
239
239
func (pc * RTCPeerConnection ) OnSignalingStateChange (f func (RTCSignalingState )) {
240
- pc .Lock ()
241
- defer pc .Unlock ()
240
+ pc .mu . Lock ()
241
+ defer pc .mu . Unlock ()
242
242
pc .onSignalingStateChangeHandler = f
243
243
}
244
244
245
245
func (pc * RTCPeerConnection ) onSignalingStateChange (newState RTCSignalingState ) (done chan struct {}) {
246
- pc .RLock ()
246
+ pc .mu . RLock ()
247
247
hdlr := pc .onSignalingStateChangeHandler
248
- pc .RUnlock ()
248
+ pc .mu . RUnlock ()
249
249
250
250
pcLog .Infof ("signaling state changed to %s" , newState )
251
251
done = make (chan struct {})
@@ -265,23 +265,23 @@ func (pc *RTCPeerConnection) onSignalingStateChange(newState RTCSignalingState)
265
265
// OnDataChannel sets an event handler which is invoked when a data
266
266
// channel message arrives from a remote peer.
267
267
func (pc * RTCPeerConnection ) OnDataChannel (f func (* RTCDataChannel )) {
268
- pc .Lock ()
269
- defer pc .Unlock ()
268
+ pc .mu . Lock ()
269
+ defer pc .mu . Unlock ()
270
270
pc .onDataChannelHandler = f
271
271
}
272
272
273
273
// OnTrack sets an event handler which is called when remote track
274
274
// arrives from a remote peer.
275
275
func (pc * RTCPeerConnection ) OnTrack (f func (* RTCTrack )) {
276
- pc .Lock ()
277
- defer pc .Unlock ()
276
+ pc .mu . Lock ()
277
+ defer pc .mu . Unlock ()
278
278
pc .onTrackHandler = f
279
279
}
280
280
281
281
func (pc * RTCPeerConnection ) onTrack (t * RTCTrack ) (done chan struct {}) {
282
- pc .RLock ()
282
+ pc .mu . RLock ()
283
283
hdlr := pc .onTrackHandler
284
- pc .RUnlock ()
284
+ pc .mu . RUnlock ()
285
285
286
286
pcLog .Debugf ("got new track: %+v" , t )
287
287
done = make (chan struct {})
@@ -301,15 +301,15 @@ func (pc *RTCPeerConnection) onTrack(t *RTCTrack) (done chan struct{}) {
301
301
// OnICEConnectionStateChange sets an event handler which is called
302
302
// when an ICE connection state is changed.
303
303
func (pc * RTCPeerConnection ) OnICEConnectionStateChange (f func (ice.ConnectionState )) {
304
- pc .Lock ()
305
- defer pc .Unlock ()
304
+ pc .mu . Lock ()
305
+ defer pc .mu . Unlock ()
306
306
pc .onICEConnectionStateChangeHandler = f
307
307
}
308
308
309
309
func (pc * RTCPeerConnection ) onICEConnectionStateChange (cs ice.ConnectionState ) (done chan struct {}) {
310
- pc .RLock ()
310
+ pc .mu . RLock ()
311
311
hdlr := pc .onICEConnectionStateChangeHandler
312
- pc .RUnlock ()
312
+ pc .mu . RUnlock ()
313
313
314
314
pcLog .Infof ("ICE connection state changed: %s" , cs )
315
315
done = make (chan struct {})
@@ -773,9 +773,9 @@ func (pc *RTCPeerConnection) SetRemoteDescription(desc RTCSessionDescription) er
773
773
774
774
// Wire up the on datachannel handler
775
775
sctp .OnDataChannel (func (d * RTCDataChannel ) {
776
- pc .RLock ()
776
+ pc .mu . RLock ()
777
777
hdlr := pc .onDataChannelHandler
778
- pc .RUnlock ()
778
+ pc .mu . RUnlock ()
779
779
if hdlr != nil {
780
780
hdlr (d )
781
781
}
@@ -1037,8 +1037,8 @@ func (pc *RTCPeerConnection) AddIceCandidate(s string) error {
1037
1037
1038
1038
// GetSenders returns the RTCRtpSender that are currently attached to this RTCPeerConnection
1039
1039
func (pc * RTCPeerConnection ) GetSenders () []* RTCRtpSender {
1040
- pc .Lock ()
1041
- defer pc .Unlock ()
1040
+ pc .mu . Lock ()
1041
+ defer pc .mu . Unlock ()
1042
1042
1043
1043
result := make ([]* RTCRtpSender , len (pc .rtpTransceivers ))
1044
1044
for i , tranceiver := range pc .rtpTransceivers {
@@ -1051,8 +1051,8 @@ func (pc *RTCPeerConnection) GetSenders() []*RTCRtpSender {
1051
1051
1052
1052
// GetReceivers returns the RTCRtpReceivers that are currently attached to this RTCPeerConnection
1053
1053
func (pc * RTCPeerConnection ) GetReceivers () []* RTCRtpReceiver {
1054
- pc .Lock ()
1055
- defer pc .Unlock ()
1054
+ pc .mu . Lock ()
1055
+ defer pc .mu . Unlock ()
1056
1056
1057
1057
result := make ([]* RTCRtpReceiver , len (pc .rtpTransceivers ))
1058
1058
for i , tranceiver := range pc .rtpTransceivers {
@@ -1066,8 +1066,8 @@ func (pc *RTCPeerConnection) GetReceivers() []*RTCRtpReceiver {
1066
1066
1067
1067
// GetTransceivers returns the RTCRtpTransceiver that are currently attached to this RTCPeerConnection
1068
1068
func (pc * RTCPeerConnection ) GetTransceivers () []* RTCRtpTransceiver {
1069
- pc .Lock ()
1070
- defer pc .Unlock ()
1069
+ pc .mu . Lock ()
1070
+ defer pc .mu . Unlock ()
1071
1071
1072
1072
return pc .rtpTransceivers
1073
1073
}
@@ -1386,9 +1386,9 @@ func flattenErrs(errs []error) error {
1386
1386
}
1387
1387
1388
1388
func (pc * RTCPeerConnection ) iceStateChange (newState ice.ConnectionState ) {
1389
- pc .Lock ()
1389
+ pc .mu . Lock ()
1390
1390
pc .IceConnectionState = newState
1391
- pc .Unlock ()
1391
+ pc .mu . Unlock ()
1392
1392
1393
1393
pc .onICEConnectionStateChange (newState )
1394
1394
}
@@ -1535,8 +1535,8 @@ func (pc *RTCPeerConnection) newRTCRtpTransceiver(
1535
1535
Sender : sender ,
1536
1536
Direction : direction ,
1537
1537
}
1538
- pc .Lock ()
1539
- defer pc .Unlock ()
1538
+ pc .mu . Lock ()
1539
+ defer pc .mu . Unlock ()
1540
1540
pc .rtpTransceivers = append (pc .rtpTransceivers , t )
1541
1541
return t
1542
1542
}
0 commit comments