blob: 956c4e086f0dbf244cb348ad93083d19ad252411 [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
63void AudioEncoder::SetProjectedPacketLossRate(double fraction) {}
64
65void AudioEncoder::SetTargetBitrate(int target_bps) {}
66
kwiberg3f81fcd2016-06-23 03:58:36 -070067rtc::ArrayView<std::unique_ptr<AudioEncoder>>
68AudioEncoder::ReclaimContainedEncoders() { return nullptr; }
69
minyue41b9c802016-10-06 07:13:54 -070070bool AudioEncoder::EnableAudioNetworkAdaptor(const std::string& config_string,
71 const Clock* clock) {
72 return false;
73}
74
75void AudioEncoder::DisableAudioNetworkAdaptor() {}
76
77void AudioEncoder::OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) {}
78
79void AudioEncoder::OnReceivedUplinkPacketLossFraction(
minyue7e304322016-10-12 05:00:55 -070080 float uplink_packet_loss_fraction) {
81 SetProjectedPacketLossRate(uplink_packet_loss_fraction);
82}
minyue41b9c802016-10-06 07:13:54 -070083
minyue7e304322016-10-12 05:00:55 -070084void AudioEncoder::OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) {
85 SetTargetBitrate(target_audio_bitrate_bps);
86}
minyue41b9c802016-10-06 07:13:54 -070087
88void AudioEncoder::OnReceivedRtt(int rtt_ms) {}
89
90void AudioEncoder::SetReceiverFrameLengthRange(int min_frame_length_ms,
91 int max_frame_length_ms) {}
92
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000093} // namespace webrtc