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 | |
| 14 | #include <memory> |
| 15 | |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame^] | 16 | #include "absl/types/optional.h" |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 17 | #include "api/call/transport.h" |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 18 | #include "call/call.h" |
| 19 | #include "call/fake_network_pipe.h" |
| 20 | #include "modules/utility/include/process_thread.h" |
| 21 | #include "system_wrappers/include/clock.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class DegradedCall : public Call, private Transport, private PacketReceiver { |
| 26 | public: |
| 27 | explicit DegradedCall(std::unique_ptr<Call> call, |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame^] | 28 | absl::optional<FakeNetworkPipe::Config> send_config, |
| 29 | absl::optional<FakeNetworkPipe::Config> receive_config); |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 30 | ~DegradedCall() override; |
| 31 | |
| 32 | // Implements Call. |
| 33 | AudioSendStream* CreateAudioSendStream( |
| 34 | const AudioSendStream::Config& config) override; |
| 35 | void DestroyAudioSendStream(AudioSendStream* send_stream) override; |
| 36 | |
| 37 | AudioReceiveStream* CreateAudioReceiveStream( |
| 38 | const AudioReceiveStream::Config& config) override; |
| 39 | void DestroyAudioReceiveStream(AudioReceiveStream* receive_stream) override; |
| 40 | |
| 41 | VideoSendStream* CreateVideoSendStream( |
| 42 | VideoSendStream::Config config, |
| 43 | VideoEncoderConfig encoder_config) override; |
| 44 | VideoSendStream* CreateVideoSendStream( |
| 45 | VideoSendStream::Config config, |
| 46 | VideoEncoderConfig encoder_config, |
| 47 | std::unique_ptr<FecController> fec_controller) override; |
| 48 | void DestroyVideoSendStream(VideoSendStream* send_stream) override; |
| 49 | |
| 50 | VideoReceiveStream* CreateVideoReceiveStream( |
| 51 | VideoReceiveStream::Config configuration) override; |
| 52 | void DestroyVideoReceiveStream(VideoReceiveStream* receive_stream) override; |
| 53 | |
| 54 | FlexfecReceiveStream* CreateFlexfecReceiveStream( |
| 55 | const FlexfecReceiveStream::Config& config) override; |
| 56 | void DestroyFlexfecReceiveStream( |
| 57 | FlexfecReceiveStream* receive_stream) override; |
| 58 | |
| 59 | PacketReceiver* Receiver() override; |
| 60 | |
| 61 | RtpTransportControllerSendInterface* GetTransportControllerSend() override; |
| 62 | |
| 63 | Stats GetStats() const override; |
| 64 | |
| 65 | void SetBitrateAllocationStrategy( |
| 66 | std::unique_ptr<rtc::BitrateAllocationStrategy> |
| 67 | bitrate_allocation_strategy) override; |
| 68 | |
| 69 | void SignalChannelNetworkState(MediaType media, NetworkState state) override; |
| 70 | |
| 71 | void OnTransportOverheadChanged(MediaType media, |
| 72 | int transport_overhead_per_packet) override; |
| 73 | |
| 74 | void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
| 75 | |
| 76 | protected: |
| 77 | // Implements Transport. |
| 78 | bool SendRtp(const uint8_t* packet, |
| 79 | size_t length, |
| 80 | const PacketOptions& options) override; |
| 81 | |
| 82 | bool SendRtcp(const uint8_t* packet, size_t length) override; |
| 83 | |
| 84 | // Implements PacketReceiver. |
| 85 | DeliveryStatus DeliverPacket(MediaType media_type, |
| 86 | rtc::CopyOnWriteBuffer packet, |
| 87 | const PacketTime& packet_time) override; |
| 88 | |
| 89 | private: |
| 90 | Clock* const clock_; |
| 91 | const std::unique_ptr<Call> call_; |
| 92 | |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame^] | 93 | const absl::optional<FakeNetworkPipe::Config> send_config_; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 94 | const std::unique_ptr<ProcessThread> send_process_thread_; |
| 95 | std::unique_ptr<FakeNetworkPipe> send_pipe_; |
| 96 | size_t num_send_streams_; |
| 97 | |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame^] | 98 | const absl::optional<FakeNetworkPipe::Config> receive_config_; |
Erik Språng | 0970851 | 2018-03-14 15:16:50 +0100 | [diff] [blame] | 99 | std::unique_ptr<FakeNetworkPipe> receive_pipe_; |
| 100 | }; |
| 101 | |
| 102 | } // namespace webrtc |
| 103 | |
| 104 | #endif // CALL_DEGRADED_CALL_H_ |