Cleanup: Replacing set extension status bool with CHECK.
This was just checked in all places were it was used, moving the check into RtpRtcp reduces the boiler plate required at the call sites. Also changing to always register and unregister extensions by URI to synchronize the code in AudioSendStream with the code in RtpVideoSender. This prepares for reducing the scope of ChannelSend. Bug: webrtc:9883 Change-Id: Ia64d79f20eb98f46cbbbe8318770e4fcf9caa1ec Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/155620 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29490}
This commit is contained in:
committed by
Commit Bot
parent
ffc8452730
commit
f39c815a1d
@ -296,8 +296,8 @@ void AudioSendStream::ConfigureStream(
|
|||||||
channel_send_->GetRtpRtcp()->DeregisterSendRtpHeaderExtension(
|
channel_send_->GetRtpRtcp()->DeregisterSendRtpHeaderExtension(
|
||||||
kRtpExtensionAbsoluteSendTime);
|
kRtpExtensionAbsoluteSendTime);
|
||||||
if (new_ids.abs_send_time) {
|
if (new_ids.abs_send_time) {
|
||||||
channel_send_->GetRtpRtcp()->RegisterSendRtpHeaderExtension(
|
rtp_rtcp_module_->RegisterRtpHeaderExtension(AbsoluteSendTime::kUri,
|
||||||
kRtpExtensionAbsoluteSendTime, new_ids.abs_send_time);
|
new_ids.abs_send_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -189,7 +189,7 @@ class ChannelSend : public ChannelSendInterface,
|
|||||||
void OnUplinkPacketLossRate(float packet_loss_rate);
|
void OnUplinkPacketLossRate(float packet_loss_rate);
|
||||||
bool InputMute() const;
|
bool InputMute() const;
|
||||||
|
|
||||||
int SetSendRtpHeaderExtension(bool enable, RTPExtensionType type, int id);
|
void SetSendRtpHeaderExtension(bool enable, absl::string_view uri, int id);
|
||||||
|
|
||||||
int32_t SendRtpAudio(AudioFrameType frameType,
|
int32_t SendRtpAudio(AudioFrameType frameType,
|
||||||
uint8_t payloadType,
|
uint8_t payloadType,
|
||||||
@ -894,22 +894,18 @@ void ChannelSend::SetRid(const std::string& rid,
|
|||||||
int repaired_extension_id) {
|
int repaired_extension_id) {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
if (extension_id != 0) {
|
if (extension_id != 0) {
|
||||||
int ret = SetSendRtpHeaderExtension(!rid.empty(), kRtpExtensionRtpStreamId,
|
SetSendRtpHeaderExtension(!rid.empty(), RtpStreamId::kUri, extension_id);
|
||||||
extension_id);
|
|
||||||
RTC_DCHECK_EQ(0, ret);
|
|
||||||
}
|
}
|
||||||
if (repaired_extension_id != 0) {
|
if (repaired_extension_id != 0) {
|
||||||
int ret = SetSendRtpHeaderExtension(!rid.empty(), kRtpExtensionRtpStreamId,
|
SetSendRtpHeaderExtension(!rid.empty(), RtpStreamId::kUri,
|
||||||
repaired_extension_id);
|
repaired_extension_id);
|
||||||
RTC_DCHECK_EQ(0, ret);
|
|
||||||
}
|
}
|
||||||
_rtpRtcpModule->SetRid(rid);
|
_rtpRtcpModule->SetRid(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelSend::SetMid(const std::string& mid, int extension_id) {
|
void ChannelSend::SetMid(const std::string& mid, int extension_id) {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
int ret = SetSendRtpHeaderExtension(true, kRtpExtensionMid, extension_id);
|
SetSendRtpHeaderExtension(true, RtpMid::kUri, extension_id);
|
||||||
RTC_DCHECK_EQ(0, ret);
|
|
||||||
_rtpRtcpModule->SetMid(mid);
|
_rtpRtcpModule->SetMid(mid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,15 +917,12 @@ void ChannelSend::SetExtmapAllowMixed(bool extmap_allow_mixed) {
|
|||||||
void ChannelSend::SetSendAudioLevelIndicationStatus(bool enable, int id) {
|
void ChannelSend::SetSendAudioLevelIndicationStatus(bool enable, int id) {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
_includeAudioLevelIndication = enable;
|
_includeAudioLevelIndication = enable;
|
||||||
int ret = SetSendRtpHeaderExtension(enable, kRtpExtensionAudioLevel, id);
|
SetSendRtpHeaderExtension(enable, AudioLevel::kUri, id);
|
||||||
RTC_DCHECK_EQ(0, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelSend::EnableSendTransportSequenceNumber(int id) {
|
void ChannelSend::EnableSendTransportSequenceNumber(int id) {
|
||||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||||
int ret =
|
SetSendRtpHeaderExtension(true, TransportSequenceNumber::kUri, id);
|
||||||
SetSendRtpHeaderExtension(true, kRtpExtensionTransportSequenceNumber, id);
|
|
||||||
RTC_DCHECK_EQ(0, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelSend::RegisterSenderCongestionControlObjects(
|
void ChannelSend::RegisterSenderCongestionControlObjects(
|
||||||
@ -1093,18 +1086,13 @@ RtpRtcp* ChannelSend::GetRtpRtcp() const {
|
|||||||
return _rtpRtcpModule.get();
|
return _rtpRtcpModule.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChannelSend::SetSendRtpHeaderExtension(bool enable,
|
void ChannelSend::SetSendRtpHeaderExtension(bool enable,
|
||||||
RTPExtensionType type,
|
absl::string_view uri,
|
||||||
int id) {
|
int id) {
|
||||||
int error = 0;
|
_rtpRtcpModule->DeregisterSendRtpHeaderExtension(uri);
|
||||||
_rtpRtcpModule->DeregisterSendRtpHeaderExtension(type);
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
// TODO(nisse): RtpRtcp::RegisterSendRtpHeaderExtension to take an int
|
_rtpRtcpModule->RegisterRtpHeaderExtension(uri, id);
|
||||||
// argument. Currently it wants an uint8_t.
|
|
||||||
error = _rtpRtcpModule->RegisterSendRtpHeaderExtension(
|
|
||||||
type, rtc::dchecked_cast<uint8_t>(id));
|
|
||||||
}
|
}
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ChannelSend::GetRTT() const {
|
int64_t ChannelSend::GetRTT() const {
|
||||||
|
|||||||
@ -381,7 +381,7 @@ RtpVideoSender::RtpVideoSender(
|
|||||||
int id = rtp_config_.extensions[i].id;
|
int id = rtp_config_.extensions[i].id;
|
||||||
RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
|
RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
|
||||||
for (const RtpStreamSender& stream : rtp_streams_) {
|
for (const RtpStreamSender& stream : rtp_streams_) {
|
||||||
RTC_CHECK(stream.rtp_rtcp->RegisterRtpHeaderExtension(extension, id));
|
stream.rtp_rtcp->RegisterRtpHeaderExtension(extension, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class RtpHeaderExtensionMap {
|
|||||||
return Register(id, Extension::kId, Extension::kUri);
|
return Register(id, Extension::kId, Extension::kUri);
|
||||||
}
|
}
|
||||||
bool RegisterByType(int id, RTPExtensionType type);
|
bool RegisterByType(int id, RTPExtensionType type);
|
||||||
bool RegisterByUri(int id, const std::string& uri);
|
bool RegisterByUri(int id, absl::string_view uri);
|
||||||
|
|
||||||
bool IsRegistered(RTPExtensionType type) const {
|
bool IsRegistered(RTPExtensionType type) const {
|
||||||
return GetId(type) != kInvalidId;
|
return GetId(type) != kInvalidId;
|
||||||
@ -56,6 +56,7 @@ class RtpHeaderExtensionMap {
|
|||||||
return RegisterByType(id, type) ? 0 : -1;
|
return RegisterByType(id, type) ? 0 : -1;
|
||||||
}
|
}
|
||||||
int32_t Deregister(RTPExtensionType type);
|
int32_t Deregister(RTPExtensionType type);
|
||||||
|
void Deregister(absl::string_view uri);
|
||||||
|
|
||||||
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
|
// Corresponds to the SDP attribute extmap-allow-mixed, see RFC8285.
|
||||||
// Set to true if it's allowed to mix one- and two-byte RTP header extensions
|
// Set to true if it's allowed to mix one- and two-byte RTP header extensions
|
||||||
|
|||||||
@ -164,12 +164,14 @@ class RtpRtcp : public Module, public RtcpFeedbackSenderInterface {
|
|||||||
|
|
||||||
// (De)registers RTP header extension type and id.
|
// (De)registers RTP header extension type and id.
|
||||||
// Returns -1 on failure else 0.
|
// Returns -1 on failure else 0.
|
||||||
virtual int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
|
RTC_DEPRECATED virtual int32_t RegisterSendRtpHeaderExtension(
|
||||||
uint8_t id) = 0;
|
RTPExtensionType type,
|
||||||
// Register extension by uri, returns false on failure.
|
uint8_t id) = 0;
|
||||||
virtual bool RegisterRtpHeaderExtension(const std::string& uri, int id) = 0;
|
// Register extension by uri, triggers CHECK on falure.
|
||||||
|
virtual void RegisterRtpHeaderExtension(absl::string_view uri, int id) = 0;
|
||||||
|
|
||||||
virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
|
virtual int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) = 0;
|
||||||
|
virtual void DeregisterSendRtpHeaderExtension(absl::string_view uri) = 0;
|
||||||
|
|
||||||
// Returns true if RTP module is send media, and any of the extensions
|
// Returns true if RTP module is send media, and any of the extensions
|
||||||
// required for bandwidth estimation is registered.
|
// required for bandwidth estimation is registered.
|
||||||
|
|||||||
@ -45,10 +45,10 @@ class MockRtpRtcp : public RtpRtcp {
|
|||||||
MOCK_METHOD1(SetExtmapAllowMixed, void(bool extmap_allow_mixed));
|
MOCK_METHOD1(SetExtmapAllowMixed, void(bool extmap_allow_mixed));
|
||||||
MOCK_METHOD2(RegisterSendRtpHeaderExtension,
|
MOCK_METHOD2(RegisterSendRtpHeaderExtension,
|
||||||
int32_t(RTPExtensionType type, uint8_t id));
|
int32_t(RTPExtensionType type, uint8_t id));
|
||||||
MOCK_METHOD2(RegisterRtpHeaderExtension,
|
MOCK_METHOD2(RegisterRtpHeaderExtension, void(absl::string_view uri, int id));
|
||||||
bool(const std::string& uri, int id));
|
|
||||||
MOCK_METHOD1(DeregisterSendRtpHeaderExtension,
|
MOCK_METHOD1(DeregisterSendRtpHeaderExtension,
|
||||||
int32_t(RTPExtensionType type));
|
int32_t(RTPExtensionType type));
|
||||||
|
MOCK_METHOD1(DeregisterSendRtpHeaderExtension, void(absl::string_view uri));
|
||||||
MOCK_CONST_METHOD0(SupportsPadding, bool());
|
MOCK_CONST_METHOD0(SupportsPadding, bool());
|
||||||
MOCK_CONST_METHOD0(SupportsRtxPayloadPadding, bool());
|
MOCK_CONST_METHOD0(SupportsRtxPayloadPadding, bool());
|
||||||
MOCK_CONST_METHOD0(StartTimestamp, uint32_t());
|
MOCK_CONST_METHOD0(StartTimestamp, uint32_t());
|
||||||
|
|||||||
@ -85,7 +85,7 @@ bool RtpHeaderExtensionMap::RegisterByType(int id, RTPExtensionType type) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtpHeaderExtensionMap::RegisterByUri(int id, const std::string& uri) {
|
bool RtpHeaderExtensionMap::RegisterByUri(int id, absl::string_view uri) {
|
||||||
for (const ExtensionInfo& extension : kExtensions)
|
for (const ExtensionInfo& extension : kExtensions)
|
||||||
if (uri == extension.uri)
|
if (uri == extension.uri)
|
||||||
return Register(id, extension.type, extension.uri);
|
return Register(id, extension.type, extension.uri);
|
||||||
@ -113,6 +113,15 @@ int32_t RtpHeaderExtensionMap::Deregister(RTPExtensionType type) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RtpHeaderExtensionMap::Deregister(absl::string_view uri) {
|
||||||
|
for (const ExtensionInfo& extension : kExtensions) {
|
||||||
|
if (extension.uri == uri) {
|
||||||
|
ids_[extension.type] = kInvalidId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool RtpHeaderExtensionMap::Register(int id,
|
bool RtpHeaderExtensionMap::Register(int id,
|
||||||
RTPExtensionType type,
|
RTPExtensionType type,
|
||||||
const char* uri) {
|
const char* uri) {
|
||||||
|
|||||||
@ -538,15 +538,20 @@ int32_t ModuleRtpRtcpImpl::RegisterSendRtpHeaderExtension(
|
|||||||
return rtp_sender_->RegisterRtpHeaderExtension(type, id);
|
return rtp_sender_->RegisterRtpHeaderExtension(type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleRtpRtcpImpl::RegisterRtpHeaderExtension(const std::string& uri,
|
void ModuleRtpRtcpImpl::RegisterRtpHeaderExtension(absl::string_view uri,
|
||||||
int id) {
|
int id) {
|
||||||
return rtp_sender_->RegisterRtpHeaderExtension(uri, id);
|
bool registered = rtp_sender_->RegisterRtpHeaderExtension(uri, id);
|
||||||
|
RTC_CHECK(registered);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension(
|
int32_t ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension(
|
||||||
const RTPExtensionType type) {
|
const RTPExtensionType type) {
|
||||||
return rtp_sender_->DeregisterRtpHeaderExtension(type);
|
return rtp_sender_->DeregisterRtpHeaderExtension(type);
|
||||||
}
|
}
|
||||||
|
void ModuleRtpRtcpImpl::DeregisterSendRtpHeaderExtension(
|
||||||
|
absl::string_view uri) {
|
||||||
|
rtp_sender_->DeregisterRtpHeaderExtension(uri);
|
||||||
|
}
|
||||||
|
|
||||||
// (TMMBR) Temporary Max Media Bit Rate.
|
// (TMMBR) Temporary Max Media Bit Rate.
|
||||||
bool ModuleRtpRtcpImpl::TMMBR() const {
|
bool ModuleRtpRtcpImpl::TMMBR() const {
|
||||||
|
|||||||
@ -71,9 +71,9 @@ class ModuleRtpRtcpImpl : public RtpRtcp, public RTCPReceiver::ModuleRtpRtcp {
|
|||||||
// Register RTP header extension.
|
// Register RTP header extension.
|
||||||
int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
|
int32_t RegisterSendRtpHeaderExtension(RTPExtensionType type,
|
||||||
uint8_t id) override;
|
uint8_t id) override;
|
||||||
bool RegisterRtpHeaderExtension(const std::string& uri, int id) override;
|
void RegisterRtpHeaderExtension(absl::string_view uri, int id) override;
|
||||||
|
|
||||||
int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) override;
|
int32_t DeregisterSendRtpHeaderExtension(RTPExtensionType type) override;
|
||||||
|
void DeregisterSendRtpHeaderExtension(absl::string_view uri) override;
|
||||||
|
|
||||||
bool SupportsPadding() const override;
|
bool SupportsPadding() const override;
|
||||||
bool SupportsRtxPayloadPadding() const override;
|
bool SupportsRtxPayloadPadding() const override;
|
||||||
|
|||||||
@ -227,7 +227,7 @@ int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
|
|||||||
return registered ? 0 : -1;
|
return registered ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RTPSender::RegisterRtpHeaderExtension(const std::string& uri, int id) {
|
bool RTPSender::RegisterRtpHeaderExtension(absl::string_view uri, int id) {
|
||||||
rtc::CritScope lock(&send_critsect_);
|
rtc::CritScope lock(&send_critsect_);
|
||||||
bool registered = rtp_header_extension_map_.RegisterByUri(id, uri);
|
bool registered = rtp_header_extension_map_.RegisterByUri(id, uri);
|
||||||
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
|
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
|
||||||
@ -246,6 +246,12 @@ int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
|
|||||||
return deregistered;
|
return deregistered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTPSender::DeregisterRtpHeaderExtension(absl::string_view uri) {
|
||||||
|
rtc::CritScope lock(&send_critsect_);
|
||||||
|
rtp_header_extension_map_.Deregister(uri);
|
||||||
|
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
|
||||||
|
}
|
||||||
|
|
||||||
void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
|
void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
|
||||||
RTC_DCHECK_GE(max_packet_size, 100);
|
RTC_DCHECK_GE(max_packet_size, 100);
|
||||||
RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
|
RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
|
||||||
|
|||||||
@ -85,9 +85,10 @@ class RTPSender {
|
|||||||
|
|
||||||
// RTP header extension
|
// RTP header extension
|
||||||
int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id);
|
int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id);
|
||||||
bool RegisterRtpHeaderExtension(const std::string& uri, int id);
|
bool RegisterRtpHeaderExtension(absl::string_view uri, int id);
|
||||||
bool IsRtpHeaderExtensionRegistered(RTPExtensionType type) const;
|
bool IsRtpHeaderExtensionRegistered(RTPExtensionType type) const;
|
||||||
int32_t DeregisterRtpHeaderExtension(RTPExtensionType type);
|
int32_t DeregisterRtpHeaderExtension(RTPExtensionType type);
|
||||||
|
void DeregisterRtpHeaderExtension(absl::string_view uri);
|
||||||
|
|
||||||
// Tries to send packet to transport. Also updates any timing extensions,
|
// Tries to send packet to transport. Also updates any timing extensions,
|
||||||
// calls observers waiting for packet send events, and updates stats.
|
// calls observers waiting for packet send events, and updates stats.
|
||||||
|
|||||||
Reference in New Issue
Block a user