OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 27 matching lines...) Expand all Loading... |
38 ///////////////////////////////////////// | 38 ///////////////////////////////////////// |
39 // Sender | 39 // Sender |
40 // | 40 // |
41 | 41 |
42 // Can be called multiple times for Codec, CNG, RED. | 42 // Can be called multiple times for Codec, CNG, RED. |
43 int RegisterSendCodec(const CodecInst& send_codec) override; | 43 int RegisterSendCodec(const CodecInst& send_codec) override; |
44 | 44 |
45 void RegisterExternalSendCodec( | 45 void RegisterExternalSendCodec( |
46 AudioEncoder* external_speech_encoder) override; | 46 AudioEncoder* external_speech_encoder) override; |
47 | 47 |
48 void ModifyEncoder( | 48 void ModifyEncoder(rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> |
49 FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) override; | 49 modifier) override; |
50 | 50 |
51 void QueryEncoder(FunctionView<void(const AudioEncoder*)> query) override; | 51 void QueryEncoder( |
| 52 rtc::FunctionView<void(const AudioEncoder*)> query) override; |
52 | 53 |
53 // Get current send codec. | 54 // Get current send codec. |
54 rtc::Optional<CodecInst> SendCodec() const override; | 55 rtc::Optional<CodecInst> SendCodec() const override; |
55 | 56 |
56 // Get current send frequency. | 57 // Get current send frequency. |
57 int SendFrequency() const override; | 58 int SendFrequency() const override; |
58 | 59 |
59 // Sets the bitrate to the specified value in bits/sec. In case the codec does | 60 // Sets the bitrate to the specified value in bits/sec. In case the codec does |
60 // not support the requested value it will choose an appropriate value | 61 // not support the requested value it will choose an appropriate value |
61 // instead. | 62 // instead. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 117 |
117 // Get current receive frequency. | 118 // Get current receive frequency. |
118 int ReceiveFrequency() const override; | 119 int ReceiveFrequency() const override; |
119 | 120 |
120 // Get current playout frequency. | 121 // Get current playout frequency. |
121 int PlayoutFrequency() const override; | 122 int PlayoutFrequency() const override; |
122 | 123 |
123 int RegisterReceiveCodec(const CodecInst& receive_codec) override; | 124 int RegisterReceiveCodec(const CodecInst& receive_codec) override; |
124 int RegisterReceiveCodec( | 125 int RegisterReceiveCodec( |
125 const CodecInst& receive_codec, | 126 const CodecInst& receive_codec, |
126 FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) override; | 127 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) override; |
127 | 128 |
128 int RegisterExternalReceiveCodec(int rtp_payload_type, | 129 int RegisterExternalReceiveCodec(int rtp_payload_type, |
129 AudioDecoder* external_decoder, | 130 AudioDecoder* external_decoder, |
130 int sample_rate_hz, | 131 int sample_rate_hz, |
131 int num_channels, | 132 int num_channels, |
132 const std::string& name) override; | 133 const std::string& name) override; |
133 | 134 |
134 // Get current received codec. | 135 // Get current received codec. |
135 int ReceiveCodec(CodecInst* current_codec) const override; | 136 int ReceiveCodec(CodecInst* current_codec) const override; |
136 | 137 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 void MaybeLog(int value); | 217 void MaybeLog(int value); |
217 | 218 |
218 private: | 219 private: |
219 int last_value_ = 0; | 220 int last_value_ = 0; |
220 int first_time_ = true; | 221 int first_time_ = true; |
221 const std::string histogram_name_; | 222 const std::string histogram_name_; |
222 }; | 223 }; |
223 | 224 |
224 int RegisterReceiveCodecUnlocked( | 225 int RegisterReceiveCodecUnlocked( |
225 const CodecInst& codec, | 226 const CodecInst& codec, |
226 FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) | 227 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) |
227 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); | 228 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); |
228 | 229 |
229 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data) | 230 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data) |
230 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); | 231 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); |
231 int Encode(const InputData& input_data) | 232 int Encode(const InputData& input_data) |
232 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); | 233 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); |
233 | 234 |
234 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); | 235 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); |
235 | 236 |
236 bool HaveValidEncoder(const char* caller_name) const | 237 bool HaveValidEncoder(const char* caller_name) const |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 rtc::CritScope lock(&acm_crit_sect_); | 581 rtc::CritScope lock(&acm_crit_sect_); |
581 encoder_factory_->codec_manager.UnsetCodecInst(); | 582 encoder_factory_->codec_manager.UnsetCodecInst(); |
582 encoder_factory_->external_speech_encoder = external_speech_encoder; | 583 encoder_factory_->external_speech_encoder = external_speech_encoder; |
583 RTC_CHECK(CreateSpeechEncoderIfNecessary(encoder_factory_.get())); | 584 RTC_CHECK(CreateSpeechEncoderIfNecessary(encoder_factory_.get())); |
584 auto* sp = encoder_factory_->codec_manager.GetStackParams(); | 585 auto* sp = encoder_factory_->codec_manager.GetStackParams(); |
585 RTC_CHECK(sp->speech_encoder); | 586 RTC_CHECK(sp->speech_encoder); |
586 encoder_stack_ = encoder_factory_->rent_a_codec.RentEncoderStack(sp); | 587 encoder_stack_ = encoder_factory_->rent_a_codec.RentEncoderStack(sp); |
587 } | 588 } |
588 | 589 |
589 void AudioCodingModuleImpl::ModifyEncoder( | 590 void AudioCodingModuleImpl::ModifyEncoder( |
590 FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) { | 591 rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) { |
591 rtc::CritScope lock(&acm_crit_sect_); | 592 rtc::CritScope lock(&acm_crit_sect_); |
592 | 593 |
593 // Wipe the encoder factory, so that everything that relies on it will fail. | 594 // Wipe the encoder factory, so that everything that relies on it will fail. |
594 // We don't want the complexity of supporting swapping back and forth. | 595 // We don't want the complexity of supporting swapping back and forth. |
595 if (encoder_factory_) { | 596 if (encoder_factory_) { |
596 encoder_factory_.reset(); | 597 encoder_factory_.reset(); |
597 RTC_CHECK(!encoder_stack_); // Ensure we hadn't started using the factory. | 598 RTC_CHECK(!encoder_stack_); // Ensure we hadn't started using the factory. |
598 } | 599 } |
599 | 600 |
600 modifier(&encoder_stack_); | 601 modifier(&encoder_stack_); |
601 } | 602 } |
602 | 603 |
603 void AudioCodingModuleImpl::QueryEncoder( | 604 void AudioCodingModuleImpl::QueryEncoder( |
604 FunctionView<void(const AudioEncoder*)> query) { | 605 rtc::FunctionView<void(const AudioEncoder*)> query) { |
605 rtc::CritScope lock(&acm_crit_sect_); | 606 rtc::CritScope lock(&acm_crit_sect_); |
606 query(encoder_stack_.get()); | 607 query(encoder_stack_.get()); |
607 } | 608 } |
608 | 609 |
609 // Get current send codec. | 610 // Get current send codec. |
610 rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const { | 611 rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const { |
611 rtc::CritScope lock(&acm_crit_sect_); | 612 rtc::CritScope lock(&acm_crit_sect_); |
612 if (encoder_factory_) { | 613 if (encoder_factory_) { |
613 auto* ci = encoder_factory_->codec_manager.GetCodecInst(); | 614 auto* ci = encoder_factory_->codec_manager.GetCodecInst(); |
614 if (ci) { | 615 if (ci) { |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 | 989 |
989 int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) { | 990 int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) { |
990 rtc::CritScope lock(&acm_crit_sect_); | 991 rtc::CritScope lock(&acm_crit_sect_); |
991 auto* ef = encoder_factory_.get(); | 992 auto* ef = encoder_factory_.get(); |
992 return RegisterReceiveCodecUnlocked( | 993 return RegisterReceiveCodecUnlocked( |
993 codec, [&] { return ef->rent_a_codec.RentIsacDecoder(codec.plfreq); }); | 994 codec, [&] { return ef->rent_a_codec.RentIsacDecoder(codec.plfreq); }); |
994 } | 995 } |
995 | 996 |
996 int AudioCodingModuleImpl::RegisterReceiveCodec( | 997 int AudioCodingModuleImpl::RegisterReceiveCodec( |
997 const CodecInst& codec, | 998 const CodecInst& codec, |
998 FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) { | 999 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) { |
999 rtc::CritScope lock(&acm_crit_sect_); | 1000 rtc::CritScope lock(&acm_crit_sect_); |
1000 return RegisterReceiveCodecUnlocked(codec, isac_factory); | 1001 return RegisterReceiveCodecUnlocked(codec, isac_factory); |
1001 } | 1002 } |
1002 | 1003 |
1003 int AudioCodingModuleImpl::RegisterReceiveCodecUnlocked( | 1004 int AudioCodingModuleImpl::RegisterReceiveCodecUnlocked( |
1004 const CodecInst& codec, | 1005 const CodecInst& codec, |
1005 FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) { | 1006 rtc::FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) { |
1006 RTC_DCHECK(receiver_initialized_); | 1007 RTC_DCHECK(receiver_initialized_); |
1007 if (codec.channels > 2) { | 1008 if (codec.channels > 2) { |
1008 LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels; | 1009 LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels; |
1009 return -1; | 1010 return -1; |
1010 } | 1011 } |
1011 | 1012 |
1012 auto codec_id = acm2::RentACodec::CodecIdByParams(codec.plname, codec.plfreq, | 1013 auto codec_id = acm2::RentACodec::CodecIdByParams(codec.plname, codec.plfreq, |
1013 codec.channels); | 1014 codec.channels); |
1014 if (!codec_id) { | 1015 if (!codec_id) { |
1015 LOG_F(LS_ERROR) << "Wrong codec params to be registered as receive codec"; | 1016 LOG_F(LS_ERROR) << "Wrong codec params to be registered as receive codec"; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 // Checks the validity of the parameters of the given codec | 1356 // Checks the validity of the parameters of the given codec |
1356 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { | 1357 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { |
1357 bool valid = acm2::RentACodec::IsCodecValid(codec); | 1358 bool valid = acm2::RentACodec::IsCodecValid(codec); |
1358 if (!valid) | 1359 if (!valid) |
1359 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, | 1360 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, |
1360 "Invalid codec setting"); | 1361 "Invalid codec setting"); |
1361 return valid; | 1362 return valid; |
1362 } | 1363 } |
1363 | 1364 |
1364 } // namespace webrtc | 1365 } // namespace webrtc |
OLD | NEW |