Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/neteq/neteq_impl.h" | 11 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <memory.h> // memset | 14 #include <memory.h> // memset |
| 15 | 15 |
| 16 #include <algorithm> | 16 #include <algorithm> |
| 17 #include <utility> | |
| 17 #include <vector> | 18 #include <vector> |
| 18 | 19 |
| 19 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
| 21 #include "webrtc/base/safe_conversions.h" | 22 #include "webrtc/base/safe_conversions.h" |
| 22 #include "webrtc/base/sanitizer.h" | 23 #include "webrtc/base/sanitizer.h" |
| 23 #include "webrtc/base/trace_event.h" | 24 #include "webrtc/base/trace_event.h" |
| 24 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" | 25 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" |
| 25 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" | 26 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" |
| 26 #include "webrtc/modules/audio_coding/neteq/accelerate.h" | 27 #include "webrtc/modules/audio_coding/neteq/accelerate.h" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 if (ret != PayloadSplitter::kOK) { | 624 if (ret != PayloadSplitter::kOK) { |
| 624 PacketBuffer::DeleteAllPackets(&packet_list); | 625 PacketBuffer::DeleteAllPackets(&packet_list); |
| 625 switch (ret) { | 626 switch (ret) { |
| 626 case PayloadSplitter::kUnknownPayloadType: | 627 case PayloadSplitter::kUnknownPayloadType: |
| 627 return kUnknownRtpPayloadType; | 628 return kUnknownRtpPayloadType; |
| 628 default: | 629 default: |
| 629 return kOtherError; | 630 return kOtherError; |
| 630 } | 631 } |
| 631 } | 632 } |
| 632 | 633 |
| 633 // Split payloads into smaller chunks. This also verifies that all payloads | |
| 634 // are of a known payload type. | |
| 635 ret = payload_splitter_->SplitAudio(&packet_list, *decoder_database_); | |
| 636 if (ret != PayloadSplitter::kOK) { | |
| 637 PacketBuffer::DeleteAllPackets(&packet_list); | |
| 638 switch (ret) { | |
| 639 case PayloadSplitter::kUnknownPayloadType: | |
| 640 return kUnknownRtpPayloadType; | |
| 641 case PayloadSplitter::kFrameSplitError: | |
| 642 return kFrameSplitError; | |
| 643 default: | |
| 644 return kOtherError; | |
| 645 } | |
| 646 } | |
| 647 | |
| 648 // Update bandwidth estimate, if the packet is not comfort noise. | 634 // Update bandwidth estimate, if the packet is not comfort noise. |
| 649 if (!packet_list.empty() && | 635 if (!packet_list.empty() && |
| 650 !decoder_database_->IsComfortNoise(main_header.payloadType)) { | 636 !decoder_database_->IsComfortNoise(main_header.payloadType)) { |
| 651 // The list can be empty here if we got nothing but DTMF payloads. | 637 // The list can be empty here if we got nothing but DTMF payloads. |
| 652 AudioDecoder* decoder = | 638 AudioDecoder* decoder = |
| 653 decoder_database_->GetDecoder(main_header.payloadType); | 639 decoder_database_->GetDecoder(main_header.payloadType); |
| 654 assert(decoder); // Should always get a valid object, since we have | 640 assert(decoder); // Should always get a valid object, since we have |
| 655 // already checked that the payload types are known. | 641 // already checked that the payload types are known. |
| 656 decoder->IncomingPacket(packet_list.front()->payload.data(), | 642 decoder->IncomingPacket(packet_list.front()->payload.data(), |
| 657 packet_list.front()->payload.size(), | 643 packet_list.front()->payload.size(), |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 675 // Carry comfort noise packets along. | 661 // Carry comfort noise packets along. |
| 676 parsed_packet_list.push_back(packet.release()); | 662 parsed_packet_list.push_back(packet.release()); |
| 677 } else { | 663 } else { |
| 678 std::vector<AudioDecoder::ParseResult> results = | 664 std::vector<AudioDecoder::ParseResult> results = |
| 679 info->GetDecoder()->ParsePayload(std::move(packet->payload), | 665 info->GetDecoder()->ParsePayload(std::move(packet->payload), |
| 680 packet->header.timestamp, | 666 packet->header.timestamp, |
| 681 packet->primary); | 667 packet->primary); |
| 682 const RTPHeader& original_header = packet->header; | 668 const RTPHeader& original_header = packet->header; |
| 683 for (auto& result : results) { | 669 for (auto& result : results) { |
| 684 RTC_DCHECK(result.frame); | 670 RTC_DCHECK(result.frame); |
| 685 // Reuse the packet if possible | 671 // Reuse the packet if possible |
|
kwiberg-webrtc
2016/09/16 00:48:08
End comment with "." Or, for a less minimalist ton
ossu
2016/09/16 11:46:00
Monoton und minimal.
| |
| 686 if (!packet) { | 672 if (!packet) { |
| 687 packet.reset(new Packet); | 673 packet.reset(new Packet); |
| 688 packet->header = original_header; | 674 packet->header = original_header; |
| 689 } | 675 } |
|
kwiberg-webrtc
2016/09/16 00:48:08
Again, should packet->payload (moved from on line
ossu
2016/09/16 11:46:00
I think it's probably best if it's not: once moved
kwiberg-webrtc
2016/09/16 12:07:39
Acknowledged.
| |
| 690 packet->header.timestamp = result.timestamp; | 676 packet->header.timestamp = result.timestamp; |
| 691 // TODO(ossu): Move from primary to some sort of priority level. | 677 // TODO(ossu): Move from primary to some sort of priority level. |
| 692 packet->primary = result.primary; | 678 packet->primary = result.primary; |
| 693 packet->frame = std::move(result.frame); | 679 packet->frame = std::move(result.frame); |
| 694 parsed_packet_list.push_back(packet.release()); | 680 parsed_packet_list.push_back(packet.release()); |
| 695 } | 681 } |
| 696 } | 682 } |
| 697 } | 683 } |
| 698 | 684 |
| 699 if (nack_enabled_) { | 685 if (nack_enabled_) { |
| (...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2098 } | 2084 } |
| 2099 } | 2085 } |
| 2100 | 2086 |
| 2101 void NetEqImpl::CreateDecisionLogic() { | 2087 void NetEqImpl::CreateDecisionLogic() { |
| 2102 decision_logic_.reset(DecisionLogic::Create( | 2088 decision_logic_.reset(DecisionLogic::Create( |
| 2103 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), | 2089 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), |
| 2104 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), | 2090 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), |
| 2105 tick_timer_.get())); | 2091 tick_timer_.get())); |
| 2106 } | 2092 } |
| 2107 } // namespace webrtc | 2093 } // namespace webrtc |
| OLD | NEW |