| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 return packet_to_return; | 46 return packet_to_return; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void EncodeNetEqInput::AdvanceOutputEvent() { | 49 void EncodeNetEqInput::AdvanceOutputEvent() { |
| 50 next_output_event_ms_ += kOutputPeriodMs; | 50 next_output_event_ms_ += kOutputPeriodMs; |
| 51 } | 51 } |
| 52 | 52 |
| 53 rtc::Optional<RTPHeader> EncodeNetEqInput::NextHeader() const { | 53 rtc::Optional<RTPHeader> EncodeNetEqInput::NextHeader() const { |
| 54 RTC_DCHECK(packet_data_); | 54 RTC_DCHECK(packet_data_); |
| 55 return rtc::Optional<RTPHeader>(packet_data_->header.header); | 55 return rtc::Optional<RTPHeader>(packet_data_->header); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void EncodeNetEqInput::CreatePacket() { | 58 void EncodeNetEqInput::CreatePacket() { |
| 59 // Create a new PacketData object. | 59 // Create a new PacketData object. |
| 60 RTC_DCHECK(!packet_data_); | 60 RTC_DCHECK(!packet_data_); |
| 61 packet_data_.reset(new NetEqInput::PacketData); | 61 packet_data_.reset(new NetEqInput::PacketData); |
| 62 RTC_DCHECK_EQ(packet_data_->payload.size(), 0); | 62 RTC_DCHECK_EQ(packet_data_->payload.size(), 0); |
| 63 | 63 |
| 64 // Loop until we get a packet. | 64 // Loop until we get a packet. |
| 65 AudioEncoder::EncodedInfo info; | 65 AudioEncoder::EncodedInfo info; |
| 66 RTC_DCHECK(!info.send_even_if_empty); | 66 RTC_DCHECK(!info.send_even_if_empty); |
| 67 int num_blocks = 0; | 67 int num_blocks = 0; |
| 68 while (packet_data_->payload.size() == 0 && !info.send_even_if_empty) { | 68 while (packet_data_->payload.size() == 0 && !info.send_even_if_empty) { |
| 69 const size_t num_samples = rtc::CheckedDivExact( | 69 const size_t num_samples = rtc::CheckedDivExact( |
| 70 static_cast<int>(encoder_->SampleRateHz() * kOutputPeriodMs), 1000); | 70 static_cast<int>(encoder_->SampleRateHz() * kOutputPeriodMs), 1000); |
| 71 | 71 |
| 72 info = encoder_->Encode(rtp_timestamp_, generator_->Generate(num_samples), | 72 info = encoder_->Encode(rtp_timestamp_, generator_->Generate(num_samples), |
| 73 &packet_data_->payload); | 73 &packet_data_->payload); |
| 74 | 74 |
| 75 rtp_timestamp_ += rtc::dchecked_cast<uint32_t>( | 75 rtp_timestamp_ += rtc::dchecked_cast<uint32_t>( |
| 76 num_samples * encoder_->RtpTimestampRateHz() / | 76 num_samples * encoder_->RtpTimestampRateHz() / |
| 77 encoder_->SampleRateHz()); | 77 encoder_->SampleRateHz()); |
| 78 ++num_blocks; | 78 ++num_blocks; |
| 79 } | 79 } |
| 80 packet_data_->header.header.timestamp = info.encoded_timestamp; | 80 packet_data_->header.timestamp = info.encoded_timestamp; |
| 81 packet_data_->header.header.payloadType = info.payload_type; | 81 packet_data_->header.payloadType = info.payload_type; |
| 82 packet_data_->header.header.sequenceNumber = sequence_number_++; | 82 packet_data_->header.sequenceNumber = sequence_number_++; |
| 83 packet_data_->time_ms = next_packet_time_ms_; | 83 packet_data_->time_ms = next_packet_time_ms_; |
| 84 next_packet_time_ms_ += num_blocks * kOutputPeriodMs; | 84 next_packet_time_ms_ += num_blocks * kOutputPeriodMs; |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace test | 87 } // namespace test |
| 88 } // namespace webrtc | 88 } // namespace webrtc |
| OLD | NEW |