• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "rtc_base/constructor_magic.h"
25 
26 namespace webrtc {
27 
28 class ControllerManager;
29 class EventLogWriter;
30 class RtcEventLog;
31 
32 class AudioNetworkAdaptorImpl final : public AudioNetworkAdaptor {
33  public:
34   struct Config {
35     Config();
36     ~Config();
37     RtcEventLog* event_log;
38   };
39 
40   AudioNetworkAdaptorImpl(
41       const Config& config,
42       std::unique_ptr<ControllerManager> controller_manager,
43       std::unique_ptr<DebugDumpWriter> debug_dump_writer = nullptr);
44 
45   ~AudioNetworkAdaptorImpl() override;
46 
47   void SetUplinkBandwidth(int uplink_bandwidth_bps) override;
48 
49   void SetUplinkPacketLossFraction(float uplink_packet_loss_fraction) override;
50 
51   void SetRtt(int rtt_ms) override;
52 
53   void SetTargetAudioBitrate(int target_audio_bitrate_bps) override;
54 
55   void SetOverhead(size_t overhead_bytes_per_packet) override;
56 
57   AudioEncoderRuntimeConfig GetEncoderRuntimeConfig() override;
58 
59   void StartDebugDump(FILE* file_handle) override;
60 
61   void StopDebugDump() override;
62 
63   ANAStats GetStats() const override;
64 
65  private:
66   void DumpNetworkMetrics();
67 
68   void UpdateNetworkMetrics(const Controller::NetworkMetrics& network_metrics);
69 
70   const Config config_;
71 
72   std::unique_ptr<ControllerManager> controller_manager_;
73 
74   std::unique_ptr<DebugDumpWriter> debug_dump_writer_;
75 
76   const std::unique_ptr<EventLogWriter> event_log_writer_;
77 
78   Controller::NetworkMetrics last_metrics_;
79 
80   absl::optional<AudioEncoderRuntimeConfig> prev_config_;
81 
82   ANAStats stats_;
83 
84   RTC_DISALLOW_COPY_AND_ASSIGN(AudioNetworkAdaptorImpl);
85 };
86 
87 }  // namespace webrtc
88 
89 #endif  // MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_AUDIO_NETWORK_ADAPTOR_IMPL_H_
90