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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 bool SetCopyRed(bool enable); | 53 bool SetCopyRed(bool enable); |
54 | 54 |
55 bool SetVAD(bool enable, ACMVADMode mode); | 55 bool SetVAD(bool enable, ACMVADMode mode); |
56 | 56 |
57 bool SetCodecFEC(bool enable_codec_fec); | 57 bool SetCodecFEC(bool enable_codec_fec); |
58 | 58 |
59 // Uses the provided Rent-A-Codec to create a new encoder stack, if we have a | 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, | 60 // complete specification; if so, it is then passed to set_encoder. On error, |
61 // returns false. | 61 // returns false. |
62 bool MakeEncoder(RentACodec* rac, AudioCodingModule* acm) { | 62 bool MakeEncoder(RentACodec* rac, AudioCodingModule* acm); |
63 RTC_DCHECK(rac); | |
64 RTC_DCHECK(acm); | |
65 if (!codec_stack_params_.speech_encoder && send_codec_inst_) { | |
66 // We have no speech encoder, but we have a specification for making one. | |
67 auto enc = rac->RentEncoder(*send_codec_inst_); | |
68 if (!enc) | |
69 return false; | |
70 codec_stack_params_.speech_encoder = std::move(enc); | |
71 } | |
72 auto stack = rac->RentEncoderStack(&codec_stack_params_); | |
73 if (stack) { | |
74 // Give new encoder stack to the ACM. | |
75 acm->SetEncoder(std::move(stack)); | |
76 } else { | |
77 // The specification was good but incomplete, so we have no encoder stack | |
78 // to give to the ACM. | |
79 } | |
80 return true; | |
81 } | |
82 | 63 |
83 private: | 64 private: |
84 rtc::ThreadChecker thread_checker_; | 65 rtc::ThreadChecker thread_checker_; |
85 rtc::Optional<CodecInst> send_codec_inst_; | 66 rtc::Optional<CodecInst> send_codec_inst_; |
86 RentACodec::StackParameters codec_stack_params_; | 67 RentACodec::StackParameters codec_stack_params_; |
| 68 bool recreate_encoder_ = true; // Need to recreate encoder? |
87 | 69 |
88 RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager); | 70 RTC_DISALLOW_COPY_AND_ASSIGN(CodecManager); |
89 }; | 71 }; |
90 | 72 |
91 } // namespace acm2 | 73 } // namespace acm2 |
92 } // namespace webrtc | 74 } // namespace webrtc |
93 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_ | 75 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_CODEC_MANAGER_H_ |
OLD | NEW |