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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false; | 646 acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false; |
646 acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate; | 647 acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate; |
647 acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate; | 648 acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate; |
648 acm_stat->currentExpandRate = neteq_stat.expand_rate; | 649 acm_stat->currentExpandRate = neteq_stat.expand_rate; |
649 acm_stat->currentSpeechExpandRate = neteq_stat.speech_expand_rate; | 650 acm_stat->currentSpeechExpandRate = neteq_stat.speech_expand_rate; |
650 acm_stat->currentPreemptiveRate = neteq_stat.preemptive_rate; | 651 acm_stat->currentPreemptiveRate = neteq_stat.preemptive_rate; |
651 acm_stat->currentAccelerateRate = neteq_stat.accelerate_rate; | 652 acm_stat->currentAccelerateRate = neteq_stat.accelerate_rate; |
652 acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate; | 653 acm_stat->currentSecondaryDecodedRate = neteq_stat.secondary_decoded_rate; |
653 acm_stat->clockDriftPPM = neteq_stat.clockdrift_ppm; | 654 acm_stat->clockDriftPPM = neteq_stat.clockdrift_ppm; |
654 acm_stat->addedSamples = neteq_stat.added_zero_samples; | 655 acm_stat->addedSamples = neteq_stat.added_zero_samples; |
655 | 656 acm_stat->meanWaitingTimeMs = neteq_stat.mean_waiting_time_ms; |
656 std::vector<int> waiting_times; | 657 acm_stat->medianWaitingTimeMs = neteq_stat.median_waiting_time_ms; |
657 neteq_->WaitingTimes(&waiting_times); | 658 acm_stat->minWaitingTimeMs = neteq_stat.min_waiting_time_ms; |
658 size_t size = waiting_times.size(); | 659 acm_stat->maxWaitingTimeMs = neteq_stat.max_waiting_time_ms; |
659 if (size == 0) { | |
660 acm_stat->meanWaitingTimeMs = -1; | |
661 acm_stat->medianWaitingTimeMs = -1; | |
662 acm_stat->minWaitingTimeMs = -1; | |
663 acm_stat->maxWaitingTimeMs = -1; | |
664 } else { | |
665 std::sort(waiting_times.begin(), waiting_times.end()); | |
666 if ((size & 0x1) == 0) { | |
667 acm_stat->medianWaitingTimeMs = (waiting_times[size / 2 - 1] + | |
668 waiting_times[size / 2]) / 2; | |
669 } else { | |
670 acm_stat->medianWaitingTimeMs = waiting_times[size / 2]; | |
671 } | |
672 acm_stat->minWaitingTimeMs = waiting_times.front(); | |
673 acm_stat->maxWaitingTimeMs = waiting_times.back(); | |
674 double sum = 0; | |
675 for (size_t i = 0; i < size; ++i) { | |
676 sum += waiting_times[i]; | |
677 } | |
678 acm_stat->meanWaitingTimeMs = static_cast<int>(sum / size); | |
679 } | |
680 } | 660 } |
681 | 661 |
682 int AcmReceiver::DecoderByPayloadType(uint8_t payload_type, | 662 int AcmReceiver::DecoderByPayloadType(uint8_t payload_type, |
683 CodecInst* codec) const { | 663 CodecInst* codec) const { |
684 CriticalSectionScoped lock(crit_sect_.get()); | 664 CriticalSectionScoped lock(crit_sect_.get()); |
685 auto it = decoders_.find(payload_type); | 665 auto it = decoders_.find(payload_type); |
686 if (it == decoders_.end()) { | 666 if (it == decoders_.end()) { |
687 LOG(LERROR) << "AcmReceiver::DecoderByPayloadType " | 667 LOG(LERROR) << "AcmReceiver::DecoderByPayloadType " |
688 << static_cast<int>(payload_type); | 668 << static_cast<int>(payload_type); |
689 return -1; | 669 return -1; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 | 822 |
843 void AcmReceiver::GetDecodingCallStatistics( | 823 void AcmReceiver::GetDecodingCallStatistics( |
844 AudioDecodingCallStats* stats) const { | 824 AudioDecodingCallStats* stats) const { |
845 CriticalSectionScoped lock(crit_sect_.get()); | 825 CriticalSectionScoped lock(crit_sect_.get()); |
846 *stats = call_stats_.GetDecodingStatistics(); | 826 *stats = call_stats_.GetDecodingStatistics(); |
847 } | 827 } |
848 | 828 |
849 } // namespace acm2 | 829 } // namespace acm2 |
850 | 830 |
851 } // namespace webrtc | 831 } // namespace webrtc |
OLD | NEW |