snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
Fuzz / fuzz (push) Failing after 0s
CodeQL / analyze (push) Failing after 0s
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
Fuzz / fuzz (push) Failing after 0s
CodeQL / analyze (push) Failing after 0s
This commit is contained in:
29
gathering_complete_promise.go
Normal file
29
gathering_complete_promise.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// GatheringCompletePromise is a Pion specific helper function that returns a channel that is closed
|
||||
// when gathering is complete.
|
||||
// This function may be helpful in cases where you are unable to trickle your ICE Candidates.
|
||||
//
|
||||
// It is better to not use this function, and instead trickle candidates.
|
||||
// If you use this function you will see longer connection startup times.
|
||||
// When the call is connected you will see no impact however.
|
||||
func GatheringCompletePromise(pc *PeerConnection) (gatherComplete <-chan struct{}) {
|
||||
gatheringComplete, done := context.WithCancel(context.Background())
|
||||
|
||||
// It's possible to miss the GatherComplete event since setGatherCompleteHandler is an atomic operation and the
|
||||
// promise might have been created after the gathering is finished. Therefore, we need to check if the ICE gathering
|
||||
// state has changed to complete so that we don't block the caller forever.
|
||||
pc.setGatherCompleteHandler(func() { done() })
|
||||
if pc.ICEGatheringState() == ICEGatheringStateComplete {
|
||||
done()
|
||||
}
|
||||
|
||||
return gatheringComplete.Done()
|
||||
}
|
||||
Reference in New Issue
Block a user