mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
GCC No-Op Pacer (#29)
* on rtcp send multiple packets. * use no op pacer.
This commit is contained in:
parent
124c5ae117
commit
0086900053
@ -213,9 +213,13 @@ func (manager *WebRTCManagerCtx) newPeerConnection(bitrate int, codecs []codec.R
|
|||||||
|
|
||||||
congestionController, err := cc.NewInterceptor(func() (cc.BandwidthEstimator, error) {
|
congestionController, err := cc.NewInterceptor(func() (cc.BandwidthEstimator, error) {
|
||||||
if bitrate == 0 {
|
if bitrate == 0 {
|
||||||
bitrate = 1000000
|
bitrate = 1_000_000
|
||||||
}
|
}
|
||||||
return gcc.NewSendSideBWE(gcc.SendSideBWEInitialBitrate(bitrate))
|
|
||||||
|
return gcc.NewSendSideBWE(
|
||||||
|
gcc.SendSideBWEInitialBitrate(bitrate),
|
||||||
|
gcc.SendSideBWEPacer(gcc.NewNoOpPacer()),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
@ -625,12 +629,14 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, bitrate int,
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
videoTrack.OnRTCP(func(p rtcp.Packet) {
|
videoTrack.OnRTCP(func(packets []rtcp.Packet) {
|
||||||
if rtcpPacket, ok := p.(*rtcp.ReceiverReport); ok {
|
for _, p := range packets {
|
||||||
l := len(rtcpPacket.Reports)
|
if rtcpPacket, ok := p.(*rtcp.ReceiverReport); ok {
|
||||||
if l > 0 {
|
l := len(rtcpPacket.Reports)
|
||||||
// use only last report
|
if l > 0 {
|
||||||
manager.metrics.SetReceiverReport(session, rtcpPacket.Reports[l-1])
|
// use only last report
|
||||||
|
manager.metrics.SetReceiverReport(session, rtcpPacket.Reports[l-1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -26,7 +26,7 @@ type Track struct {
|
|||||||
stream types.StreamSinkManager
|
stream types.StreamSinkManager
|
||||||
streamMu sync.Mutex
|
streamMu sync.Mutex
|
||||||
|
|
||||||
onRtcp func(rtcp.Packet)
|
onRtcp func([]rtcp.Packet)
|
||||||
onRtcpMu sync.RWMutex
|
onRtcpMu sync.RWMutex
|
||||||
|
|
||||||
bitrateChange func(int) (bool, error)
|
bitrateChange func(int) (bool, error)
|
||||||
@ -84,9 +84,8 @@ func NewTrack(logger zerolog.Logger, codec codec.RTPCodec, connection *webrtc.Pe
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Track) rtcpReader(sender *webrtc.RTPSender) {
|
func (t *Track) rtcpReader(sender *webrtc.RTPSender) {
|
||||||
rtcpBuf := make([]byte, 1500)
|
|
||||||
for {
|
for {
|
||||||
n, _, err := sender.Read(rtcpBuf)
|
packets, _, err := sender.ReadRTCP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF || err == io.ErrClosedPipe {
|
if err == io.EOF || err == io.ErrClosedPipe {
|
||||||
return
|
return
|
||||||
@ -96,21 +95,11 @@ func (t *Track) rtcpReader(sender *webrtc.RTPSender) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
packets, err := rtcp.Unmarshal(rtcpBuf[:n])
|
|
||||||
if err != nil {
|
|
||||||
t.logger.Err(err).Msg("RTCP unmarshal error")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
t.onRtcpMu.RLock()
|
t.onRtcpMu.RLock()
|
||||||
handler := t.onRtcp
|
if t.onRtcp != nil {
|
||||||
t.onRtcpMu.RUnlock()
|
go t.onRtcp(packets)
|
||||||
|
|
||||||
for _, packet := range packets {
|
|
||||||
if handler != nil {
|
|
||||||
go handler(packet)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
t.onRtcpMu.RUnlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +141,7 @@ func (t *Track) SetPaused(paused bool) {
|
|||||||
t.paused = paused
|
t.paused = paused
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Track) OnRTCP(f func(rtcp.Packet)) {
|
func (t *Track) OnRTCP(f func([]rtcp.Packet)) {
|
||||||
t.onRtcpMu.Lock()
|
t.onRtcpMu.Lock()
|
||||||
defer t.onRtcpMu.Unlock()
|
defer t.onRtcpMu.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user