blob: 660a9c0fa024f1ff2573821efe896214e89adbce [file] [log] [blame]
Henrik Lundin45c64492015-03-30 19:00:44 +02001/*
2 * Copyright (c) 2015 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
kjellander3e6db232015-11-26 04:44:54 -080011#ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
12#define WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
Henrik Lundin45c64492015-03-30 19:00:44 +020013
kwiberge1a27d42015-11-18 07:32:49 -080014#include <map>
15
Henrik Lundin45c64492015-03-30 19:00:44 +020016#include "webrtc/base/constructormagic.h"
Karl Wibergbe579832015-11-10 22:34:18 +010017#include "webrtc/base/optional.h"
Henrik Lundin45c64492015-03-30 19:00:44 +020018#include "webrtc/base/thread_checker.h"
kjellander3e6db232015-11-26 04:44:54 -080019#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
20#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
Henrik Lundin45c64492015-03-30 19:00:44 +020021#include "webrtc/common_types.h"
22
23namespace webrtc {
24
25class AudioDecoder;
Karl Wibergbd1bc472015-05-18 12:18:54 +020026class AudioEncoder;
Henrik Lundin45c64492015-03-30 19:00:44 +020027
28namespace acm2 {
29
Henrik Lundin45c64492015-03-30 19:00:44 +020030class CodecManager final {
31 public:
Karl Wibergbd1bc472015-05-18 12:18:54 +020032 CodecManager();
Henrik Lundin45c64492015-03-30 19:00:44 +020033 ~CodecManager();
34
kwiberga6db4952015-12-16 04:19:08 -080035 // Parses the given specification. On success, returns true and updates the
36 // stored CodecInst and stack parameters; on error, returns false.
37 bool RegisterEncoder(const CodecInst& send_codec);
Henrik Lundin45c64492015-03-30 19:00:44 +020038
kwiberga6db4952015-12-16 04:19:08 -080039 static CodecInst ForgeCodecInst(const AudioEncoder* external_speech_encoder);
Karl Wiberg7e0c7d42015-05-18 14:52:29 +020040
kwiberga6db4952015-12-16 04:19:08 -080041 const CodecInst* GetCodecInst() const {
42 return send_codec_inst_ ? &*send_codec_inst_ : nullptr;
43 }
44 const RentACodec::StackParameters* GetStackParams() const {
45 return &codec_stack_params_;
46 }
47 RentACodec::StackParameters* GetStackParams() { return &codec_stack_params_; }
Henrik Lundin45c64492015-03-30 19:00:44 +020048
Henrik Lundin45c64492015-03-30 19:00:44 +020049 bool SetCopyRed(bool enable);
50
kwiberga6db4952015-12-16 04:19:08 -080051 bool SetVAD(bool enable, ACMVADMode mode);
Henrik Lundin45c64492015-03-30 19:00:44 +020052
kwiberga6db4952015-12-16 04:19:08 -080053 bool SetCodecFEC(bool enable_codec_fec);
Henrik Lundin45c64492015-03-30 19:00:44 +020054
Henrik Lundin45c64492015-03-30 19:00:44 +020055 private:
Henrik Lundin45c64492015-03-30 19:00:44 +020056 rtc::ThreadChecker thread_checker_;
kwiberga6db4952015-12-16 04:19:08 -080057 rtc::Optional<CodecInst> send_codec_inst_;
kwiberg1379f1f2015-11-23 04:30:52 -080058 RentACodec::StackParameters codec_stack_params_;
kwiberge1a27d42015-11-18 07:32:49 -080059
henrikg3c089d72015-09-16 05:37:44 -070060 RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
Henrik Lundin45c64492015-03-30 19:00:44 +020061};
62
63} // namespace acm2
64} // namespace webrtc
kjellander3e6db232015-11-26 04:44:54 -080065#endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_