OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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_NETEQ_DECISION_LOGIC_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
13 | 13 |
14 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
15 #include "webrtc/modules/audio_coding/neteq/defines.h" | 15 #include "webrtc/modules/audio_coding/neteq/defines.h" |
16 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | 16 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
17 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" | 17 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" |
18 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 | 21 |
22 // Forward declarations. | 22 // Forward declarations. |
23 class BufferLevelFilter; | 23 class BufferLevelFilter; |
24 class DecoderDatabase; | 24 class DecoderDatabase; |
25 class DelayManager; | 25 class DelayManager; |
26 class Expand; | 26 class Expand; |
27 class PacketBuffer; | 27 class PacketBuffer; |
28 class SyncBuffer; | 28 class SyncBuffer; |
29 struct RTPHeader; | 29 struct Packet; |
30 | 30 |
31 // This is the base class for the decision tree implementations. Derived classes | 31 // This is the base class for the decision tree implementations. Derived classes |
32 // must implement the method GetDecisionSpecialized(). | 32 // must implement the method GetDecisionSpecialized(). |
33 class DecisionLogic { | 33 class DecisionLogic { |
34 public: | 34 public: |
35 // Static factory function which creates different types of objects depending | 35 // Static factory function which creates different types of objects depending |
36 // on the |playout_mode|. | 36 // on the |playout_mode|. |
37 static DecisionLogic* Create(int fs_hz, | 37 static DecisionLogic* Create(int fs_hz, |
38 size_t output_size_samples, | 38 size_t output_size_samples, |
39 NetEqPlayoutMode playout_mode, | 39 NetEqPlayoutMode playout_mode, |
(...skipping 20 matching lines...) Expand all Loading... | |
60 | 60 |
61 // Resets parts of the state. Typically done when switching codecs. | 61 // Resets parts of the state. Typically done when switching codecs. |
62 void SoftReset(); | 62 void SoftReset(); |
63 | 63 |
64 // Sets the sample rate and the output block size. | 64 // Sets the sample rate and the output block size. |
65 void SetSampleRate(int fs_hz, size_t output_size_samples); | 65 void SetSampleRate(int fs_hz, size_t output_size_samples); |
66 | 66 |
67 // Returns the operation that should be done next. |sync_buffer| and |expand| | 67 // Returns the operation that should be done next. |sync_buffer| and |expand| |
68 // are provided for reference. |decoder_frame_length| is the number of samples | 68 // are provided for reference. |decoder_frame_length| is the number of samples |
69 // obtained from the last decoded frame. If there is a packet available, the | 69 // obtained from the last decoded frame. If there is a packet available, the |
70 // packet header should be supplied in |packet_header|; otherwise it should | 70 // packet header should be supplied in |packet_header|; otherwise it should |
hlundin-webrtc
2016/10/12 20:39:57
Fix the comment, still mentioning packet_header.
ossu
2016/10/12 21:46:02
Done.
| |
71 // be NULL. The mode resulting form the last call to NetEqImpl::GetAudio is | 71 // be NULL. The mode resulting form the last call to NetEqImpl::GetAudio is |
72 // supplied in |prev_mode|. If there is a DTMF event to play, |play_dtmf| | 72 // supplied in |prev_mode|. If there is a DTMF event to play, |play_dtmf| |
73 // should be set to true. The output variable |reset_decoder| will be set to | 73 // should be set to true. The output variable |reset_decoder| will be set to |
74 // true if a reset is required; otherwise it is left unchanged (i.e., it can | 74 // true if a reset is required; otherwise it is left unchanged (i.e., it can |
75 // remain true if it was true before the call). | 75 // remain true if it was true before the call). |
76 // This method end with calling GetDecisionSpecialized to get the actual | 76 // This method end with calling GetDecisionSpecialized to get the actual |
77 // return value. | 77 // return value. |
78 Operations GetDecision(const SyncBuffer& sync_buffer, | 78 Operations GetDecision(const SyncBuffer& sync_buffer, |
79 const Expand& expand, | 79 const Expand& expand, |
80 size_t decoder_frame_length, | 80 size_t decoder_frame_length, |
81 const RTPHeader* packet_header, | 81 const Packet* next_packet, |
82 Modes prev_mode, | 82 Modes prev_mode, |
83 bool play_dtmf, | 83 bool play_dtmf, |
84 size_t generated_noise_samples, | 84 size_t generated_noise_samples, |
85 bool* reset_decoder); | 85 bool* reset_decoder); |
86 | 86 |
87 // These methods test the |cng_state_| for different conditions. | 87 // These methods test the |cng_state_| for different conditions. |
88 bool CngRfc3389On() const { return cng_state_ == kCngRfc3389On; } | 88 bool CngRfc3389On() const { return cng_state_ == kCngRfc3389On; } |
89 bool CngOff() const { return cng_state_ == kCngOff; } | 89 bool CngOff() const { return cng_state_ == kCngOff; } |
90 | 90 |
91 // Resets the |cng_state_| to kCngOff. | 91 // Resets the |cng_state_| to kCngOff. |
(...skipping 26 matching lines...) Expand all Loading... | |
118 | 118 |
119 enum CngState { | 119 enum CngState { |
120 kCngOff, | 120 kCngOff, |
121 kCngRfc3389On, | 121 kCngRfc3389On, |
122 kCngInternalOn | 122 kCngInternalOn |
123 }; | 123 }; |
124 | 124 |
125 // Returns the operation that should be done next. |sync_buffer| and |expand| | 125 // Returns the operation that should be done next. |sync_buffer| and |expand| |
126 // are provided for reference. |decoder_frame_length| is the number of samples | 126 // are provided for reference. |decoder_frame_length| is the number of samples |
127 // obtained from the last decoded frame. If there is a packet available, the | 127 // obtained from the last decoded frame. If there is a packet available, the |
128 // packet header should be supplied in |packet_header|; otherwise it should | 128 // packet header should be supplied in |packet_header|; otherwise it should |
hlundin-webrtc
2016/10/12 20:39:57
And here.
ossu
2016/10/12 21:46:02
Done.
| |
129 // be NULL. The mode resulting form the last call to NetEqImpl::GetAudio is | 129 // be NULL. The mode resulting form the last call to NetEqImpl::GetAudio is |
130 // supplied in |prev_mode|. If there is a DTMF event to play, |play_dtmf| | 130 // supplied in |prev_mode|. If there is a DTMF event to play, |play_dtmf| |
131 // should be set to true. The output variable |reset_decoder| will be set to | 131 // should be set to true. The output variable |reset_decoder| will be set to |
132 // true if a reset is required; otherwise it is left unchanged (i.e., it can | 132 // true if a reset is required; otherwise it is left unchanged (i.e., it can |
133 // remain true if it was true before the call). | 133 // remain true if it was true before the call). |
134 // Should be implemented by derived classes. | 134 // Should be implemented by derived classes. |
135 virtual Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer, | 135 virtual Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer, |
136 const Expand& expand, | 136 const Expand& expand, |
137 size_t decoder_frame_length, | 137 size_t decoder_frame_length, |
138 const RTPHeader* packet_header, | 138 const Packet* next_packet, |
139 Modes prev_mode, | 139 Modes prev_mode, |
140 bool play_dtmf, | 140 bool play_dtmf, |
141 bool* reset_decoder, | 141 bool* reset_decoder, |
142 size_t generated_noise_samples) = 0; | 142 size_t generated_noise_samples) = 0; |
143 | 143 |
144 // Updates the |buffer_level_filter_| with the current buffer level | 144 // Updates the |buffer_level_filter_| with the current buffer level |
145 // |buffer_size_packets|. | 145 // |buffer_size_packets|. |
146 void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode); | 146 void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode); |
147 | 147 |
148 DecoderDatabase* decoder_database_; | 148 DecoderDatabase* decoder_database_; |
(...skipping 12 matching lines...) Expand all Loading... | |
161 std::unique_ptr<TickTimer::Countdown> timescale_countdown_; | 161 std::unique_ptr<TickTimer::Countdown> timescale_countdown_; |
162 int num_consecutive_expands_; | 162 int num_consecutive_expands_; |
163 const NetEqPlayoutMode playout_mode_; | 163 const NetEqPlayoutMode playout_mode_; |
164 | 164 |
165 private: | 165 private: |
166 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic); | 166 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic); |
167 }; | 167 }; |
168 | 168 |
169 } // namespace webrtc | 169 } // namespace webrtc |
170 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ | 170 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
OLD | NEW |