Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.h

Issue 2669733002: Add 120ms frame ability to ANA (Closed)
Patch Set: Respond to comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLE R_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLE R_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLE R_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTROLLE R_H_
13 13
14 #include <map> 14 #include <map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h" 18 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 // Determines target frame length based on the network metrics and the decision 22 // Determines target frame length based on the network metrics and the decision
23 // of FEC controller. 23 // of FEC controller.
24 class FrameLengthController final : public Controller { 24 class FrameLengthController final : public Controller {
25 public: 25 public:
26 struct Config { 26 struct Config {
27 struct FrameLengthChange {
28 FrameLengthChange(int from_frame_length_ms, int to_frame_length_ms);
29 bool operator<(const FrameLengthChange& rhs) const;
30 int from_frame_length_ms;
31 int to_frame_length_ms;
32 };
27 Config(const std::vector<int>& encoder_frame_lengths_ms, 33 Config(const std::vector<int>& encoder_frame_lengths_ms,
28 int initial_frame_length_ms, 34 int initial_frame_length_ms,
29 float fl_increasing_packet_loss_fraction, 35 float fl_increasing_packet_loss_fraction,
30 float fl_decreasing_packet_loss_fraction, 36 float fl_decreasing_packet_loss_fraction,
31 int fl_20ms_to_60ms_bandwidth_bps, 37 std::map<FrameLengthChange, int> fl_changing_bandwidths_bps);
32 int fl_60ms_to_20ms_bandwidth_bps);
33 Config(const Config& other); 38 Config(const Config& other);
34 ~Config(); 39 ~Config();
35 std::vector<int> encoder_frame_lengths_ms; 40 std::vector<int> encoder_frame_lengths_ms;
36 int initial_frame_length_ms; 41 int initial_frame_length_ms;
37 // Uplink packet loss fraction below which frame length can increase. 42 // Uplink packet loss fraction below which frame length can increase.
38 float fl_increasing_packet_loss_fraction; 43 float fl_increasing_packet_loss_fraction;
39 // Uplink packet loss fraction below which frame length should decrease. 44 // Uplink packet loss fraction below which frame length should decrease.
40 float fl_decreasing_packet_loss_fraction; 45 float fl_decreasing_packet_loss_fraction;
41 // Uplink bandwidth below which frame length can switch from 20ms to 60ms. 46 std::map<FrameLengthChange, int> fl_changing_bandwidths_bps;
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 };
47 48
48 explicit FrameLengthController(const Config& config); 49 explicit FrameLengthController(const Config& config);
49 50
50 ~FrameLengthController() override; 51 ~FrameLengthController() override;
51 52
52 void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override; 53 void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
53 54
54 void MakeDecision(AudioNetworkAdaptor::EncoderRuntimeConfig* config) override; 55 void MakeDecision(AudioNetworkAdaptor::EncoderRuntimeConfig* config) override;
55 56
56 private: 57 private:
57 friend class FrameLengthControllerForTest;
58
59 struct FrameLengthChange {
60 FrameLengthChange(int from_frame_length_ms, int to_frame_length_ms);
61 ~FrameLengthChange();
62 bool operator<(const FrameLengthChange& rhs) const;
63 int from_frame_length_ms;
64 int to_frame_length_ms;
65 };
66
67 bool FrameLengthIncreasingDecision( 58 bool FrameLengthIncreasingDecision(
68 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const; 59 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const;
69 60
70 bool FrameLengthDecreasingDecision( 61 bool FrameLengthDecreasingDecision(
71 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const; 62 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) const;
72 63
73 const Config config_; 64 const Config config_;
74 65
75 std::vector<int>::const_iterator frame_length_ms_; 66 std::vector<int>::const_iterator frame_length_ms_;
76 67
77 std::map<FrameLengthChange, int> frame_length_change_criteria_;
78
79 rtc::Optional<int> uplink_bandwidth_bps_; 68 rtc::Optional<int> uplink_bandwidth_bps_;
80 69
81 rtc::Optional<float> uplink_packet_loss_fraction_; 70 rtc::Optional<float> uplink_packet_loss_fraction_;
82 71
83 RTC_DISALLOW_COPY_AND_ASSIGN(FrameLengthController); 72 RTC_DISALLOW_COPY_AND_ASSIGN(FrameLengthController);
84 }; 73 };
85 74
86 } // namespace webrtc 75 } // namespace webrtc
87 76
88 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTRO LLER_H_ 77 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FRAME_LENGTH_CONTRO LLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698