提交 1c4f5aa7 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Working on RtpStream::Params

上级 a022224c
...@@ -304,7 +304,7 @@ namespace RTC ...@@ -304,7 +304,7 @@ namespace RTC
Json::Value toJson() const; Json::Value toJson() const;
void ReduceCodecsAndEncodings(RtpCapabilities& capabilities); void ReduceCodecsAndEncodings(RtpCapabilities& capabilities);
void ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions); void ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions);
uint32_t GetClockRateForEncoding(RtpEncodingParameters& encoding) const; RTC::RtpCodecParameters& GetCodecForEncoding(RtpEncodingParameters& encoding);
private: private:
void ValidateCodecs(); void ValidateCodecs();
......
...@@ -57,6 +57,7 @@ namespace RTC ...@@ -57,6 +57,7 @@ namespace RTC
void ReceiveRtcpFeedback(RTC::RTCP::FeedbackRtpPacket* packet); void ReceiveRtcpFeedback(RTC::RTCP::FeedbackRtpPacket* packet);
private: private:
void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void ClearRtpStreams(); void ClearRtpStreams();
/* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */ /* Pure virtual methods inherited from RTC::RtpStreamRecv::Listener. */
......
...@@ -64,6 +64,7 @@ namespace RTC ...@@ -64,6 +64,7 @@ namespace RTC
uint32_t GetTransmissionRate(uint64_t now); uint32_t GetTransmissionRate(uint64_t now);
private: private:
void CreateRtpStream(RTC::RtpEncodingParameters& encoding);
void RetransmitRtpPacket(RTC::RtpPacket* packet); void RetransmitRtpPacket(RTC::RtpPacket* packet);
void EmitActiveChange() const; void EmitActiveChange() const;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpDictionaries.hpp"
#include <json/json.h> #include <json/json.h>
namespace RTC namespace RTC
...@@ -10,7 +11,21 @@ namespace RTC ...@@ -10,7 +11,21 @@ namespace RTC
class RtpStream class RtpStream
{ {
public: public:
explicit RtpStream(uint32_t ssrc, uint32_t clockRate); struct Params
{
public:
Json::Value toJson() const;
public:
uint32_t ssrc = 0;
uint8_t payloadType = 0;
RTC::RtpCodecMime mime;
uint32_t clockRate = 0;
bool useNack = false;
};
public:
RtpStream(RTC::RtpStream::Params& params);
virtual ~RtpStream(); virtual ~RtpStream();
virtual Json::Value toJson() const = 0; virtual Json::Value toJson() const = 0;
...@@ -27,8 +42,8 @@ namespace RTC ...@@ -27,8 +42,8 @@ namespace RTC
protected: protected:
// Given as argument. // Given as argument.
uint32_t ssrc = 0; RtpStream::Params params;
uint32_t clockRate = 0; // Others.
bool started = false; // Whether at least a RTP packet has been received. bool started = false; // Whether at least a RTP packet has been received.
// https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff. // https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
uint16_t max_seq = 0; // Highest seq. number seen. uint16_t max_seq = 0; // Highest seq. number seen.
...@@ -48,7 +63,7 @@ namespace RTC ...@@ -48,7 +63,7 @@ namespace RTC
inline inline
uint32_t RtpStream::GetSsrc() uint32_t RtpStream::GetSsrc()
{ {
return this->ssrc; return this->params.ssrc;
} }
} }
......
...@@ -18,7 +18,7 @@ namespace RTC ...@@ -18,7 +18,7 @@ namespace RTC
}; };
public: public:
explicit RtpStreamRecv(Listener* listener, uint32_t ssrc, uint32_t clockRate, bool useNack); RtpStreamRecv(Listener* listener, RTC::RtpStream::Params& params);
virtual ~RtpStreamRecv(); virtual ~RtpStreamRecv();
virtual Json::Value toJson() const override; virtual Json::Value toJson() const override;
...@@ -38,7 +38,7 @@ namespace RTC ...@@ -38,7 +38,7 @@ namespace RTC
private: private:
// Passed by argument. // Passed by argument.
Listener* listener = nullptr; Listener* listener = nullptr;
bool useNack = false; // Others.
uint32_t last_sr_timestamp = 0; // The middle 32 bits out of 64 in the NTP timestamp received in the most recent sender report. uint32_t last_sr_timestamp = 0; // The middle 32 bits out of 64 in the NTP timestamp received in the most recent sender report.
uint64_t last_sr_received = 0; // Wallclock time representing the most recent sender report arrival. uint64_t last_sr_received = 0; // Wallclock time representing the most recent sender report arrival.
uint32_t transit = 0; // Relative trans time for prev pkt. uint32_t transit = 0; // Relative trans time for prev pkt.
......
...@@ -25,7 +25,7 @@ namespace RTC ...@@ -25,7 +25,7 @@ namespace RTC
}; };
public: public:
RtpStreamSend(uint32_t ssrc, uint32_t clockRate, size_t bufferSize); RtpStreamSend(RTC::RtpStream::Params& params, size_t bufferSize);
virtual ~RtpStreamSend(); virtual ~RtpStreamSend();
virtual Json::Value toJson() const override; virtual Json::Value toJson() const override;
......
...@@ -247,12 +247,12 @@ namespace RTC ...@@ -247,12 +247,12 @@ namespace RTC
this->headerExtensions = updatedHeaderExtensions; this->headerExtensions = updatedHeaderExtensions;
} }
uint32_t RtpParameters::GetClockRateForEncoding(RtpEncodingParameters& encoding) const RTC::RtpCodecParameters& RtpParameters::GetCodecForEncoding(RtpEncodingParameters& encoding)
{ {
MS_TRACE(); MS_TRACE();
static RTC::RtpCodecParameters fakeCodec;
uint8_t payloadType = encoding.codecPayloadType; uint8_t payloadType = encoding.codecPayloadType;
uint32_t clockRate = 0;
auto it = this->codecs.begin(); auto it = this->codecs.begin();
for (; it != this->codecs.end(); ++it) for (; it != this->codecs.end(); ++it)
...@@ -260,11 +260,7 @@ namespace RTC ...@@ -260,11 +260,7 @@ namespace RTC
auto& codec = *it; auto& codec = *it;
if (codec.payloadType == payloadType) if (codec.payloadType == payloadType)
{ return codec;
clockRate = codec.clockRate;
break;
}
} }
// This should never happen. // This should never happen.
if (it == this->codecs.end()) if (it == this->codecs.end())
...@@ -272,7 +268,7 @@ namespace RTC ...@@ -272,7 +268,7 @@ namespace RTC
MS_ABORT("no valid codec payload type for the given encoding"); MS_ABORT("no valid codec payload type for the given encoding");
} }
return clockRate; return fakeCodec;
} }
inline inline
......
...@@ -176,29 +176,10 @@ namespace RTC ...@@ -176,29 +176,10 @@ namespace RTC
// And notify again. // And notify again.
this->listener->onRtpReceiverParametersDone(this); this->listener->onRtpReceiverParametersDone(this);
// Set the RtpStreamRecv instances. // Create RtpStreamRecv instances.
for (auto& encoding : this->rtpParameters->encodings) for (auto& encoding : this->rtpParameters->encodings)
{ {
// Don't create an RtpStreamRecv if the encoding has no SSRC. CreateRtpStream(encoding);
// TODO: For simulcast or, if not announced, this would be done
// dynamicall by the RtpListener when matching a RID with its SSRC.
if (!encoding.ssrc)
continue;
uint32_t ssrc = encoding.ssrc;
// Don't create a RtpStreamRecv if there is already one for the same SSRC.
// TODO: This may not work for SVC codecs.
if (this->rtpStreams.find(ssrc) != this->rtpStreams.end())
continue;
// Get the clock rate of the stream/encoding.
uint32_t streamClockRate = this->rtpParameters->GetClockRateForEncoding(encoding);
// TODO: Let's assume that, if video, NACK is negotiated. Must do this better.
bool useNack = (this->kind != RTC::Media::Kind::AUDIO);
// Create a RtpStreamRecv for receiving a media stream.
this->rtpStreams[ssrc] = new RTC::RtpStreamRecv(this, ssrc, streamClockRate, useNack);
} }
break; break;
...@@ -371,6 +352,39 @@ namespace RTC ...@@ -371,6 +352,39 @@ namespace RTC
} }
} }
void RtpReceiver::CreateRtpStream(RTC::RtpEncodingParameters& encoding)
{
MS_TRACE();
// Don't create an RtpStreamRecv if the encoding has no SSRC.
// TODO: For simulcast or, if not announced, this would be done
// dynamicall by the RtpListener when matching a RID with its SSRC.
if (!encoding.ssrc)
return;
uint32_t ssrc = encoding.ssrc;
// Don't create a RtpStreamRecv if there is already one for the same SSRC.
// TODO: This may not work for SVC codecs.
if (this->rtpStreams.find(ssrc) != this->rtpStreams.end())
return;
// Get the codec of the stream/encoding.
auto& codec = this->rtpParameters->GetCodecForEncoding(encoding);
// Create stream params.
RTC::RtpStream::Params params;
params.ssrc = ssrc;
params.payloadType = codec.payloadType;
params.mime = codec.mime;
params.clockRate = codec.clockRate;
params.useNack = (this->kind != RTC::Media::Kind::AUDIO);
// Create a RtpStreamRecv for receiving a media stream.
this->rtpStreams[ssrc] = new RTC::RtpStreamRecv(this, params);
}
void RtpReceiver::ClearRtpStreams() void RtpReceiver::ClearRtpStreams()
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -261,31 +261,7 @@ namespace RTC ...@@ -261,31 +261,7 @@ namespace RTC
this->available = true; this->available = true;
// NOTE: We assume a single stream/encoding when sending to remote peers. // NOTE: We assume a single stream/encoding when sending to remote peers.
auto encoding = encodings[0]; CreateRtpStream(encodings[0]);
uint32_t ssrc = encoding.ssrc;
uint32_t streamClockRate = this->rtpParameters->GetClockRateForEncoding(encoding);
// Create a RtpStreamSend for sending a single media stream.
switch (this->kind)
{
case RTC::Media::Kind::VIDEO:
case RTC::Media::Kind::DEPTH:
{
// Buffer up to N packets.
this->rtpStream = new RTC::RtpStreamSend(ssrc, streamClockRate, 200);
break;
}
case RTC::Media::Kind::AUDIO:
{
// No buffer for audio streams.
this->rtpStream = new RTC::RtpStreamSend(ssrc, streamClockRate, 0);
break;
}
default:
;
}
} }
else else
{ {
...@@ -409,6 +385,46 @@ namespace RTC ...@@ -409,6 +385,46 @@ namespace RTC
} }
} }
void RtpSender::CreateRtpStream(RTC::RtpEncodingParameters& encoding)
{
MS_TRACE();
uint32_t ssrc = encoding.ssrc;
// Get the codec of the stream/encoding.
auto& codec = this->rtpParameters->GetCodecForEncoding(encoding);
// Create stream params.
RTC::RtpStream::Params params;
params.ssrc = ssrc;
params.payloadType = codec.payloadType;
params.mime = codec.mime;
params.clockRate = codec.clockRate;
params.useNack = (this->kind != RTC::Media::Kind::AUDIO);
// Create a RtpStreamSend for sending a single media stream.
switch (this->kind)
{
case RTC::Media::Kind::VIDEO:
case RTC::Media::Kind::DEPTH:
{
// Buffer up to N packets.
this->rtpStream = new RTC::RtpStreamSend(params, 200);
break;
}
case RTC::Media::Kind::AUDIO:
{
// No buffer for audio streams.
this->rtpStream = new RTC::RtpStreamSend(params, 0);
break;
}
default:
;
}
}
void RtpSender::RetransmitRtpPacket(RTC::RtpPacket* packet) void RtpSender::RetransmitRtpPacket(RTC::RtpPacket* packet)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -15,9 +15,8 @@ namespace RTC ...@@ -15,9 +15,8 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
RtpStream::RtpStream(uint32_t ssrc, uint32_t clockRate) : RtpStream::RtpStream(RTC::RtpStream::Params& params) :
ssrc(ssrc), params(params)
clockRate(clockRate)
{ {
MS_TRACE(); MS_TRACE();
} }
...@@ -154,4 +153,25 @@ namespace RTC ...@@ -154,4 +153,25 @@ namespace RTC
return true; return true;
} }
Json::Value RtpStream::Params::toJson() const
{
MS_TRACE();
static const Json::StaticString k_ssrc("ssrc");
static const Json::StaticString k_payloadType("payloadType");
static const Json::StaticString k_mime("mime");
static const Json::StaticString k_clockRate("clockRate");
static const Json::StaticString k_useNack("useNack");
Json::Value json(Json::objectValue);
json[k_ssrc] = (Json::UInt)this->ssrc;
json[k_payloadType] = (Json::UInt)this->payloadType;
json[k_mime] = this->mime.name;
json[k_clockRate] = (Json::UInt)this->clockRate;
json[k_useNack] = this->useNack;
return json;
}
} }
...@@ -10,10 +10,9 @@ namespace RTC ...@@ -10,10 +10,9 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
RtpStreamRecv::RtpStreamRecv(Listener* listener, uint32_t ssrc, uint32_t clockRate, bool useNack) : RtpStreamRecv::RtpStreamRecv(Listener* listener, RTC::RtpStream::Params& params) :
RtpStream::RtpStream(ssrc, clockRate), RtpStream::RtpStream(params),
listener(listener), listener(listener)
useNack(useNack)
{ {
MS_TRACE(); MS_TRACE();
} }
...@@ -27,9 +26,7 @@ namespace RTC ...@@ -27,9 +26,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
static Json::Value null_data(Json::nullValue); static const Json::StaticString k_params("params");
static const Json::StaticString k_ssrc("ssrc");
static const Json::StaticString k_clockRate("clockRate");
static const Json::StaticString k_received("received"); static const Json::StaticString k_received("received");
static const Json::StaticString k_maxTimestamp("maxTimestamp"); static const Json::StaticString k_maxTimestamp("maxTimestamp");
static const Json::StaticString k_transit("transit"); static const Json::StaticString k_transit("transit");
...@@ -37,8 +34,7 @@ namespace RTC ...@@ -37,8 +34,7 @@ namespace RTC
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
json[k_ssrc] = (Json::UInt)this->ssrc; json[k_params] = this->params.toJson();
json[k_clockRate] = (Json::UInt)this->clockRate;
json[k_received] = (Json::UInt)this->received; json[k_received] = (Json::UInt)this->received;
json[k_maxTimestamp] = (Json::UInt)this->max_timestamp; json[k_maxTimestamp] = (Json::UInt)this->max_timestamp;
...@@ -60,7 +56,7 @@ namespace RTC ...@@ -60,7 +56,7 @@ namespace RTC
CalculateJitter(packet->GetTimestamp()); CalculateJitter(packet->GetTimestamp());
// May trigger a NACK to the sender. // May trigger a NACK to the sender.
if (this->useNack) if (this->params.useNack)
MayTriggerNack(packet); MayTriggerNack(packet);
return true; return true;
...@@ -129,10 +125,10 @@ namespace RTC ...@@ -129,10 +125,10 @@ namespace RTC
void RtpStreamRecv::CalculateJitter(uint32_t rtpTimestamp) void RtpStreamRecv::CalculateJitter(uint32_t rtpTimestamp)
{ {
if (!this->clockRate) if (!this->params.clockRate)
return; return;
int transit = DepLibUV::GetTime() - (rtpTimestamp * 1000 / this->clockRate); int transit = DepLibUV::GetTime() - (rtpTimestamp * 1000 / this->params.clockRate);
int d = transit - this->transit; int d = transit - this->transit;
this->transit = transit; this->transit = transit;
...@@ -160,7 +156,7 @@ namespace RTC ...@@ -160,7 +156,7 @@ namespace RTC
else else
this->last_seq32 = seq32; this->last_seq32 = seq32;
// Just received next expected seq, do nothing else. // Just received next expected seq, do nothing.
if (diff_seq32 == 1) if (diff_seq32 == 1)
return; return;
...@@ -178,7 +174,7 @@ namespace RTC ...@@ -178,7 +174,7 @@ namespace RTC
uint16_t nack_bitmask = (uint16_t)nack_bitset.to_ulong(); uint16_t nack_bitmask = (uint16_t)nack_bitset.to_ulong();
MS_DEBUG_TAG(rtcp, "NACK triggered [ssrc:%" PRIu32 ", seq:%" PRIu16 ", bitmask:" MS_UINT16_TO_BINARY_PATTERN "]", MS_DEBUG_TAG(rtcp, "NACK triggered [ssrc:%" PRIu32 ", seq:%" PRIu16 ", bitmask:" MS_UINT16_TO_BINARY_PATTERN "]",
this->ssrc, nack_seq, MS_UINT16_TO_BINARY(nack_bitmask)); this->params.ssrc, nack_seq, MS_UINT16_TO_BINARY(nack_bitmask));
this->listener->onNackRequired(this, nack_seq, nack_bitmask); this->listener->onNackRequired(this, nack_seq, nack_bitmask);
} }
......
...@@ -13,8 +13,8 @@ namespace RTC ...@@ -13,8 +13,8 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
RtpStreamSend::RtpStreamSend(uint32_t ssrc, uint32_t clockRate, size_t bufferSize) : RtpStreamSend::RtpStreamSend(RTC::RtpStream::Params& params, size_t bufferSize) :
RtpStream::RtpStream(ssrc, clockRate), RtpStream::RtpStream(params),
storage(bufferSize) storage(bufferSize)
{ {
MS_TRACE(); MS_TRACE();
...@@ -32,17 +32,14 @@ namespace RTC ...@@ -32,17 +32,14 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
static Json::Value null_data(Json::nullValue); static const Json::StaticString k_params("params");
static const Json::StaticString k_ssrc("ssrc");
static const Json::StaticString k_clockRate("clockRate");
static const Json::StaticString k_received("received"); static const Json::StaticString k_received("received");
static const Json::StaticString k_maxTimestamp("maxTimestamp"); static const Json::StaticString k_maxTimestamp("maxTimestamp");
static const Json::StaticString k_receivedBytes("receivedBytes"); static const Json::StaticString k_receivedBytes("receivedBytes");
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
json[k_ssrc] = (Json::UInt)this->ssrc; json[k_params] = this->params.toJson();
json[k_clockRate] = (Json::UInt)this->clockRate;
json[k_received] = (Json::UInt)this->received; json[k_received] = (Json::UInt)this->received;
json[k_maxTimestamp] = (Json::UInt)this->max_timestamp; json[k_maxTimestamp] = (Json::UInt)this->max_timestamp;
...@@ -156,7 +153,7 @@ namespace RTC ...@@ -156,7 +153,7 @@ namespace RTC
if (current_seq32 == seq32) if (current_seq32 == seq32)
{ {
auto current_packet = (*buffer_it).packet; auto current_packet = (*buffer_it).packet;
uint32_t diff = (this->max_timestamp - current_packet->GetTimestamp()) * 1000 / this->clockRate; uint32_t diff = (this->max_timestamp - current_packet->GetTimestamp()) * 1000 / this->params.clockRate;
// Just provide the packet if no older than MAX_RETRANSMISSION_AGE ms. // Just provide the packet if no older than MAX_RETRANSMISSION_AGE ms.
if (diff <= MAX_RETRANSMISSION_AGE) if (diff <= MAX_RETRANSMISSION_AGE)
...@@ -235,7 +232,7 @@ namespace RTC ...@@ -235,7 +232,7 @@ namespace RTC
// Calculate RTP timestamp diff between now and last received RTP packet. // Calculate RTP timestamp diff between now and last received RTP packet.
uint32_t diffMs = now - this->lastPacketTimeMs; uint32_t diffMs = now - this->lastPacketTimeMs;
uint32_t diffRtpTimestamp = diffMs * this->clockRate / 1000; uint32_t diffRtpTimestamp = diffMs * this->params.clockRate / 1000;
report->SetRtpTs(this->lastPacketRtpTimestamp + diffRtpTimestamp); report->SetRtpTs(this->lastPacketRtpTimestamp + diffRtpTimestamp);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "common.hpp" #include "common.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RTCP/FeedbackRtpNack.hpp" #include "RTC/RTCP/FeedbackRtpNack.hpp"
#include "RTC/RtpStream.hpp"
#include "RTC/RtpStreamSend.hpp" #include "RTC/RtpStreamSend.hpp"
#include <vector> #include <vector>
...@@ -59,8 +60,14 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp]") ...@@ -59,8 +60,14 @@ SCENARIO("NACK and RTP packets retransmission", "[rtp][rtcp]")
REQUIRE(packet5->GetSequenceNumber() == 21010); REQUIRE(packet5->GetSequenceNumber() == 21010);
REQUIRE(packet5->GetTimestamp() == 1533796931); REQUIRE(packet5->GetTimestamp() == 1533796931);
RtpStream::Params params;
params.ssrc = packet1->GetSsrc();
params.clockRate = 90000;
params.useNack = true;
// Create a RtpStreamSend. // Create a RtpStreamSend.
RtpStreamSend* stream = new RtpStreamSend(packet1->GetSsrc(), 90000, 200); RtpStreamSend* stream = new RtpStreamSend(params, 200);
// Receive all the packets in order into the stream. // Receive all the packets in order into the stream.
stream->ReceivePacket(packet1); stream->ReceivePacket(packet1);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "include/helpers.hpp" #include "include/helpers.hpp"
#include "common.hpp" #include "common.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp"
#include "RTC/RtpStreamRecv.hpp" #include "RTC/RtpStreamRecv.hpp"
#include "Logger.hpp" #include "Logger.hpp"
#include <bitset> // std::bitset() #include <bitset> // std::bitset()
...@@ -49,8 +50,14 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -49,8 +50,14 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
REQUIRE(packet->GetSequenceNumber() == 100); REQUIRE(packet->GetSequenceNumber() == 100);
RtpStream::Params params;
params.ssrc = packet->GetSsrc();
params.clockRate = 90000;
params.useNack = true;
RtpStreamRecvListener listener; RtpStreamRecvListener listener;
RtpStreamRecv rtpStream(&listener, packet->GetSsrc(), 90000, true); RtpStreamRecv rtpStream(&listener, params);
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
...@@ -65,6 +72,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -65,6 +72,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
listener.expected_nack_seq = 102; listener.expected_nack_seq = 102;
listener.expected_nack_bitmask = 0b0000000000000001; listener.expected_nack_bitmask = 0b0000000000000001;
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
REQUIRE(listener.should_trigger == false);
packet->SetSequenceNumber(104); packet->SetSequenceNumber(104);
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
...@@ -80,6 +88,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -80,6 +88,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
listener.expected_nack_seq = 105; listener.expected_nack_seq = 105;
listener.expected_nack_bitmask = 0b0000000000000011; listener.expected_nack_bitmask = 0b0000000000000011;
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
REQUIRE(listener.should_trigger == false);
delete packet; delete packet;
} }
...@@ -100,8 +109,14 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -100,8 +109,14 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
REQUIRE(packet->GetSequenceNumber() == 100); REQUIRE(packet->GetSequenceNumber() == 100);
RtpStream::Params params;
params.ssrc = packet->GetSsrc();
params.clockRate = 90000;
params.useNack = true;
RtpStreamRecvListener listener; RtpStreamRecvListener listener;
RtpStreamRecv rtpStream(&listener, packet->GetSsrc(), 90000, true); RtpStreamRecv rtpStream(&listener, params);
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
...@@ -110,6 +125,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -110,6 +125,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
listener.expected_nack_seq = 103; listener.expected_nack_seq = 103;
listener.expected_nack_bitmask = 0b1111111111111111; listener.expected_nack_bitmask = 0b1111111111111111;
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
REQUIRE(listener.should_trigger == false);
delete packet; delete packet;
} }
...@@ -130,8 +146,14 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -130,8 +146,14 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
REQUIRE(packet->GetSequenceNumber() == 65535); REQUIRE(packet->GetSequenceNumber() == 65535);
RtpStream::Params params;
params.ssrc = packet->GetSsrc();
params.clockRate = 90000;
params.useNack = true;
RtpStreamRecvListener listener; RtpStreamRecvListener listener;
RtpStreamRecv rtpStream(&listener, packet->GetSsrc(), 90000, true); RtpStreamRecv rtpStream(&listener, params);
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
...@@ -140,6 +162,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]") ...@@ -140,6 +162,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
listener.expected_nack_seq = 3; listener.expected_nack_seq = 3;
listener.expected_nack_bitmask = 0b1111111111111111; listener.expected_nack_bitmask = 0b1111111111111111;
rtpStream.ReceivePacket(packet); rtpStream.ReceivePacket(packet);
REQUIRE(listener.should_trigger == false);
delete packet; delete packet;
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论