blob: 9227e13f09ad14077af9cab46c7fdf39611e268c [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"
Karl Wiberg2ea71c32015-05-07 15:49:23 +020018#include "webrtc/base/scoped_ptr.h"
Henrik Lundin45c64492015-03-30 19:00:44 +020019#include "webrtc/base/thread_checker.h"
kjellander3e6db232015-11-26 04:44:54 -080020#include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
21#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
Henrik Lundin45c64492015-03-30 19:00:44 +020022#include "webrtc/common_types.h"
23
24namespace webrtc {
25
26class AudioDecoder;
Karl Wibergbd1bc472015-05-18 12:18:54 +020027class AudioEncoder;
Henrik Lundin45c64492015-03-30 19:00:44 +020028
29namespace acm2 {
30
Henrik Lundin45c64492015-03-30 19:00:44 +020031class CodecManager final {
32 public:
Karl Wibergbd1bc472015-05-18 12:18:54 +020033 CodecManager();
Henrik Lundin45c64492015-03-30 19:00:44 +020034 ~CodecManager();
35
kwiberga6db4952015-12-16 04:19:08 -080036 // Parses the given specification. On success, returns true and updates the
37 // stored CodecInst and stack parameters; on error, returns false.
38 bool RegisterEncoder(const CodecInst& send_codec);
Henrik Lundin45c64492015-03-30 19:00:44 +020039
kwiberga6db4952015-12-16 04:19:08 -080040 static CodecInst ForgeCodecInst(const AudioEncoder* external_speech_encoder);
Karl Wiberg7e0c7d42015-05-18 14:52:29 +020041
kwiberga6db4952015-12-16 04:19:08 -080042 const CodecInst* GetCodecInst() const {
43 return send_codec_inst_ ? &*send_codec_inst_ : nullptr;
44 }
45 const RentACodec::StackParameters* GetStackParams() const {
46 return &codec_stack_params_;
47 }
48 RentACodec::StackParameters* GetStackParams() { return &codec_stack_params_; }
Henrik Lundin45c64492015-03-30 19:00:44 +020049
Henrik Lundin45c64492015-03-30 19:00:44 +020050 bool SetCopyRed(bool enable);
51
kwiberga6db4952015-12-16 04:19:08 -080052 bool SetVAD(bool enable, ACMVADMode mode);
Henrik Lundin45c64492015-03-30 19:00:44 +020053
kwiberga6db4952015-12-16 04:19:08 -080054 bool SetCodecFEC(bool enable_codec_fec);
Henrik Lundin45c64492015-03-30 19:00:44 +020055
Henrik Lundin45c64492015-03-30 19:00:44 +020056 private:
Henrik Lundin45c64492015-03-30 19:00:44 +020057 rtc::ThreadChecker thread_checker_;
kwiberga6db4952015-12-16 04:19:08 -080058 rtc::Optional<CodecInst> send_codec_inst_;
kwiberg1379f1f2015-11-23 04:30:52 -080059 RentACodec::StackParameters codec_stack_params_;
kwiberge1a27d42015-11-18 07:32:49 -080060
henrikg3c089d72015-09-16 05:37:44 -070061 RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
Henrik Lundin45c64492015-03-30 19:00:44 +020062};
63
64} // namespace acm2
65} // namespace webrtc
kjellander3e6db232015-11-26 04:44:54 -080066#endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_