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 | |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 14 | #include "webrtc/base/scoped_ptr.h" |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 15 | #include "webrtc/common_types.h" |
| 16 | #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h" |
| 17 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | class AudioFrame; |
| 21 | |
| 22 | class AudioCoder : public AudioPacketizationCallback |
| 23 | { |
| 24 | public: |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 25 | AudioCoder(uint32_t instanceID); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | ~AudioCoder(); |
| 27 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 28 | int32_t SetEncodeCodec( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | const CodecInst& codecInst, |
henrike@webrtc.org | 47658f1 | 2014-09-10 22:14:59 +0000 | [diff] [blame] | 30 | ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 32 | int32_t SetDecodeCodec( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | const CodecInst& codecInst, |
henrike@webrtc.org | 47658f1 | 2014-09-10 22:14:59 +0000 | [diff] [blame] | 34 | ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 36 | int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 37 | const int8_t* incomingPayload, size_t payloadLength); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 39 | int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 41 | int32_t Encode(const AudioFrame& audio, int8_t* encodedData, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 42 | size_t& encodedLengthInBytes); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
| 44 | protected: |
henrike@webrtc.org | 47658f1 | 2014-09-10 22:14:59 +0000 | [diff] [blame] | 45 | virtual int32_t SendData( |
| 46 | FrameType frameType, |
| 47 | uint8_t payloadType, |
| 48 | uint32_t timeStamp, |
| 49 | const uint8_t* payloadData, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 50 | size_t payloadSize, |
henrike@webrtc.org | 47658f1 | 2014-09-10 22:14:59 +0000 | [diff] [blame] | 51 | const RTPFragmentationHeader* fragmentation) OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
| 53 | private: |
kwiberg@webrtc.org | 00b8f6b | 2015-02-26 14:34:55 +0000 | [diff] [blame] | 54 | rtc::scoped_ptr<AudioCodingModule> _acm; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
| 56 | CodecInst _receiveCodec; |
| 57 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 58 | uint32_t _encodeTimestamp; |
| 59 | int8_t* _encodedData; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 60 | size_t _encodedLengthInBytes; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 62 | uint32_t _decodeTimestamp; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 64 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | |
| 66 | #endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_ |