mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Add Rust_setIncomingAudioMuted
This commit is contained in:
parent
e667578458
commit
6504b2a0f9
22 changed files with 111 additions and 0 deletions
|
@ -302,6 +302,9 @@ class NetEq {
|
|||
// Flushes both the packet buffer and the sync buffer.
|
||||
virtual void FlushBuffers() = 0;
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
virtual void SetIncomingAudioMuted(bool muted) = 0;
|
||||
|
||||
// Enables NACK and sets the maximum size of the NACK list, which should be
|
||||
// positive and no larger than Nack::kNackListSizeLimit. If NACK is already
|
||||
// enabled then the maximum NACK list size is modified accordingly.
|
||||
|
|
|
@ -1217,6 +1217,9 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
|
|||
// the appropriate SDP is also applied.
|
||||
virtual void SetAudioRecording(bool recording) {}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
virtual void SetIncomingAudioMuted(uint32_t ssrc, bool muted) {}
|
||||
|
||||
// Looks up the DtlsTransport associated with a MID value.
|
||||
// In the Javascript API, DtlsTransport is a property of a sender, but
|
||||
// because the PeerConnection owns the DtlsTransport in this implementation,
|
||||
|
|
|
@ -182,6 +182,11 @@ void AudioReceiveStreamImpl::ReconfigureForTesting(
|
|||
config_ = config;
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void AudioReceiveStreamImpl::SetIncomingAudioMuted(bool muted) {
|
||||
channel_receive_->SetIncomingAudioMuted(muted);
|
||||
}
|
||||
|
||||
// RingRTC change to get recv audio levels
|
||||
uint16_t AudioReceiveStreamImpl::GetAudioLevel() {
|
||||
return channel_receive_->GetSpeechOutputLevelFullRange();
|
||||
|
|
|
@ -143,6 +143,9 @@ class AudioReceiveStreamImpl final : public webrtc::AudioReceiveStreamInterface,
|
|||
void ReconfigureForTesting(
|
||||
const webrtc::AudioReceiveStreamInterface::Config& config);
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(bool muted) override;
|
||||
|
||||
// RingRTC change to get recv audio levels
|
||||
uint16_t GetAudioLevel() override;
|
||||
|
||||
|
|
|
@ -129,6 +129,8 @@ class ChannelReceive : public ChannelReceiveInterface,
|
|||
|
||||
// Muting, Volume and Level.
|
||||
void SetChannelOutputVolumeScaling(float scaling) override;
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(bool muted) override;
|
||||
int GetSpeechOutputLevelFullRange() const override;
|
||||
// See description of "totalAudioEnergy" in the WebRTC stats spec:
|
||||
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
|
||||
|
@ -777,6 +779,11 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) {
|
|||
}
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void ChannelReceive::SetIncomingAudioMuted(bool muted) {
|
||||
acm_receiver_.SetIncomingAudioMuted(muted);
|
||||
}
|
||||
|
||||
int ChannelReceive::GetSpeechOutputLevelFullRange() const {
|
||||
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
|
||||
return _outputAudioLevel.LevelFullRange();
|
||||
|
|
|
@ -104,6 +104,8 @@ class ChannelReceiveInterface : public RtpPacketSinkInterface {
|
|||
virtual void ReceivedRTCPPacket(const uint8_t* data, size_t length) = 0;
|
||||
|
||||
virtual void SetChannelOutputVolumeScaling(float scaling) = 0;
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
virtual void SetIncomingAudioMuted(bool muted) = 0;
|
||||
virtual int GetSpeechOutputLevelFullRange() const = 0;
|
||||
// See description of "totalAudioEnergy" in the WebRTC stats spec:
|
||||
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
|
||||
|
|
|
@ -199,6 +199,9 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
|
|||
// Returns current value of base minimum delay in milliseconds.
|
||||
virtual int GetBaseMinimumPlayoutDelayMs() const = 0;
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
virtual void SetIncomingAudioMuted(bool muted) = 0;
|
||||
|
||||
// RingRTC change to get recv audio levels
|
||||
virtual uint16_t GetAudioLevel() {
|
||||
RTC_LOG(LS_WARNING) << "Default AudioReceiveStream::GetAudioLevel() does nothing!";
|
||||
|
|
|
@ -919,6 +919,9 @@ class VoiceMediaReceiveChannelInterface : public MediaReceiveChannelInterface {
|
|||
virtual void SetDefaultRawAudioSink(
|
||||
std::unique_ptr<webrtc::AudioSinkInterface> sink) = 0;
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
virtual void SetIncomingAudioMuted(uint32_t ssrc, bool muted) = 0;
|
||||
|
||||
// RingRTC change to get audio levels
|
||||
virtual void GetReceivedAudioLevels(
|
||||
cricket::ReceivedAudioLevel* received_out,
|
||||
|
|
|
@ -273,6 +273,11 @@ class VoiceMediaShimChannel : public VoiceMediaChannel {
|
|||
return receive_impl()->GetStats(info, reset_legacy);
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(uint32_t ssrc, bool muted) override {
|
||||
return receive_impl()->SetIncomingAudioMuted(ssrc, muted);
|
||||
}
|
||||
|
||||
// RingRTC change to get audio levels
|
||||
void GetReceivedAudioLevels(
|
||||
cricket::ReceivedAudioLevel* received_out,
|
||||
|
|
|
@ -2769,6 +2769,19 @@ bool WebRtcVoiceReceiveChannel::MaybeDeregisterUnsignaledRecvStream(
|
|||
return false;
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void WebRtcVoiceReceiveChannel::SetIncomingAudioMuted(uint32_t ssrc, bool muted) {
|
||||
auto it = recv_streams_.find(ssrc);
|
||||
if (it == recv_streams_.end()) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Attempting to SetIncomingAudioMuted for stream with ssrc "
|
||||
<< ssrc << " which doesn't exist.";
|
||||
return;
|
||||
}
|
||||
|
||||
it->second->stream().SetIncomingAudioMuted(muted);
|
||||
}
|
||||
|
||||
// RingRTC change to get audio levels
|
||||
void WebRtcVoiceReceiveChannel::GetReceivedAudioLevels(
|
||||
cricket::ReceivedAudioLevel* received_out,
|
||||
|
|
|
@ -460,6 +460,9 @@ class WebRtcVoiceReceiveChannel final
|
|||
void SetReceiveNackEnabled(bool enabled) override;
|
||||
void SetReceiveNonSenderRttEnabled(bool enabled) override;
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(uint32_t ssrc, bool muted) override;
|
||||
|
||||
// RingRTC change to get audio levels
|
||||
void GetReceivedAudioLevels(
|
||||
cricket::ReceivedAudioLevel* received_out,
|
||||
|
|
|
@ -322,6 +322,11 @@ void AcmReceiver::GetNetworkStatistics(
|
|||
neteq_operations_and_state.packet_buffer_flushes;
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void AcmReceiver::SetIncomingAudioMuted(bool muted) {
|
||||
neteq_->SetIncomingAudioMuted(muted);
|
||||
}
|
||||
|
||||
int AcmReceiver::EnableNack(size_t max_nack_list_size) {
|
||||
neteq_->EnableNack(max_nack_list_size);
|
||||
return 0;
|
||||
|
|
|
@ -187,6 +187,9 @@ class AcmReceiver {
|
|||
//
|
||||
absl::optional<std::pair<int, SdpAudioFormat>> LastDecoder() const;
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(bool muted);
|
||||
|
||||
//
|
||||
// Enable NACK and set the maximum size of the NACK list. If NACK is already
|
||||
// enabled then the maximum NACK list size is modified accordingly.
|
||||
|
|
|
@ -119,6 +119,8 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
|
|||
stats_(std::move(deps.stats)),
|
||||
controller_(std::move(deps.neteq_controller)),
|
||||
last_mode_(Mode::kNormal),
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
muted_(false),
|
||||
decoded_buffer_length_(kMaxFrameSize),
|
||||
decoded_buffer_(new int16_t[decoded_buffer_length_]),
|
||||
playout_timestamp_(0),
|
||||
|
@ -451,6 +453,12 @@ void NetEqImpl::FlushBuffers() {
|
|||
first_packet_ = true;
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void NetEqImpl::SetIncomingAudioMuted(bool muted) {
|
||||
MutexLock lock(&mutex_);
|
||||
muted_ = muted;
|
||||
}
|
||||
|
||||
void NetEqImpl::EnableNack(size_t max_nack_list_size) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!nack_enabled_) {
|
||||
|
@ -817,6 +825,11 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
|
|||
return return_value;
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
if (operation == Operation::kCodecInternalCng && muted_) {
|
||||
operation = Operation::kExpand;
|
||||
}
|
||||
|
||||
AudioDecoder::SpeechType speech_type;
|
||||
int length = 0;
|
||||
const size_t start_num_packets = packet_list.size();
|
||||
|
|
|
@ -188,6 +188,9 @@ class NetEqImpl : public webrtc::NetEq {
|
|||
// Flushes both the packet buffer and the sync buffer.
|
||||
void FlushBuffers() override;
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(bool muted) override;
|
||||
|
||||
void EnableNack(size_t max_nack_list_size) override;
|
||||
|
||||
void DisableNack() override;
|
||||
|
@ -376,6 +379,8 @@ class NetEqImpl : public webrtc::NetEq {
|
|||
size_t decoder_frame_length_ RTC_GUARDED_BY(mutex_);
|
||||
Mode last_mode_ RTC_GUARDED_BY(mutex_);
|
||||
Operation last_operation_ RTC_GUARDED_BY(mutex_);
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
bool muted_ RTC_GUARDED_BY(mutex_);
|
||||
absl::optional<AudioDecoder::SpeechType> last_decoded_type_
|
||||
RTC_GUARDED_BY(mutex_);
|
||||
size_t decoded_buffer_length_ RTC_GUARDED_BY(mutex_);
|
||||
|
|
|
@ -1031,6 +1031,13 @@ void VoiceChannel::GetAudioLevels(
|
|||
});
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void VoiceChannel::SetIncomingAudioMuted(uint32_t ssrc, bool muted) {
|
||||
worker_thread()->BlockingCall([this, ssrc, muted] {
|
||||
voice_media_receive_channel()->SetIncomingAudioMuted(ssrc, muted);
|
||||
});
|
||||
}
|
||||
|
||||
VideoChannel::VideoChannel(
|
||||
rtc::Thread* worker_thread,
|
||||
rtc::Thread* network_thread,
|
||||
|
|
|
@ -452,6 +452,9 @@ class VoiceChannel : public BaseChannel {
|
|||
// RingRTC change to configure OPUS
|
||||
void ConfigureEncoders(const webrtc::AudioEncoder::Config& config);
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(uint32_t ssrc, bool muted);
|
||||
|
||||
// RingRTC change to get audio levels
|
||||
void GetAudioLevels(
|
||||
cricket::AudioLevel* captured_out,
|
||||
|
|
|
@ -1747,6 +1747,14 @@ void PeerConnection::SetAudioRecording(bool recording) {
|
|||
audio_state->SetRecording(recording);
|
||||
}
|
||||
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void PeerConnection::SetIncomingAudioMuted(uint32_t ssrc, bool muted) {
|
||||
auto* voice_channel = static_cast<cricket::VoiceChannel*>(rtp_manager()->GetAudioTransceiver()->internal()->channel());
|
||||
if (voice_channel) {
|
||||
voice_channel->SetIncomingAudioMuted(ssrc, muted);
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnection::AddAdaptationResource(
|
||||
rtc::scoped_refptr<Resource> resource) {
|
||||
if (!worker_thread()->IsCurrent()) {
|
||||
|
|
|
@ -259,6 +259,8 @@ class PeerConnection : public PeerConnectionInternal,
|
|||
|
||||
void SetAudioPlayout(bool playout) override;
|
||||
void SetAudioRecording(bool recording) override;
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
void SetIncomingAudioMuted(uint32_t ssrc, bool muted) override;
|
||||
|
||||
rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
|
||||
const std::string& mid) override;
|
||||
|
|
|
@ -164,6 +164,8 @@ PROXY_METHOD1(bool, SetIncomingRtpEnabled, bool)
|
|||
PROXY_METHOD1(RTCError, SetBitrate, const BitrateSettings&)
|
||||
PROXY_METHOD1(void, SetAudioPlayout, bool)
|
||||
PROXY_METHOD1(void, SetAudioRecording, bool)
|
||||
// RingRTC change to disable CNG for muted incoming streams.
|
||||
PROXY_METHOD2(void, SetIncomingAudioMuted, uint32_t, bool)
|
||||
// This method will be invoked on the network thread. See
|
||||
// PeerConnectionFactory::CreatePeerConnectionOrError for more details.
|
||||
PROXY_SECONDARY_METHOD1(rtc::scoped_refptr<DtlsTransportInterface>,
|
||||
|
|
|
@ -131,6 +131,11 @@ RUSTEXPORT void
|
|||
Rust_setAudioRecordingEnabled(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc,
|
||||
bool enabled);
|
||||
|
||||
RUSTEXPORT void
|
||||
Rust_setIncomingAudioMuted(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc,
|
||||
uint32_t ssrc,
|
||||
bool muted);
|
||||
|
||||
RUSTEXPORT bool
|
||||
Rust_addIceCandidateFromSdp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc,
|
||||
const char* sdp);
|
||||
|
|
|
@ -741,6 +741,14 @@ Rust_setAudioRecordingEnabled(webrtc::PeerConnectionInterface* peer_connection_b
|
|||
peer_connection_borrowed_rc->SetAudioRecording(enabled);
|
||||
}
|
||||
|
||||
RUSTEXPORT void
|
||||
Rust_setIncomingAudioMuted(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc,
|
||||
uint32_t ssrc,
|
||||
bool muted) {
|
||||
RTC_LOG(LS_INFO) << "Rust_setIncomingAudioMuted(" << ssrc << ", " << muted << ")";
|
||||
peer_connection_borrowed_rc->SetIncomingAudioMuted(ssrc, muted);
|
||||
}
|
||||
|
||||
RUSTEXPORT bool
|
||||
Rust_addIceCandidateFromSdp(PeerConnectionInterface* peer_connection_borrowed_rc,
|
||||
const char* sdp_borrowed) {
|
||||
|
|
Loading…
Reference in a new issue