Line data Source code
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 WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLER_H_
12 : #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLER_H_
13 :
14 : #include <map>
15 : #include <vector>
16 :
17 : #include "webrtc/base/constructormagic.h"
18 : #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h"
19 :
20 : namespace webrtc {
21 :
22 : // Determines target frame length based on the network metrics and the decision
23 : // of FEC controller.
24 0 : class FrameLengthController final : public Controller {
25 : public:
26 0 : struct Config {
27 : Config(const std::vector<int>& encoder_frame_lengths_ms,
28 : int initial_frame_length_ms,
29 : float fl_increasing_packet_loss_fraction,
30 : float fl_decreasing_packet_loss_fraction,
31 : int fl_20ms_to_60ms_bandwidth_bps,
32 : int fl_60ms_to_20ms_bandwidth_bps);
33 : Config(const Config& other);
34 : ~Config();
35 : std::vector<int> encoder_frame_lengths_ms;
36 : int initial_frame_length_ms;
37 : // Uplink packet loss fraction below which frame length can increase.
38 : float fl_increasing_packet_loss_fraction;
39 : // Uplink packet loss fraction below which frame length should decrease.
40 : float fl_decreasing_packet_loss_fraction;
41 : // Uplink bandwidth below which frame length can switch from 20ms to 60ms.
42 : int fl_20ms_to_60ms_bandwidth_bps;
43 : // Uplink bandwidth above which frame length should switch from 60ms to
44 : // 20ms.
45 : int fl_60ms_to_20ms_bandwidth_bps;
46 : };
47 :
48 : explicit FrameLengthController(const Config& config);
49 :
50 : ~FrameLengthController() override;
51 :
52 : void MakeDecision(const NetworkMetrics& metrics,
53 : AudioNetworkAdaptor::EncoderRuntimeConfig* config) override;
54 :
55 : private:
56 : friend class FrameLengthControllerForTest;
57 :
58 0 : struct FrameLengthChange {
59 : FrameLengthChange(int from_frame_length_ms, int to_frame_length_ms);
60 : ~FrameLengthChange();
61 : bool operator<(const FrameLengthChange& rhs) const;
62 : int from_frame_length_ms;
63 : int to_frame_length_ms;
64 : };
65 :
66 : bool FrameLengthIncreasingDecision(
67 : const NetworkMetrics& metrics,
68 : const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const;
69 :
70 : bool FrameLengthDecreasingDecision(
71 : const NetworkMetrics& metrics,
72 : const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const;
73 :
74 : const Config config_;
75 :
76 : std::vector<int>::const_iterator frame_length_ms_;
77 :
78 : std::map<FrameLengthChange, int> frame_length_change_criteria_;
79 :
80 : RTC_DISALLOW_COPY_AND_ASSIGN(FrameLengthController);
81 : };
82 :
83 : } // namespace webrtc
84 :
85 : #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLER_H_
|