Line data Source code
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 :
11 : #ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
12 : #define WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
13 :
14 : #include <map>
15 :
16 : #include "webrtc/base/constructormagic.h"
17 : #include "webrtc/base/optional.h"
18 : #include "webrtc/base/thread_checker.h"
19 : #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
20 : #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
21 : #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
22 : #include "webrtc/common_types.h"
23 :
24 : namespace webrtc {
25 :
26 : class AudioDecoder;
27 : class AudioEncoder;
28 :
29 : namespace acm2 {
30 :
31 0 : class CodecManager final {
32 : public:
33 : CodecManager();
34 : ~CodecManager();
35 :
36 : // 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);
39 :
40 : static CodecInst ForgeCodecInst(const AudioEncoder* external_speech_encoder);
41 :
42 0 : const CodecInst* GetCodecInst() const {
43 0 : return send_codec_inst_ ? &*send_codec_inst_ : nullptr;
44 : }
45 :
46 0 : void UnsetCodecInst() { send_codec_inst_ = rtc::Optional<CodecInst>(); }
47 :
48 : const RentACodec::StackParameters* GetStackParams() const {
49 : return &codec_stack_params_;
50 : }
51 0 : RentACodec::StackParameters* GetStackParams() { return &codec_stack_params_; }
52 :
53 : bool SetCopyRed(bool enable);
54 :
55 : bool SetVAD(bool enable, ACMVADMode mode);
56 :
57 : bool SetCodecFEC(bool enable_codec_fec);
58 :
59 : // Uses the provided Rent-A-Codec to create a new encoder stack, if we have a
60 : // complete specification; if so, it is then passed to set_encoder. On error,
61 : // returns false.
62 : bool MakeEncoder(RentACodec* rac, AudioCodingModule* acm);
63 :
64 : private:
65 : rtc::ThreadChecker thread_checker_;
66 : rtc::Optional<CodecInst> send_codec_inst_;
67 : RentACodec::StackParameters codec_stack_params_;
68 : bool recreate_encoder_ = true; // Need to recreate encoder?
69 :
70 : RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
71 : };
72 :
73 : } // namespace acm2
74 : } // namespace webrtc
75 : #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
|