blob: 3ee371f1cee7f4b5d5390bd8c3340d7d1abd42a3 [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
ossueb1fde42017-05-02 06:46:30 -070011#include "webrtc/api/audio_codecs/audio_encoder.h"
Peter Boströmd7b7ae82015-12-08 13:41:35 +010012
Edward Lemurc20978e2017-07-06 19:44:34 +020013#include "webrtc/rtc_base/checks.h"
14#include "webrtc/rtc_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>>
ossueb1fde42017-05-02 06:46:30 -070066AudioEncoder::ReclaimContainedEncoders() {
67 return nullptr;
68}
kwiberg3f81fcd2016-06-23 03:58:36 -070069
minyue41b9c802016-10-06 07:13:54 -070070bool AudioEncoder::EnableAudioNetworkAdaptor(const std::string& config_string,
michaelt92aef172017-04-18 00:11:48 -070071 RtcEventLog* event_log) {
minyue41b9c802016-10-06 07:13:54 -070072 return false;
73}
74
75void AudioEncoder::DisableAudioNetworkAdaptor() {}
76
minyue41b9c802016-10-06 07:13:54 -070077void AudioEncoder::OnReceivedUplinkPacketLossFraction(
minyue4b9a2cb2016-11-30 06:49:59 -080078 float uplink_packet_loss_fraction) {}
minyue41b9c802016-10-06 07:13:54 -070079
elad.alondadb4dc2017-03-23 15:29:50 -070080void AudioEncoder::OnReceivedUplinkRecoverablePacketLossFraction(
81 float uplink_recoverable_packet_loss_fraction) {}
82
michaelt566d8202017-01-12 10:17:38 -080083void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
84 OnReceivedUplinkBandwidth(target_audio_bitrate_bps, rtc::Optional<int64_t>());
85}
86
87void AudioEncoder::OnReceivedUplinkBandwidth(
88 int target_audio_bitrate_bps,
minyue93e45222017-05-18 14:32:41 -070089 rtc::Optional<int64_t> bwe_period_ms) {}
minyue41b9c802016-10-06 07:13:54 -070090
91void AudioEncoder::OnReceivedRtt(int rtt_ms) {}
92
minyueeca373f2016-12-07 01:40:34 -080093void AudioEncoder::OnReceivedOverhead(size_t overhead_bytes_per_packet) {}
94
minyue41b9c802016-10-06 07:13:54 -070095void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms,
96 int max_frame_length_ms) {}
97
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000098} // namespace webrtc