mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Disable audio and media flow by default
This commit is contained in:
parent
e202610239
commit
94ae6702c9
19 changed files with 43 additions and 33 deletions
|
@ -55,7 +55,7 @@ bool PeerConnectionInterface::UseSharedIceGatherer(
|
|||
return false;
|
||||
}
|
||||
|
||||
// RingRTC change to RTP from being processed before the call is accepted
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
bool PeerConnectionInterface::SetIncomingRtpEnabled(bool enabled) {
|
||||
RTC_LOG(LS_ERROR) << "No enabling of incoming RTP in dummy implementation";
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ bool PeerConnectionInterface::SendRtp(std::unique_ptr<RtpPacket> rtp_packet) {
|
|||
}
|
||||
|
||||
// RingRTC change to receive RTP data
|
||||
bool PeerConnectionInterface::ReceiveRtp(uint8_t pt) {
|
||||
bool PeerConnectionInterface::ReceiveRtp(uint8_t pt, bool enable_incoming) {
|
||||
RTC_LOG(LS_ERROR) << "No SendRtp in dummy implementation";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1162,8 +1162,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
|
|||
virtual bool UseSharedIceGatherer(
|
||||
rtc::scoped_refptr<webrtc::IceGathererInterface> shared_ice_gatherer);
|
||||
|
||||
// RingRTC change to RTP from being processed before the call is accepted
|
||||
// If false, all RTP and RTCP packets will be dropped before being processed.
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
virtual bool SetIncomingRtpEnabled(bool enabled);
|
||||
|
||||
// RingRTC change to send RTP data
|
||||
|
@ -1173,7 +1172,7 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
|
|||
|
||||
// RingRTC change to receive RTP data
|
||||
// Packets will go to the PeerConnectionObserver
|
||||
virtual bool ReceiveRtp(uint8_t pt);
|
||||
virtual bool ReceiveRtp(uint8_t pt, bool enable_incoming);
|
||||
|
||||
virtual void ConfigureAudioEncoders(const webrtc::AudioEncoder::Config& config) {
|
||||
RTC_LOG(LS_WARNING) << "Default PeerConnectionInterface::ConfigureAudioEncoders(...) does nothing!";
|
||||
|
|
|
@ -510,7 +510,8 @@ struct RTC_EXPORT RtpEncodingParameters {
|
|||
// off.
|
||||
// TODO(webrtc.bugs.org/8807): Updating this parameter will trigger an encoder
|
||||
// reset, but this isn't necessarily required.
|
||||
bool active = true;
|
||||
// RingRTC change to make the RTP encoding disabled by default
|
||||
bool active = false;
|
||||
|
||||
// Value to use for RID RTP header extension.
|
||||
// Called "encodingId" in ORTC.
|
||||
|
|
|
@ -210,8 +210,9 @@ class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface {
|
|||
bool(rtc::scoped_refptr<webrtc::IceGathererInterface>));
|
||||
MOCK_METHOD1(SendRtp,
|
||||
bool(std::unique_ptr<RtpPacket>));
|
||||
MOCK_METHOD1(ReceiveRtp,
|
||||
bool(uint8_t));
|
||||
MOCK_METHOD2(ReceiveRtp,
|
||||
bool(uint8_t),
|
||||
bool(bool));
|
||||
MOCK_METHOD1(SetIncomingRtpEnabled,
|
||||
bool(bool));
|
||||
};
|
||||
|
|
|
@ -128,8 +128,7 @@ void AudioState::SetPlayout(bool enabled) {
|
|||
if (enabled) {
|
||||
UpdateNullAudioPollerState();
|
||||
if (!receiving_streams_.empty()) {
|
||||
// RingRTC change to ensure the ADM is initialized before attempting
|
||||
// to start playout (preventing a crash on some ADMs).
|
||||
// RingRTC change to ensure the ADM is initialized before starting
|
||||
if (config_.audio_device_module->InitPlayout() == 0) {
|
||||
config_.audio_device_module->StartPlayout();
|
||||
} else {
|
||||
|
|
|
@ -67,8 +67,9 @@ class AudioState : public webrtc::AudioState {
|
|||
SequenceChecker thread_checker_;
|
||||
SequenceChecker process_thread_checker_{SequenceChecker::kDetached};
|
||||
const webrtc::AudioState::Config config_;
|
||||
bool recording_enabled_ = true;
|
||||
bool playout_enabled_ = true;
|
||||
// RingRTC change to make the audio state disabled by default
|
||||
bool recording_enabled_ = false;
|
||||
bool playout_enabled_ = false;
|
||||
|
||||
// Transports mixed audio from the mixer to the audio device and
|
||||
// recorded audio to the sending streams.
|
||||
|
|
|
@ -300,6 +300,7 @@ void JsepTransportController::StartGatheringWithSharedIceGatherer(
|
|||
}
|
||||
}
|
||||
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
bool JsepTransportController::SetIncomingRtpEnabled(bool enabled) {
|
||||
if (!network_thread_->IsCurrent()) {
|
||||
return network_thread_->BlockingCall([=] {
|
||||
|
@ -310,6 +311,8 @@ bool JsepTransportController::SetIncomingRtpEnabled(bool enabled) {
|
|||
RTC_DCHECK_RUN_ON(network_thread_);
|
||||
|
||||
for (const auto& transport : transports_.Transports()) {
|
||||
RTC_LOG(LS_WARNING) << "JsepTransportController::SetIncomingRtpEnabled(" << enabled << ") "
|
||||
<< transport->rtp_transport()->transport_name();
|
||||
if (!transport->rtp_transport()->SetIncomingRtpEnabled(enabled)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -251,6 +251,7 @@ class JsepTransportController : public sigslot::has_slots<> {
|
|||
|
||||
RTCError RollbackTransports();
|
||||
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
bool SetIncomingRtpEnabled(bool enabled);
|
||||
|
||||
// F: void(const std::string&, const std::vector<cricket::Candidate>&)
|
||||
|
|
|
@ -3015,6 +3015,7 @@ bool PeerConnection::UseSharedIceGatherer(
|
|||
return true;
|
||||
}
|
||||
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
bool PeerConnection::SetIncomingRtpEnabled(bool enabled) {
|
||||
return network_thread()->BlockingCall([this, enabled] {
|
||||
JsepTransportController* transport_controller = this->transport_controller_n();
|
||||
|
@ -3045,16 +3046,20 @@ bool PeerConnection::SendRtp(std::unique_ptr<RtpPacket> rtp_packet) {
|
|||
});
|
||||
}
|
||||
|
||||
bool PeerConnection::ReceiveRtp(uint8_t pt) {
|
||||
// RingRTC change to receive RTP data
|
||||
bool PeerConnection::ReceiveRtp(uint8_t pt, bool enable_incoming) {
|
||||
RtpDemuxerCriteria demux_criteria;
|
||||
demux_criteria.payload_types().insert(pt);
|
||||
RtpPacketSinkInterface* sink = Observer();
|
||||
return network_thread()->BlockingCall([this, demux_criteria, sink] {
|
||||
return network_thread()->BlockingCall([this, demux_criteria, sink, enable_incoming] {
|
||||
JsepTransportController* transport_controller = this->transport_controller_n();
|
||||
RtpTransportInternal* rtp_transport = transport_controller->GetBundledRtpTransport();
|
||||
if (!rtp_transport) {
|
||||
return false;
|
||||
}
|
||||
if (enable_incoming) {
|
||||
rtp_transport->SetIncomingRtpEnabled(true);
|
||||
}
|
||||
return rtp_transport->RegisterRtpDemuxerSink(demux_criteria, sink);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ class PeerConnection : public PeerConnectionInternal,
|
|||
bool SetIncomingRtpEnabled(bool enabled) override;
|
||||
|
||||
bool SendRtp(std::unique_ptr<RtpPacket> rtp_packet) override;
|
||||
bool ReceiveRtp(uint8_t pt) override;
|
||||
bool ReceiveRtp(uint8_t pt, bool enable_incoming) override;
|
||||
|
||||
void ConfigureAudioEncoders(const webrtc::AudioEncoder::Config& config) override;
|
||||
|
||||
|
|
|
@ -144,9 +144,10 @@ PROXY_METHOD1(bool,
|
|||
PROXY_METHOD1(bool,
|
||||
SendRtp,
|
||||
std::unique_ptr<RtpPacket>)
|
||||
PROXY_METHOD1(bool,
|
||||
PROXY_METHOD2(bool,
|
||||
ReceiveRtp,
|
||||
uint8_t)
|
||||
uint8_t,
|
||||
bool)
|
||||
PROXY_METHOD1(void,
|
||||
ConfigureAudioEncoders,
|
||||
const webrtc::AudioEncoder::Config&)
|
||||
|
|
|
@ -294,8 +294,8 @@ bool PeerConnectionWrapper::SendRtp(std::unique_ptr<RtpPacket> rtp_packet) {
|
|||
return pc()->SendRtp(std::move(rtp_packet));
|
||||
}
|
||||
|
||||
bool PeerConnectionWrapper::ReceiveRtp(uint8_t pt) {
|
||||
return pc()->ReceiveRtp(pt);
|
||||
bool PeerConnectionWrapper::ReceiveRtp(uint8_t pt, bool enable_incoming) {
|
||||
return pc()->ReceiveRtp(pt, enable_incoming);
|
||||
}
|
||||
|
||||
void PeerConnectionWrapper::GetAudioLevels(
|
||||
|
|
|
@ -148,7 +148,7 @@ class PeerConnectionWrapper {
|
|||
bool SetIncomingRtpEnabled(bool enabled);
|
||||
|
||||
bool SendRtp(std::unique_ptr<RtpPacket> rtp_packet);
|
||||
bool ReceiveRtp(uint8_t pt);
|
||||
bool ReceiveRtp(uint8_t pt, bool enable_incoming);
|
||||
|
||||
void GetAudioLevels(
|
||||
cricket::AudioLevel* captured_out,
|
||||
|
|
|
@ -282,10 +282,10 @@ void RtpTransport::OnReadPacket(rtc::PacketTransportInternal* transport,
|
|||
}
|
||||
}
|
||||
|
||||
// RingRTC change to avoid processing RTP packets too soon
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
bool RtpTransport::SetIncomingRtpEnabled(bool enabled) {
|
||||
RTC_LOG(LS_WARNING) << "RtpTransport::SetIncomingRtpEnabled(" << enabled << ") was " << incoming_rtp_enabled_;
|
||||
incoming_rtp_enabled_ = enabled;
|
||||
RTC_LOG(LS_INFO) << "RtpTransport::SetIncomingRtpEnabled(" << enabled << ")";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,7 @@ class RtpTransport : public RtpTransportInternal {
|
|||
|
||||
bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) override;
|
||||
|
||||
// RingRTC change to avoid processing RTP packets too soon
|
||||
// If false, drop all RTP and RTCP packets before processing them.
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
bool SetIncomingRtpEnabled(bool enabled) override;
|
||||
|
||||
protected:
|
||||
|
@ -143,7 +142,8 @@ class RtpTransport : public RtpTransportInternal {
|
|||
RtpHeaderExtensionMap header_extension_map_;
|
||||
|
||||
// If false, drop all RTP and RTCP packets before processing them.
|
||||
bool incoming_rtp_enabled_ = true;
|
||||
// RingRTC change to drop all incoming packets until explicitly allowed
|
||||
bool incoming_rtp_enabled_ = false;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -104,8 +104,7 @@ class RtpTransportInternal : public sigslot::has_slots<> {
|
|||
|
||||
virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0;
|
||||
|
||||
// RingRTC change to avoid processing RTP packets too soon
|
||||
// If false, drop all RTP and RTCP packets before processing them.
|
||||
// RingRTC change to explicitly control when incoming packets can be processed
|
||||
virtual bool SetIncomingRtpEnabled(bool enabled) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ class FakePeerConnectionBase : public PeerConnectionInternal {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ReceiveRtp(uint8_t pt) override {
|
||||
bool ReceiveRtp(uint8_t pt, bool enable_incoming) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ Rust_sendRtp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc,
|
|||
size_t payload_size);
|
||||
|
||||
RUSTEXPORT bool
|
||||
Rust_receiveRtp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc, uint8_t pt);
|
||||
Rust_receiveRtp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc, uint8_t pt, bool enable_incoming);
|
||||
|
||||
RUSTEXPORT void
|
||||
Rust_configureAudioEncoders(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc, const webrtc::AudioEncoder::Config* config_borrowed);
|
||||
|
|
|
@ -706,12 +706,12 @@ Rust_deleteSessionDescription(SessionDescriptionInterface* description_owned) {
|
|||
RUSTEXPORT void
|
||||
Rust_setOutgoingMediaEnabled(PeerConnectionInterface* peer_connection_borrowed_rc,
|
||||
bool enabled) {
|
||||
// Note: calling SetAudioRecording(enabled) is deprecated and it's not clear
|
||||
// that it even does anything any more.
|
||||
RTC_LOG(LS_INFO) << "Rust_setOutgoingMediaEnabled(" << enabled << ")";
|
||||
int encodings_changed = 0;
|
||||
for (auto& sender : peer_connection_borrowed_rc->GetSenders()) {
|
||||
RtpParameters parameters = sender->GetParameters();
|
||||
for (auto& encoding: parameters.encodings) {
|
||||
RTC_LOG(LS_INFO) << "Rust_setOutgoingMediaEnabled() encoding.active was: " << encoding.active;
|
||||
encoding.active = enabled;
|
||||
encodings_changed++;
|
||||
}
|
||||
|
@ -883,8 +883,8 @@ Rust_sendRtp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc,
|
|||
// while holding a lock, especially a lock also taken in a callback
|
||||
// from the network thread.
|
||||
RUSTEXPORT bool
|
||||
Rust_receiveRtp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc, uint8_t pt) {
|
||||
return peer_connection_borrowed_rc->ReceiveRtp(pt);
|
||||
Rust_receiveRtp(webrtc::PeerConnectionInterface* peer_connection_borrowed_rc, uint8_t pt, bool enable_incoming) {
|
||||
return peer_connection_borrowed_rc->ReceiveRtp(pt, enable_incoming);
|
||||
}
|
||||
|
||||
RUSTEXPORT void
|
||||
|
|
Loading…
Reference in a new issue