| 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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 int AudioCodingModuleImpl::LeastRequiredDelayMs() const { | 796 int AudioCodingModuleImpl::LeastRequiredDelayMs() const { |
| 797 return receiver_.LeastRequiredDelayMs(); | 797 return receiver_.LeastRequiredDelayMs(); |
| 798 } | 798 } |
| 799 | 799 |
| 800 void AudioCodingModuleImpl::GetDecodingCallStatistics( | 800 void AudioCodingModuleImpl::GetDecodingCallStatistics( |
| 801 AudioDecodingCallStats* call_stats) const { | 801 AudioDecodingCallStats* call_stats) const { |
| 802 receiver_.GetDecodingCallStatistics(call_stats); | 802 receiver_.GetDecodingCallStatistics(call_stats); |
| 803 } | 803 } |
| 804 | 804 |
| 805 } // namespace acm2 | 805 } // namespace acm2 |
| 806 | |
| 807 AudioCodingImpl::AudioCodingImpl(const Config& config) { | |
| 808 AudioCodingModule::Config config_old = config.ToOldConfig(); | |
| 809 acm_old_.reset(new acm2::AudioCodingModuleImpl(config_old)); | |
| 810 acm_old_->RegisterTransportCallback(config.transport); | |
| 811 acm_old_->RegisterVADCallback(config.vad_callback); | |
| 812 if (config.initial_playout_delay_ms > 0) { | |
| 813 acm_old_->SetInitialPlayoutDelay(config.initial_playout_delay_ms); | |
| 814 } | |
| 815 playout_frequency_hz_ = config.playout_frequency_hz; | |
| 816 } | |
| 817 | |
| 818 AudioCodingImpl::~AudioCodingImpl() = default; | |
| 819 | |
| 820 bool AudioCodingImpl::RegisterSendCodec(AudioEncoder* send_codec) { | |
| 821 FATAL() << "Not implemented yet."; | |
| 822 return false; | |
| 823 } | |
| 824 | |
| 825 bool AudioCodingImpl::RegisterSendCodec(int encoder_type, | |
| 826 uint8_t payload_type, | |
| 827 int frame_size_samples) { | |
| 828 std::string codec_name; | |
| 829 int sample_rate_hz; | |
| 830 int channels; | |
| 831 if (!MapCodecTypeToParameters( | |
| 832 encoder_type, &codec_name, &sample_rate_hz, &channels)) { | |
| 833 return false; | |
| 834 } | |
| 835 webrtc::CodecInst codec; | |
| 836 AudioCodingModule::Codec( | |
| 837 codec_name.c_str(), &codec, sample_rate_hz, channels); | |
| 838 codec.pltype = payload_type; | |
| 839 if (frame_size_samples > 0) { | |
| 840 codec.pacsize = frame_size_samples; | |
| 841 } | |
| 842 return acm_old_->RegisterSendCodec(codec) == 0; | |
| 843 } | |
| 844 | |
| 845 const AudioEncoder* AudioCodingImpl::GetSenderInfo() const { | |
| 846 FATAL() << "Not implemented yet."; | |
| 847 return reinterpret_cast<const AudioEncoder*>(NULL); | |
| 848 } | |
| 849 | |
| 850 const CodecInst* AudioCodingImpl::GetSenderCodecInst() { | |
| 851 if (acm_old_->SendCodec(¤t_send_codec_) != 0) { | |
| 852 return NULL; | |
| 853 } | |
| 854 return ¤t_send_codec_; | |
| 855 } | |
| 856 | |
| 857 int AudioCodingImpl::Add10MsAudio(const AudioFrame& audio_frame) { | |
| 858 acm2::AudioCodingModuleImpl::InputData input_data; | |
| 859 CriticalSectionScoped lock(acm_old_->acm_crit_sect_.get()); | |
| 860 if (acm_old_->Add10MsDataInternal(audio_frame, &input_data) != 0) | |
| 861 return -1; | |
| 862 return acm_old_->Encode(input_data); | |
| 863 } | |
| 864 | |
| 865 const ReceiverInfo* AudioCodingImpl::GetReceiverInfo() const { | |
| 866 FATAL() << "Not implemented yet."; | |
| 867 return reinterpret_cast<const ReceiverInfo*>(NULL); | |
| 868 } | |
| 869 | |
| 870 bool AudioCodingImpl::RegisterReceiveCodec(AudioDecoder* receive_codec) { | |
| 871 FATAL() << "Not implemented yet."; | |
| 872 return false; | |
| 873 } | |
| 874 | |
| 875 bool AudioCodingImpl::RegisterReceiveCodec(int decoder_type, | |
| 876 uint8_t payload_type) { | |
| 877 std::string codec_name; | |
| 878 int sample_rate_hz; | |
| 879 int channels; | |
| 880 if (!MapCodecTypeToParameters( | |
| 881 decoder_type, &codec_name, &sample_rate_hz, &channels)) { | |
| 882 return false; | |
| 883 } | |
| 884 webrtc::CodecInst codec; | |
| 885 AudioCodingModule::Codec( | |
| 886 codec_name.c_str(), &codec, sample_rate_hz, channels); | |
| 887 codec.pltype = payload_type; | |
| 888 return acm_old_->RegisterReceiveCodec(codec) == 0; | |
| 889 } | |
| 890 | |
| 891 bool AudioCodingImpl::InsertPacket(const uint8_t* incoming_payload, | |
| 892 size_t payload_len_bytes, | |
| 893 const WebRtcRTPHeader& rtp_info) { | |
| 894 return acm_old_->IncomingPacket( | |
| 895 incoming_payload, payload_len_bytes, rtp_info) == 0; | |
| 896 } | |
| 897 | |
| 898 bool AudioCodingImpl::InsertPayload(const uint8_t* incoming_payload, | |
| 899 size_t payload_len_byte, | |
| 900 uint8_t payload_type, | |
| 901 uint32_t timestamp) { | |
| 902 FATAL() << "Not implemented yet."; | |
| 903 return false; | |
| 904 } | |
| 905 | |
| 906 bool AudioCodingImpl::SetMinimumPlayoutDelay(int time_ms) { | |
| 907 FATAL() << "Not implemented yet."; | |
| 908 return false; | |
| 909 } | |
| 910 | |
| 911 bool AudioCodingImpl::SetMaximumPlayoutDelay(int time_ms) { | |
| 912 FATAL() << "Not implemented yet."; | |
| 913 return false; | |
| 914 } | |
| 915 | |
| 916 int AudioCodingImpl::LeastRequiredDelayMs() const { | |
| 917 FATAL() << "Not implemented yet."; | |
| 918 return -1; | |
| 919 } | |
| 920 | |
| 921 bool AudioCodingImpl::PlayoutTimestamp(uint32_t* timestamp) { | |
| 922 FATAL() << "Not implemented yet."; | |
| 923 return false; | |
| 924 } | |
| 925 | |
| 926 bool AudioCodingImpl::Get10MsAudio(AudioFrame* audio_frame) { | |
| 927 return acm_old_->PlayoutData10Ms(playout_frequency_hz_, audio_frame) == 0; | |
| 928 } | |
| 929 | |
| 930 bool AudioCodingImpl::GetNetworkStatistics( | |
| 931 NetworkStatistics* network_statistics) { | |
| 932 FATAL() << "Not implemented yet."; | |
| 933 return false; | |
| 934 } | |
| 935 | |
| 936 bool AudioCodingImpl::EnableNack(size_t max_nack_list_size) { | |
| 937 FATAL() << "Not implemented yet."; | |
| 938 return false; | |
| 939 } | |
| 940 | |
| 941 void AudioCodingImpl::DisableNack() { | |
| 942 // A bug in the linker of Visual Studio 2013 Update 3 prevent us from using | |
| 943 // FATAL() here, if we do so then the linker hang when the WPO is turned on. | |
| 944 // TODO(sebmarchand): Re-evaluate this when we upgrade the toolchain. | |
| 945 } | |
| 946 | |
| 947 bool AudioCodingImpl::SetVad(bool enable_dtx, | |
| 948 bool enable_vad, | |
| 949 ACMVADMode vad_mode) { | |
| 950 return acm_old_->SetVAD(enable_dtx, enable_vad, vad_mode) == 0; | |
| 951 } | |
| 952 | |
| 953 std::vector<uint16_t> AudioCodingImpl::GetNackList( | |
| 954 int round_trip_time_ms) const { | |
| 955 return acm_old_->GetNackList(round_trip_time_ms); | |
| 956 } | |
| 957 | |
| 958 void AudioCodingImpl::GetDecodingCallStatistics( | |
| 959 AudioDecodingCallStats* call_stats) const { | |
| 960 acm_old_->GetDecodingCallStatistics(call_stats); | |
| 961 } | |
| 962 | |
| 963 bool AudioCodingImpl::MapCodecTypeToParameters(int codec_type, | |
| 964 std::string* codec_name, | |
| 965 int* sample_rate_hz, | |
| 966 int* channels) { | |
| 967 switch (codec_type) { | |
| 968 case acm2::ACMCodecDB::kPCM16B: | |
| 969 *codec_name = "L16"; | |
| 970 *sample_rate_hz = 8000; | |
| 971 *channels = 1; | |
| 972 break; | |
| 973 case acm2::ACMCodecDB::kPCM16Bwb: | |
| 974 *codec_name = "L16"; | |
| 975 *sample_rate_hz = 16000; | |
| 976 *channels = 1; | |
| 977 break; | |
| 978 case acm2::ACMCodecDB::kPCM16Bswb32kHz: | |
| 979 *codec_name = "L16"; | |
| 980 *sample_rate_hz = 32000; | |
| 981 *channels = 1; | |
| 982 break; | |
| 983 case acm2::ACMCodecDB::kPCM16B_2ch: | |
| 984 *codec_name = "L16"; | |
| 985 *sample_rate_hz = 8000; | |
| 986 *channels = 2; | |
| 987 break; | |
| 988 case acm2::ACMCodecDB::kPCM16Bwb_2ch: | |
| 989 *codec_name = "L16"; | |
| 990 *sample_rate_hz = 16000; | |
| 991 *channels = 2; | |
| 992 break; | |
| 993 case acm2::ACMCodecDB::kPCM16Bswb32kHz_2ch: | |
| 994 *codec_name = "L16"; | |
| 995 *sample_rate_hz = 32000; | |
| 996 *channels = 2; | |
| 997 break; | |
| 998 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) | |
| 999 case acm2::ACMCodecDB::kISAC: | |
| 1000 *codec_name = "ISAC"; | |
| 1001 *sample_rate_hz = 16000; | |
| 1002 *channels = 1; | |
| 1003 break; | |
| 1004 #endif | |
| 1005 #ifdef WEBRTC_CODEC_ISAC | |
| 1006 case acm2::ACMCodecDB::kISACSWB: | |
| 1007 *codec_name = "ISAC"; | |
| 1008 *sample_rate_hz = 32000; | |
| 1009 *channels = 1; | |
| 1010 break; | |
| 1011 #endif | |
| 1012 #ifdef WEBRTC_CODEC_ILBC | |
| 1013 case acm2::ACMCodecDB::kILBC: | |
| 1014 *codec_name = "ILBC"; | |
| 1015 *sample_rate_hz = 8000; | |
| 1016 *channels = 1; | |
| 1017 break; | |
| 1018 #endif | |
| 1019 case acm2::ACMCodecDB::kPCMA: | |
| 1020 *codec_name = "PCMA"; | |
| 1021 *sample_rate_hz = 8000; | |
| 1022 *channels = 1; | |
| 1023 break; | |
| 1024 case acm2::ACMCodecDB::kPCMA_2ch: | |
| 1025 *codec_name = "PCMA"; | |
| 1026 *sample_rate_hz = 8000; | |
| 1027 *channels = 2; | |
| 1028 break; | |
| 1029 case acm2::ACMCodecDB::kPCMU: | |
| 1030 *codec_name = "PCMU"; | |
| 1031 *sample_rate_hz = 8000; | |
| 1032 *channels = 1; | |
| 1033 break; | |
| 1034 case acm2::ACMCodecDB::kPCMU_2ch: | |
| 1035 *codec_name = "PCMU"; | |
| 1036 *sample_rate_hz = 8000; | |
| 1037 *channels = 2; | |
| 1038 break; | |
| 1039 #ifdef WEBRTC_CODEC_G722 | |
| 1040 case acm2::ACMCodecDB::kG722: | |
| 1041 *codec_name = "G722"; | |
| 1042 *sample_rate_hz = 16000; | |
| 1043 *channels = 1; | |
| 1044 break; | |
| 1045 case acm2::ACMCodecDB::kG722_2ch: | |
| 1046 *codec_name = "G722"; | |
| 1047 *sample_rate_hz = 16000; | |
| 1048 *channels = 2; | |
| 1049 break; | |
| 1050 #endif | |
| 1051 #ifdef WEBRTC_CODEC_OPUS | |
| 1052 case acm2::ACMCodecDB::kOpus: | |
| 1053 *codec_name = "opus"; | |
| 1054 *sample_rate_hz = 48000; | |
| 1055 *channels = 2; | |
| 1056 break; | |
| 1057 #endif | |
| 1058 case acm2::ACMCodecDB::kCNNB: | |
| 1059 *codec_name = "CN"; | |
| 1060 *sample_rate_hz = 8000; | |
| 1061 *channels = 1; | |
| 1062 break; | |
| 1063 case acm2::ACMCodecDB::kCNWB: | |
| 1064 *codec_name = "CN"; | |
| 1065 *sample_rate_hz = 16000; | |
| 1066 *channels = 1; | |
| 1067 break; | |
| 1068 case acm2::ACMCodecDB::kCNSWB: | |
| 1069 *codec_name = "CN"; | |
| 1070 *sample_rate_hz = 32000; | |
| 1071 *channels = 1; | |
| 1072 break; | |
| 1073 case acm2::ACMCodecDB::kRED: | |
| 1074 *codec_name = "red"; | |
| 1075 *sample_rate_hz = 8000; | |
| 1076 *channels = 1; | |
| 1077 break; | |
| 1078 case acm2::ACMCodecDB::kAVT: | |
| 1079 *codec_name = "telephone-event"; | |
| 1080 *sample_rate_hz = 8000; | |
| 1081 *channels = 1; | |
| 1082 break; | |
| 1083 default: | |
| 1084 FATAL() << "Codec type " << codec_type << " not supported."; | |
| 1085 } | |
| 1086 return true; | |
| 1087 } | |
| 1088 | |
| 1089 } // namespace webrtc | 806 } // namespace webrtc |
| OLD | NEW |