blob: fbd3a18b188efa203949159bf0e0b8c9bde353b3 [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 }
kwiberg6030a122016-03-08 06:01:31 -080044
45 void UnsetCodecInst() { send_codec_inst_ = rtc::Optional<CodecInst>(); }
46
kwiberga6db4952015-12-16 04:19:08 -080047 const RentACodec::StackParameters* GetStackParams() const {
48 return &codec_stack_params_;
49 }
50 RentACodec::StackParameters* GetStackParams() { return &codec_stack_params_; }
Henrik Lundin45c64492015-03-30 19:00:44 +020051
Henrik Lundin45c64492015-03-30 19:00:44 +020052 bool SetCopyRed(bool enable);
53
kwiberga6db4952015-12-16 04:19:08 -080054 bool SetVAD(bool enable, ACMVADMode mode);
Henrik Lundin45c64492015-03-30 19:00:44 +020055
kwiberga6db4952015-12-16 04:19:08 -080056 bool SetCodecFEC(bool enable_codec_fec);
Henrik Lundin45c64492015-03-30 19:00:44 +020057
Henrik Lundin45c64492015-03-30 19:00:44 +020058 private:
Henrik Lundin45c64492015-03-30 19:00:44 +020059 rtc::ThreadChecker thread_checker_;
kwiberga6db4952015-12-16 04:19:08 -080060 rtc::Optional<CodecInst> send_codec_inst_;
kwiberg1379f1f2015-11-23 04:30:52 -080061 RentACodec::StackParameters codec_stack_params_;
kwiberge1a27d42015-11-18 07:32:49 -080062
henrikg3c089d72015-09-16 05:37:44 -070063 RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
Henrik Lundin45c64492015-03-30 19:00:44 +020064};
65
66} // namespace acm2
67} // namespace webrtc
kjellander3e6db232015-11-26 04:44:54 -080068#endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_