Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_ |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 13 | |
kwiberg | e1a27d4 | 2015-11-18 07:32:49 -0800 | [diff] [blame] | 14 | #include <map> |
| 15 | |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 16 | #include "webrtc/base/constructormagic.h" |
Karl Wiberg | be57983 | 2015-11-10 22:34:18 +0100 | [diff] [blame] | 17 | #include "webrtc/base/optional.h" |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 18 | #include "webrtc/base/thread_checker.h" |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 19 | #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
| 20 | #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 21 | #include "webrtc/common_types.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | class AudioDecoder; |
Karl Wiberg | bd1bc47 | 2015-05-18 12:18:54 +0200 | [diff] [blame] | 26 | class AudioEncoder; |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 27 | |
| 28 | namespace acm2 { |
| 29 | |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 30 | class CodecManager final { |
| 31 | public: |
Karl Wiberg | bd1bc47 | 2015-05-18 12:18:54 +0200 | [diff] [blame] | 32 | CodecManager(); |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 33 | ~CodecManager(); |
| 34 | |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 35 | // 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 Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 38 | |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 39 | static CodecInst ForgeCodecInst(const AudioEncoder* external_speech_encoder); |
Karl Wiberg | 7e0c7d4 | 2015-05-18 14:52:29 +0200 | [diff] [blame] | 40 | |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 41 | const CodecInst* GetCodecInst() const { |
| 42 | return send_codec_inst_ ? &*send_codec_inst_ : nullptr; |
| 43 | } |
kwiberg | 6030a12 | 2016-03-08 06:01:31 -0800 | [diff] [blame] | 44 | |
| 45 | void UnsetCodecInst() { send_codec_inst_ = rtc::Optional<CodecInst>(); } |
| 46 | |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 47 | const RentACodec::StackParameters* GetStackParams() const { |
| 48 | return &codec_stack_params_; |
| 49 | } |
| 50 | RentACodec::StackParameters* GetStackParams() { return &codec_stack_params_; } |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 51 | |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 52 | bool SetCopyRed(bool enable); |
| 53 | |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 54 | bool SetVAD(bool enable, ACMVADMode mode); |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 55 | |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 56 | bool SetCodecFEC(bool enable_codec_fec); |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 57 | |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 58 | private: |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 59 | rtc::ThreadChecker thread_checker_; |
kwiberg | a6db495 | 2015-12-16 04:19:08 -0800 | [diff] [blame] | 60 | rtc::Optional<CodecInst> send_codec_inst_; |
kwiberg | 1379f1f | 2015-11-23 04:30:52 -0800 | [diff] [blame] | 61 | RentACodec::StackParameters codec_stack_params_; |
kwiberg | e1a27d4 | 2015-11-18 07:32:49 -0800 | [diff] [blame] | 62 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 63 | RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager); |
Henrik Lundin | 45c6449 | 2015-03-30 19:00:44 +0200 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } // namespace acm2 |
| 67 | } // namespace webrtc |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 68 | #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_ |