blob: e04372d9a5bbfc5a52a2cef85f6815024618bbcf [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,
henrike@webrtc.org47658f12014-09-10 22:14:59 +000030 ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
pbos@webrtc.orgc75102e2013-04-09 13:32:55 +000032 int32_t SetDecodeCodec(
niklase@google.com470e71d2011-07-07 08:21:25 +000033 const CodecInst& codecInst,
henrike@webrtc.org47658f12014-09-10 22:14:59 +000034 ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
niklase@google.com470e71d2011-07-07 08:21:25 +000035
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:
henrike@webrtc.org47658f12014-09-10 22:14:59 +000045 virtual int32_t SendData(
46 FrameType frameType,
47 uint8_t payloadType,
48 uint32_t timeStamp,
49 const uint8_t* payloadData,
50 uint16_t payloadSize,
51 const RTPFragmentationHeader* fragmentation) OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
53private:
andrew@webrtc.orgeb524d92013-09-23 23:02:24 +000054 scoped_ptr<AudioCodingModule> _acm;
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;
60 uint32_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_