blob: f6bdd49f694af927cbf902e0cdde930fba27782f [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;
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000019
kjellander470dd372016-04-19 03:03:23 -070020AudioEncoder::EncodedInfo::EncodedInfo(const EncodedInfo&) = default;
21
kwiberg12cfc9b2015-09-08 05:57:53 -070022AudioEncoder::EncodedInfo::~EncodedInfo() = default;
23
24int AudioEncoder::RtpTimestampRateHz() const {
25 return SampleRateHz();
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000026}
27
kwiberg288886b2015-11-06 01:21:35 -080028AudioEncoder::EncodedInfo AudioEncoder::Encode(
29 uint32_t rtp_timestamp,
30 rtc::ArrayView<const int16_t> audio,
ossu10a029e2016-03-01 00:41:31 -080031 rtc::Buffer* encoded) {
32 TRACE_EVENT0("webrtc", "AudioEncoder::Encode");
33 RTC_CHECK_EQ(audio.size(),
34 static_cast<size_t>(NumChannels() * SampleRateHz() / 100));
35
36 const size_t old_size = encoded->size();
ossu4f43fcf2016-03-04 00:54:32 -080037 EncodedInfo info = EncodeImpl(rtp_timestamp, audio, encoded);
ossu10a029e2016-03-01 00:41:31 -080038 RTC_CHECK_EQ(encoded->size() - old_size, info.encoded_bytes);
39 return info;
40}
41
kwiberg12cfc9b2015-09-08 05:57:53 -070042bool AudioEncoder::SetFec(bool enable) {
43 return !enable;
henrik.lundin@webrtc.org478cedc2015-01-27 18:24:45 +000044}
45
kwiberg12cfc9b2015-09-08 05:57:53 -070046bool AudioEncoder::SetDtx(bool enable) {
47 return !enable;
48}
49
50bool AudioEncoder::SetApplication(Application application) {
51 return false;
52}
53
kwiberg3f5f1c22015-09-08 23:15:33 -070054void AudioEncoder::SetMaxPlaybackRate(int frequency_hz) {}
kwiberg12cfc9b2015-09-08 05:57:53 -070055
56void AudioEncoder::SetProjectedPacketLossRate(double fraction) {}
57
58void AudioEncoder::SetTargetBitrate(int target_bps) {}
59
ossu2903ba52016-04-18 06:14:33 -070060size_t AudioEncoder::MaxEncodedBytes() const {
61 RTC_CHECK(false);
62 return 0;
63}
64
henrik.lundin@webrtc.orgc1c92912014-12-16 13:41:36 +000065} // namespace webrtc