| 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 #include "webrtc/modules/audio_coding/main/acm2/acm_receiver.h" | 11 #include "webrtc/modules/audio_coding/main/acm2/acm_receiver.h" |
| 12 | 12 |
| 13 #include <stdlib.h> // malloc | 13 #include <stdlib.h> // malloc |
| 14 | 14 |
| 15 #include <algorithm> // sort | 15 #include <algorithm> // sort |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/format_macros.h" | 19 #include "webrtc/base/format_macros.h" |
| 19 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 21 #include "webrtc/common_types.h" | 22 #include "webrtc/common_types.h" |
| 22 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 23 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
| 23 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" | 24 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" |
| 24 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" | 25 #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" |
| 25 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" | 26 #include "webrtc/modules/audio_coding/main/acm2/call_statistics.h" |
| 26 #include "webrtc/modules/audio_coding/main/acm2/nack.h" | 27 #include "webrtc/modules/audio_coding/main/acm2/nack.h" |
| 27 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h" | 28 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h" |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false; | 641 acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false; |
| 641 acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate; | 642 acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate; |
| 642 acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate; | 643 acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate; |
| 643 acm_stat->currentExpandRate = neteq_stat.expand_rate; | 644 acm_stat->currentExpandRate = neteq_stat.expand_rate; |
| 644 acm_stat->currentSpeechExpandRate = neteq_stat.speech_expand_rate; | 645 acm_stat->currentSpeechExpandRate = neteq_stat.speech_expand_rate; |
| 645 acm_stat->currentPreemptiveRate = neteq_stat.preemptive_rate; | 646 acm_stat->currentPreemptiveRate = neteq_stat.preemptive_rate; |
| 646 acm_stat->currentAccelerateRate = neteq_stat.accelerate_rate; | 647 acm_stat->currentAccelerateRate = neteq_stat.accelerate_rate; |
| 647 acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate; | 648 acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate; |
| 648 acm_stat->clockDriftPPM = neteq_stat.clockdrift_ppm; | 649 acm_stat->clockDriftPPM = neteq_stat.clockdrift_ppm; |
| 649 acm_stat->addedSamples = neteq_stat.added_zero_samples; | 650 acm_stat->addedSamples = neteq_stat.added_zero_samples; |
| 650 | 651 acm_stat->meanWaitingTimeMs = neteq_stat.mean_waiting_time_ms; |
| 651 std::vector<int> waiting_times; | 652 acm_stat->medianWaitingTimeMs = neteq_stat.median_waiting_time_ms; |
| 652 neteq_->WaitingTimes(&waiting_times); | 653 acm_stat->minWaitingTimeMs = neteq_stat.min_waiting_time_ms; |
| 653 size_t size = waiting_times.size(); | 654 acm_stat->maxWaitingTimeMs = neteq_stat.max_waiting_time_ms; |
| 654 if (size == 0) { | |
| 655 acm_stat->meanWaitingTimeMs = -1; | |
| 656 acm_stat->medianWaitingTimeMs = -1; | |
| 657 acm_stat->minWaitingTimeMs = -1; | |
| 658 acm_stat->maxWaitingTimeMs = -1; | |
| 659 } else { | |
| 660 std::sort(waiting_times.begin(), waiting_times.end()); | |
| 661 if ((size & 0x1) == 0) { | |
| 662 acm_stat->medianWaitingTimeMs = (waiting_times[size / 2 - 1] + | |
| 663 waiting_times[size / 2]) / 2; | |
| 664 } else { | |
| 665 acm_stat->medianWaitingTimeMs = waiting_times[size / 2]; | |
| 666 } | |
| 667 acm_stat->minWaitingTimeMs = waiting_times.front(); | |
| 668 acm_stat->maxWaitingTimeMs = waiting_times.back(); | |
| 669 double sum = 0; | |
| 670 for (size_t i = 0; i < size; ++i) { | |
| 671 sum += waiting_times[i]; | |
| 672 } | |
| 673 acm_stat->meanWaitingTimeMs = static_cast<int>(sum / size); | |
| 674 } | |
| 675 } | 655 } |
| 676 | 656 |
| 677 int AcmReceiver::DecoderByPayloadType(uint8_t payload_type, | 657 int AcmReceiver::DecoderByPayloadType(uint8_t payload_type, |
| 678 CodecInst* codec) const { | 658 CodecInst* codec) const { |
| 679 CriticalSectionScoped lock(crit_sect_.get()); | 659 CriticalSectionScoped lock(crit_sect_.get()); |
| 680 auto it = decoders_.find(payload_type); | 660 auto it = decoders_.find(payload_type); |
| 681 if (it == decoders_.end()) { | 661 if (it == decoders_.end()) { |
| 682 LOG(LERROR) << "AcmReceiver::DecoderByPayloadType " | 662 LOG(LERROR) << "AcmReceiver::DecoderByPayloadType " |
| 683 << static_cast<int>(payload_type); | 663 << static_cast<int>(payload_type); |
| 684 return -1; | 664 return -1; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 816 |
| 837 void AcmReceiver::GetDecodingCallStatistics( | 817 void AcmReceiver::GetDecodingCallStatistics( |
| 838 AudioDecodingCallStats* stats) const { | 818 AudioDecodingCallStats* stats) const { |
| 839 CriticalSectionScoped lock(crit_sect_.get()); | 819 CriticalSectionScoped lock(crit_sect_.get()); |
| 840 *stats = call_stats_.GetDecodingStatistics(); | 820 *stats = call_stats_.GetDecodingStatistics(); |
| 841 } | 821 } |
| 842 | 822 |
| 843 } // namespace acm2 | 823 } // namespace acm2 |
| 844 | 824 |
| 845 } // namespace webrtc | 825 } // namespace webrtc |
| OLD | NEW |