add helpers for partiicpant reconnect and version (#3034)

This commit is contained in:
Paul Wells
2024-09-22 23:37:35 -07:00
committed by GitHub
parent 5e3b3ee3c1
commit d26ade0076
5 changed files with 166 additions and 86 deletions
+18 -5
View File
@@ -134,6 +134,7 @@ type ParticipantParams struct {
ClientInfo ClientInfo
Region string
Migration bool
Reconnect bool
AdaptiveStream bool
AllowTCPFallback bool
TCPFallbackRTTThreshold int
@@ -620,11 +621,7 @@ func (p *ParticipantImpl) CanSkipBroadcast() bool {
return !p.requireBroadcast
}
func (p *ParticipantImpl) VersionNumber() uint32 {
return p.version.Load()
}
func (p *ParticipantImpl) ToProtoWithVersion() (*livekit.ParticipantInfo, utils.TimedVersion) {
func (p *ParticipantImpl) maybeIncVersion() {
if p.dirty.Load() {
p.lock.Lock()
if p.dirty.Swap(false) {
@@ -633,6 +630,18 @@ func (p *ParticipantImpl) ToProtoWithVersion() (*livekit.ParticipantInfo, utils.
}
p.lock.Unlock()
}
}
func (p *ParticipantImpl) Version() utils.TimedVersion {
p.maybeIncVersion()
p.lock.RLock()
defer p.lock.RUnlock()
return p.timedVersion
}
func (p *ParticipantImpl) ToProtoWithVersion() (*livekit.ParticipantInfo, utils.TimedVersion) {
p.maybeIncVersion()
p.lock.RLock()
grants := p.grants.Load()
@@ -935,6 +944,10 @@ func (p *ParticipantImpl) SetMigrateInfo(
p.TransportManager.SetMigrateInfo(previousOffer, previousAnswer, dataChannels)
}
func (p *ParticipantImpl) IsReconnect() bool {
return p.params.Reconnect
}
func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseReason, isExpectedToResume bool) error {
if p.isClosed.Swap(true) {
// already closed