| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "webrtc/modules/audio_coding/neteq/packet_buffer.h" | 21 #include "webrtc/modules/audio_coding/neteq/packet_buffer.h" |
| 22 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" | 22 #include "webrtc/modules/audio_coding/neteq/sync_buffer.h" |
| 23 #include "webrtc/modules/include/module_common_types.h" | 23 #include "webrtc/modules/include/module_common_types.h" |
| 24 | 24 |
| 25 namespace webrtc { | 25 namespace webrtc { |
| 26 | 26 |
| 27 Operations DecisionLogicNormal::GetDecisionSpecialized( | 27 Operations DecisionLogicNormal::GetDecisionSpecialized( |
| 28 const SyncBuffer& sync_buffer, | 28 const SyncBuffer& sync_buffer, |
| 29 const Expand& expand, | 29 const Expand& expand, |
| 30 size_t decoder_frame_length, | 30 size_t decoder_frame_length, |
| 31 const RTPHeader* packet_header, | 31 const Packet* next_packet, |
| 32 Modes prev_mode, | 32 Modes prev_mode, |
| 33 bool play_dtmf, | 33 bool play_dtmf, |
| 34 bool* reset_decoder, | 34 bool* reset_decoder, |
| 35 size_t generated_noise_samples) { | 35 size_t generated_noise_samples) { |
| 36 assert(playout_mode_ == kPlayoutOn || playout_mode_ == kPlayoutStreaming); | 36 assert(playout_mode_ == kPlayoutOn || playout_mode_ == kPlayoutStreaming); |
| 37 // Guard for errors, to avoid getting stuck in error mode. | 37 // Guard for errors, to avoid getting stuck in error mode. |
| 38 if (prev_mode == kModeError) { | 38 if (prev_mode == kModeError) { |
| 39 if (!packet_header) { | 39 if (!next_packet) { |
| 40 return kExpand; | 40 return kExpand; |
| 41 } else { | 41 } else { |
| 42 return kUndefined; // Use kUndefined to flag for a reset. | 42 return kUndefined; // Use kUndefined to flag for a reset. |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 uint32_t target_timestamp = sync_buffer.end_timestamp(); | 46 uint32_t target_timestamp = sync_buffer.end_timestamp(); |
| 47 uint32_t available_timestamp = 0; | 47 uint32_t available_timestamp = 0; |
| 48 bool is_cng_packet = false; | 48 bool is_cng_packet = false; |
| 49 if (packet_header) { | 49 if (next_packet) { |
| 50 available_timestamp = packet_header->timestamp; | 50 available_timestamp = next_packet->timestamp; |
| 51 is_cng_packet = | 51 is_cng_packet = |
| 52 decoder_database_->IsComfortNoise(packet_header->payloadType); | 52 decoder_database_->IsComfortNoise(next_packet->payload_type); |
| 53 } | 53 } |
| 54 | 54 |
| 55 if (is_cng_packet) { | 55 if (is_cng_packet) { |
| 56 return CngOperation(prev_mode, target_timestamp, available_timestamp, | 56 return CngOperation(prev_mode, target_timestamp, available_timestamp, |
| 57 generated_noise_samples); | 57 generated_noise_samples); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Handle the case with no packet at all available (except maybe DTMF). | 60 // Handle the case with no packet at all available (except maybe DTMF). |
| 61 if (!packet_header) { | 61 if (!next_packet) { |
| 62 return NoPacket(play_dtmf); | 62 return NoPacket(play_dtmf); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // If the expand period was very long, reset NetEQ since it is likely that the | 65 // If the expand period was very long, reset NetEQ since it is likely that the |
| 66 // sender was restarted. | 66 // sender was restarted. |
| 67 if (num_consecutive_expands_ > kReinitAfterExpands) { | 67 if (num_consecutive_expands_ > kReinitAfterExpands) { |
| 68 *reset_decoder = true; | 68 *reset_decoder = true; |
| 69 return kNormal; | 69 return kNormal; |
| 70 } | 70 } |
| 71 | 71 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 bool DecisionLogicNormal::PacketTooEarly(uint32_t timestamp_leap) const { | 235 bool DecisionLogicNormal::PacketTooEarly(uint32_t timestamp_leap) const { |
| 236 return timestamp_leap > | 236 return timestamp_leap > |
| 237 static_cast<uint32_t>(output_size_samples_ * num_consecutive_expands_); | 237 static_cast<uint32_t>(output_size_samples_ * num_consecutive_expands_); |
| 238 } | 238 } |
| 239 | 239 |
| 240 bool DecisionLogicNormal::MaxWaitForPacket() const { | 240 bool DecisionLogicNormal::MaxWaitForPacket() const { |
| 241 return num_consecutive_expands_ >= kMaxWaitForPacket; | 241 return num_consecutive_expands_ >= kMaxWaitForPacket; |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace webrtc | 244 } // namespace webrtc |
| OLD | NEW |