blob: ead1e22345bedcd9999a47a842dd5accb0b7fa38 [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
pbos@webrtc.org8b062002013-07-12 08:28:10 +000014#include "webrtc/common_types.h"
15#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
andrew@webrtc.orgeb524d92013-09-23 23:02:24 +000016#include "webrtc/system_wrappers/interface/scoped_ptr.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
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000028 int32_t SetEncodeCodec(
niklase@google.com470e71d2011-07-07 08:21:25 +000029 const CodecInst& codecInst,
30 ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
31
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000032 int32_t SetDecodeCodec(
niklase@google.com470e71d2011-07-07 08:21:25 +000033 const CodecInst& codecInst,
34 ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
35
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000036 int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
37 const int8_t* incomingPayload, int32_t payloadLength);
niklase@google.com470e71d2011-07-07 08:21:25 +000038
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000039 int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000041 int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
42 uint32_t& encodedLengthInBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
44protected:
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000045 virtual int32_t SendData(FrameType frameType,
46 uint8_t payloadType,
47 uint32_t timeStamp,
48 const uint8_t* payloadData,
49 uint16_t payloadSize,
50 const RTPFragmentationHeader* fragmentation);
niklase@google.com470e71d2011-07-07 08:21:25 +000051
52private:
andrew@webrtc.orgeb524d92013-09-23 23:02:24 +000053 scoped_ptr<AudioCodingModule> _acm;
niklase@google.com470e71d2011-07-07 08:21:25 +000054
55 CodecInst _receiveCodec;
56
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000057 uint32_t _encodeTimestamp;
58 int8_t* _encodedData;
59 uint32_t _encodedLengthInBytes;
niklase@google.com470e71d2011-07-07 08:21:25 +000060
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000061 uint32_t _decodeTimestamp;
niklase@google.com470e71d2011-07-07 08:21:25 +000062};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000063} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000064
65#endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_