blob: e7cbfb8bbe276b4b6684ded8af8a739c1aeb247a [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
14#include "audio_coding_module.h"
15#include "common_types.h"
16#include "typedefs.h"
17
18namespace webrtc {
19class AudioFrame;
20
21class AudioCoder : public AudioPacketizationCallback
22{
23public:
24 AudioCoder(WebRtc_UWord32 instanceID);
25 ~AudioCoder();
26
27 WebRtc_Word32 SetEncodeCodec(
28 const CodecInst& codecInst,
29 ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
30
31 WebRtc_Word32 SetDecodeCodec(
32 const CodecInst& codecInst,
33 ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
34
35 WebRtc_Word32 Decode(AudioFrame& decodedAudio, WebRtc_UWord32 sampFreqHz,
36 const WebRtc_Word8* incomingPayload,
37 WebRtc_Word32 payloadLength);
38
39 WebRtc_Word32 PlayoutData(AudioFrame& decodedAudio,
40 WebRtc_UWord16& sampFreqHz);
41
42 WebRtc_Word32 Encode(const AudioFrame& audio,
43 WebRtc_Word8* encodedData,
44 WebRtc_UWord32& encodedLengthInBytes);
45
46protected:
47 virtual WebRtc_Word32 SendData(FrameType frameType,
48 WebRtc_UWord8 payloadType,
49 WebRtc_UWord32 timeStamp,
50 const WebRtc_UWord8* payloadData,
51 WebRtc_UWord16 payloadSize,
52 const RTPFragmentationHeader* fragmentation);
53
54private:
niklase@google.com470e71d2011-07-07 08:21:25 +000055 AudioCodingModule* _acm;
56
57 CodecInst _receiveCodec;
58
59 WebRtc_UWord32 _encodeTimestamp;
60 WebRtc_Word8* _encodedData;
61 WebRtc_UWord32 _encodedLengthInBytes;
62
63 WebRtc_UWord32 _decodeTimestamp;
64};
65} // namespace webrtc
66
67#endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_