@@ -27,18 +27,18 @@ import (
2727// silenceFiller detects RTP timestamp discontinuities (silence suppression)
2828// and generates silence samples to fill the gaps before passing packets to the decoder.
2929type silenceFiller struct {
30- maxGapSize int
31- encodedSink rtp.Handler
32- pcmSink msdk.PCM16Writer
33- rtpSamplesPerFrame int // For gap detection (based on RTP clock rate)
34- pcmSamplesPerFrame int // For silence generation (based on PCM output rate)
35- log logger.Logger
36- lastTS atomic.Uint64
37- lastSeq atomic.Uint64
38- packets atomic.Uint64
39- gapCount atomic.Uint64
40- gapSizeSum atomic.Uint64
41- lastPrintTime time.Time
30+ maxGapSize int
31+ encodedSink rtp.HandlerCloser
32+ pcmSink msdk.PCM16Writer
33+ rtpSamplesPerFrame int // For gap detection (based on RTP clock rate)
34+ pcmSamplesPerFrame int // For silence generation (based on PCM output rate)
35+ log logger.Logger
36+ lastTS atomic.Uint64
37+ lastSeq atomic.Uint64
38+ packets atomic.Uint64
39+ gapCount atomic.Uint64
40+ gapSizeSum atomic.Uint64
41+ lastPrintTime time.Time
4242}
4343
4444type SilenceSuppressionOption func (* silenceFiller )
@@ -51,7 +51,7 @@ func WithMaxGapSize(maxGapSize int) SilenceSuppressionOption {
5151 }
5252}
5353
54- func newSilenceFiller (encodedSink rtp.Handler , pcmSink msdk.PCM16Writer , rtpClockRate int , pcmSampleRate int , log logger.Logger , options ... SilenceSuppressionOption ) rtp.Handler {
54+ func newSilenceFiller (encodedSink rtp.HandlerCloser , pcmSink msdk.PCM16Writer , rtpClockRate int , pcmSampleRate int , log logger.Logger , options ... SilenceSuppressionOption ) rtp.HandlerCloser {
5555 // TODO: We assume 20ms frame. We would need to adjust this when:
5656 // - When we add support for other frame durations.
5757 // - When we add support for re-INVITE sdp renegotiation (maybe, if we don't destroy this and start over).
@@ -75,6 +75,10 @@ func newSilenceFiller(encodedSink rtp.Handler, pcmSink msdk.PCM16Writer, rtpCloc
7575 return h
7676}
7777
78+ func (h * silenceFiller ) Close () {
79+ h .encodedSink .Close ()
80+ }
81+
7882func (h * silenceFiller ) String () string {
7983 return fmt .Sprintf ("SilenceFiller(%d) -> %s" , h .maxGapSize , h .encodedSink .String ())
8084}
0 commit comments