| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 19 matching lines...) Expand all Loading... |
| 30 TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); | 30 TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); |
| 31 RTC_CHECK_EQ(audio.size(), | 31 RTC_CHECK_EQ(audio.size(), |
| 32 static_cast<size_t>(NumChannels() * SampleRateHz() / 100)); | 32 static_cast<size_t>(NumChannels() * SampleRateHz() / 100)); |
| 33 | 33 |
| 34 const size_t old_size = encoded->size(); | 34 const size_t old_size = encoded->size(); |
| 35 EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded); | 35 EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded); |
| 36 RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes); | 36 RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes); |
| 37 return info; | 37 return info; |
| 38 } | 38 } |
| 39 | 39 |
| 40 AudioEncoder::EncodedInfo AudioEncoder::Encode( | |
| 41 uint32_t rtp_timestamp, | |
| 42 rtc::ArrayView<const int16_t> audio, | |
| 43 size_t max_encoded_bytes, | |
| 44 uint8_t* encoded) { | |
| 45 return DEPRECATED_Encode(rtp_timestamp, audio, max_encoded_bytes, encoded); | |
| 46 } | |
| 47 | |
| 48 AudioEncoder::EncodedInfo AudioEncoder::DEPRECATED_Encode( | |
| 49 uint32_t rtp_timestamp, | |
| 50 rtc::ArrayView<const int16_t> audio, | |
| 51 size_t max_encoded_bytes, | |
| 52 uint8_t* encoded) { | |
| 53 TRACE_EVENT0("webrtc", "AudioEncoder::Encode"); | |
| 54 RTC_CHECK_EQ(audio.size(), | |
| 55 static_cast<size_t>(NumChannels() * SampleRateHz() / 100)); | |
| 56 EncodedInfo info = | |
| 57 EncodeInternal(rtp_timestamp, audio, max_encoded_bytes, encoded); | |
| 58 RTC_CHECK_LE(info.encoded_bytes, max_encoded_bytes); | |
| 59 return info; | |
| 60 } | |
| 61 | |
| 62 AudioEncoder::EncodedInfo AudioEncoder::EncodeImpl( | |
| 63 uint32_t rtp_timestamp, | |
| 64 rtc::ArrayView<const int16_t> audio, | |
| 65 rtc::Buffer* encoded) | |
| 66 { | |
| 67 EncodedInfo info; | |
| 68 encoded->AppendData(MaxEncodedBytes(), [&] (rtc::ArrayView<uint8_t> encoded) { | |
| 69 info = EncodeInternal(rtp_timestamp, audio, | |
| 70 encoded.size(), encoded.data()); | |
| 71 return info.encoded_bytes; | |
| 72 }); | |
| 73 return info; | |
| 74 } | |
| 75 | |
| 76 AudioEncoder::EncodedInfo AudioEncoder::EncodeInternal( | |
| 77 uint32_t rtp_timestamp, | |
| 78 rtc::ArrayView<const int16_t> audio, | |
| 79 size_t max_encoded_bytes, | |
| 80 uint8_t* encoded) | |
| 81 { | |
| 82 rtc::Buffer temp_buffer; | |
| 83 EncodedInfo info = EncodeImpl(rtp_timestamp, audio, &temp_buffer); | |
| 84 RTC_DCHECK_LE(temp_buffer.size(), max_encoded_bytes); | |
| 85 std::memcpy(encoded, temp_buffer.data(), info.encoded_bytes); | |
| 86 return info; | |
| 87 } | |
| 88 | |
| 89 bool AudioEncoder::SetFec(bool enable) { | 40 bool AudioEncoder::SetFec(bool enable) { |
| 90 return !enable; | 41 return !enable; |
| 91 } | 42 } |
| 92 | 43 |
| 93 bool AudioEncoder::SetDtx(bool enable) { | 44 bool AudioEncoder::SetDtx(bool enable) { |
| 94 return !enable; | 45 return !enable; |
| 95 } | 46 } |
| 96 | 47 |
| 97 bool AudioEncoder::SetApplication(Application application) { | 48 bool AudioEncoder::SetApplication(Application application) { |
| 98 return false; | 49 return false; |
| 99 } | 50 } |
| 100 | 51 |
| 101 void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {} | 52 void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {} |
| 102 | 53 |
| 103 void AudioEncoder::SetProjectedPacketLossRate(double fraction) {} | 54 void AudioEncoder::SetProjectedPacketLossRate(double fraction) {} |
| 104 | 55 |
| 105 void AudioEncoder::SetTargetBitrate(int target_bps) {} | 56 void AudioEncoder::SetTargetBitrate(int target_bps) {} |
| 106 | 57 |
| 58 size_t AudioEncoder::MaxEncodedBytes() const { |
| 59 RTC_CHECK(false); |
| 60 return 0; |
| 61 } |
| 62 |
| 107 } // namespace webrtc | 63 } // namespace webrtc |
| OLD | NEW |