blob: 399edbd7fb8e162315e04aafde9273ae58a1dc5a [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"
kjellander3e6db232015-11-26 04:44:54 -080017#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000018#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20namespace webrtc {
21class AudioFrame;
22
23class AudioCoder : public AudioPacketizationCallback
24{
25public:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000026 AudioCoder(uint32_t instanceID);
niklase@google.com470e71d2011-07-07 08:21:25 +000027 ~AudioCoder();
28
henrik.lundin8387c5f2015-09-28 09:24:51 -070029 int32_t SetEncodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000030
henrik.lundin8387c5f2015-09-28 09:24:51 -070031 int32_t SetDecodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000032
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000033 int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000034 const int8_t* incomingPayload, size_t payloadLength);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000036 int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000038 int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000039 size_t& encodedLengthInBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41protected:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000042 int32_t SendData(FrameType frameType,
43 uint8_t payloadType,
44 uint32_t timeStamp,
45 const uint8_t* payloadData,
46 size_t payloadSize,
47 const RTPFragmentationHeader* fragmentation) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000048
49private:
kwiberg22feaa32016-03-17 09:17:43 -070050 std::unique_ptr<AudioCodingModule> _acm;
niklase@google.com470e71d2011-07-07 08:21:25 +000051
52 CodecInst _receiveCodec;
53
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000054 uint32_t _encodeTimestamp;
55 int8_t* _encodedData;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000056 size_t _encodedLengthInBytes;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000058 uint32_t _decodeTimestamp;
niklase@google.com470e71d2011-07-07 08:21:25 +000059};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000060} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000061
62#endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_