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 | 22feaa3 | 2016-03-17 09:17:43 -0700 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 16 | #include "webrtc/common_types.h" |
kwiberg | c8d071e | 2016-04-06 12:22:38 -0700 | [diff] [blame] | 17 | #include "webrtc/modules/audio_coding/acm2/codec_manager.h" |
| 18 | #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 19 | #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 20 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | class AudioFrame; |
| 24 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 25 | class AudioCoder : public AudioPacketizationCallback { |
| 26 | public: |
| 27 | AudioCoder(uint32_t instanceID); |
| 28 | ~AudioCoder(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 30 | int32_t SetEncodeCodec(const CodecInst& codecInst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 32 | int32_t SetDecodeCodec(const CodecInst& codecInst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 34 | int32_t Decode(AudioFrame& decodedAudio, |
| 35 | uint32_t sampFreqHz, |
| 36 | const int8_t* incomingPayload, |
| 37 | size_t payloadLength); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [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 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 41 | int32_t Encode(const AudioFrame& audio, |
| 42 | int8_t* encodedData, |
| 43 | size_t& encodedLengthInBytes); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 45 | protected: |
| 46 | int32_t SendData(FrameType frameType, |
| 47 | uint8_t payloadType, |
| 48 | uint32_t timeStamp, |
| 49 | const uint8_t* payloadData, |
| 50 | size_t payloadSize, |
| 51 | const RTPFragmentationHeader* fragmentation) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 53 | private: |
| 54 | std::unique_ptr<AudioCodingModule> _acm; |
| 55 | acm2::CodecManager codec_manager_; |
| 56 | acm2::RentACodec rent_a_codec_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 58 | CodecInst _receiveCodec; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 60 | uint32_t _encodeTimestamp; |
| 61 | int8_t* _encodedData; |
| 62 | size_t _encodedLengthInBytes; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 64 | uint32_t _decodeTimestamp; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 66 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 68 | #endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_ |