diff options
author | Erik Språng <sprang@webrtc.org> | 2018-03-14 10:47:02 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2018-03-14 10:22:50 +0000 |
commit | 31a12c557dcd84a31f9c3f2d8858d9646c2a3135 (patch) | |
tree | ba2f0abe2721b754cdde9e412e39aabccb04a09d /call/degraded_call.h | |
parent | e10675a66657580a68ad2b2b3604b740e8a8d81b (diff) | |
download | webrtc-31a12c557dcd84a31f9c3f2d8858d9646c2a3135.tar.gz |
Add ability to emulate degraded network in Call via field trial
This is especially useful in Chrome, allowing use to emulate network
conditions in incoming or outgoing media without the need for platform
specific tools or hacks. It also doesn't interfere with the rest of the
network traffic.
Also includes some refactorings.
Bug: webrtc:8910
Change-Id: I2656a2d4218acbe7f8ffd669de19a02275735438
Reviewed-on: https://webrtc-review.googlesource.com/33013
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22418}
Diffstat (limited to 'call/degraded_call.h')
-rw-r--r-- | call/degraded_call.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/call/degraded_call.h b/call/degraded_call.h new file mode 100644 index 0000000000..5658873922 --- /dev/null +++ b/call/degraded_call.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef CALL_DEGRADED_CALL_H_ +#define CALL_DEGRADED_CALL_H_ + +#include <memory> + +#include "api/call/transport.h" +#include "api/optional.h" +#include "call/call.h" +#include "call/fake_network_pipe.h" +#include "modules/utility/include/process_thread.h" +#include "system_wrappers/include/clock.h" + +namespace webrtc { + +class DegradedCall : public Call, private Transport, private PacketReceiver { + public: + explicit DegradedCall(std::unique_ptr<Call> call, + rtc::Optional<FakeNetworkPipe::Config> send_config, + rtc::Optional<FakeNetworkPipe::Config> receive_config); + ~DegradedCall() override; + + // Implements Call. + AudioSendStream* CreateAudioSendStream( + const AudioSendStream::Config& config) override; + void DestroyAudioSendStream(AudioSendStream* send_stream) override; + + AudioReceiveStream* CreateAudioReceiveStream( + const AudioReceiveStream::Config& config) override; + void DestroyAudioReceiveStream(AudioReceiveStream* receive_stream) override; + + VideoSendStream* CreateVideoSendStream( + VideoSendStream::Config config, + VideoEncoderConfig encoder_config) override; + VideoSendStream* CreateVideoSendStream( + VideoSendStream::Config config, + VideoEncoderConfig encoder_config, + std::unique_ptr<FecController> fec_controller) override; + void DestroyVideoSendStream(VideoSendStream* send_stream) override; + + VideoReceiveStream* CreateVideoReceiveStream( + VideoReceiveStream::Config configuration) override; + void DestroyVideoReceiveStream(VideoReceiveStream* receive_stream) override; + + FlexfecReceiveStream* CreateFlexfecReceiveStream( + const FlexfecReceiveStream::Config& config) override; + void DestroyFlexfecReceiveStream( + FlexfecReceiveStream* receive_stream) override; + + PacketReceiver* Receiver() override; + + RtpTransportControllerSendInterface* GetTransportControllerSend() override; + + Stats GetStats() const override; + + void SetBitrateAllocationStrategy( + std::unique_ptr<rtc::BitrateAllocationStrategy> + bitrate_allocation_strategy) override; + + void SignalChannelNetworkState(MediaType media, NetworkState state) override; + + void OnTransportOverheadChanged(MediaType media, + int transport_overhead_per_packet) override; + + void OnSentPacket(const rtc::SentPacket& sent_packet) override; + + protected: + // Implements Transport. + bool SendRtp(const uint8_t* packet, + size_t length, + const PacketOptions& options) override; + + bool SendRtcp(const uint8_t* packet, size_t length) override; + + // Implements PacketReceiver. + DeliveryStatus DeliverPacket(MediaType media_type, + rtc::CopyOnWriteBuffer packet, + const PacketTime& packet_time) override; + + private: + Clock* const clock_; + const std::unique_ptr<Call> call_; + + const rtc::Optional<FakeNetworkPipe::Config> send_config_; + const std::unique_ptr<ProcessThread> send_process_thread_; + std::unique_ptr<FakeNetworkPipe> send_pipe_; + size_t num_send_streams_; + + const rtc::Optional<FakeNetworkPipe::Config> receive_config_; + std::unique_ptr<FakeNetworkPipe> receive_pipe_; +}; + +} // namespace webrtc + +#endif // CALL_DEGRADED_CALL_H_ |