PeerConnection::SetBitrate now also configures media transport.
(so far SetBitrate did not do anything for media transport) Bug: webrtc:9719 Change-Id: I48e669341ffe6c9e4697ff9146c314be7796a209 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127980 Reviewed-by: Steve Anton <steveanton@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Reviewed-by: Bjorn Mellem <mellem@webrtc.org> Commit-Queue: Peter Slatala <psla@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27169}
This commit is contained in:
parent
ae88f39801
commit
7fbfaa49d2
36
call/call.cc
36
call/call.cc
@ -244,6 +244,8 @@ class Call final : public webrtc::Call,
|
||||
// at least once after that.
|
||||
void MediaTransportChange(MediaTransportInterface* media_transport) override;
|
||||
|
||||
void SetClientBitratePreferences(const BitrateSettings& preferences) override;
|
||||
|
||||
private:
|
||||
DeliveryStatus DeliverRtcp(MediaType media_type,
|
||||
const uint8_t* packet,
|
||||
@ -275,6 +277,9 @@ class Call final : public webrtc::Call,
|
||||
Clock* const clock_;
|
||||
TaskQueueFactory* const task_queue_factory_;
|
||||
|
||||
// Caching the last SetBitrate for media transport.
|
||||
absl::optional<MediaTransportTargetRateConstraints> last_set_bitrate_
|
||||
RTC_GUARDED_BY(&target_observer_crit_);
|
||||
const int num_cpu_cores_;
|
||||
const std::unique_ptr<ProcessThread> module_process_thread_;
|
||||
const std::unique_ptr<CallStats> call_stats_;
|
||||
@ -580,6 +585,37 @@ void Call::MediaTransportChange(MediaTransportInterface* media_transport) {
|
||||
constraints.min_bitrate =
|
||||
DataRate::bps(config_.bitrate_config.min_bitrate_bps);
|
||||
}
|
||||
|
||||
// User called ::SetBitrate on peer connection before
|
||||
// media transport was created.
|
||||
if (last_set_bitrate_) {
|
||||
media_transport_->SetTargetBitrateLimits(*last_set_bitrate_);
|
||||
} else {
|
||||
media_transport_->SetTargetBitrateLimits(constraints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Call::SetClientBitratePreferences(const BitrateSettings& preferences) {
|
||||
GetTransportControllerSend()->SetClientBitratePreferences(preferences);
|
||||
// Can the client code invoke 'SetBitrate' before media transport is created?
|
||||
// It's probably possible :/
|
||||
MediaTransportTargetRateConstraints constraints;
|
||||
if (preferences.start_bitrate_bps.has_value()) {
|
||||
constraints.starting_bitrate =
|
||||
webrtc::DataRate::bps(*preferences.start_bitrate_bps);
|
||||
}
|
||||
if (preferences.max_bitrate_bps.has_value()) {
|
||||
constraints.max_bitrate =
|
||||
webrtc::DataRate::bps(*preferences.max_bitrate_bps);
|
||||
}
|
||||
if (preferences.min_bitrate_bps.has_value()) {
|
||||
constraints.min_bitrate =
|
||||
webrtc::DataRate::bps(*preferences.min_bitrate_bps);
|
||||
}
|
||||
rtc::CritScope lock(&target_observer_crit_);
|
||||
last_set_bitrate_ = constraints;
|
||||
if (media_transport_) {
|
||||
media_transport_->SetTargetBitrateLimits(constraints);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,6 +124,9 @@ class Call {
|
||||
|
||||
virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
|
||||
|
||||
virtual void SetClientBitratePreferences(
|
||||
const BitrateSettings& preferences) = 0;
|
||||
|
||||
virtual ~Call() {}
|
||||
};
|
||||
|
||||
|
||||
@ -133,6 +133,8 @@ class DegradedCall : public Call, private Transport, private PacketReceiver {
|
||||
const std::unique_ptr<Call> call_;
|
||||
|
||||
void MediaTransportChange(MediaTransportInterface* media_transport) override;
|
||||
void SetClientBitratePreferences(
|
||||
const webrtc::BitrateSettings& preferences) override {}
|
||||
const absl::optional<BuiltInNetworkBehaviorConfig> send_config_;
|
||||
const std::unique_ptr<ProcessThread> send_process_thread_;
|
||||
SimulatedNetwork* send_simulated_network_;
|
||||
|
||||
@ -303,6 +303,9 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver {
|
||||
void MediaTransportChange(
|
||||
webrtc::MediaTransportInterface* media_transport_interface) override;
|
||||
|
||||
void SetClientBitratePreferences(
|
||||
const webrtc::BitrateSettings& preferences) override {}
|
||||
|
||||
private:
|
||||
webrtc::AudioSendStream* CreateAudioSendStream(
|
||||
const webrtc::AudioSendStream::Config& config) override;
|
||||
|
||||
@ -3611,7 +3611,7 @@ RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) {
|
||||
}
|
||||
|
||||
RTC_DCHECK(call_.get());
|
||||
call_->GetTransportControllerSend()->SetClientBitratePreferences(bitrate);
|
||||
call_->SetClientBitratePreferences(bitrate);
|
||||
|
||||
return RTCError::OK();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user