mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
add more tests to rtcpreceiver
This commit is contained in:
@@ -506,7 +506,7 @@ func (c *ConnClient) Setup(u *base.URL, mode headers.TransportMode, proto base.S
|
|||||||
c.tracks = append(c.tracks, track)
|
c.tracks = append(c.tracks, track)
|
||||||
|
|
||||||
if mode == headers.TransportModePlay {
|
if mode == headers.TransportModePlay {
|
||||||
c.rtcpReceivers[track.Id] = rtcpreceiver.New()
|
c.rtcpReceivers[track.Id] = rtcpreceiver.New(nil)
|
||||||
|
|
||||||
if proto == StreamProtocolUDP {
|
if proto == StreamProtocolUDP {
|
||||||
v := time.Now().Unix()
|
v := time.Now().Unix()
|
||||||
|
@@ -28,14 +28,14 @@ func TestRtcpReceiver(t *testing.T) {
|
|||||||
byts, _ := rtpPkt.Marshal()
|
byts, _ := rtpPkt.Marshal()
|
||||||
rr.OnFrame(base.StreamTypeRtp, byts)
|
rr.OnFrame(base.StreamTypeRtp, byts)
|
||||||
|
|
||||||
rtcpPkt := rtcp.SenderReport{
|
srPkt := rtcp.SenderReport{
|
||||||
SSRC: 0xba9da416,
|
SSRC: 0xba9da416,
|
||||||
NTPTime: 0xe363887a17ced916,
|
NTPTime: 0xe363887a17ced916,
|
||||||
RTPTime: 1287981738,
|
RTPTime: 1287981738,
|
||||||
PacketCount: 714,
|
PacketCount: 714,
|
||||||
OctetCount: 859127,
|
OctetCount: 859127,
|
||||||
}
|
}
|
||||||
byts, _ = rtcpPkt.Marshal()
|
byts, _ = srPkt.Marshal()
|
||||||
rr.OnFrame(base.StreamTypeRtcp, byts)
|
rr.OnFrame(base.StreamTypeRtcp, byts)
|
||||||
|
|
||||||
res := rr.Report()
|
res := rr.Report()
|
||||||
@@ -51,6 +51,34 @@ func TestRtcpReceiver(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
expected, _ := expectedPkt.Marshal()
|
expected, _ := expectedPkt.Marshal()
|
||||||
|
require.Equal(t, expected, res)
|
||||||
|
|
||||||
|
rtpPkt = rtp.Packet{
|
||||||
|
Header: rtp.Header{
|
||||||
|
Version: 2,
|
||||||
|
Marker: true,
|
||||||
|
PayloadType: 96,
|
||||||
|
SequenceNumber: 945,
|
||||||
|
Timestamp: 1287987768,
|
||||||
|
SSRC: 0xba9da416,
|
||||||
|
},
|
||||||
|
Payload: []byte("\x00\x00"),
|
||||||
|
}
|
||||||
|
byts, _ = rtpPkt.Marshal()
|
||||||
|
rr.OnFrame(base.StreamTypeRtp, byts)
|
||||||
|
|
||||||
|
res = rr.Report()
|
||||||
|
|
||||||
|
expectedPkt = rtcp.ReceiverReport{
|
||||||
|
SSRC: 0x65f83afb,
|
||||||
|
Reports: []rtcp.ReceptionReport{
|
||||||
|
{
|
||||||
|
SSRC: 0xba9da416,
|
||||||
|
LastSequenceNumber: uint32(1<<16 | 945),
|
||||||
|
LastSenderReport: uint32(0x887a17ce),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expected, _ = expectedPkt.Marshal()
|
||||||
require.Equal(t, expected, res)
|
require.Equal(t, expected, res)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user