blob: 41a7c59bbf1bc4e1e5e9ca080805af43167c1640 [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
kwibergdc65ea22016-08-15 10:36:32 -070011#ifndef WEBRTC_VOICE_ENGINE_CODER_H_
12#define WEBRTC_VOICE_ENGINE_CODER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg22feaa32016-03-17 09:17:43 -070014#include <memory>
15
pbos@webrtc.org8b062002013-07-12 08:28:10 +000016#include "webrtc/common_types.h"
kwibergc8d071e2016-04-06 12:22:38 -070017#include "webrtc/modules/audio_coding/acm2/codec_manager.h"
18#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
kjellander3e6db232015-11-26 04:44:54 -080019#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
pbos@webrtc.org8b062002013-07-12 08:28:10 +000020#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22namespace webrtc {
23class AudioFrame;
24
kwiberg73987c92016-05-04 05:12:19 -070025class AudioCoder : public AudioPacketizationCallback {
26 public:
kwiberg8a707142016-05-11 04:26:39 -070027 AudioCoder(uint32_t instance_id);
kwiberg73987c92016-05-04 05:12:19 -070028 ~AudioCoder();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
kwiberg8a707142016-05-11 04:26:39 -070030 int32_t SetEncodeCodec(const CodecInst& codec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
kwiberg8a707142016-05-11 04:26:39 -070032 int32_t SetDecodeCodec(const CodecInst& codec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000033
kwiberg8a707142016-05-11 04:26:39 -070034 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.com470e71d2011-07-07 08:21:25 +000038
kwiberg8a707142016-05-11 04:26:39 -070039 int32_t PlayoutData(AudioFrame& decoded_audio, uint16_t& samp_freq_hz);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
kwiberg73987c92016-05-04 05:12:19 -070041 int32_t Encode(const AudioFrame& audio,
kwiberg8a707142016-05-11 04:26:39 -070042 int8_t* encoded_data,
43 size_t& encoded_length_in_bytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000044
kwiberg73987c92016-05-04 05:12:19 -070045 protected:
kwiberg8a707142016-05-11 04:26:39 -070046 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,
kwiberg73987c92016-05-04 05:12:19 -070051 const RTPFragmentationHeader* fragmentation) override;
niklase@google.com470e71d2011-07-07 08:21:25 +000052
kwiberg73987c92016-05-04 05:12:19 -070053 private:
kwiberg8a707142016-05-11 04:26:39 -070054 std::unique_ptr<AudioCodingModule> acm_;
kwiberg73987c92016-05-04 05:12:19 -070055 acm2::CodecManager codec_manager_;
56 acm2::RentACodec rent_a_codec_;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
kwiberg8a707142016-05-11 04:26:39 -070058 CodecInst receive_codec_;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
kwiberg8a707142016-05-11 04:26:39 -070060 uint32_t encode_timestamp_;
61 int8_t* encoded_data_;
62 size_t encoded_length_in_bytes_;
niklase@google.com470e71d2011-07-07 08:21:25 +000063
kwiberg8a707142016-05-11 04:26:39 -070064 uint32_t decode_timestamp_;
niklase@google.com470e71d2011-07-07 08:21:25 +000065};
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000066} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000067
kwibergdc65ea22016-08-15 10:36:32 -070068#endif // WEBRTC_VOICE_ENGINE_CODER_H_