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

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc

Issue 2838353002: NetEq: Limit payload size for replacement audio input (Closed)
Patch Set: alessiob's comments Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // If CNG, simply insert a zero-energy one-byte payload. 79 // If CNG, simply insert a zero-energy one-byte payload.
80 uint8_t cng_payload[1] = {127}; // Max attenuation of CNG. 80 uint8_t cng_payload[1] = {127}; // Max attenuation of CNG.
81 packet_->payload.SetData(cng_payload); 81 packet_->payload.SetData(cng_payload);
82 return; 82 return;
83 } 83 }
84 84
85 rtc::Optional<RTPHeader> next_hdr = source_->NextHeader(); 85 rtc::Optional<RTPHeader> next_hdr = source_->NextHeader();
86 RTC_DCHECK(next_hdr); 86 RTC_DCHECK(next_hdr);
87 uint8_t payload[12]; 87 uint8_t payload[12];
88 uint32_t input_frame_size_timestamps = last_frame_size_timestamps_; 88 uint32_t input_frame_size_timestamps = last_frame_size_timestamps_;
89 if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1) { 89 const uint32_t timestamp_diff =
90 // Packets are in order. 90 next_hdr->timestamp - packet_->header.timestamp;
91 input_frame_size_timestamps = 91 if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1 &&
92 next_hdr->timestamp - packet_->header.timestamp; 92 timestamp_diff <= 120 * 48) {
93 // Packets are in order and the timestamp diff is less than 5760 samples.
94 // Accept the timestamp diff as a valid frame size.
95 input_frame_size_timestamps = timestamp_diff;
93 last_frame_size_timestamps_ = input_frame_size_timestamps; 96 last_frame_size_timestamps_ = input_frame_size_timestamps;
94 } 97 }
98 RTC_DCHECK_LE(input_frame_size_timestamps, 120 * 48);
AleBzk 2017/04/26 14:26:48 I'd rather do this before line 88 and on last_fram
hlundin-webrtc 2017/04/26 14:32:32 I see your point. But I think that we are not as m
95 FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp, 99 FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp,
96 input_frame_size_timestamps, 100 input_frame_size_timestamps,
97 packet_->payload.size(), payload); 101 packet_->payload.size(), payload);
98 packet_->payload.SetData(payload); 102 packet_->payload.SetData(payload);
99 packet_->header.payloadType = replacement_payload_type_; 103 packet_->header.payloadType = replacement_payload_type_;
100 return; 104 return;
101 } 105 }
102 106
103 } // namespace test 107 } // namespace test
104 } // namespace webrtc 108 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698