Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc

Issue 1308283003: Remove no-op and unused methods from AudioCodingModule (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 } 229 }
230 previous_pltype_ = encoded_info.payload_type; 230 previous_pltype_ = encoded_info.payload_type;
231 return static_cast<int32_t>(encoded_info.encoded_bytes); 231 return static_cast<int32_t>(encoded_info.encoded_bytes);
232 } 232 }
233 233
234 ///////////////////////////////////////// 234 /////////////////////////////////////////
235 // Sender 235 // Sender
236 // 236 //
237 237
238 // TODO(henrik.lundin): Remove this method; only used in tests.
239 int AudioCodingModuleImpl::ResetEncoder() {
240 CriticalSectionScoped lock(acm_crit_sect_);
241 if (!HaveValidEncoder("ResetEncoder")) {
242 return -1;
243 }
244 return 0;
245 }
246
247 // Can be called multiple times for Codec, CNG, RED. 238 // Can be called multiple times for Codec, CNG, RED.
248 int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) { 239 int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) {
249 CriticalSectionScoped lock(acm_crit_sect_); 240 CriticalSectionScoped lock(acm_crit_sect_);
250 return codec_manager_.RegisterEncoder(send_codec); 241 return codec_manager_.RegisterEncoder(send_codec);
251 } 242 }
252 243
253 void AudioCodingModuleImpl::RegisterExternalSendCodec( 244 void AudioCodingModuleImpl::RegisterExternalSendCodec(
254 AudioEncoderMutable* external_speech_encoder) { 245 AudioEncoderMutable* external_speech_encoder) {
255 CriticalSectionScoped lock(acm_crit_sect_); 246 CriticalSectionScoped lock(acm_crit_sect_);
256 codec_manager_.RegisterEncoder(external_speech_encoder); 247 codec_manager_.RegisterEncoder(external_speech_encoder);
(...skipping 13 matching lines...) Expand all
270 261
271 if (!codec_manager_.CurrentEncoder()) { 262 if (!codec_manager_.CurrentEncoder()) {
272 WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, 263 WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
273 "SendFrequency Failed, no codec is registered"); 264 "SendFrequency Failed, no codec is registered");
274 return -1; 265 return -1;
275 } 266 }
276 267
277 return codec_manager_.CurrentEncoder()->SampleRateHz(); 268 return codec_manager_.CurrentEncoder()->SampleRateHz();
278 } 269 }
279 270
280 // Get encode bitrate.
281 // Adaptive rate codecs return their current encode target rate, while other
282 // codecs return there longterm avarage or their fixed rate.
283 // TODO(henrik.lundin): Remove; not used.
284 int AudioCodingModuleImpl::SendBitrate() const {
285 FATAL() << "Deprecated";
286 // This return statement is required to workaround a bug in VS2013 Update 4
287 // when turning on the whole program optimizations. Without hit the linker
288 // will hang because it doesn't seem to find an exit path for this function.
289 // This is likely a bug in link.exe and would probably be fixed in VS2015.
290 return -1;
291 // CriticalSectionScoped lock(acm_crit_sect_);
292 //
293 // if (!codec_manager_.current_encoder()) {
294 // WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
295 // "SendBitrate Failed, no codec is registered");
296 // return -1;
297 // }
298 //
299 // WebRtcACMCodecParams encoder_param;
300 // codec_manager_.current_encoder()->EncoderParams(&encoder_param);
301 //
302 // return encoder_param.codec_inst.rate;
303 }
304
305 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) { 271 void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
306 CriticalSectionScoped lock(acm_crit_sect_); 272 CriticalSectionScoped lock(acm_crit_sect_);
307 if (codec_manager_.CurrentEncoder()) { 273 if (codec_manager_.CurrentEncoder()) {
308 codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps); 274 codec_manager_.CurrentEncoder()->SetTargetBitrate(bitrate_bps);
309 } 275 }
310 } 276 }
311 277
312 // Set available bandwidth, inform the encoder about the estimated bandwidth
313 // received from the remote party.
314 // TODO(henrik.lundin): Remove; not used.
315 int AudioCodingModuleImpl::SetReceivedEstimatedBandwidth(int bw) {
316 CriticalSectionScoped lock(acm_crit_sect_);
317 FATAL() << "Dead code?";
318 return -1;
319 // return codecs_[current_send_codec_idx_]->SetEstimatedBandwidth(bw);
320 }
321
322 // Register a transport callback which will be called to deliver 278 // Register a transport callback which will be called to deliver
323 // the encoded buffers. 279 // the encoded buffers.
324 int AudioCodingModuleImpl::RegisterTransportCallback( 280 int AudioCodingModuleImpl::RegisterTransportCallback(
325 AudioPacketizationCallback* transport) { 281 AudioPacketizationCallback* transport) {
326 CriticalSectionScoped lock(callback_crit_sect_); 282 CriticalSectionScoped lock(callback_crit_sect_);
327 packetization_callback_ = transport; 283 packetization_callback_ = transport;
328 return 0; 284 return 0;
329 } 285 }
330 286
331 // Add 10MS of raw (PCM) audio data to the encoder. 287 // Add 10MS of raw (PCM) audio data to the encoder.
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, 554 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
599 "Cannot register master codec."); 555 "Cannot register master codec.");
600 return -1; 556 return -1;
601 } 557 }
602 } 558 }
603 } 559 }
604 receiver_initialized_ = true; 560 receiver_initialized_ = true;
605 return 0; 561 return 0;
606 } 562 }
607 563
608 // TODO(turajs): If NetEq opens an API for reseting the state of decoders then
609 // implement this method. Otherwise it should be removed. I might be that by
610 // removing and registering a decoder we can achieve the effect of resetting.
611 // Reset the decoder state.
612 // TODO(henrik.lundin): Remove; only used in one test, and does nothing.
613 int AudioCodingModuleImpl::ResetDecoder() {
614 return 0;
615 }
616
617 // Get current receive frequency. 564 // Get current receive frequency.
618 int AudioCodingModuleImpl::ReceiveFrequency() const { 565 int AudioCodingModuleImpl::ReceiveFrequency() const {
619 WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_, 566 WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
620 "ReceiveFrequency()"); 567 "ReceiveFrequency()");
621 568
622 CriticalSectionScoped lock(acm_crit_sect_); 569 CriticalSectionScoped lock(acm_crit_sect_);
623 570
624 int codec_id = receiver_.last_audio_codec_id(); 571 int codec_id = receiver_.last_audio_codec_id();
625 572
626 return codec_id < 0 ? receiver_.current_sample_rate_hz() : 573 return codec_id < 0 ? receiver_.current_sample_rate_hz() :
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 662
716 int AudioCodingModuleImpl::SetMaximumPlayoutDelay(int time_ms) { 663 int AudioCodingModuleImpl::SetMaximumPlayoutDelay(int time_ms) {
717 if ((time_ms < 0) || (time_ms > 10000)) { 664 if ((time_ms < 0) || (time_ms > 10000)) {
718 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_, 665 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
719 "Delay must be in the range of 0-1000 milliseconds."); 666 "Delay must be in the range of 0-1000 milliseconds.");
720 return -1; 667 return -1;
721 } 668 }
722 return receiver_.SetMaximumDelay(time_ms); 669 return receiver_.SetMaximumDelay(time_ms);
723 } 670 }
724 671
725 // Estimate the Bandwidth based on the incoming stream, needed for one way
726 // audio where the RTCP send the BW estimate.
727 // This is also done in the RTP module.
728 int AudioCodingModuleImpl::DecoderEstimatedBandwidth() const {
729 // We can estimate far-end to near-end bandwidth if the iSAC are sent. Check
730 // if the last received packets were iSAC packet then retrieve the bandwidth.
731 int last_audio_codec_id = receiver_.last_audio_codec_id();
732 if (last_audio_codec_id >= 0 &&
733 STR_CASE_CMP("ISAC", ACMCodecDB::database_[last_audio_codec_id].plname)) {
734 CriticalSectionScoped lock(acm_crit_sect_);
735 FATAL() << "Dead code?";
736 // return codecs_[last_audio_codec_id]->GetEstimatedBandwidth();
737 }
738 return -1;
739 }
740
741 // Set playout mode for: voice, fax, streaming or off. 672 // Set playout mode for: voice, fax, streaming or off.
742 int AudioCodingModuleImpl::SetPlayoutMode(AudioPlayoutMode mode) { 673 int AudioCodingModuleImpl::SetPlayoutMode(AudioPlayoutMode mode) {
743 receiver_.SetPlayoutMode(mode); 674 receiver_.SetPlayoutMode(mode);
744 return 0; // TODO(turajs): return value is for backward compatibility. 675 return 0; // TODO(turajs): return value is for backward compatibility.
745 } 676 }
746 677
747 // Get playout mode voice, fax, streaming or off. 678 // Get playout mode voice, fax, streaming or off.
748 AudioPlayoutMode AudioCodingModuleImpl::PlayoutMode() const { 679 AudioPlayoutMode AudioCodingModuleImpl::PlayoutMode() const {
749 return receiver_.PlayoutMode(); 680 return receiver_.PlayoutMode();
750 } 681 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 aux_rtp_header_->type.Audio.channel = 1; 734 aux_rtp_header_->type.Audio.channel = 1;
804 } 735 }
805 736
806 aux_rtp_header_->header.timestamp = timestamp; 737 aux_rtp_header_->header.timestamp = timestamp;
807 IncomingPacket(incoming_payload, payload_length, *aux_rtp_header_); 738 IncomingPacket(incoming_payload, payload_length, *aux_rtp_header_);
808 // Get ready for the next payload. 739 // Get ready for the next payload.
809 aux_rtp_header_->header.sequenceNumber++; 740 aux_rtp_header_->header.sequenceNumber++;
810 return 0; 741 return 0;
811 } 742 }
812 743
813 int AudioCodingModuleImpl::ReplaceInternalDTXWithWebRtc(bool use_webrtc_dtx) {
814 CriticalSectionScoped lock(acm_crit_sect_);
815
816 if (!HaveValidEncoder("ReplaceInternalDTXWithWebRtc")) {
817 WEBRTC_TRACE(
818 webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
819 "Cannot replace codec internal DTX when no send codec is registered.");
820 return -1;
821 }
822
823 FATAL() << "Dead code?";
824 // int res = codecs_[current_send_codec_idx_]->ReplaceInternalDTX(
825 // use_webrtc_dtx);
826 // Check if VAD is turned on, or if there is any error.
827 // if (res == 1) {
828 // vad_enabled_ = true;
829 // } else if (res < 0) {
830 // WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
831 // "Failed to set ReplaceInternalDTXWithWebRtc(%d)",
832 // use_webrtc_dtx);
833 // return res;
834 // }
835
836 return 0;
837 }
838
839 int AudioCodingModuleImpl::IsInternalDTXReplacedWithWebRtc(
840 bool* uses_webrtc_dtx) {
841 *uses_webrtc_dtx = true;
842 return 0;
843 }
844
845 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine. 744 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine.
846 int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) { 745 int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) {
847 CriticalSectionScoped lock(acm_crit_sect_); 746 CriticalSectionScoped lock(acm_crit_sect_);
848 747
849 if (!HaveValidEncoder("SetISACMaxRate")) { 748 if (!HaveValidEncoder("SetISACMaxRate")) {
850 return -1; 749 return -1;
851 } 750 }
852 751
853 codec_manager_.CurrentSpeechEncoder()->SetMaxRate(max_bit_per_sec); 752 codec_manager_.CurrentSpeechEncoder()->SetMaxRate(max_bit_per_sec);
854 return 0; 753 return 0;
855 } 754 }
856 755
857 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine. 756 // TODO(henrik.lundin): Remove? Only used in tests. Deprecated in VoiceEngine.
858 int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) { 757 int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) {
859 CriticalSectionScoped lock(acm_crit_sect_); 758 CriticalSectionScoped lock(acm_crit_sect_);
860 759
861 if (!HaveValidEncoder("SetISACMaxPayloadSize")) { 760 if (!HaveValidEncoder("SetISACMaxPayloadSize")) {
862 return -1; 761 return -1;
863 } 762 }
864 763
865 codec_manager_.CurrentSpeechEncoder()->SetMaxPayloadSize(max_size_bytes); 764 codec_manager_.CurrentSpeechEncoder()->SetMaxPayloadSize(max_size_bytes);
866 return 0; 765 return 0;
867 } 766 }
868 767
869 // TODO(henrik.lundin): Remove? Only used in tests.
870 int AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
871 int frame_size_ms,
872 int rate_bit_per_sec,
873 bool enforce_frame_size) {
874 CriticalSectionScoped lock(acm_crit_sect_);
875
876 if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) {
877 return -1;
878 }
879
880 FATAL() << "Dead code?";
881 return -1;
882 // return codecs_[current_send_codec_idx_]->ConfigISACBandwidthEstimator(
883 // frame_size_ms, rate_bit_per_sec, enforce_frame_size);
884 }
885
886 int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) { 768 int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) {
887 CriticalSectionScoped lock(acm_crit_sect_); 769 CriticalSectionScoped lock(acm_crit_sect_);
888 if (!HaveValidEncoder("SetOpusApplication")) { 770 if (!HaveValidEncoder("SetOpusApplication")) {
889 return -1; 771 return -1;
890 } 772 }
891 AudioEncoderMutable::Application app; 773 AudioEncoderMutable::Application app;
892 switch (application) { 774 switch (application) {
893 case kVoip: 775 case kVoip:
894 app = AudioEncoderMutable::kApplicationSpeech; 776 app = AudioEncoderMutable::kApplicationSpeech;
895 break; 777 break;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 "%s failed: No send codec is registered.", caller_name); 822 "%s failed: No send codec is registered.", caller_name);
941 return false; 823 return false;
942 } 824 }
943 return true; 825 return true;
944 } 826 }
945 827
946 int AudioCodingModuleImpl::UnregisterReceiveCodec(uint8_t payload_type) { 828 int AudioCodingModuleImpl::UnregisterReceiveCodec(uint8_t payload_type) {
947 return receiver_.RemoveCodec(payload_type); 829 return receiver_.RemoveCodec(payload_type);
948 } 830 }
949 831
950 // TODO(turajs): correct the type of |length_bytes| when it is corrected in
951 // GenericCodec.
952 int AudioCodingModuleImpl::REDPayloadISAC(int isac_rate,
953 int isac_bw_estimate,
954 uint8_t* payload,
955 int16_t* length_bytes) {
956 CriticalSectionScoped lock(acm_crit_sect_);
957 if (!HaveValidEncoder("EncodeData")) {
958 return -1;
959 }
960 FATAL() << "Dead code?";
961 return -1;
962 // int status;
963 // status = codecs_[current_send_codec_idx_]->REDPayloadISAC(isac_rate,
964 // isac_bw_estimate,
965 // payload,
966 // length_bytes);
967 // return status;
968 }
969
970 int AudioCodingModuleImpl::SetInitialPlayoutDelay(int delay_ms) { 832 int AudioCodingModuleImpl::SetInitialPlayoutDelay(int delay_ms) {
971 { 833 {
972 CriticalSectionScoped lock(acm_crit_sect_); 834 CriticalSectionScoped lock(acm_crit_sect_);
973 // Initialize receiver, if it is not initialized. Otherwise, initial delay 835 // Initialize receiver, if it is not initialized. Otherwise, initial delay
974 // is reset upon initialization of the receiver. 836 // is reset upon initialization of the receiver.
975 if (!receiver_initialized_) 837 if (!receiver_initialized_)
976 InitializeReceiverSafe(); 838 InitializeReceiverSafe();
977 } 839 }
978 return receiver_.SetInitialDelay(delay_ms); 840 return receiver_.SetInitialDelay(delay_ms);
979 } 841 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 *channels = 1; 1158 *channels = 1;
1297 break; 1159 break;
1298 #endif 1160 #endif
1299 default: 1161 default:
1300 FATAL() << "Codec type " << codec_type << " not supported."; 1162 FATAL() << "Codec type " << codec_type << " not supported.";
1301 } 1163 }
1302 return true; 1164 return true;
1303 } 1165 }
1304 1166
1305 } // namespace webrtc 1167 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698