2018-03-14 15:16:50 +01:00
|
|
|
/*
|
|
|
|
|
* 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_
|
|
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2018-03-14 15:16:50 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2018-06-15 12:28:07 +02:00
|
|
|
#include "absl/types/optional.h"
|
2018-03-14 15:16:50 +01:00
|
|
|
#include "api/call/transport.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/fec_controller.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/media_types.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/rtp_headers.h"
|
2018-08-17 13:00:54 +02:00
|
|
|
#include "api/test/simulated_network.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/video_codecs/video_encoder_config.h"
|
|
|
|
|
#include "call/audio_receive_stream.h"
|
|
|
|
|
#include "call/audio_send_stream.h"
|
2018-03-14 15:16:50 +01:00
|
|
|
#include "call/call.h"
|
|
|
|
|
#include "call/fake_network_pipe.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "call/flexfec_receive_stream.h"
|
|
|
|
|
#include "call/packet_receiver.h"
|
|
|
|
|
#include "call/rtp_transport_controller_send_interface.h"
|
2018-08-17 13:00:54 +02:00
|
|
|
#include "call/simulated_network.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "call/video_receive_stream.h"
|
|
|
|
|
#include "call/video_send_stream.h"
|
2019-02-08 16:08:10 +01:00
|
|
|
#include "modules/include/module.h"
|
2018-03-14 15:16:50 +01:00
|
|
|
#include "modules/utility/include/process_thread.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/bitrate_allocation_strategy.h"
|
|
|
|
|
#include "rtc_base/copy_on_write_buffer.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/network/sent_packet.h"
|
2018-03-14 15:16:50 +01:00
|
|
|
#include "system_wrappers/include/clock.h"
|
|
|
|
|
|
|
|
|
|
namespace webrtc {
|
2019-02-08 16:08:10 +01:00
|
|
|
class FakeNetworkPipeModule : public Module {
|
|
|
|
|
public:
|
|
|
|
|
FakeNetworkPipeModule(
|
|
|
|
|
Clock* clock,
|
|
|
|
|
std::unique_ptr<NetworkBehaviorInterface> network_behavior,
|
|
|
|
|
Transport* transport);
|
|
|
|
|
~FakeNetworkPipeModule() override;
|
|
|
|
|
void SendRtp(const uint8_t* packet,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketOptions& options);
|
|
|
|
|
void SendRtcp(const uint8_t* packet, size_t length);
|
|
|
|
|
|
|
|
|
|
// Implements Module interface
|
|
|
|
|
int64_t TimeUntilNextProcess() override;
|
|
|
|
|
void ProcessThreadAttached(ProcessThread* process_thread) override;
|
|
|
|
|
void Process() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void MaybeResumeProcess();
|
|
|
|
|
FakeNetworkPipe pipe_;
|
|
|
|
|
rtc::CriticalSection process_thread_lock_;
|
|
|
|
|
ProcessThread* process_thread_ RTC_GUARDED_BY(process_thread_lock_) = nullptr;
|
|
|
|
|
bool pending_process_ RTC_GUARDED_BY(process_thread_lock_) = false;
|
|
|
|
|
};
|
2018-03-14 15:16:50 +01:00
|
|
|
|
|
|
|
|
class DegradedCall : public Call, private Transport, private PacketReceiver {
|
|
|
|
|
public:
|
2018-08-17 13:00:54 +02:00
|
|
|
explicit DegradedCall(
|
|
|
|
|
std::unique_ptr<Call> call,
|
2018-10-08 12:28:56 +02:00
|
|
|
absl::optional<BuiltInNetworkBehaviorConfig> send_config,
|
|
|
|
|
absl::optional<BuiltInNetworkBehaviorConfig> receive_config);
|
2018-03-14 15:16:50 +01:00
|
|
|
~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;
|
2018-10-04 15:21:55 +02:00
|
|
|
void OnAudioTransportOverheadChanged(
|
|
|
|
|
int transport_overhead_per_packet) override;
|
2018-03-14 15:16:50 +01:00
|
|
|
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,
|
2018-08-07 11:03:12 +02:00
|
|
|
int64_t packet_time_us) override;
|
2018-03-14 15:16:50 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Clock* const clock_;
|
|
|
|
|
const std::unique_ptr<Call> call_;
|
|
|
|
|
|
2018-11-15 08:26:19 -08:00
|
|
|
void MediaTransportChange(MediaTransportInterface* media_transport) override;
|
2019-03-18 10:31:54 -07:00
|
|
|
void SetClientBitratePreferences(
|
|
|
|
|
const webrtc::BitrateSettings& preferences) override {}
|
2018-10-08 12:28:56 +02:00
|
|
|
const absl::optional<BuiltInNetworkBehaviorConfig> send_config_;
|
2018-03-14 15:16:50 +01:00
|
|
|
const std::unique_ptr<ProcessThread> send_process_thread_;
|
2018-08-17 13:00:54 +02:00
|
|
|
SimulatedNetwork* send_simulated_network_;
|
2019-02-08 16:08:10 +01:00
|
|
|
std::unique_ptr<FakeNetworkPipeModule> send_pipe_;
|
2018-03-14 15:16:50 +01:00
|
|
|
size_t num_send_streams_;
|
|
|
|
|
|
2018-10-08 12:28:56 +02:00
|
|
|
const absl::optional<BuiltInNetworkBehaviorConfig> receive_config_;
|
2018-08-17 13:00:54 +02:00
|
|
|
SimulatedNetwork* receive_simulated_network_;
|
2018-03-14 15:16:50 +01:00
|
|
|
std::unique_ptr<FakeNetworkPipe> receive_pipe_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
#endif // CALL_DEGRADED_CALL_H_
|