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 |
40 bool AudioEncoder::SetFec(bool enable) { | 89 bool AudioEncoder::SetFec(bool enable) { |
41 return !enable; | 90 return !enable; |
42 } | 91 } |
43 | 92 |
44 bool AudioEncoder::SetDtx(bool enable) { | 93 bool AudioEncoder::SetDtx(bool enable) { |
45 return !enable; | 94 return !enable; |
46 } | 95 } |
47 | 96 |
48 bool AudioEncoder::SetApplication(Application application) { | 97 bool AudioEncoder::SetApplication(Application application) { |
49 return false; | 98 return false; |
50 } | 99 } |
51 | 100 |
52 void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {} | 101 void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {} |
53 | 102 |
54 void AudioEncoder::SetProjectedPacketLossRate(double fraction) {} | 103 void AudioEncoder::SetProjectedPacketLossRate(double fraction) {} |
55 | 104 |
56 void AudioEncoder::SetTargetBitrate(int target_bps) {} | 105 void AudioEncoder::SetTargetBitrate(int target_bps) {} |
57 | 106 |
58 size_t AudioEncoder::MaxEncodedBytes() const { | |
59 RTC_CHECK(false); | |
60 return 0; | |
61 } | |
62 | |
63 } // namespace webrtc | 107 } // namespace webrtc |
OLD | NEW |