diff --git a/core/webrtc/peer.go b/core/webrtc/peer.go index 64a1cc8..7782ed2 100644 --- a/core/webrtc/peer.go +++ b/core/webrtc/peer.go @@ -152,6 +152,12 @@ func (p *Peer) Answer() webrtc.SessionDescription { return p.answer } // ResourceID returns the stable resource id used in the WHEP Location header. func (p *Peer) ResourceID() string { return p.resourceID } +// Done returns a channel that is closed when the Peer has been torn down +// (either explicitly via Close, or because Pion observed an ICE +// failure / disconnection). Consumers can range over it to drive +// index cleanup without polling. +func (p *Peer) Done() <-chan struct{} { return p.done } + // Close tears down the peer connection and unsubscribes from each // source. Safe to call multiple times. func (p *Peer) Close() error { @@ -257,6 +263,14 @@ func (f *PeerFactory) CreatePeerFromSources(ctx context.Context, return p, nil } + +// AddICECandidate forwards a trickle-ICE candidate to the underlying +// PeerConnection. Returns the underlying error if the candidate is +// malformed or the connection has already been closed. +func (p *Peer) AddICECandidate(c webrtc.ICECandidateInit) error { + return p.pc.AddICECandidate(c) +} + func newResourceID() string { b := make([]byte, 8) _, _ = rand.Read(b)