Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: webrtc/modules/audio_coding/neteq/timestamp_scaler.cc

Issue 2355503002: Stopped using the NetEqDecoder enum internally in NetEq. (Closed)
Patch Set: Clarified comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 27 matching lines...) Expand all
38 uint8_t rtp_payload_type) { 38 uint8_t rtp_payload_type) {
39 const DecoderDatabase::DecoderInfo* info = 39 const DecoderDatabase::DecoderInfo* info =
40 decoder_database_.GetDecoderInfo(rtp_payload_type); 40 decoder_database_.GetDecoderInfo(rtp_payload_type);
41 if (!info) { 41 if (!info) {
42 // Payload type is unknown. Do not scale. 42 // Payload type is unknown. Do not scale.
43 return external_timestamp; 43 return external_timestamp;
44 } 44 }
45 if (!(info->IsComfortNoise() || info->IsDtmf())) { 45 if (!(info->IsComfortNoise() || info->IsDtmf())) {
46 // Do not change the timestamp scaling settings for DTMF or CNG. 46 // Do not change the timestamp scaling settings for DTMF or CNG.
47 numerator_ = info->SampleRateHz(); 47 numerator_ = info->SampleRateHz();
48 if (info->codec_type == NetEqDecoder::kDecoderArbitrary) { 48 if (info->GetFormat().clockrate_hz == 0) {
49 // We have no format mapping for "arbitrary" external codecs, so we cannot 49 // If the clockrate is invalid (i.e. with an old-style external codec)
50 // support timestamp scaling of them. 50 // we cannot do any timestamp scaling.
51 denominator_ = numerator_; 51 denominator_ = numerator_;
52 } else { 52 } else {
53 denominator_ = info->GetFormat()->clockrate_hz; 53 denominator_ = info->GetFormat().clockrate_hz;
54 } 54 }
55 } 55 }
56 if (numerator_ != denominator_) { 56 if (numerator_ != denominator_) {
57 // We have a scale factor != 1. 57 // We have a scale factor != 1.
58 if (!first_packet_received_) { 58 if (!first_packet_received_) {
59 external_ref_ = external_timestamp; 59 external_ref_ = external_timestamp;
60 internal_ref_ = external_timestamp; 60 internal_ref_ = external_timestamp;
61 first_packet_received_ = true; 61 first_packet_received_ = true;
62 } 62 }
63 const int64_t external_diff = int64_t{external_timestamp} - external_ref_; 63 const int64_t external_diff = int64_t{external_timestamp} - external_ref_;
(...skipping 15 matching lines...) Expand all
79 } else { 79 } else {
80 const int64_t internal_diff = int64_t{internal_timestamp} - internal_ref_; 80 const int64_t internal_diff = int64_t{internal_timestamp} - internal_ref_;
81 assert(numerator_ > 0); // Should not be possible. 81 assert(numerator_ > 0); // Should not be possible.
82 // Do not update references in this method. 82 // Do not update references in this method.
83 // Switch |denominator_| and |numerator_| to convert the other way. 83 // Switch |denominator_| and |numerator_| to convert the other way.
84 return external_ref_ + (internal_diff * denominator_) / numerator_; 84 return external_ref_ + (internal_diff * denominator_) / numerator_;
85 } 85 }
86 } 86 }
87 87
88 } // namespace webrtc 88 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698