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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // RTCP is enabled by default. | 867 // RTCP is enabled by default. |
868 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); | 868 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); |
869 // --- Register all permanent callbacks | 869 // --- Register all permanent callbacks |
870 if (audio_coding_->RegisterTransportCallback(this) == -1) { | 870 if (audio_coding_->RegisterTransportCallback(this) == -1) { |
871 _engineStatisticsPtr->SetLastError( | 871 _engineStatisticsPtr->SetLastError( |
872 VE_CANNOT_INIT_CHANNEL, kTraceError, | 872 VE_CANNOT_INIT_CHANNEL, kTraceError, |
873 "Channel::Init() callbacks not registered"); | 873 "Channel::Init() callbacks not registered"); |
874 return -1; | 874 return -1; |
875 } | 875 } |
876 | 876 |
877 // TODO(solenberg): Remove? | |
878 // Register a default set of send codecs. | |
879 const int nSupportedCodecs = AudioCodingModule::NumberOfCodecs(); | |
880 for (int idx = 0; idx < nSupportedCodecs; idx++) { | |
881 CodecInst codec; | |
882 RTC_CHECK_EQ(0, audio_coding_->Codec(idx, &codec)); | |
883 | |
884 // Ensure that PCMU is used as default send codec. | |
885 if (STR_CASE_CMP(codec.plname, "PCMU") == 0 && codec.channels == 1) { | |
886 SetSendCodec(codec); | |
887 } | |
888 | |
889 // Register default PT for 'telephone-event' | |
890 if (STR_CASE_CMP(codec.plname, "telephone-event") == 0) { | |
891 if (_rtpRtcpModule->RegisterSendPayload(codec) == -1) { | |
892 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | |
893 "Channel::Init() failed to register outband " | |
894 "'telephone-event' (%d/%d) correctly", | |
895 codec.pltype, codec.plfreq); | |
896 } | |
897 } | |
898 | |
899 if (STR_CASE_CMP(codec.plname, "CN") == 0) { | |
900 if (!codec_manager_.RegisterEncoder(codec) || | |
901 !codec_manager_.MakeEncoder(&rent_a_codec_, audio_coding_.get()) || | |
902 _rtpRtcpModule->RegisterSendPayload(codec) == -1) { | |
903 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | |
904 "Channel::Init() failed to register CN (%d/%d) " | |
905 "correctly - 1", | |
906 codec.pltype, codec.plfreq); | |
907 } | |
908 } | |
909 } | |
910 | |
911 return 0; | 877 return 0; |
912 } | 878 } |
913 | 879 |
914 void Channel::Terminate() { | 880 void Channel::Terminate() { |
915 RTC_DCHECK(construction_thread_.CalledOnValidThread()); | 881 RTC_DCHECK(construction_thread_.CalledOnValidThread()); |
916 // Must be called on the same thread as Init(). | 882 // Must be called on the same thread as Init(). |
917 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 883 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
918 "Channel::Terminate"); | 884 "Channel::Terminate"); |
919 | 885 |
920 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); | 886 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); |
921 | 887 |
922 StopSend(); | 888 StopSend(); |
923 StopPlayout(); | 889 StopPlayout(); |
924 | 890 |
925 // The order to safely shutdown modules in a channel is: | 891 // The order to safely shutdown modules in a channel is: |
926 // 1. De-register callbacks in modules | 892 // 1. De-register callbacks in modules |
927 // 2. De-register modules in process thread | 893 // 2. De-register modules in process thread |
928 // 3. Destroy modules | 894 // 3. Destroy modules |
929 if (audio_coding_->RegisterTransportCallback(NULL) == -1) { | 895 if (audio_coding_->RegisterTransportCallback(NULL) == -1) { |
930 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 896 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
931 "Terminate() failed to de-register transport callback" | 897 "Terminate() failed to de-register transport callback" |
932 " (Audio coding module)"); | 898 " (Audio coding module)"); |
933 } | 899 } |
934 | 900 |
935 if (audio_coding_->RegisterVADCallback(NULL) == -1) { | |
936 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | |
937 "Terminate() failed to de-register VAD callback" | |
938 " (Audio coding module)"); | |
939 } | |
940 | |
941 // De-register modules in process thread | 901 // De-register modules in process thread |
942 if (_moduleProcessThreadPtr) | 902 if (_moduleProcessThreadPtr) |
943 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); | 903 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); |
944 | 904 |
945 // End of modules shutdown | 905 // End of modules shutdown |
946 } | 906 } |
947 | 907 |
948 int32_t Channel::SetEngineInformation(Statistics& engineStatistics, | 908 int32_t Channel::SetEngineInformation(Statistics& engineStatistics, |
949 ProcessThread& moduleProcessThread, | 909 ProcessThread& moduleProcessThread, |
950 AudioDeviceModule& audioDeviceModule, | 910 AudioDeviceModule& audioDeviceModule, |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 int64_t min_rtt = 0; | 1956 int64_t min_rtt = 0; |
1997 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 1957 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
1998 0) { | 1958 0) { |
1999 return 0; | 1959 return 0; |
2000 } | 1960 } |
2001 return rtt; | 1961 return rtt; |
2002 } | 1962 } |
2003 | 1963 |
2004 } // namespace voe | 1964 } // namespace voe |
2005 } // namespace webrtc | 1965 } // namespace webrtc |
OLD | NEW |