| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_CODEC_MANAGER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_CODEC_MANAGER_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_CODEC_MANAGER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_CODEC_MANAGER_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
| 15 #include "webrtc/base/scoped_ptr.h" | 15 #include "webrtc/base/scoped_ptr.h" |
| 16 #include "webrtc/base/thread_checker.h" | 16 #include "webrtc/base/thread_checker.h" |
| 17 #include "webrtc/modules/audio_coding/main/acm2/codec_owner.h" | 17 #include "webrtc/modules/audio_coding/main/acm2/codec_owner.h" |
| 18 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef
s.h" | 18 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedef
s.h" |
| 19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 | 22 |
| 23 class AudioDecoder; | 23 class AudioDecoder; |
| 24 class AudioEncoder; | 24 class AudioEncoder; |
| 25 class AudioEncoderMutable; | |
| 26 | 25 |
| 27 namespace acm2 { | 26 namespace acm2 { |
| 28 | 27 |
| 29 class CodecManager final { | 28 class CodecManager final { |
| 30 public: | 29 public: |
| 31 CodecManager(); | 30 CodecManager(); |
| 32 ~CodecManager(); | 31 ~CodecManager(); |
| 33 | 32 |
| 34 int RegisterEncoder(const CodecInst& send_codec); | 33 int RegisterEncoder(const CodecInst& send_codec); |
| 35 | 34 |
| 36 void RegisterEncoder(AudioEncoderMutable* external_speech_encoder); | 35 void RegisterEncoder(AudioEncoder* external_speech_encoder); |
| 37 | 36 |
| 38 int GetCodecInst(CodecInst* current_codec) const; | 37 int GetCodecInst(CodecInst* current_codec) const; |
| 39 | 38 |
| 40 bool SetCopyRed(bool enable); | 39 bool SetCopyRed(bool enable); |
| 41 | 40 |
| 42 int SetVAD(bool enable, ACMVADMode mode); | 41 int SetVAD(bool enable, ACMVADMode mode); |
| 43 | 42 |
| 44 void VAD(bool* dtx_enabled, bool* vad_enabled, ACMVADMode* mode) const; | 43 void VAD(bool* dtx_enabled, bool* vad_enabled, ACMVADMode* mode) const; |
| 45 | 44 |
| 46 int SetCodecFEC(bool enable_codec_fec); | 45 int SetCodecFEC(bool enable_codec_fec); |
| 47 | 46 |
| 48 // Returns a pointer to AudioDecoder of the given codec. For iSAC, encoding | 47 // Returns a pointer to AudioDecoder of the given codec. For iSAC, encoding |
| 49 // and decoding have to be performed on a shared codec instance. By calling | 48 // and decoding have to be performed on a shared codec instance. By calling |
| 50 // this method, we get the codec instance that ACM owns. | 49 // this method, we get the codec instance that ACM owns. |
| 51 // If |codec| does not share an instance between encoder and decoder, returns | 50 // If |codec| does not share an instance between encoder and decoder, returns |
| 52 // null. | 51 // null. |
| 53 AudioDecoder* GetAudioDecoder(const CodecInst& codec); | 52 AudioDecoder* GetAudioDecoder(const CodecInst& codec); |
| 54 | 53 |
| 55 bool stereo_send() const { return stereo_send_; } | 54 bool stereo_send() const { return stereo_send_; } |
| 56 | 55 |
| 57 bool red_enabled() const { return red_enabled_; } | 56 bool red_enabled() const { return red_enabled_; } |
| 58 | 57 |
| 59 bool codec_fec_enabled() const { return codec_fec_enabled_; } | 58 bool codec_fec_enabled() const { return codec_fec_enabled_; } |
| 60 | 59 |
| 61 AudioEncoderMutable* CurrentSpeechEncoder() { | |
| 62 return codec_owner_.SpeechEncoder(); | |
| 63 } | |
| 64 AudioEncoder* CurrentEncoder() { return codec_owner_.Encoder(); } | 60 AudioEncoder* CurrentEncoder() { return codec_owner_.Encoder(); } |
| 65 const AudioEncoder* CurrentEncoder() const { return codec_owner_.Encoder(); } | 61 const AudioEncoder* CurrentEncoder() const { return codec_owner_.Encoder(); } |
| 66 | 62 |
| 63 bool CurrentEncoderIsOpus() const { return encoder_is_opus_; } |
| 64 |
| 67 private: | 65 private: |
| 68 int CngPayloadType(int sample_rate_hz) const; | 66 int CngPayloadType(int sample_rate_hz) const; |
| 69 | 67 |
| 70 int RedPayloadType(int sample_rate_hz) const; | 68 int RedPayloadType(int sample_rate_hz) const; |
| 71 | 69 |
| 72 rtc::ThreadChecker thread_checker_; | 70 rtc::ThreadChecker thread_checker_; |
| 73 uint8_t cng_nb_pltype_; | 71 uint8_t cng_nb_pltype_; |
| 74 uint8_t cng_wb_pltype_; | 72 uint8_t cng_wb_pltype_; |
| 75 uint8_t cng_swb_pltype_; | 73 uint8_t cng_swb_pltype_; |
| 76 uint8_t cng_fb_pltype_; | 74 uint8_t cng_fb_pltype_; |
| 77 uint8_t red_nb_pltype_; | 75 uint8_t red_nb_pltype_; |
| 78 bool stereo_send_; | 76 bool stereo_send_; |
| 79 bool dtx_enabled_; | 77 bool dtx_enabled_; |
| 80 ACMVADMode vad_mode_; | 78 ACMVADMode vad_mode_; |
| 81 CodecInst send_codec_inst_; | 79 CodecInst send_codec_inst_; |
| 82 bool red_enabled_; | 80 bool red_enabled_; |
| 83 bool codec_fec_enabled_; | 81 bool codec_fec_enabled_; |
| 84 CodecOwner codec_owner_; | 82 CodecOwner codec_owner_; |
| 83 bool encoder_is_opus_; |
| 85 | 84 |
| 86 DISALLOW_COPY_AND_ASSIGN(CodecManager); | 85 DISALLOW_COPY_AND_ASSIGN(CodecManager); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace acm2 | 88 } // namespace acm2 |
| 90 } // namespace webrtc | 89 } // namespace webrtc |
| 91 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_CODEC_MANAGER_H_ | 90 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_CODEC_MANAGER_H_ |
| OLD | NEW |