Home | History | Annotate | Download | only in acm2
      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/scoped_ptr.h"
     19 #include "webrtc/base/thread_checker.h"
     20 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.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 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   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_; }
     49 
     50   bool SetCopyRed(bool enable);
     51 
     52   bool SetVAD(bool enable, ACMVADMode mode);
     53 
     54   bool SetCodecFEC(bool enable_codec_fec);
     55 
     56  private:
     57   rtc::ThreadChecker thread_checker_;
     58   rtc::Optional<CodecInst> send_codec_inst_;
     59   RentACodec::StackParameters codec_stack_params_;
     60 
     61   RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager);
     62 };
     63 
     64 }  // namespace acm2
     65 }  // namespace webrtc
     66 #endif  // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_
     67