blob: cd17574784b644352c3c23f90f02718d1bc0f8fe [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
11#ifndef WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
12#define WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_
13
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:
27 AudioCoder(uint32_t instanceID);
28 ~AudioCoder();
niklase@google.com470e71d2011-07-07 08:21:25 +000029
kwiberg73987c92016-05-04 05:12:19 -070030 int32_t SetEncodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000031
kwiberg73987c92016-05-04 05:12:19 -070032 int32_t SetDecodeCodec(const CodecInst& codecInst);
niklase@google.com470e71d2011-07-07 08:21:25 +000033
kwiberg73987c92016-05-04 05:12:19 -070034 int32_t Decode(AudioFrame& decodedAudio,
35 uint32_t sampFreqHz,
36 const int8_t* incomingPayload,
37 size_t payloadLength);
niklase@google.com470e71d2011-07-07 08:21:25 +000038
kwiberg73987c92016-05-04 05:12:19 -070039 int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
kwiberg73987c92016-05-04 05:12:19 -070041 int32_t Encode(const AudioFrame& audio,
42 int8_t* encodedData,
43 size_t& encodedLengthInBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +000044
kwiberg73987c92016-05-04 05:12:19 -070045 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.com470e71d2011-07-07 08:21:25 +000052
kwiberg73987c92016-05-04 05:12:19 -070053 private:
54 std::unique_ptr<AudioCodingModule> _acm;
55 acm2::CodecManager codec_manager_;
56 acm2::RentACodec rent_a_codec_;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
kwiberg73987c92016-05-04 05:12:19 -070058 CodecInst _receiveCodec;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
kwiberg73987c92016-05-04 05:12:19 -070060 uint32_t _encodeTimestamp;
61 int8_t* _encodedData;
62 size_t _encodedLengthInBytes;
niklase@google.com470e71d2011-07-07 08:21:25 +000063
kwiberg73987c92016-05-04 05:12:19 -070064 uint32_t _decodeTimestamp;
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
kwiberg73987c92016-05-04 05:12:19 -070068#endif // WEBRTC_MODULES_UTILITY_SOURCE_CODER_H_