An attempt to use publisher side RTCP sender report while forwarding (#1286)
* WIP commit * comment * clean up * remove unused stuff * cleaner comment * remove unused stuff * remove unused stuff * more comments * TrackSender method to handle RTCP sender report data * fix test * push rtcp sender report data to down tracks * Need payload type for codec id mapping in relay protocol * rename variable a bit
This commit is contained in:
@@ -83,9 +83,10 @@ type Buffer struct {
|
||||
lastFractionLostToReport uint8 // Last fraction lost from subscribers, should report to publisher; Audio only
|
||||
|
||||
// callbacks
|
||||
onClose func()
|
||||
onRtcpFeedback func([]rtcp.Packet)
|
||||
onFpsChanged func()
|
||||
onClose func()
|
||||
onRtcpFeedback func([]rtcp.Packet)
|
||||
onRtcpSenderReport func(*RTCPSenderReportData)
|
||||
onFpsChanged func()
|
||||
|
||||
// logger
|
||||
logger logger.Logger
|
||||
@@ -615,14 +616,32 @@ func (b *Buffer) buildReceptionReport() *rtcp.ReceptionReport {
|
||||
}
|
||||
|
||||
func (b *Buffer) SetSenderReportData(rtpTime uint32, ntpTime uint64) {
|
||||
srData := &RTCPSenderReportData{
|
||||
RTPTimestamp: rtpTime,
|
||||
NTPTimestamp: mediatransportutil.NtpTime(ntpTime),
|
||||
ArrivalTime: time.Now(),
|
||||
}
|
||||
|
||||
b.RLock()
|
||||
if b.rtpStats != nil {
|
||||
b.rtpStats.SetRtcpSenderReportData(srData)
|
||||
}
|
||||
b.RUnlock()
|
||||
|
||||
if b.onRtcpSenderReport != nil {
|
||||
b.onRtcpSenderReport(srData)
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Buffer) GetSenderReportData() *RTCPSenderReportData {
|
||||
b.RLock()
|
||||
defer b.RUnlock()
|
||||
|
||||
if b.rtpStats == nil {
|
||||
return
|
||||
if b.rtpStats != nil {
|
||||
return b.rtpStats.GetRtcpSenderReportData()
|
||||
}
|
||||
|
||||
b.rtpStats.SetRtcpSenderReportData(rtpTime, mediatransportutil.NtpTime(ntpTime), time.Now())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Buffer) SetLastFractionLostReport(lost uint8) {
|
||||
@@ -664,6 +683,10 @@ func (b *Buffer) OnRtcpFeedback(fn func(fb []rtcp.Packet)) {
|
||||
b.onRtcpFeedback = fn
|
||||
}
|
||||
|
||||
func (b *Buffer) OnRtcpSenderReport(fn func(srData *RTCPSenderReportData)) {
|
||||
b.onRtcpSenderReport = fn
|
||||
}
|
||||
|
||||
// GetMediaSSRC returns the associated SSRC of the RTP stream
|
||||
func (b *Buffer) GetMediaSSRC() uint32 {
|
||||
return b.mediaSSRC
|
||||
|
||||
Reference in New Issue
Block a user