Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions audio/audio_receive_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ void AudioReceiveStreamImpl::SetSink(AudioSinkInterface* sink) {
void AudioReceiveStreamImpl::SetGain(float gain) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
channel_receive_->SetChannelOutputVolumeScaling(gain);

const bool muted = (gain == 0.f);
if(muted) {
channel_receive_->StopPlayout();
} else {
channel_receive_->StartPlayout();
}
// trying turn off/on hardware
audio_state()->ReceivingStreamMuted(this, muted);
}

bool AudioReceiveStreamImpl::SetBaseMinimumPlayoutDelayMs(int delay_ms) {
Expand Down
65 changes: 53 additions & 12 deletions audio/audio_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@ AudioTransport* AudioState::audio_transport() {
return &audio_transport_;
}

void AudioState::AddReceivingStream(
webrtc::AudioReceiveStreamInterface* stream) {
void AudioState::StartPlayout()
{
RTC_DCHECK_RUN_ON(&thread_checker_);
RTC_DCHECK_EQ(0, receiving_streams_.count(stream));
receiving_streams_.insert(stream);
if (!config_.audio_mixer->AddSource(
static_cast<AudioReceiveStreamImpl*>(stream))) {
RTC_DLOG(LS_ERROR) << "Failed to add source to mixer.";
}

// Make sure playback is initialized; start playing if enabled.
UpdateNullAudioPollerState();
Expand All @@ -75,16 +69,64 @@ void AudioState::AddReceivingStream(
}
}

void AudioState::StopPlayout()
{
RTC_DCHECK_RUN_ON(&thread_checker_);

config_.audio_device_module->StopPlayout();
UpdateNullAudioPollerState();
}

void AudioState::AddReceivingStream(
webrtc::AudioReceiveStreamInterface* stream) {
RTC_DCHECK_RUN_ON(&thread_checker_);
RTC_DCHECK_EQ(0, receiving_streams_.count(stream));
receiving_streams_.insert(std::make_pair(stream, ReceiveStreamProperties()));
if (!config_.audio_mixer->AddSource(
static_cast<AudioReceiveStreamImpl*>(stream))) {
RTC_DLOG(LS_ERROR) << "Failed to add source to mixer.";
}

StartPlayout();
}

void AudioState::ReceivingStreamMuted(
webrtc::AudioReceiveStreamInterface* stream,
bool muted)
{
auto it = receiving_streams_.find(stream);
if (it != receiving_streams_.end()) {
if (it->second.muted != muted) {
it->second.muted = muted;
}
}

bool allMuted = true;
for (const auto& pair: receiving_streams_) {
if (!pair.second.muted) {
allMuted = false;
break;
}
}

if (allMuted)
StopPlayout();
else
StartPlayout();
}

void AudioState::RemoveReceivingStream(
webrtc::AudioReceiveStreamInterface* stream) {
RTC_DCHECK_RUN_ON(&thread_checker_);
auto count = receiving_streams_.erase(stream);
RTC_DCHECK_EQ(1, count);
config_.audio_mixer->RemoveSource(
static_cast<AudioReceiveStreamImpl*>(stream));
UpdateNullAudioPollerState();

if (receiving_streams_.empty()) {
config_.audio_device_module->StopPlayout();
StopPlayout();
} else {
UpdateNullAudioPollerState();
}
}

Expand Down Expand Up @@ -131,8 +173,7 @@ void AudioState::SetPlayout(bool enabled) {
config_.audio_device_module->StartPlayout();
}
} else {
config_.audio_device_module->StopPlayout();
UpdateNullAudioPollerState();
StopPlayout();
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion audio/audio_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AudioState : public webrtc::AudioState {
}

void AddReceivingStream(webrtc::AudioReceiveStreamInterface* stream);
void ReceivingStreamMuted(webrtc::AudioReceiveStreamInterface* stream, bool);
void RemoveReceivingStream(webrtc::AudioReceiveStreamInterface* stream);

void AddSendingStream(webrtc::AudioSendStream* stream,
Expand All @@ -64,6 +65,9 @@ class AudioState : public webrtc::AudioState {
void UpdateAudioTransportWithSendingStreams();
void UpdateNullAudioPollerState() RTC_RUN_ON(&thread_checker_);

void StartPlayout();
void StopPlayout();

SequenceChecker thread_checker_;
SequenceChecker process_thread_checker_{SequenceChecker::kDetached};
const webrtc::AudioState::Config config_;
Expand All @@ -79,7 +83,10 @@ class AudioState : public webrtc::AudioState {
// stats are still updated.
RepeatingTaskHandle null_audio_poller_ RTC_GUARDED_BY(&thread_checker_);

webrtc::flat_set<webrtc::AudioReceiveStreamInterface*> receiving_streams_;
struct ReceiveStreamProperties {
bool muted = false;
};
std::map<webrtc::AudioReceiveStreamInterface*, ReceiveStreamProperties> receiving_streams_;
struct StreamProperties {
int sample_rate_hz = 0;
size_t num_channels = 0;
Expand Down
1 change: 1 addition & 0 deletions audio/channel_receive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ void ChannelReceive::SetSink(AudioSinkInterface* sink) {

void ChannelReceive::StartPlayout() {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
acm_receiver_.FlushBuffers();
playing_ = true;
}

Expand Down
4 changes: 2 additions & 2 deletions call/rtp_transport_controller_send.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ void RtpTransportControllerSend::OnNetworkRouteChanged(
auto kv = result.first;
bool inserted = result.second;
if (inserted || !(kv->second == network_route)) {
RTC_LOG(LS_INFO) << "Network route changed on transport " << transport_name
RTC_LOG(LS_VERBOSE) << "Network route changed on transport " << transport_name
<< ": new_route = " << network_route.DebugString();
if (!inserted) {
RTC_LOG(LS_INFO) << "old_route = " << kv->second.DebugString();
RTC_LOG(LS_VERBOSE) << "old_route = " << kv->second.DebugString();
}
}

Expand Down
6 changes: 3 additions & 3 deletions modules/congestion_controller/goog_cc/probe_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ std::vector<ProbeClusterConfig> ProbeController::SetEstimatedBitrate(
? network_estimate_->link_capacity_upper *
config_.further_probe_threshold
: DataRate::PlusInfinity();
RTC_LOG(LS_INFO) << "Measured bitrate: " << bitrate
RTC_LOG(LS_VERBOSE) << "Measured bitrate: " << bitrate
<< " Minimum to probe further: "
<< min_bitrate_to_probe_further_ << " upper limit: "
<< network_state_estimate_probe_further_limit;
Expand Down Expand Up @@ -409,7 +409,7 @@ std::vector<ProbeClusterConfig> ProbeController::RequestProbe(
if (min_expected_probe_result > estimated_bitrate_ &&
time_since_drop < kBitrateDropTimeout &&
time_since_probe > kMinTimeBetweenAlrProbes) {
RTC_LOG(LS_INFO) << "Detected big bandwidth drop, start probing.";
RTC_LOG(LS_VERBOSE) << "Detected big bandwidth drop, start probing.";
// Track how often we probe in response to bandwidth drop in ALR.
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.BWE.BweDropProbingIntervalInS",
Expand Down Expand Up @@ -501,7 +501,7 @@ std::vector<ProbeClusterConfig> ProbeController::Process(Timestamp at_time) {
if (at_time - time_last_probing_initiated_ >
kMaxWaitingTimeForProbingResult) {
if (state_ == State::kWaitingForProbingResult) {
RTC_LOG(LS_INFO) << "kWaitingForProbingResult: timeout";
RTC_LOG(LS_VERBOSE) << "kWaitingForProbingResult: timeout";
UpdateState(State::kProbingComplete);
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ void ModuleRtpRtcpImpl2::MaybeSendRtcpAtOrAfterTimestamp(
TimeDelta delta = execution_time - now;
// TaskQueue may run task 1ms earlier, so don't print warning if in this case.
if (delta > TimeDelta::Millis(1)) {
RTC_DLOG(LS_WARNING) << "BUGBUG: Task queue scheduled delayed call "
RTC_DLOG(LS_VERBOSE) << "BUGBUG: Task queue scheduled delayed call "
<< delta << " too early.";
}

Expand Down
6 changes: 3 additions & 3 deletions p2p/base/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ bool Connection::pruned() const {
void Connection::Prune() {
RTC_DCHECK_RUN_ON(network_thread_);
if (!pruned_ || active()) {
RTC_LOG(LS_INFO) << ToString() << ": Connection pruned";
RTC_LOG(LS_VERBOSE) << ToString() << ": Connection pruned";
pruned_ = true;
requests_.Clear();
set_write_state(STATE_WRITE_TIMEOUT);
Expand Down Expand Up @@ -1406,7 +1406,7 @@ void Connection::OnConnectionRequestResponse(StunRequest* request,
RTC_DCHECK_RUN_ON(network_thread_);
// Log at LS_INFO if we receive a ping response on an unwritable
// connection.
rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE;
rtc::LoggingSeverity sev = !writable() ? rtc::LS_VERBOSE : rtc::LS_VERBOSE;

int rtt = request->Elapsed();

Expand Down Expand Up @@ -1530,7 +1530,7 @@ void Connection::OnConnectionRequestTimeout(ConnectionRequest* request) {
void Connection::OnConnectionRequestSent(ConnectionRequest* request) {
RTC_DCHECK_RUN_ON(network_thread_);
// Log at LS_INFO if we send a ping on an unwritable connection.
rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE;
rtc::LoggingSeverity sev = !writable() ? rtc::LS_VERBOSE : rtc::LS_VERBOSE;
RTC_LOG_V(sev) << ToString() << ": Sent "
<< StunMethodToString(request->msg()->type())
<< ", id=" << rtc::hex_encode(request->id())
Expand Down
12 changes: 6 additions & 6 deletions p2p/base/port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Port::Port(const PortParametersRef& args,
network_->SignalTypeChanged.connect(this, &Port::OnNetworkTypeChanged);

PostDestroyIfDead(/*delayed=*/true);
RTC_LOG(LS_INFO) << ToString() << ": Port created with network cost "
RTC_LOG(LS_VERBOSE) << ToString() << ": Port created with network cost "
<< network_cost_;
}

Expand Down Expand Up @@ -338,7 +338,7 @@ void Port::OnReadPacket(const rtc::ReceivedPacket& packet, ProtocolType proto) {
} else if (!msg) {
// STUN message handled already
} else if (msg->type() == STUN_BINDING_REQUEST) {
RTC_LOG(LS_INFO) << "Received " << StunMethodToString(msg->type())
RTC_LOG(LS_VERBOSE) << "Received " << StunMethodToString(msg->type())
<< " id=" << rtc::hex_encode(msg->transaction_id())
<< " from unknown address " << addr.ToSensitiveString();
// We need to signal an unknown address before we handle any role conflict
Expand All @@ -347,7 +347,7 @@ void Port::OnReadPacket(const rtc::ReceivedPacket& packet, ProtocolType proto) {
SignalUnknownAddress(this, addr, proto, msg.get(), remote_username, false);
// Check for role conflicts.
if (!MaybeIceRoleConflict(addr, msg.get(), remote_username)) {
RTC_LOG(LS_INFO) << "Received conflicting role from the peer.";
RTC_LOG(LS_VERBOSE) << "Received conflicting role from the peer.";
return;
}
} else if (msg->type() == GOOG_PING_REQUEST) {
Expand Down Expand Up @@ -737,7 +737,7 @@ void Port::SendBindingErrorResponse(StunMessage* message,
options.info_signaled_after_sent.packet_type =
rtc::PacketType::kIceConnectivityCheckResponse;
SendTo(buf.Data(), buf.Length(), addr, options, false);
RTC_LOG(LS_INFO) << ToString() << ": Sending STUN "
RTC_LOG(LS_VERBOSE) << ToString() << ": Sending STUN "
<< StunMethodToString(response.type())
<< ": reason=" << reason << " to "
<< addr.ToSensitiveString();
Expand Down Expand Up @@ -855,7 +855,7 @@ void Port::UpdateNetworkCost() {
if (network_cost_ == new_cost) {
return;
}
RTC_LOG(LS_INFO) << "Network cost changed from " << network_cost_ << " to "
RTC_LOG(LS_VERBOSE) << "Network cost changed from " << network_cost_ << " to "
<< new_cost
<< ". Number of candidates created: " << candidates_.size()
<< ". Number of connections created: "
Expand Down Expand Up @@ -917,7 +917,7 @@ void Port::DestroyConnectionInternal(Connection* conn, bool async) {

void Port::Destroy() {
RTC_DCHECK(connections_.empty());
RTC_LOG(LS_INFO) << ToString() << ": Port deleted";
RTC_LOG(LS_VERBOSE) << ToString() << ": Port deleted";
SendPortDestroyed(this);
delete this;
}
Expand Down
6 changes: 3 additions & 3 deletions p2p/base/stun_port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class StunBindingRequest : public StunRequest {
}
}
void OnTimeout() override {
RTC_LOG(LS_ERROR) << "Binding request timed out from "
RTC_LOG(LS_WARNING) << "Binding request timed out from "
<< port_->GetLocalAddress().ToSensitiveString() << " ("
<< port_->Network()->name() << ")";
port_->OnStunBindingOrResolveRequestFailed(
Expand Down Expand Up @@ -428,7 +428,7 @@ void UDPPort::ResolveStunAddress(const rtc::SocketAddress& stun_addr) {
}));
}

RTC_LOG(LS_INFO) << ToString() << ": Starting STUN host lookup for "
RTC_LOG(LS_VERBOSE) << ToString() << ": Starting STUN host lookup for "
<< stun_addr.ToSensitiveString();
resolver_->Resolve(stun_addr, Network()->family(), field_trials());
}
Expand Down Expand Up @@ -586,7 +586,7 @@ void UDPPort::OnSendPacket(const void* data, size_t size, StunRequest* req) {
options.info_signaled_after_sent.packet_type = rtc::PacketType::kStunMessage;
CopyPortInformationToPacketInfo(&options.info_signaled_after_sent);
if (socket_->SendTo(data, size, sreq->server_addr(), options) < 0) {
RTC_LOG_ERR_EX(LS_ERROR, socket_->GetError())
RTC_LOG_ERR_EX(LS_WARNING, socket_->GetError())
<< "UDP send of " << size << " bytes to host "
<< sreq->server_addr().ToSensitiveNameAndAddressString()
<< " failed with error " << error_;
Expand Down
Loading
Loading