1 /* 2 * Copyright (c) 2016 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 MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_AUDIO_NETWORK_ADAPTOR_IMPL_H_ 12 #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_AUDIO_NETWORK_ADAPTOR_IMPL_H_ 13 14 #include <stdio.h> 15 16 #include <memory> 17 18 #include "absl/types/optional.h" 19 #include "api/audio_codecs/audio_encoder.h" 20 #include "modules/audio_coding/audio_network_adaptor/controller.h" 21 #include "modules/audio_coding/audio_network_adaptor/debug_dump_writer.h" 22 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h" 23 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h" 24 25 namespace webrtc { 26 27 class ControllerManager; 28 class EventLogWriter; 29 class RtcEventLog; 30 31 class AudioNetworkAdaptorImpl final : public AudioNetworkAdaptor { 32 public: 33 struct Config { 34 Config(); 35 ~Config(); 36 RtcEventLog* event_log; 37 }; 38 39 AudioNetworkAdaptorImpl( 40 const Config& config, 41 std::unique_ptr<ControllerManager> controller_manager, 42 std::unique_ptr<DebugDumpWriter> debug_dump_writer = nullptr); 43 44 ~AudioNetworkAdaptorImpl() override; 45 46 AudioNetworkAdaptorImpl(const AudioNetworkAdaptorImpl&) = delete; 47 AudioNetworkAdaptorImpl& operator=(const AudioNetworkAdaptorImpl&) = delete; 48 49 void SetUplinkBandwidth(int uplink_bandwidth_bps) override; 50 51 void SetUplinkPacketLossFraction(float uplink_packet_loss_fraction) override; 52 53 void SetRtt(int rtt_ms) override; 54 55 void SetTargetAudioBitrate(int target_audio_bitrate_bps) override; 56 57 void SetOverhead(size_t overhead_bytes_per_packet) override; 58 59 AudioEncoderRuntimeConfig GetEncoderRuntimeConfig() override; 60 61 void StartDebugDump(FILE* file_handle) override; 62 63 void StopDebugDump() override; 64 65 ANAStats GetStats() const override; 66 67 private: 68 void DumpNetworkMetrics(); 69 70 void UpdateNetworkMetrics(const Controller::NetworkMetrics& network_metrics); 71 72 const Config config_; 73 74 std::unique_ptr<ControllerManager> controller_manager_; 75 76 std::unique_ptr<DebugDumpWriter> debug_dump_writer_; 77 78 const std::unique_ptr<EventLogWriter> event_log_writer_; 79 80 Controller::NetworkMetrics last_metrics_; 81 82 absl::optional<AudioEncoderRuntimeConfig> prev_config_; 83 84 ANAStats stats_; 85 }; 86 87 } // namespace webrtc 88 89 #endif // MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_AUDIO_NETWORK_ADAPTOR_IMPL_H_ 90