Check forwarder started when seeing. (#1191)
When switching from local -> remote or remote -> local, the forwarder state is cached and restored after the switch to ensure continuity in sequence number /time stamp. But, if the forwarder had not started before the switch, the sequence number always starts at 1 because of seeding. So, do not see unless forwarder was started before the switch.
This commit is contained in:
@@ -179,7 +179,7 @@ func (r *RTPStats) Seed(from *RTPStats) {
|
|||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
||||||
if from == nil {
|
if from == nil || !from.initialized {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -171,14 +171,15 @@ var (
|
|||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
type ForwarderState struct {
|
type ForwarderState struct {
|
||||||
|
Started bool
|
||||||
LastTSCalc int64
|
LastTSCalc int64
|
||||||
RTP RTPMungerState
|
RTP RTPMungerState
|
||||||
VP8 VP8MungerState
|
VP8 VP8MungerState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f ForwarderState) String() string {
|
func (f ForwarderState) String() string {
|
||||||
return fmt.Sprintf("ForwarderState{lTSCalc: %d, rtp: %s, vp8: %s}",
|
return fmt.Sprintf("ForwarderState{started: %v, lTSCalc: %d, rtp: %s, vp8: %s}",
|
||||||
f.LastTSCalc, f.RTP.String(), f.VP8.String())
|
f.Started, f.LastTSCalc, f.RTP.String(), f.VP8.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
@@ -261,7 +262,12 @@ func (f *Forwarder) GetState() ForwarderState {
|
|||||||
f.lock.RLock()
|
f.lock.RLock()
|
||||||
defer f.lock.RUnlock()
|
defer f.lock.RUnlock()
|
||||||
|
|
||||||
|
if !f.started {
|
||||||
|
return ForwarderState{}
|
||||||
|
}
|
||||||
|
|
||||||
state := ForwarderState{
|
state := ForwarderState{
|
||||||
|
Started: f.started,
|
||||||
LastTSCalc: f.lTSCalc,
|
LastTSCalc: f.lTSCalc,
|
||||||
RTP: f.rtpMunger.GetLast(),
|
RTP: f.rtpMunger.GetLast(),
|
||||||
}
|
}
|
||||||
@@ -274,6 +280,10 @@ func (f *Forwarder) GetState() ForwarderState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Forwarder) SeedState(state ForwarderState) {
|
func (f *Forwarder) SeedState(state ForwarderState) {
|
||||||
|
if !state.Started {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
f.lock.Lock()
|
f.lock.Lock()
|
||||||
defer f.lock.Unlock()
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user