blob: 9536a027d0e913aad4b50c3c3db77365eaa85cf8 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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#ifndef WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
12#define WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
13
kwiberg22feaa32016-03-17 09:17:43 -070014#include <memory>
15
pbos@webrtc.org8b062002013-07-12 08:28:10 +000016#include "webrtc/common_types.h"
kwibergc8d071e2016-04-06 12:22:38 -070017#include "webrtc/modules/audio_coding/acm2/codec_manager.h"
18#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
kjellander3e6db232015-11-26 04:44:54 -080019#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000020#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22namespace webrtc {
23class AudioFrame;
24
25class AudioCoder : public AudioPacketizationCallback
26{
27public:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000028 AudioCoder(uint32_t instanceID);
niklase@google.com470e71d2011-07-07 08:21:25 +000029 ~AudioCoder();
30
henrik.lundin8387c5f2015-09-28 09:24:51 -070031 int32_t SetEncodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000032
henrik.lundin8387c5f2015-09-28 09:24:51 -070033 int32_t SetDecodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000035 int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000036 const int8_t* incomingPayload, size_t payloadLength);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000038 int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
niklase@google.com470e71d2011-07-07 08:21:25 +000039
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000040 int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000041 size_t& encodedLengthInBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000042
43protected:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000044 int32_t SendData(FrameType frameType,
45 uint8_t payloadType,
46 uint32_t timeStamp,
47 const uint8_t* payloadData,
48 size_t payloadSize,
49 const RTPFragmentationHeader* fragmentation) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
51private:
kwiberg22feaa32016-03-17 09:17:43 -070052 std::unique_ptr<AudioCodingModule> _acm;
kwibergc8d071e2016-04-06 12:22:38 -070053 acm2::CodecManager codec_manager_;
54 acm2::RentACodec rent_a_codec_;
niklase@google.com470e71d2011-07-07 08:21:25 +000055
56 CodecInst _receiveCodec;
57
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000058 uint32_t _encodeTimestamp;
59 int8_t* _encodedData;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000060 size_t _encodedLengthInBytes;
niklase@google.com470e71d2011-07-07 08:21:25 +000061
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000062 uint32_t _decodeTimestamp;
niklase@google.com470e71d2011-07-07 08:21:25 +000063};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000064} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000065
66#endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_