niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | namespace webrtc { |
| 19 | class AudioFrame; |
| 20 | |
| 21 | class AudioCoder : public AudioPacketizationCallback |
| 22 | { |
| 23 | public: |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 24 | AudioCoder(uint32_t instanceID); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | ~AudioCoder(); |
| 26 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 27 | int32_t SetEncodeCodec( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | const CodecInst& codecInst, |
| 29 | ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient); |
| 30 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 31 | int32_t SetDecodeCodec( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | const CodecInst& codecInst, |
| 33 | ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient); |
| 34 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 35 | int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz, |
| 36 | const int8_t* incomingPayload, int32_t payloadLength); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 38 | int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 40 | int32_t Encode(const AudioFrame& audio, int8_t* encodedData, |
| 41 | uint32_t& encodedLengthInBytes); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
| 43 | protected: |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 44 | virtual int32_t SendData(FrameType frameType, |
| 45 | uint8_t payloadType, |
| 46 | uint32_t timeStamp, |
| 47 | const uint8_t* payloadData, |
| 48 | uint16_t payloadSize, |
| 49 | const RTPFragmentationHeader* fragmentation); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | AudioCodingModule* _acm; |
| 53 | |
| 54 | CodecInst _receiveCodec; |
| 55 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 56 | uint32_t _encodeTimestamp; |
| 57 | int8_t* _encodedData; |
| 58 | uint32_t _encodedLengthInBytes; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 60 | uint32_t _decodeTimestamp; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | }; |
| 62 | } // namespace webrtc |
| 63 | |
| 64 | #endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_ |