mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +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 {
|
for trackID, track := range st.stTracks {
|
||||||
cTrackID := trackID
|
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(
|
track.udpRTCPSender = rtcpsender.New(
|
||||||
st.s.udpSenderReportPeriod,
|
st.s.udpSenderReportPeriod,
|
||||||
st.tracks[trackID].ClockRate(),
|
st.tracks[trackID].ClockRate(),
|
||||||
func(pkt rtcp.Packet) {
|
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)
|
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