mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
server: send RTCP sender reports to TCP clients too
this allows Nvidia Deepstream to compute NTP timestamp of frames (https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_NTP_Timestamp.html)
This commit is contained in:
@@ -130,11 +130,17 @@ func (st *ServerStream) readerAdd(
|
||||
|
||||
for trackID, track := range st.stTracks {
|
||||
cTrackID := trackID
|
||||
|
||||
// always generate RTCP sender reports.
|
||||
// they're mandatory needed when transport protocol is UDP or UDP-multicast.
|
||||
// they're also needed when transport protocol is TCP and client is Nvidia Deepstream
|
||||
// since they're used to compute NTP timestamp of frames:
|
||||
// https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_NTP_Timestamp.html
|
||||
track.udpRTCPSender = rtcpsender.New(
|
||||
st.s.udpSenderReportPeriod,
|
||||
st.tracks[trackID].ClockRate(),
|
||||
func(pkt rtcp.Packet) {
|
||||
st.writePacketRTCPSenderReport(cTrackID, pkt)
|
||||
st.WritePacketRTCP(cTrackID, pkt)
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -289,25 +295,3 @@ func (st *ServerStream) WritePacketRTCP(trackID int, pkt rtcp.Packet) {
|
||||
st.serverMulticastHandlers[trackID].writePacketRTCP(byts)
|
||||
}
|
||||
}
|
||||
|
||||
func (st *ServerStream) writePacketRTCPSenderReport(trackID int, pkt rtcp.Packet) {
|
||||
byts, err := pkt.Marshal()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
st.mutex.RLock()
|
||||
defer st.mutex.RUnlock()
|
||||
|
||||
// send unicast (UDP only)
|
||||
for r := range st.readersUnicast {
|
||||
if *r.setuppedTransport == TransportUDP {
|
||||
r.writePacketRTCP(trackID, byts)
|
||||
}
|
||||
}
|
||||
|
||||
// send multicast
|
||||
if st.serverMulticastHandlers != nil {
|
||||
st.serverMulticastHandlers[trackID].writePacketRTCP(byts)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user