mirror of
https://github.com/aler9/gortsplib
synced 2025-09-27 03:25:52 +08:00
set SSRC of outgoing packets (#803)
In client and server, each format now has a fixed, unique, known in advance SSRC, that is applied to outgoing packets belonging to each format. This is needed to support SRTP/MIKEY, that require each format to have a fixed, unique, and known in advance SSRC. A secondary effect is that SETUP responses now always contain SSRCs of each format, regardless of the fact that the first packet has been produced or not (previously we needed at least one packet, from which the SSRC was extracted).
This commit is contained in:
@@ -558,6 +558,48 @@ func TestClientPlay(t *testing.T) {
|
||||
<-packetRecv
|
||||
|
||||
s := c.Stats()
|
||||
require.Equal(t, &ClientStats{
|
||||
Conn: StatsConn{
|
||||
BytesReceived: s.Conn.BytesReceived,
|
||||
BytesSent: s.Conn.BytesSent,
|
||||
},
|
||||
Session: StatsSession{
|
||||
BytesReceived: s.Session.BytesReceived,
|
||||
BytesSent: s.Session.BytesSent,
|
||||
RTPPacketsReceived: s.Session.RTPPacketsReceived,
|
||||
RTCPPacketsReceived: s.Session.RTCPPacketsReceived,
|
||||
RTCPPacketsSent: s.Session.RTCPPacketsSent,
|
||||
Medias: map[*description.Media]StatsSessionMedia{
|
||||
sd.Medias[0]: { //nolint:dupl
|
||||
BytesReceived: s.Session.Medias[sd.Medias[0]].BytesReceived,
|
||||
BytesSent: s.Session.Medias[sd.Medias[0]].BytesSent,
|
||||
RTCPPacketsReceived: s.Session.Medias[sd.Medias[0]].RTCPPacketsReceived,
|
||||
RTCPPacketsSent: s.Session.Medias[sd.Medias[0]].RTCPPacketsSent,
|
||||
Formats: map[format.Format]StatsSessionFormat{
|
||||
sd.Medias[0].Formats[0]: {
|
||||
RTPPacketsReceived: s.Session.Medias[sd.Medias[0]].Formats[sd.Medias[0].Formats[0]].RTPPacketsReceived,
|
||||
LocalSSRC: s.Session.Medias[sd.Medias[0]].Formats[sd.Medias[0].Formats[0]].LocalSSRC,
|
||||
RemoteSSRC: s.Session.Medias[sd.Medias[0]].Formats[sd.Medias[0].Formats[0]].RemoteSSRC,
|
||||
},
|
||||
},
|
||||
},
|
||||
sd.Medias[1]: { //nolint:dupl
|
||||
BytesReceived: s.Session.Medias[sd.Medias[1]].BytesReceived,
|
||||
BytesSent: s.Session.Medias[sd.Medias[1]].BytesSent,
|
||||
RTCPPacketsReceived: s.Session.Medias[sd.Medias[1]].RTCPPacketsReceived,
|
||||
RTCPPacketsSent: s.Session.Medias[sd.Medias[1]].RTCPPacketsSent,
|
||||
Formats: map[format.Format]StatsSessionFormat{
|
||||
sd.Medias[1].Formats[0]: {
|
||||
RTPPacketsReceived: s.Session.Medias[sd.Medias[1]].Formats[sd.Medias[1].Formats[0]].RTPPacketsReceived,
|
||||
LocalSSRC: s.Session.Medias[sd.Medias[1]].Formats[sd.Medias[1].Formats[0]].LocalSSRC,
|
||||
RemoteSSRC: s.Session.Medias[sd.Medias[1]].Formats[sd.Medias[1].Formats[0]].RemoteSSRC,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, s)
|
||||
|
||||
require.Greater(t, s.Session.BytesSent, uint64(19))
|
||||
require.Less(t, s.Session.BytesSent, uint64(41))
|
||||
require.Greater(t, s.Session.BytesReceived, uint64(31))
|
||||
|
Reference in New Issue
Block a user