blob: c9d85f860562f3443d212ba71bb0c2928f956b7c [file] [log] [blame]
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +00001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
Peter Boströmd7b7ae82015-12-08 13:41:35 +010012
henrik.lundin@webrtc.orgf45c8ca2015-02-05 18:29:39 +000013#include "webrtc/base/checks.h"
Peter Boströmd7b7ae82015-12-08 13:41:35 +010014#include "webrtc/base/trace_event.h"
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000015
16namespace webrtc {
17
kwiberg12cfc9b2015-09-08 05:57:53 -070018AudioEncoder::EncodedInfo::EncodedInfo() = default;
kjellander470dd372016-04-19 03:03:23 -070019AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default;
kwiberg4fb3d2b2016-04-22 04:59:31 -070020AudioEncoder::EncodedInfo::EncodedInfo(EncodedInfo&&) = default;
kwiberg12cfc9b2015-09-08 05:57:53 -070021AudioEncoder::EncodedInfo::~EncodedInfo() = default;
kwiberg4fb3d2b2016-04-22 04:59:31 -070022AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(
23 const EncodedInfo&) = default;
24AudioEncoder::EncodedInfo& AudioEncoder::EncodedInfo::operator=(EncodedInfo&&) =
25 default;
kwiberg12cfc9b2015-09-08 05:57:53 -070026
27int AudioEncoder::RtpTimestampRateHz() const {
28 return SampleRateHz();
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000029}
30
kwiberg288886b2015-11-06 01:21:35 -080031AudioEncoder::EncodedInfo AudioEncoder::Encode(
32 uint32_t rtp_timestamp,
33 rtc::ArrayView<const int16_t> audio,
ossu10a029e2016-03-01 00:41:31 -080034 rtc::Buffer* encoded) {
35 TRACE_EVENT0("webrtc", "AudioEncoder::Encode");
36 RTC_CHECK_EQ(audio.size(),
37 static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
38
39 const size_t old_size = encoded->size();
ossu4f43fcf2016-03-04 00:54:32 -080040 EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded);
ossu10a029e2016-03-01 00:41:31 -080041 RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
42 return info;
43}
44
kwiberg12cfc9b2015-09-08 05:57:53 -070045bool AudioEncoder::SetFec(bool enable) {
46 return !enable;
henrik.lundin@webrtc.org478cedc2015-01-27 18:24:45 +000047}
48
kwiberg12cfc9b2015-09-08 05:57:53 -070049bool AudioEncoder::SetDtx(bool enable) {
50 return !enable;
51}
52
ivoc85228d62016-07-27 04:53:47 -070053bool AudioEncoder::GetDtx() const {
54 return false;
55}
56
kwiberg12cfc9b2015-09-08 05:57:53 -070057bool AudioEncoder::SetApplication(Application application) {
58 return false;
59}
60
kwiberg3f5f1c22015-09-08 23:15:33 -070061void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {}
kwiberg12cfc9b2015-09-08 05:57:53 -070062
minyuee69b4682016-11-30 01:18:58 -080063void AudioEncoder::SetTargetBitrate(int target_bps) {}
64
kwiberg3f81fcd2016-06-23 03:58:36 -070065rtc::ArrayView<std::unique_ptr<AudioEncoder>>
66AudioEncoder::ReclaimContainedEncoders() { return nullptr; }
67
minyue41b9c802016-10-06 07:13:54 -070068bool AudioEncoder::EnableAudioNetworkAdaptor(const std::string& config_string,
michaeltbf279fc2017-01-13 06:02:29 -080069 RtcEventLog* event_log,
minyue41b9c802016-10-06 07:13:54 -070070 const Clock* clock) {
71 return false;
72}
73
74void AudioEncoder::DisableAudioNetworkAdaptor() {}
75
minyue41b9c802016-10-06 07:13:54 -070076void AudioEncoder::OnReceivedUplinkPacketLossFraction(
minyue4b9a2cb2016-11-30 06:49:59 -080077 float uplink_packet_loss_fraction) {}
minyue41b9c802016-10-06 07:13:54 -070078
elad.alondadb4dc2017-03-23 15:29:50 -070079void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction(
80 float uplink_recoverable_packet_loss_fraction) {}
81
michaelt566d8202017-01-12 10:17:38 -080082void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
83 OnReceivedUplinkBandwidth(target_audio_bitrate_bps, rtc::Optional<int64_t>());
84}
85
86void AudioEncoder::OnReceivedUplinkBandwidth(
87 int target_audio_bitrate_bps,
88 rtc::Optional<int64_t> probing_interval_ms) {}
minyue41b9c802016-10-06 07:13:54 -070089
90void AudioEncoder::OnReceivedRtt(int rtt_ms) {}
91
minyueeca373f2016-12-07 01:40:34 -080092void AudioEncoder::OnReceivedOverhead(size_t overhead_bytes_per_packet) {}
93
minyue41b9c802016-10-06 07:13:54 -070094void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms,
95 int max_frame_length_ms) {}
96
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000097} // namespace webrtc