Remove add/removal of ViEReceiver RTP modules.
Since all possible modules are known on Init we don't need to add/remove them in runtime. BUG=webrtc:5494 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/1739893005 . Cr-Commit-Position: refs/heads/master@{#11843}
This commit is contained in:
parent
f475277547
commit
4fa7ecad12
@ -121,7 +121,7 @@ ViEChannel::ViEChannel(Transport* transport,
|
||||
&send_frame_count_observer_,
|
||||
&send_side_delay_observer_,
|
||||
max_rtp_streams)) {
|
||||
vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]);
|
||||
vie_receiver_.Init(rtp_rtcp_modules_);
|
||||
if (sender_) {
|
||||
RTC_DCHECK(send_payload_router_);
|
||||
RTC_DCHECK(!vcm_);
|
||||
@ -198,16 +198,9 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
|
||||
send_payload_router_->set_active(false);
|
||||
send_payload_router_->SetSendingRtpModules(0);
|
||||
|
||||
std::vector<RtpRtcp*> registered_modules;
|
||||
size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0
|
||||
? video_codec.numberOfSimulcastStreams
|
||||
: 1;
|
||||
for (size_t i = 0; i < num_active_modules; ++i)
|
||||
registered_modules.push_back(rtp_rtcp_modules_[i]);
|
||||
|
||||
// |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old
|
||||
// modules can be deleted after this step.
|
||||
vie_receiver_.RegisterRtpRtcpModules(registered_modules);
|
||||
|
||||
// Update the packet and payload routers with the sending RtpRtcp modules.
|
||||
send_payload_router_->SetSendingRtpModules(num_active_modules);
|
||||
|
||||
@ -17,10 +17,8 @@
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/fec_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||
@ -37,20 +35,17 @@ ViEReceiver::ViEReceiver(VideoCodingModule* module_vcm,
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator,
|
||||
RtpFeedback* rtp_feedback)
|
||||
: clock_(Clock::GetRealTimeClock()),
|
||||
rtp_header_parser_(RtpHeaderParser::Create()),
|
||||
rtp_payload_registry_(
|
||||
new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))),
|
||||
rtp_receiver_(
|
||||
RtpReceiver::CreateVideoReceiver(clock_,
|
||||
this,
|
||||
rtp_feedback,
|
||||
rtp_payload_registry_.get())),
|
||||
rtp_receive_statistics_(ReceiveStatistics::Create(clock_)),
|
||||
fec_receiver_(FecReceiver::Create(this)),
|
||||
rtp_rtcp_(NULL),
|
||||
vcm_(module_vcm),
|
||||
remote_bitrate_estimator_(remote_bitrate_estimator),
|
||||
ntp_estimator_(new RemoteNtpTimeEstimator(clock_)),
|
||||
ntp_estimator_(clock_),
|
||||
rtp_payload_registry_(RTPPayloadStrategy::CreateStrategy(false)),
|
||||
rtp_header_parser_(RtpHeaderParser::Create()),
|
||||
rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_,
|
||||
this,
|
||||
rtp_feedback,
|
||||
&rtp_payload_registry_)),
|
||||
rtp_receive_statistics_(ReceiveStatistics::Create(clock_)),
|
||||
fec_receiver_(FecReceiver::Create(this)),
|
||||
receiving_(false),
|
||||
restored_packet_in_use_(false),
|
||||
last_packet_log_ms_(-1) {}
|
||||
@ -75,23 +70,15 @@ void ViEReceiver::UpdateHistograms() {
|
||||
|
||||
bool ViEReceiver::SetReceiveCodec(const VideoCodec& video_codec) {
|
||||
int8_t old_pltype = -1;
|
||||
if (rtp_payload_registry_->ReceivePayloadType(video_codec.plName,
|
||||
kVideoPayloadTypeFrequency,
|
||||
0,
|
||||
video_codec.maxBitrate,
|
||||
&old_pltype) != -1) {
|
||||
rtp_payload_registry_->DeRegisterReceivePayload(old_pltype);
|
||||
if (rtp_payload_registry_.ReceivePayloadType(
|
||||
video_codec.plName, kVideoPayloadTypeFrequency, 0,
|
||||
video_codec.maxBitrate, &old_pltype) != -1) {
|
||||
rtp_payload_registry_.DeRegisterReceivePayload(old_pltype);
|
||||
}
|
||||
|
||||
return RegisterPayload(video_codec);
|
||||
}
|
||||
|
||||
bool ViEReceiver::RegisterPayload(const VideoCodec& video_codec) {
|
||||
return rtp_receiver_->RegisterReceivePayload(video_codec.plName,
|
||||
video_codec.plType,
|
||||
kVideoPayloadTypeFrequency,
|
||||
0,
|
||||
video_codec.maxBitrate) == 0;
|
||||
return rtp_receiver_->RegisterReceivePayload(
|
||||
video_codec.plName, video_codec.plType, kVideoPayloadTypeFrequency,
|
||||
0, 0) == 0;
|
||||
}
|
||||
|
||||
void ViEReceiver::SetNackStatus(bool enable,
|
||||
@ -108,24 +95,24 @@ void ViEReceiver::SetNackStatus(bool enable,
|
||||
|
||||
void ViEReceiver::SetRtxPayloadType(int payload_type,
|
||||
int associated_payload_type) {
|
||||
rtp_payload_registry_->SetRtxPayloadType(payload_type,
|
||||
associated_payload_type);
|
||||
rtp_payload_registry_.SetRtxPayloadType(payload_type,
|
||||
associated_payload_type);
|
||||
}
|
||||
|
||||
void ViEReceiver::SetUseRtxPayloadMappingOnRestore(bool val) {
|
||||
rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(val);
|
||||
rtp_payload_registry_.set_use_rtx_payload_mapping_on_restore(val);
|
||||
}
|
||||
|
||||
void ViEReceiver::SetRtxSsrc(uint32_t ssrc) {
|
||||
rtp_payload_registry_->SetRtxSsrc(ssrc);
|
||||
rtp_payload_registry_.SetRtxSsrc(ssrc);
|
||||
}
|
||||
|
||||
bool ViEReceiver::GetRtxSsrc(uint32_t* ssrc) const {
|
||||
return rtp_payload_registry_->GetRtxSsrc(ssrc);
|
||||
return rtp_payload_registry_.GetRtxSsrc(ssrc);
|
||||
}
|
||||
|
||||
bool ViEReceiver::IsFecEnabled() const {
|
||||
return rtp_payload_registry_->ulpfec_payload_type() > -1;
|
||||
return rtp_payload_registry_.ulpfec_payload_type() > -1;
|
||||
}
|
||||
|
||||
uint32_t ViEReceiver::GetRemoteSsrc() const {
|
||||
@ -136,24 +123,14 @@ int ViEReceiver::GetCsrcs(uint32_t* csrcs) const {
|
||||
return rtp_receiver_->CSRCs(csrcs);
|
||||
}
|
||||
|
||||
void ViEReceiver::SetRtpRtcpModule(RtpRtcp* module) {
|
||||
rtp_rtcp_ = module;
|
||||
void ViEReceiver::Init(const std::vector<RtpRtcp*>& modules) {
|
||||
rtp_rtcp_ = modules;
|
||||
}
|
||||
|
||||
RtpReceiver* ViEReceiver::GetRtpReceiver() const {
|
||||
return rtp_receiver_.get();
|
||||
}
|
||||
|
||||
void ViEReceiver::RegisterRtpRtcpModules(
|
||||
const std::vector<RtpRtcp*>& rtp_modules) {
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
// Only change the "simulcast" modules, the base module can be accessed
|
||||
// without a lock whereas the simulcast modules require locking as they can be
|
||||
// changed in runtime.
|
||||
rtp_rtcp_simulcast_ =
|
||||
std::vector<RtpRtcp*>(rtp_modules.begin() + 1, rtp_modules.end());
|
||||
}
|
||||
|
||||
void ViEReceiver::EnableReceiveRtpHeaderExtension(const std::string& extension,
|
||||
int id) {
|
||||
RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
|
||||
@ -167,7 +144,7 @@ int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data,
|
||||
RTC_DCHECK(vcm_);
|
||||
WebRtcRTPHeader rtp_header_with_ntp = *rtp_header;
|
||||
rtp_header_with_ntp.ntp_time_ms =
|
||||
ntp_estimator_->Estimate(rtp_header->header.timestamp);
|
||||
ntp_estimator_.Estimate(rtp_header->header.timestamp);
|
||||
if (vcm_->IncomingPacket(payload_data,
|
||||
payload_size,
|
||||
rtp_header_with_ntp) != 0) {
|
||||
@ -235,7 +212,7 @@ bool ViEReceiver::DeliverRtp(const uint8_t* rtp_packet,
|
||||
header.payload_type_frequency = kVideoPayloadTypeFrequency;
|
||||
|
||||
bool in_order = IsPacketInOrder(header);
|
||||
rtp_payload_registry_->SetIncomingPayloadType(header);
|
||||
rtp_payload_registry_.SetIncomingPayloadType(header);
|
||||
bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order);
|
||||
// Update receive statistics after ReceivePacket.
|
||||
// Receive statistics will be reset if the payload type changes (make sure
|
||||
@ -249,15 +226,15 @@ bool ViEReceiver::ReceivePacket(const uint8_t* packet,
|
||||
size_t packet_length,
|
||||
const RTPHeader& header,
|
||||
bool in_order) {
|
||||
if (rtp_payload_registry_->IsEncapsulated(header)) {
|
||||
if (rtp_payload_registry_.IsEncapsulated(header)) {
|
||||
return ParseAndHandleEncapsulatingHeader(packet, packet_length, header);
|
||||
}
|
||||
const uint8_t* payload = packet + header.headerLength;
|
||||
assert(packet_length >= header.headerLength);
|
||||
size_t payload_length = packet_length - header.headerLength;
|
||||
PayloadUnion payload_specific;
|
||||
if (!rtp_payload_registry_->GetPayloadSpecifics(header.payloadType,
|
||||
&payload_specific)) {
|
||||
if (!rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
|
||||
&payload_specific)) {
|
||||
return false;
|
||||
}
|
||||
return rtp_receiver_->IncomingRtpPacket(header, payload, payload_length,
|
||||
@ -267,8 +244,8 @@ bool ViEReceiver::ReceivePacket(const uint8_t* packet,
|
||||
bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
size_t packet_length,
|
||||
const RTPHeader& header) {
|
||||
if (rtp_payload_registry_->IsRed(header)) {
|
||||
int8_t ulpfec_pt = rtp_payload_registry_->ulpfec_payload_type();
|
||||
if (rtp_payload_registry_.IsRed(header)) {
|
||||
int8_t ulpfec_pt = rtp_payload_registry_.ulpfec_payload_type();
|
||||
if (packet[header.headerLength] == ulpfec_pt) {
|
||||
rtp_receive_statistics_->FecPacketReceived(header, packet_length);
|
||||
// Notify vcm about received FEC packets to avoid NACKing these packets.
|
||||
@ -279,7 +256,7 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
return false;
|
||||
}
|
||||
return fec_receiver_->ProcessReceivedFec() == 0;
|
||||
} else if (rtp_payload_registry_->IsRtx(header)) {
|
||||
} else if (rtp_payload_registry_.IsRtx(header)) {
|
||||
if (header.headerLength + header.paddingLength == packet_length) {
|
||||
// This is an empty packet and should be silently dropped before trying to
|
||||
// parse the RTX header.
|
||||
@ -295,7 +272,7 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet.";
|
||||
return false;
|
||||
}
|
||||
if (!rtp_payload_registry_->RestoreOriginalPacket(
|
||||
if (!rtp_payload_registry_.RestoreOriginalPacket(
|
||||
restored_packet_, packet, &packet_length, rtp_receiver_->SSRC(),
|
||||
header)) {
|
||||
LOG(LS_WARNING) << "Incoming RTX packet: Invalid RTP header ssrc: "
|
||||
@ -313,7 +290,7 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
|
||||
void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) {
|
||||
int8_t last_media_payload_type =
|
||||
rtp_payload_registry_->last_received_media_payload_type();
|
||||
rtp_payload_registry_.last_received_media_payload_type();
|
||||
if (last_media_payload_type < 0) {
|
||||
LOG(LS_WARNING) << "Failed to get last media payload type.";
|
||||
return;
|
||||
@ -324,8 +301,8 @@ void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) {
|
||||
rtp_header.header.payloadType = last_media_payload_type;
|
||||
rtp_header.header.paddingLength = 0;
|
||||
PayloadUnion payload_specific;
|
||||
if (!rtp_payload_registry_->GetPayloadSpecifics(last_media_payload_type,
|
||||
&payload_specific)) {
|
||||
if (!rtp_payload_registry_.GetPayloadSpecifics(last_media_payload_type,
|
||||
&payload_specific)) {
|
||||
LOG(LS_WARNING) << "Failed to get payload specifics.";
|
||||
return;
|
||||
}
|
||||
@ -340,23 +317,20 @@ void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) {
|
||||
|
||||
bool ViEReceiver::DeliverRtcp(const uint8_t* rtcp_packet,
|
||||
size_t rtcp_packet_length) {
|
||||
// Should be set by owner at construction time.
|
||||
RTC_DCHECK(!rtp_rtcp_.empty());
|
||||
{
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
if (!receiving_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (RtpRtcp* rtp_rtcp : rtp_rtcp_simulcast_)
|
||||
rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
}
|
||||
assert(rtp_rtcp_); // Should be set by owner at construction time.
|
||||
int ret = rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
if (ret != 0) {
|
||||
return false;
|
||||
}
|
||||
for (RtpRtcp* rtp_rtcp : rtp_rtcp_)
|
||||
rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
|
||||
int64_t rtt = 0;
|
||||
rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL);
|
||||
rtp_rtcp_[0]->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL);
|
||||
if (rtt == 0) {
|
||||
// Waiting for valid rtt.
|
||||
return true;
|
||||
@ -364,12 +338,12 @@ bool ViEReceiver::DeliverRtcp(const uint8_t* rtcp_packet,
|
||||
uint32_t ntp_secs = 0;
|
||||
uint32_t ntp_frac = 0;
|
||||
uint32_t rtp_timestamp = 0;
|
||||
if (0 != rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL,
|
||||
&rtp_timestamp)) {
|
||||
if (rtp_rtcp_[0]->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL,
|
||||
&rtp_timestamp) != 0) {
|
||||
// Waiting for RTCP.
|
||||
return true;
|
||||
}
|
||||
ntp_estimator_->UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
|
||||
ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -399,7 +373,7 @@ bool ViEReceiver::IsPacketInOrder(const RTPHeader& header) const {
|
||||
bool ViEReceiver::IsPacketRetransmitted(const RTPHeader& header,
|
||||
bool in_order) const {
|
||||
// Retransmissions are handled separately if RTX is enabled.
|
||||
if (rtp_payload_registry_->RtxEnabled())
|
||||
if (rtp_payload_registry_.RtxEnabled())
|
||||
return false;
|
||||
StreamStatistician* statistician =
|
||||
rtp_receive_statistics_->GetStatistician(header.ssrc);
|
||||
@ -407,7 +381,7 @@ bool ViEReceiver::IsPacketRetransmitted(const RTPHeader& header,
|
||||
return false;
|
||||
// Check if this is a retransmission.
|
||||
int64_t min_rtt = 0;
|
||||
rtp_rtcp_->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL);
|
||||
rtp_rtcp_[0]->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL);
|
||||
return !in_order &&
|
||||
statistician->IsRetransmitOfOldPacket(header, min_rtt);
|
||||
}
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -42,7 +44,6 @@ class ViEReceiver : public RtpData {
|
||||
~ViEReceiver();
|
||||
|
||||
bool SetReceiveCodec(const VideoCodec& video_codec);
|
||||
bool RegisterPayload(const VideoCodec& video_codec);
|
||||
|
||||
void SetNackStatus(bool enable, int max_nack_reordering_threshold);
|
||||
void SetRtxPayloadType(int payload_type, int associated_payload_type);
|
||||
@ -59,12 +60,10 @@ class ViEReceiver : public RtpData {
|
||||
uint32_t GetRemoteSsrc() const;
|
||||
int GetCsrcs(uint32_t* csrcs) const;
|
||||
|
||||
void SetRtpRtcpModule(RtpRtcp* module);
|
||||
void Init(const std::vector<RtpRtcp*>& modules);
|
||||
|
||||
RtpReceiver* GetRtpReceiver() const;
|
||||
|
||||
void RegisterRtpRtcpModules(const std::vector<RtpRtcp*>& rtp_modules);
|
||||
|
||||
void EnableReceiveRtpHeaderExtension(const std::string& extension, int id);
|
||||
|
||||
void StartReceive();
|
||||
@ -98,24 +97,26 @@ class ViEReceiver : public RtpData {
|
||||
bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
|
||||
void UpdateHistograms();
|
||||
|
||||
rtc::CriticalSection receive_cs_;
|
||||
Clock* clock_;
|
||||
std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
|
||||
std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_;
|
||||
std::unique_ptr<RtpReceiver> rtp_receiver_;
|
||||
Clock* const clock_;
|
||||
VideoCodingModule* const vcm_;
|
||||
RemoteBitrateEstimator* const remote_bitrate_estimator_;
|
||||
|
||||
// TODO(pbos): Make const and set on construction.
|
||||
std::vector<RtpRtcp*> rtp_rtcp_;
|
||||
|
||||
RemoteNtpTimeEstimator ntp_estimator_;
|
||||
RTPPayloadRegistry rtp_payload_registry_;
|
||||
|
||||
const std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
|
||||
const std::unique_ptr<RtpReceiver> rtp_receiver_;
|
||||
const std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_;
|
||||
std::unique_ptr<FecReceiver> fec_receiver_;
|
||||
RtpRtcp* rtp_rtcp_;
|
||||
std::vector<RtpRtcp*> rtp_rtcp_simulcast_;
|
||||
VideoCodingModule* vcm_;
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator_;
|
||||
|
||||
std::unique_ptr<RemoteNtpTimeEstimator> ntp_estimator_;
|
||||
|
||||
bool receiving_;
|
||||
uint8_t restored_packet_[IP_PACKET_SIZE];
|
||||
bool restored_packet_in_use_;
|
||||
int64_t last_packet_log_ms_;
|
||||
rtc::CriticalSection receive_cs_;
|
||||
bool receiving_ GUARDED_BY(receive_cs_);
|
||||
uint8_t restored_packet_[IP_PACKET_SIZE] GUARDED_BY(receive_cs_);
|
||||
bool restored_packet_in_use_ GUARDED_BY(receive_cs_);
|
||||
int64_t last_packet_log_ms_ GUARDED_BY(receive_cs_);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user