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 | |
kwiberg | dc65ea2 | 2016-08-15 10:36:32 -0700 | [diff] [blame^] | 11 | #ifndef WEBRTC_VOICE_ENGINE_CODER_H_ |
| 12 | #define WEBRTC_VOICE_ENGINE_CODER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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: |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 27 | AudioCoder(uint32_t instance_id); |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 28 | ~AudioCoder(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 30 | int32_t SetEncodeCodec(const CodecInst& codec_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 32 | int32_t SetDecodeCodec(const CodecInst& codec_inst); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 34 | int32_t Decode(AudioFrame& decoded_audio, |
| 35 | uint32_t samp_freq_hz, |
| 36 | const int8_t* incoming_payload, |
| 37 | size_t payload_length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 39 | int32_t PlayoutData(AudioFrame& decoded_audio, uint16_t& samp_freq_hz); |
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, |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 42 | int8_t* encoded_data, |
| 43 | size_t& encoded_length_in_bytes); |
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: |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 46 | int32_t SendData(FrameType frame_type, |
| 47 | uint8_t payload_type, |
| 48 | uint32_t time_stamp, |
| 49 | const uint8_t* payload_data, |
| 50 | size_t payload_size, |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 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: |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 54 | std::unique_ptr<AudioCodingModule> acm_; |
kwiberg | 73987c9 | 2016-05-04 05:12:19 -0700 | [diff] [blame] | 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 | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 58 | CodecInst receive_codec_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 60 | uint32_t encode_timestamp_; |
| 61 | int8_t* encoded_data_; |
| 62 | size_t encoded_length_in_bytes_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
kwiberg | 8a70714 | 2016-05-11 04:26:39 -0700 | [diff] [blame] | 64 | uint32_t decode_timestamp_; |
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 | dc65ea2 | 2016-08-15 10:36:32 -0700 | [diff] [blame^] | 68 | #endif // WEBRTC_VOICE_ENGINE_CODER_H_ |