MediaChannel: remove lock recursions.
This change removes lock recursions and adds thread annotations. Bug: webrtc:11567 Change-Id: I2730e8159673e7a2802ab0525ebcf26be0e36fd7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175100 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31270}
This commit is contained in:
parent
8133ffb187
commit
772b1494a9
@ -203,7 +203,8 @@ class MediaChannel : public sigslot::has_slots<> {
|
||||
// transport.
|
||||
virtual void SetInterface(
|
||||
NetworkInterface* iface,
|
||||
const webrtc::MediaTransportConfig& media_transport_config);
|
||||
const webrtc::MediaTransportConfig& media_transport_config)
|
||||
RTC_LOCKS_EXCLUDED(network_interface_crit_);
|
||||
// Called when a RTP packet is received.
|
||||
virtual void OnPacketReceived(rtc::CopyOnWriteBuffer packet,
|
||||
int64_t packet_time_us) = 0;
|
||||
@ -264,12 +265,9 @@ class MediaChannel : public sigslot::has_slots<> {
|
||||
|
||||
int SetOption(NetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option) {
|
||||
int option) RTC_LOCKS_EXCLUDED(network_interface_crit_) {
|
||||
rtc::CritScope cs(&network_interface_crit_);
|
||||
if (!network_interface_)
|
||||
return -1;
|
||||
|
||||
return network_interface_->SetOption(type, opt, option);
|
||||
return SetOptionLocked(type, opt, option);
|
||||
}
|
||||
|
||||
const webrtc::MediaTransportConfig& media_transport_config() const {
|
||||
@ -298,16 +296,27 @@ class MediaChannel : public sigslot::has_slots<> {
|
||||
rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer);
|
||||
|
||||
protected:
|
||||
int SetOptionLocked(NetworkInterface::SocketType type,
|
||||
rtc::Socket::Option opt,
|
||||
int option)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_crit_) {
|
||||
if (!network_interface_)
|
||||
return -1;
|
||||
return network_interface_->SetOption(type, opt, option);
|
||||
}
|
||||
|
||||
bool DscpEnabled() const { return enable_dscp_; }
|
||||
|
||||
// This is the DSCP value used for both RTP and RTCP channels if DSCP is
|
||||
// enabled. It can be changed at any time via |SetPreferredDscp|.
|
||||
rtc::DiffServCodePoint PreferredDscp() const {
|
||||
rtc::DiffServCodePoint PreferredDscp() const
|
||||
RTC_LOCKS_EXCLUDED(network_interface_crit_) {
|
||||
rtc::CritScope cs(&network_interface_crit_);
|
||||
return preferred_dscp_;
|
||||
}
|
||||
|
||||
int SetPreferredDscp(rtc::DiffServCodePoint preferred_dscp) {
|
||||
int SetPreferredDscp(rtc::DiffServCodePoint preferred_dscp)
|
||||
RTC_LOCKS_EXCLUDED(network_interface_crit_) {
|
||||
rtc::CritScope cs(&network_interface_crit_);
|
||||
if (preferred_dscp == preferred_dscp_) {
|
||||
return 0;
|
||||
@ -322,16 +331,19 @@ class MediaChannel : public sigslot::has_slots<> {
|
||||
int UpdateDscp() RTC_EXCLUSIVE_LOCKS_REQUIRED(network_interface_crit_) {
|
||||
rtc::DiffServCodePoint value =
|
||||
enable_dscp_ ? preferred_dscp_ : rtc::DSCP_DEFAULT;
|
||||
int ret = SetOption(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value);
|
||||
int ret =
|
||||
SetOptionLocked(NetworkInterface::ST_RTP, rtc::Socket::OPT_DSCP, value);
|
||||
if (ret == 0) {
|
||||
ret = SetOption(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP, value);
|
||||
ret = SetOptionLocked(NetworkInterface::ST_RTCP, rtc::Socket::OPT_DSCP,
|
||||
value);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool DoSendPacket(rtc::CopyOnWriteBuffer* packet,
|
||||
bool rtcp,
|
||||
const rtc::PacketOptions& options) {
|
||||
const rtc::PacketOptions& options)
|
||||
RTC_LOCKS_EXCLUDED(network_interface_crit_) {
|
||||
rtc::CritScope cs(&network_interface_crit_);
|
||||
if (!network_interface_)
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user