Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef CALL_DEGRADED_CALL_H_ |
| 12 | #define CALL_DEGRADED_CALL_H_ |
| 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 16 | #include <memory> |
| 17 | |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 18 | #include "absl/types/optional.h" |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 19 | #include "api/call/transport.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 20 | #include "api/fec_controller.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 21 | #include "api/media_types.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 22 | #include "api/rtp_headers.h" |
Artem Titov | 3229d65 | 2018-08-17 13:00:54 +0200 | [diff] [blame] | 23 | #include "api/test/simulated_network.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 24 | #include "api/video_codecs/video_encoder_config.h" |
| 25 | #include "call/audio_receive_stream.h" |
| 26 | #include "call/audio_send_stream.h" |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 27 | #include "call/call.h" |
| 28 | #include "call/fake_network_pipe.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 29 | #include "call/flexfec_receive_stream.h" |
| 30 | #include "call/packet_receiver.h" |
| 31 | #include "call/rtp_transport_controller_send_interface.h" |
Artem Titov | 3229d65 | 2018-08-17 13:00:54 +0200 | [diff] [blame] | 32 | #include "call/simulated_network.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 33 | #include "call/video_receive_stream.h" |
| 34 | #include "call/video_send_stream.h" |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 35 | #include "modules/utility/include/process_thread.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 36 | #include "rtc_base/bitrate_allocation_strategy.h" |
| 37 | #include "rtc_base/copy_on_write_buffer.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 38 | #include "rtc_base/network/sent_packet.h" |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 39 | #include "system_wrappers/include/clock.h" |
| 40 | |
| 41 | namespace webrtc { |
| 42 | |
| 43 | class DegradedCall : public Call, private Transport, private PacketReceiver { |
| 44 | public: |
Artem Titov | 3229d65 | 2018-08-17 13:00:54 +0200 | [diff] [blame] | 45 | explicit DegradedCall( |
| 46 | std::unique_ptr<Call> call, |
Artem Titov | 75e3647 | 2018-10-08 12:28:56 +0200 | [diff] [blame] | 47 | absl::optional<BuiltInNetworkBehaviorConfig> send_config, |
| 48 | absl::optional<BuiltInNetworkBehaviorConfig> receive_config); |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 49 | ~DegradedCall() override; |
| 50 | |
| 51 | // Implements Call. |
| 52 | AudioSendStream* CreateAudioSendStream( |
| 53 | const AudioSendStream::Config& config) override; |
| 54 | void DestroyAudioSendStream(AudioSendStream* send_stream) override; |
| 55 | |
| 56 | AudioReceiveStream* CreateAudioReceiveStream( |
| 57 | const AudioReceiveStream::Config& config) override; |
| 58 | void DestroyAudioReceiveStream(AudioReceiveStream* receive_stream) override; |
| 59 | |
| 60 | VideoSendStream* CreateVideoSendStream( |
| 61 | VideoSendStream::Config config, |
| 62 | VideoEncoderConfig encoder_config) override; |
| 63 | VideoSendStream* CreateVideoSendStream( |
| 64 | VideoSendStream::Config config, |
| 65 | VideoEncoderConfig encoder_config, |
| 66 | std::unique_ptr<FecController> fec_controller) override; |
| 67 | void DestroyVideoSendStream(VideoSendStream* send_stream) override; |
| 68 | |
| 69 | VideoReceiveStream* CreateVideoReceiveStream( |
| 70 | VideoReceiveStream::Config configuration) override; |
| 71 | void DestroyVideoReceiveStream(VideoReceiveStream* receive_stream) override; |
| 72 | |
| 73 | FlexfecReceiveStream* CreateFlexfecReceiveStream( |
| 74 | const FlexfecReceiveStream::Config& config) override; |
| 75 | void DestroyFlexfecReceiveStream( |
| 76 | FlexfecReceiveStream* receive_stream) override; |
| 77 | |
| 78 | PacketReceiver* Receiver() override; |
| 79 | |
| 80 | RtpTransportControllerSendInterface* GetTransportControllerSend() override; |
| 81 | |
| 82 | Stats GetStats() const override; |
| 83 | |
| 84 | void SetBitrateAllocationStrategy( |
| 85 | std::unique_ptr<rtc::BitrateAllocationStrategy> |
| 86 | bitrate_allocation_strategy) override; |
| 87 | |
| 88 | void SignalChannelNetworkState(MediaType media, NetworkState state) override; |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 89 | void OnAudioTransportOverheadChanged( |
| 90 | int transport_overhead_per_packet) override; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 91 | void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
| 92 | |
| 93 | protected: |
| 94 | // Implements Transport. |
| 95 | bool SendRtp(const uint8_t* packet, |
| 96 | size_t length, |
| 97 | const PacketOptions& options) override; |
| 98 | |
| 99 | bool SendRtcp(const uint8_t* packet, size_t length) override; |
| 100 | |
| 101 | // Implements PacketReceiver. |
| 102 | DeliveryStatus DeliverPacket(MediaType media_type, |
| 103 | rtc::CopyOnWriteBuffer packet, |
Niels Möller | 7008287 | 2018-08-07 11:03:12 +0200 | [diff] [blame] | 104 | int64_t packet_time_us) override; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 105 | |
| 106 | private: |
| 107 | Clock* const clock_; |
| 108 | const std::unique_ptr<Call> call_; |
| 109 | |
Piotr (Peter) Slatala | cc8e8bb | 2018-11-15 08:26:19 -0800 | [diff] [blame] | 110 | void MediaTransportChange(MediaTransportInterface* media_transport) override; |
Artem Titov | 75e3647 | 2018-10-08 12:28:56 +0200 | [diff] [blame] | 111 | const absl::optional<BuiltInNetworkBehaviorConfig> send_config_; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 112 | const std::unique_ptr<ProcessThread> send_process_thread_; |
Artem Titov | 3229d65 | 2018-08-17 13:00:54 +0200 | [diff] [blame] | 113 | SimulatedNetwork* send_simulated_network_; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 114 | std::unique_ptr<FakeNetworkPipe> send_pipe_; |
| 115 | size_t num_send_streams_; |
| 116 | |
Artem Titov | 75e3647 | 2018-10-08 12:28:56 +0200 | [diff] [blame] | 117 | const absl::optional<BuiltInNetworkBehaviorConfig> receive_config_; |
Artem Titov | 3229d65 | 2018-08-17 13:00:54 +0200 | [diff] [blame] | 118 | SimulatedNetwork* receive_simulated_network_; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 119 | std::unique_ptr<FakeNetworkPipe> receive_pipe_; |
| 120 | }; |
| 121 | |
| 122 | } // namespace webrtc |
| 123 | |
| 124 | #endif // CALL_DEGRADED_CALL_H_ |