* events * bump * update incoming stats * publisher stats * outgoing rtcp * stats * remove unnecessary struct * merge mediaTrack * put comment back
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package telemetry
|
|
|
|
import (
|
|
livekit "github.com/livekit/protocol/proto"
|
|
"github.com/pion/interceptor"
|
|
"github.com/pion/rtcp"
|
|
)
|
|
|
|
type StatsInterceptorFactory struct {
|
|
t *TelemetryService
|
|
participantID string
|
|
identity string
|
|
}
|
|
|
|
func (f *StatsInterceptorFactory) NewInterceptor(id string) (interceptor.Interceptor, error) {
|
|
return &StatsInterceptor{
|
|
t: f.t,
|
|
participantID: f.participantID,
|
|
identity: f.identity,
|
|
}, nil
|
|
}
|
|
|
|
type StatsInterceptor struct {
|
|
interceptor.NoOp
|
|
|
|
t *TelemetryService
|
|
participantID string
|
|
identity string
|
|
}
|
|
|
|
// BindRTCPWriter lets you modify any outgoing RTCP packets. It is called once per PeerConnection. The returned method
|
|
// will be called once per packet batch.
|
|
func (s *StatsInterceptor) BindRTCPWriter(writer interceptor.RTCPWriter) interceptor.RTCPWriter {
|
|
return interceptor.RTCPWriterFunc(func(pkts []rtcp.Packet, attributes interceptor.Attributes) (int, error) {
|
|
s.t.HandleRTCP(livekit.StreamType_UPSTREAM, s.participantID, pkts)
|
|
return writer.Write(pkts, attributes)
|
|
})
|
|
}
|