blob: 22dbf4e72bbd6dec4349b52e9c2b3e9be1f31665 [file] [log] [blame]
Henrik Lundin45c64492015-03-30 17:00:441/*
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
Mirko Bonadei92ea95e2017-09-15 04:47:3111#ifndef MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
12#define MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
Henrik Lundin45c64492015-03-30 17:00:4413
Danil Chapovalovb6021232018-06-19 11:26:3614#include "absl/types/optional.h"
Mirko Bonadei71207422017-09-15 11:58:0915#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 04:47:3116#include "modules/audio_coding/acm2/rent_a_codec.h"
17#include "modules/audio_coding/include/audio_coding_module.h"
18#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
19#include "rtc_base/constructormagic.h"
20#include "rtc_base/thread_checker.h"
Henrik Lundin45c64492015-03-30 17:00:4421
22namespace webrtc {
23
Karl Wibergbd1bc472015-05-18 10:18:5424class AudioEncoder;
Henrik Lundin45c64492015-03-30 17:00:4425
26namespace acm2 {
27
Henrik Lundin45c64492015-03-30 17:00:4428class CodecManager final {
29 public:
Karl Wibergbd1bc472015-05-18 10:18:5430 CodecManager();
Henrik Lundin45c64492015-03-30 17:00:4431 ~CodecManager();
32
kwiberga6db4952015-12-16 12:19:0833 // Parses the given specification. On success, returns true and updates the
34 // stored CodecInst and stack parameters; on error, returns false.
35 bool RegisterEncoder(const CodecInst& send_codec);
Henrik Lundin45c64492015-03-30 17:00:4436
kwiberga6db4952015-12-16 12:19:0837 static CodecInst ForgeCodecInst(const AudioEncoder* external_speech_encoder);
Karl Wiberg7e0c7d42015-05-18 12:52:2938
kwiberga6db4952015-12-16 12:19:0839 const CodecInst* GetCodecInst() const {
40 return send_codec_inst_ ? &*send_codec_inst_ : nullptr;
41 }
kwiberg6030a122016-03-08 14:01:3142
Danil Chapovalovb6021232018-06-19 11:26:3643 void UnsetCodecInst() { send_codec_inst_ = absl::nullopt; }
kwiberg6030a122016-03-08 14:01:3144
kwiberga6db4952015-12-16 12:19:0845 const RentACodec::StackParameters* GetStackParams() const {
46 return &codec_stack_params_;
47 }
48 RentACodec::StackParameters* GetStackParams() { return &codec_stack_params_; }
Henrik Lundin45c64492015-03-30 17:00:4449
Henrik Lundin45c64492015-03-30 17:00:4450 bool SetCopyRed(bool enable);
51
kwiberga6db4952015-12-16 12:19:0852 bool SetVAD(bool enable, ACMVADMode mode);
Henrik Lundin45c64492015-03-30 17:00:4453
kwiberga6db4952015-12-16 12:19:0854 bool SetCodecFEC(bool enable_codec_fec);
Henrik Lundin45c64492015-03-30 17:00:4455
kwibergc8d071e2016-04-06 19:22:3856 // Uses the provided Rent-A-Codec to create a new encoder stack, if we have a
57 // complete specification; if so, it is then passed to set_encoder. On error,
58 // returns false.
kwiberg3f81fcd2016-06-23 10:58:3659 bool MakeEncoder(RentACodec* rac, AudioCodingModule* acm);
kwibergc8d071e2016-04-06 19:22:3860
Henrik Lundin45c64492015-03-30 17:00:4461 private:
Henrik Lundin45c64492015-03-30 17:00:4462 rtc::ThreadChecker thread_checker_;
Danil Chapovalovb6021232018-06-19 11:26:3663 absl::optional<CodecInst> send_codec_inst_;
kwiberg1379f1f2015-11-23 12:30:5264 RentACodec::StackParameters codec_stack_params_;
kwiberg3f81fcd2016-06-23 10:58:3665 bool recreate_encoder_ = true; // Need to recreate encoder?
kwiberge1a27d42015-11-18 15:32:4966
henrikg3c089d72015-09-16 12:37:4467 RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
Henrik Lundin45c64492015-03-30 17:00:4468};
69
70} // namespace acm2
71} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 04:47:3172#endif // MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_