|
6 | 6 | "time" |
7 | 7 |
|
8 | 8 | "github.com/pion/interceptor" |
| 9 | + "github.com/pion/logging" |
9 | 10 | "github.com/pion/rtcp" |
10 | 11 | "github.com/pion/rtp" |
11 | 12 | ) |
@@ -88,6 +89,7 @@ func (f *InterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor, |
88 | 89 | i := &Interceptor{ |
89 | 90 | NoOp: interceptor.NoOp{}, |
90 | 91 | lock: sync.Mutex{}, |
| 92 | + log: logging.NewDefaultLoggerFactory().NewLogger("ccfb_interceptor"), |
91 | 93 | timestamp: time.Now, |
92 | 94 | convertCCFB: convertCCFB, |
93 | 95 | convertTWCC: convertTWCC, |
@@ -117,6 +119,7 @@ func (f *InterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor, |
117 | 119 | type Interceptor struct { |
118 | 120 | interceptor.NoOp |
119 | 121 | lock sync.Mutex |
| 122 | + log logging.LeveledLogger |
120 | 123 | timestamp func() time.Time |
121 | 124 | convertCCFB func(ts time.Time, feedback *rtcp.CCFeedbackReport) (time.Time, map[uint32][]acknowledgement) |
122 | 125 | convertTWCC func(feedback *rtcp.TransportLayerCC) (time.Time, map[uint32][]acknowledgement) |
@@ -157,12 +160,16 @@ func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer inter |
157 | 160 | ssrc := header.SSRC |
158 | 161 | seqNr := header.SequenceNumber |
159 | 162 | if useTWCC { |
160 | | - ssrc = 0 |
161 | 163 | var twccHdrExt rtp.TransportCCExtension |
162 | 164 | if err := twccHdrExt.Unmarshal(header.GetExtension(twccHdrExtID)); err != nil { |
163 | | - return 0, err |
| 165 | + i.log.Warnf("CCFB configured for TWCC, but failed to get TWCC header extension from outgoing packet. Falling back to saving history for CCFB feedback reports. err: %v", err) |
| 166 | + if _, ok := i.ssrcToHistory[ssrc]; !ok { |
| 167 | + i.ssrcToHistory[ssrc] = i.historyFactory(i.historySize) |
| 168 | + } |
| 169 | + } else { |
| 170 | + seqNr = twccHdrExt.TransportSequence |
| 171 | + ssrc = 0 |
164 | 172 | } |
165 | | - seqNr = twccHdrExt.TransportSequence |
166 | 173 | } |
167 | 174 | if err := i.ssrcToHistory[ssrc].add(seqNr, header.MarshalSize()+len(payload), i.timestamp()); err != nil { |
168 | 175 | return 0, err |
|
0 commit comments