@@ -55,12 +55,12 @@ type PeerConnection struct {
55
55
56
56
idpLoginURL * string
57
57
58
- isClosed * atomicBool
58
+ isClosed * atomic. Bool
59
59
isGracefullyClosingOrClosed bool
60
60
isCloseDone chan struct {}
61
61
isGracefulCloseDone chan struct {}
62
- isNegotiationNeeded * atomicBool
63
- updateNegotiationNeededFlagOnEmptyChain * atomicBool
62
+ isNegotiationNeeded * atomic. Bool
63
+ updateNegotiationNeededFlagOnEmptyChain * atomic. Bool
64
64
65
65
lastOffer string
66
66
lastAnswer string
@@ -124,11 +124,11 @@ func (api *API) NewPeerConnection(configuration Configuration) (*PeerConnection,
124
124
Certificates : []Certificate {},
125
125
ICECandidatePoolSize : 0 ,
126
126
},
127
- isClosed : & atomicBool {},
127
+ isClosed : & atomic. Bool {},
128
128
isCloseDone : make (chan struct {}),
129
129
isGracefulCloseDone : make (chan struct {}),
130
- isNegotiationNeeded : & atomicBool {},
131
- updateNegotiationNeededFlagOnEmptyChain : & atomicBool {},
130
+ isNegotiationNeeded : & atomic. Bool {},
131
+ updateNegotiationNeededFlagOnEmptyChain : & atomic. Bool {},
132
132
lastOffer : "" ,
133
133
lastAnswer : "" ,
134
134
greaterMid : - 1 ,
@@ -296,7 +296,7 @@ func (pc *PeerConnection) onNegotiationNeeded() {
296
296
// 4.7.3.1 If the length of connection.[[Operations]] is not 0, then set
297
297
// connection.[[UpdateNegotiationNeededFlagOnEmptyChain]] to true, and abort these steps.
298
298
if ! pc .ops .IsEmpty () {
299
- pc .updateNegotiationNeededFlagOnEmptyChain .set (true )
299
+ pc .updateNegotiationNeededFlagOnEmptyChain .Store (true )
300
300
301
301
return
302
302
}
@@ -306,15 +306,15 @@ func (pc *PeerConnection) onNegotiationNeeded() {
306
306
// https://www.w3.org/TR/webrtc/#dfn-update-the-negotiation-needed-flag
307
307
func (pc * PeerConnection ) negotiationNeededOp () {
308
308
// 4.7.3.2.1 If connection.[[IsClosed]] is true, abort these steps.
309
- if pc .isClosed .get () {
309
+ if pc .isClosed .Load () {
310
310
return
311
311
}
312
312
313
313
// 4.7.3.2.2 If the length of connection.[[Operations]] is not 0,
314
314
// then set connection.[[UpdateNegotiationNeededFlagOnEmptyChain]] to
315
315
// true, and abort these steps.
316
316
if ! pc .ops .IsEmpty () {
317
- pc .updateNegotiationNeededFlagOnEmptyChain .set (true )
317
+ pc .updateNegotiationNeededFlagOnEmptyChain .Store (true )
318
318
319
319
return
320
320
}
@@ -328,18 +328,18 @@ func (pc *PeerConnection) negotiationNeededOp() {
328
328
// clear the negotiation-needed flag by setting connection.[[NegotiationNeeded]]
329
329
// to false, and abort these steps.
330
330
if ! pc .checkNegotiationNeeded () {
331
- pc .isNegotiationNeeded .set (false )
331
+ pc .isNegotiationNeeded .Store (false )
332
332
333
333
return
334
334
}
335
335
336
336
// 4.7.3.2.5 If connection.[[NegotiationNeeded]] is already true, abort these steps.
337
- if pc .isNegotiationNeeded .get () {
337
+ if pc .isNegotiationNeeded .Load () {
338
338
return
339
339
}
340
340
341
341
// 4.7.3.2.6 Set connection.[[NegotiationNeeded]] to true.
342
- pc .isNegotiationNeeded .set (true )
342
+ pc .isNegotiationNeeded .Store (true )
343
343
344
344
// 4.7.3.2.7 Fire an event named negotiationneeded at connection.
345
345
if handler , ok := pc .onNegotiationNeededHandler .Load ().(func ()); ok && handler != nil {
@@ -513,7 +513,7 @@ func (pc *PeerConnection) onConnectionStateChange(cs PeerConnectionState) {
513
513
// SetConfiguration updates the configuration of this PeerConnection object.
514
514
func (pc * PeerConnection ) SetConfiguration (configuration Configuration ) error { //nolint:gocognit,cyclop
515
515
// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-setconfiguration (step #2)
516
- if pc .isClosed .get () {
516
+ if pc .isClosed .Load () {
517
517
return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
518
518
}
519
519
@@ -623,7 +623,7 @@ func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription
623
623
switch {
624
624
case useIdentity :
625
625
return SessionDescription {}, errIdentityProviderNotImplemented
626
- case pc .isClosed .get ():
626
+ case pc .isClosed .Load ():
627
627
return SessionDescription {}, & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
628
628
}
629
629
@@ -763,7 +763,7 @@ func (pc *PeerConnection) updateConnectionState(
763
763
connectionState := PeerConnectionStateNew
764
764
switch {
765
765
// The RTCPeerConnection object's [[IsClosed]] slot is true.
766
- case pc .isClosed .get ():
766
+ case pc .isClosed .Load ():
767
767
connectionState = PeerConnectionStateClosed
768
768
769
769
// Any of the RTCIceTransports or RTCDtlsTransports are in a "failed" state.
@@ -844,7 +844,7 @@ func (pc *PeerConnection) CreateAnswer(*AnswerOptions) (SessionDescription, erro
844
844
return SessionDescription {}, & rtcerr.InvalidStateError {Err : ErrNoRemoteDescription }
845
845
case useIdentity :
846
846
return SessionDescription {}, errIdentityProviderNotImplemented
847
- case pc .isClosed .get ():
847
+ case pc .isClosed .Load ():
848
848
return SessionDescription {}, & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
849
849
case pc .signalingState .Get () != SignalingStateHaveRemoteOffer &&
850
850
pc .signalingState .Get () != SignalingStateHaveLocalPranswer :
@@ -891,7 +891,7 @@ func (pc *PeerConnection) CreateAnswer(*AnswerOptions) (SessionDescription, erro
891
891
//nolint:gocognit,cyclop
892
892
func (pc * PeerConnection ) setDescription (sd * SessionDescription , op stateChangeOp ) error {
893
893
switch {
894
- case pc .isClosed .get ():
894
+ case pc .isClosed .Load ():
895
895
return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
896
896
case NewSDPType (sd .Type .String ()) == SDPTypeUnknown :
897
897
return & rtcerr.TypeError {
@@ -995,7 +995,7 @@ func (pc *PeerConnection) setDescription(sd *SessionDescription, op stateChangeO
995
995
if err == nil {
996
996
pc .signalingState .Set (nextState )
997
997
if pc .signalingState .Get () == SignalingStateStable {
998
- pc .isNegotiationNeeded .set (false )
998
+ pc .isNegotiationNeeded .Store (false )
999
999
pc .mu .Lock ()
1000
1000
pc .onNegotiationNeeded ()
1001
1001
pc .mu .Unlock ()
@@ -1010,7 +1010,7 @@ func (pc *PeerConnection) setDescription(sd *SessionDescription, op stateChangeO
1010
1010
//
1011
1011
//nolint:cyclop
1012
1012
func (pc * PeerConnection ) SetLocalDescription (desc SessionDescription ) error {
1013
- if pc .isClosed .get () {
1013
+ if pc .isClosed .Load () {
1014
1014
return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
1015
1015
}
1016
1016
@@ -1081,7 +1081,7 @@ func (pc *PeerConnection) LocalDescription() *SessionDescription {
1081
1081
//
1082
1082
//nolint:gocognit,gocyclo,cyclop,maintidx
1083
1083
func (pc * PeerConnection ) SetRemoteDescription (desc SessionDescription ) error {
1084
- if pc .isClosed .get () {
1084
+ if pc .isClosed .Load () {
1085
1085
return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
1086
1086
}
1087
1087
@@ -1886,7 +1886,7 @@ func (pc *PeerConnection) undeclaredRTPMediaProcessor() { //nolint:cyclop
1886
1886
return
1887
1887
}
1888
1888
1889
- if pc .isClosed .get () {
1889
+ if pc .isClosed .Load () {
1890
1890
if err = srtpReadStream .Close (); err != nil {
1891
1891
pc .log .Warnf ("Failed to close RTP stream %v" , err )
1892
1892
}
@@ -2076,7 +2076,7 @@ func (pc *PeerConnection) GetTransceivers() []*RTPTransceiver {
2076
2076
//
2077
2077
//nolint:cyclop
2078
2078
func (pc * PeerConnection ) AddTrack (track TrackLocal ) (* RTPSender , error ) {
2079
- if pc .isClosed .get () {
2079
+ if pc .isClosed .Load () {
2080
2080
return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
2081
2081
}
2082
2082
@@ -2118,7 +2118,7 @@ func (pc *PeerConnection) AddTrack(track TrackLocal) (*RTPSender, error) {
2118
2118
2119
2119
// RemoveTrack removes a Track from the PeerConnection.
2120
2120
func (pc * PeerConnection ) RemoveTrack (sender * RTPSender ) (err error ) {
2121
- if pc .isClosed .get () {
2121
+ if pc .isClosed .Load () {
2122
2122
return & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
2123
2123
}
2124
2124
@@ -2186,7 +2186,7 @@ func (pc *PeerConnection) AddTransceiverFromKind(
2186
2186
kind RTPCodecType ,
2187
2187
init ... RTPTransceiverInit ,
2188
2188
) (t * RTPTransceiver , err error ) {
2189
- if pc .isClosed .get () {
2189
+ if pc .isClosed .Load () {
2190
2190
return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
2191
2191
}
2192
2192
@@ -2231,7 +2231,7 @@ func (pc *PeerConnection) AddTransceiverFromTrack(
2231
2231
track TrackLocal ,
2232
2232
init ... RTPTransceiverInit ,
2233
2233
) (t * RTPTransceiver , err error ) {
2234
- if pc .isClosed .get () {
2234
+ if pc .isClosed .Load () {
2235
2235
return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
2236
2236
}
2237
2237
@@ -2259,7 +2259,7 @@ func (pc *PeerConnection) AddTransceiverFromTrack(
2259
2259
//nolint:cyclop
2260
2260
func (pc * PeerConnection ) CreateDataChannel (label string , options * DataChannelInit ) (* DataChannel , error ) {
2261
2261
// https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #2)
2262
- if pc .isClosed .get () {
2262
+ if pc .isClosed .Load () {
2263
2263
return nil , & rtcerr.InvalidStateError {Err : ErrConnectionClosed }
2264
2264
}
2265
2265
@@ -2380,7 +2380,7 @@ func (pc *PeerConnection) close(shouldGracefullyClose bool) error { //nolint:cyc
2380
2380
// some overlapping close cases when both normal and graceful close are used
2381
2381
// that should be idempotent, but be cautioned when writing new close behavior
2382
2382
// to preserve this property.
2383
- isAlreadyClosingOrClosed := pc .isClosed .swap (true )
2383
+ isAlreadyClosingOrClosed := pc .isClosed .Swap (true )
2384
2384
isAlreadyGracefullyClosingOrClosed := pc .isGracefullyClosingOrClosed
2385
2385
if shouldGracefullyClose && ! isAlreadyGracefullyClosingOrClosed {
2386
2386
pc .isGracefullyClosingOrClosed = true
@@ -2668,7 +2668,7 @@ func (pc *PeerConnection) startTransports(
2668
2668
}
2669
2669
2670
2670
pc .dtlsTransport .internalOnCloseHandler = func () {
2671
- if pc .isClosed .get () || pc .api .settingEngine .disableCloseByDTLS {
2671
+ if pc .isClosed .Load () || pc .api .settingEngine .disableCloseByDTLS {
2672
2672
return
2673
2673
}
2674
2674
0 commit comments