blob: 4270e9b380f32a43de80bdf0627e56647cbf5b01 [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
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000014#include "webrtc/base/scoped_ptr.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000015#include "webrtc/common_types.h"
Henrik Kjellander74640892015-10-29 11:31:02 +010016#include "webrtc/modules/audio_coding/main/include/audio_coding_module.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000017#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000018
19namespace webrtc {
20class AudioFrame;
21
22class AudioCoder : public AudioPacketizationCallback
23{
24public:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000025 AudioCoder(uint32_t instanceID);
niklase@google.com470e71d2011-07-07 08:21:25 +000026 ~AudioCoder();
27
henrik.lundin8387c5f2015-09-28 09:24:51 -070028 int32_t SetEncodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000029
henrik.lundin8387c5f2015-09-28 09:24:51 -070030 int32_t SetDecodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000032 int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000033 const int8_t* incomingPayload, size_t payloadLength);
niklase@google.com470e71d2011-07-07 08:21:25 +000034
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000035 int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
niklase@google.com470e71d2011-07-07 08:21:25 +000036
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000037 int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000038 size_t& encodedLengthInBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000039
40protected:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +000041 int32_t SendData(FrameType frameType,
42 uint8_t payloadType,
43 uint32_t timeStamp,
44 const uint8_t* payloadData,
45 size_t payloadSize,
46 const RTPFragmentationHeader* fragmentation) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000047
48private:
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000049 rtc::scoped_ptr<AudioCodingModule> _acm;
niklase@google.com470e71d2011-07-07 08:21:25 +000050
51 CodecInst _receiveCodec;
52
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000053 uint32_t _encodeTimestamp;
54 int8_t* _encodedData;
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000055 size_t _encodedLengthInBytes;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000057 uint32_t _decodeTimestamp;
niklase@google.com470e71d2011-07-07 08:21:25 +000058};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000059} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000060
61#endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_