Remove ChannelSendState

Also remove an unnecessary call to ACM::InitializeReceiver().

Bug: webrtc:9801
Change-Id: I68034f2673f47ecf7dcf1a3be198f240fea54f82
Reviewed-on: https://webrtc-review.googlesource.com/c/111251
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25693}
This commit is contained in:
Fredrik Solenberg 2018-11-19 14:13:15 +01:00 committed by Commit Bot
parent c3313a3e6c
commit eb134846fd

View File

@ -77,40 +77,6 @@ class TransportFeedbackProxy;
class TransportSequenceNumberProxy;
class VoERtcpObserver;
// Helper class to simplify locking scheme for members that are accessed from
// multiple threads.
// Example: a member can be set on thread T1 and read by an internal audio
// thread T2. Accessing the member via this class ensures that we are
// safe and also avoid TSan v2 warnings.
class ChannelSendState {
public:
struct State {
bool sending = false;
};
ChannelSendState() {}
virtual ~ChannelSendState() {}
void Reset() {
rtc::CritScope lock(&lock_);
state_ = State();
}
State Get() const {
rtc::CritScope lock(&lock_);
return state_;
}
void SetSending(bool enable) {
rtc::CritScope lock(&lock_);
state_.sending = enable;
}
private:
rtc::CriticalSection lock_;
State state_;
};
class ChannelSend
: public ChannelSendInterface,
public Transport,
@ -142,7 +108,6 @@ class ChannelSend
modifier) override;
// API methods
void StartSend() override;
void StopSend() override;
@ -152,7 +117,6 @@ class ChannelSend
// Network
void RegisterTransport(Transport* transport) override;
bool ReceivedRTCPPacket(const uint8_t* data, size_t length) override;
// Muting, Volume and Level.
@ -171,7 +135,6 @@ class ChannelSend
// RTP+RTCP
void SetLocalSSRC(uint32_t ssrc) override;
void SetMid(const std::string& mid, int extension_id) override;
void SetExtmapAllowMixed(bool extmap_allow_mixed) override;
void SetSendAudioLevelIndicationStatus(bool enable, int id) override;
@ -231,8 +194,6 @@ class ChannelSend
const PacketOptions& packet_options) override;
bool SendRtcp(const uint8_t* data, size_t len) override;
bool Sending() const { return channel_state_.Get().sending; }
// From OverheadObserver in the RTP/RTCP module
void OnOverheadChanged(size_t overhead_bytes_per_packet) override;
@ -286,7 +247,7 @@ class ChannelSend
rtc::CriticalSection _callbackCritSect;
rtc::CriticalSection volume_settings_critsect_;
ChannelSendState channel_state_;
bool sending_ = false;
RtcEventLog* const event_log_;
@ -802,13 +763,8 @@ ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue,
RTC_DLOG(LS_INFO) << "Not setting media_transport_ rate observers.";
}
channel_state_.Reset();
_moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get(), RTC_FROM_HERE);
int error = audio_coding_->InitializeReceiver();
RTC_DCHECK_EQ(0, error);
// Ensure that RTCP is enabled by default for the created channel.
// Note that, the module will keep generating RTCP until it is explicitly
// disabled by the user.
@ -817,7 +773,7 @@ ChannelSend::ChannelSend(rtc::TaskQueue* encoder_queue,
// RTCP is enabled by default.
_rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound);
error = audio_coding_->RegisterTransportCallback(this);
int error = audio_coding_->RegisterTransportCallback(this);
RTC_DCHECK_EQ(0, error);
}
@ -835,14 +791,12 @@ ChannelSend::~ChannelSend() {
if (_moduleProcessThreadPtr)
_moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get());
RTC_DCHECK(!channel_state_.Get().sending);
}
void ChannelSend::StartSend() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RTC_DCHECK(!channel_state_.Get().sending);
channel_state_.SetSending(true);
RTC_DCHECK(!sending_);
sending_ = true;
// Resume the previous sequence number which was reset by StopSend(). This
// needs to be done before |sending| is set to true on the RTP/RTCP module.
@ -861,10 +815,10 @@ void ChannelSend::StartSend() {
void ChannelSend::StopSend() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
if (!channel_state_.Get().sending) {
if (!sending_) {
return;
}
channel_state_.SetSending(false);
sending_ = false;
// Post a task to the encoder thread which sets an event when the task is
// executed. We know that no more encoding tasks will be added to the task
@ -1058,7 +1012,7 @@ bool ChannelSend::SendTelephoneEventOutband(int event, int duration_ms) {
RTC_DCHECK_GE(255, event);
RTC_DCHECK_LE(0, duration_ms);
RTC_DCHECK_GE(65535, duration_ms);
if (!Sending()) {
if (!sending_) {
return false;
}
if (_rtpRtcpModule->SendTelephoneEventOutband(
@ -1092,7 +1046,7 @@ bool ChannelSend::SetSendTelephoneEventPayloadType(int payload_type,
void ChannelSend::SetLocalSSRC(uint32_t ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RTC_DCHECK(!channel_state_.Get().sending);
RTC_DCHECK(!sending_);
if (media_transport_) {
rtc::CritScope cs(&media_transport_lock_);