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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 } | 453 } |
454 | 454 |
455 bool Channel::SendRtp(const uint8_t* data, | 455 bool Channel::SendRtp(const uint8_t* data, |
456 size_t len, | 456 size_t len, |
457 const PacketOptions& options) { | 457 const PacketOptions& options) { |
458 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 458 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
459 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); | 459 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); |
460 | 460 |
461 rtc::CritScope cs(&_callbackCritSect); | 461 rtc::CritScope cs(&_callbackCritSect); |
462 | 462 |
463 if (_transportPtr == NULL) { | 463 if (_transportPtr == nullptr) { |
464 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 464 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
465 "Channel::SendPacket() failed to send RTP packet due to" | 465 "Channel::SendPacket() failed to send RTP packet due to" |
466 " invalid transport object"); | 466 " invalid transport object"); |
467 return false; | 467 return false; |
468 } | 468 } |
469 | 469 |
470 uint8_t* bufferToSendPtr = (uint8_t*)data; | 470 uint8_t* bufferToSendPtr = (uint8_t*)data; |
471 size_t bufferLength = len; | 471 size_t bufferLength = len; |
472 | 472 |
473 if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) { | 473 if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) { |
474 std::string transport_name = | 474 std::string transport_name = |
475 _externalTransport ? "external transport" : "WebRtc sockets"; | 475 _externalTransport ? "external transport" : "WebRtc sockets"; |
476 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 476 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
477 "Channel::SendPacket() RTP transmission using %s failed", | 477 "Channel::SendPacket() RTP transmission using %s failed", |
478 transport_name.c_str()); | 478 transport_name.c_str()); |
479 return false; | 479 return false; |
480 } | 480 } |
481 return true; | 481 return true; |
482 } | 482 } |
483 | 483 |
484 bool Channel::SendRtcp(const uint8_t* data, size_t len) { | 484 bool Channel::SendRtcp(const uint8_t* data, size_t len) { |
485 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 485 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
486 "Channel::SendRtcp(len=%" PRIuS ")", len); | 486 "Channel::SendRtcp(len=%" PRIuS ")", len); |
487 | 487 |
488 rtc::CritScope cs(&_callbackCritSect); | 488 rtc::CritScope cs(&_callbackCritSect); |
489 if (_transportPtr == NULL) { | 489 if (_transportPtr == nullptr) { |
490 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 490 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
491 "Channel::SendRtcp() failed to send RTCP packet" | 491 "Channel::SendRtcp() failed to send RTCP packet" |
492 " due to invalid transport object"); | 492 " due to invalid transport object"); |
493 return false; | 493 return false; |
494 } | 494 } |
495 | 495 |
496 uint8_t* bufferToSendPtr = (uint8_t*)data; | 496 uint8_t* bufferToSendPtr = (uint8_t*)data; |
497 size_t bufferLength = len; | 497 size_t bufferLength = len; |
498 | 498 |
499 int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength); | 499 int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 // Push the incoming payload (parsed and ready for decoding) into the ACM | 582 // Push the incoming payload (parsed and ready for decoding) into the ACM |
583 if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) != | 583 if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) != |
584 0) { | 584 0) { |
585 _engineStatisticsPtr->SetLastError( | 585 _engineStatisticsPtr->SetLastError( |
586 VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, | 586 VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, |
587 "Channel::OnReceivedPayloadData() unable to push data to the ACM"); | 587 "Channel::OnReceivedPayloadData() unable to push data to the ACM"); |
588 return -1; | 588 return -1; |
589 } | 589 } |
590 | 590 |
591 int64_t round_trip_time = 0; | 591 int64_t round_trip_time = 0; |
592 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, NULL, NULL, | 592 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, nullptr, nullptr, |
593 NULL); | 593 nullptr); |
594 | 594 |
595 std::vector<uint16_t> nack_list = audio_coding_->GetNackList(round_trip_time); | 595 std::vector<uint16_t> nack_list = audio_coding_->GetNackList(round_trip_time); |
596 if (!nack_list.empty()) { | 596 if (!nack_list.empty()) { |
597 // Can't use nack_list.data() since it's not supported by all | 597 // Can't use nack_list.data() since it's not supported by all |
598 // compilers. | 598 // compilers. |
599 ResendPackets(&(nack_list[0]), static_cast<int>(nack_list.size())); | 599 ResendPackets(&(nack_list[0]), static_cast<int>(nack_list.size())); |
600 } | 600 } |
601 return 0; | 601 return 0; |
602 } | 602 } |
603 | 603 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 int32_t Channel::CreateChannel( | 819 int32_t Channel::CreateChannel( |
820 Channel*& channel, | 820 Channel*& channel, |
821 int32_t channelId, | 821 int32_t channelId, |
822 uint32_t instanceId, | 822 uint32_t instanceId, |
823 const VoEBase::ChannelConfig& config) { | 823 const VoEBase::ChannelConfig& config) { |
824 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 824 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
825 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, | 825 "Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId, |
826 instanceId); | 826 instanceId); |
827 | 827 |
828 channel = new Channel(channelId, instanceId, config); | 828 channel = new Channel(channelId, instanceId, config); |
829 if (channel == NULL) { | 829 if (channel == nullptr) { |
830 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), | 830 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId), |
831 "Channel::CreateChannel() unable to allocate memory for" | 831 "Channel::CreateChannel() unable to allocate memory for" |
832 " channel"); | 832 " channel"); |
833 return -1; | 833 return -1; |
834 } | 834 } |
835 return 0; | 835 return 0; |
836 } | 836 } |
837 | 837 |
838 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { | 838 void Channel::PlayNotification(int32_t id, uint32_t durationMs) { |
839 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 839 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), | 901 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), |
902 _outputAudioLevel(), | 902 _outputAudioLevel(), |
903 _externalTransport(false), | 903 _externalTransport(false), |
904 // Avoid conflict with other channels by adding 1024 - 1026, | 904 // Avoid conflict with other channels by adding 1024 - 1026, |
905 // won't use as much as 1024 channels. | 905 // won't use as much as 1024 channels. |
906 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), | 906 _inputFilePlayerId(VoEModuleId(instanceId, channelId) + 1024), |
907 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), | 907 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), |
908 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), | 908 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), |
909 _outputFileRecording(false), | 909 _outputFileRecording(false), |
910 _outputExternalMedia(false), | 910 _outputExternalMedia(false), |
911 _inputExternalMediaCallbackPtr(NULL), | 911 _inputExternalMediaCallbackPtr(nullptr), |
912 _outputExternalMediaCallbackPtr(NULL), | 912 _outputExternalMediaCallbackPtr(nullptr), |
913 _timeStamp(0), // This is just an offset, RTP module will add it's own | 913 _timeStamp(0), // This is just an offset, RTP module will add it's own |
914 // random offset | 914 // random offset |
915 ntp_estimator_(Clock::GetRealTimeClock()), | 915 ntp_estimator_(Clock::GetRealTimeClock()), |
916 playout_timestamp_rtp_(0), | 916 playout_timestamp_rtp_(0), |
917 playout_timestamp_rtcp_(0), | 917 playout_timestamp_rtcp_(0), |
918 playout_delay_ms_(0), | 918 playout_delay_ms_(0), |
919 _numberOfDiscardedPackets(0), | 919 _numberOfDiscardedPackets(0), |
920 send_sequence_number_(0), | 920 send_sequence_number_(0), |
921 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), | 921 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), |
922 capture_start_rtp_time_stamp_(-1), | 922 capture_start_rtp_time_stamp_(-1), |
923 capture_start_ntp_time_ms_(-1), | 923 capture_start_ntp_time_ms_(-1), |
924 _engineStatisticsPtr(NULL), | 924 _engineStatisticsPtr(nullptr), |
925 _outputMixerPtr(NULL), | 925 _outputMixerPtr(nullptr), |
926 _transmitMixerPtr(NULL), | 926 _transmitMixerPtr(nullptr), |
927 _moduleProcessThreadPtr(NULL), | 927 _moduleProcessThreadPtr(nullptr), |
928 _audioDeviceModulePtr(NULL), | 928 _audioDeviceModulePtr(nullptr), |
929 _voiceEngineObserverPtr(NULL), | 929 _voiceEngineObserverPtr(nullptr), |
930 _callbackCritSectPtr(NULL), | 930 _callbackCritSectPtr(nullptr), |
931 _transportPtr(NULL), | 931 _transportPtr(nullptr), |
932 _sendFrameType(0), | 932 _sendFrameType(0), |
933 _externalMixing(false), | 933 _externalMixing(false), |
934 _mixFileWithMicrophone(false), | 934 _mixFileWithMicrophone(false), |
935 input_mute_(false), | 935 input_mute_(false), |
936 previous_frame_muted_(false), | 936 previous_frame_muted_(false), |
937 _panLeft(1.0f), | 937 _panLeft(1.0f), |
938 _panRight(1.0f), | 938 _panRight(1.0f), |
939 _outputGain(1.0f), | 939 _outputGain(1.0f), |
940 _lastLocalTimeStamp(0), | 940 _lastLocalTimeStamp(0), |
941 _lastPayloadType(0), | 941 _lastPayloadType(0), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 | 981 |
982 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); | 982 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); |
983 _rtpRtcpModule->SetSendingMediaStatus(false); | 983 _rtpRtcpModule->SetSendingMediaStatus(false); |
984 | 984 |
985 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); | 985 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC())); |
986 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( | 986 rtp_receive_statistics_->RegisterRtcpStatisticsCallback( |
987 statistics_proxy_.get()); | 987 statistics_proxy_.get()); |
988 } | 988 } |
989 | 989 |
990 Channel::~Channel() { | 990 Channel::~Channel() { |
991 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); | 991 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(nullptr); |
992 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 992 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
993 "Channel::~Channel() - dtor"); | 993 "Channel::~Channel() - dtor"); |
994 | 994 |
995 if (_outputExternalMedia) { | 995 if (_outputExternalMedia) { |
996 DeRegisterExternalMediaProcessing(kPlaybackPerChannel); | 996 DeRegisterExternalMediaProcessing(kPlaybackPerChannel); |
997 } | 997 } |
998 if (channel_state_.Get().input_external_media) { | 998 if (channel_state_.Get().input_external_media) { |
999 DeRegisterExternalMediaProcessing(kRecordingPerChannel); | 999 DeRegisterExternalMediaProcessing(kRecordingPerChannel); |
1000 } | 1000 } |
1001 StopSend(); | 1001 StopSend(); |
1002 StopPlayout(); | 1002 StopPlayout(); |
1003 | 1003 |
1004 { | 1004 { |
1005 rtc::CritScope cs(&_fileCritSect); | 1005 rtc::CritScope cs(&_fileCritSect); |
1006 if (input_file_player_) { | 1006 if (input_file_player_) { |
1007 input_file_player_->RegisterModuleFileCallback(NULL); | 1007 input_file_player_->RegisterModuleFileCallback(nullptr); |
1008 input_file_player_->StopPlayingFile(); | 1008 input_file_player_->StopPlayingFile(); |
1009 } | 1009 } |
1010 if (output_file_player_) { | 1010 if (output_file_player_) { |
1011 output_file_player_->RegisterModuleFileCallback(NULL); | 1011 output_file_player_->RegisterModuleFileCallback(nullptr); |
1012 output_file_player_->StopPlayingFile(); | 1012 output_file_player_->StopPlayingFile(); |
1013 } | 1013 } |
1014 if (output_file_recorder_) { | 1014 if (output_file_recorder_) { |
1015 output_file_recorder_->RegisterModuleFileCallback(NULL); | 1015 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
1016 output_file_recorder_->StopRecording(); | 1016 output_file_recorder_->StopRecording(); |
1017 } | 1017 } |
1018 } | 1018 } |
1019 | 1019 |
1020 // The order to safely shutdown modules in a channel is: | 1020 // The order to safely shutdown modules in a channel is: |
1021 // 1. De-register callbacks in modules | 1021 // 1. De-register callbacks in modules |
1022 // 2. De-register modules in process thread | 1022 // 2. De-register modules in process thread |
1023 // 3. Destroy modules | 1023 // 3. Destroy modules |
1024 if (audio_coding_->RegisterTransportCallback(NULL) == -1) { | 1024 if (audio_coding_->RegisterTransportCallback(nullptr) == -1) { |
1025 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1025 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
1026 "~Channel() failed to de-register transport callback" | 1026 "~Channel() failed to de-register transport callback" |
1027 " (Audio coding module)"); | 1027 " (Audio coding module)"); |
1028 } | 1028 } |
1029 if (audio_coding_->RegisterVADCallback(NULL) == -1) { | 1029 if (audio_coding_->RegisterVADCallback(nullptr) == -1) { |
1030 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1030 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
1031 "~Channel() failed to de-register VAD callback" | 1031 "~Channel() failed to de-register VAD callback" |
1032 " (Audio coding module)"); | 1032 " (Audio coding module)"); |
1033 } | 1033 } |
1034 // De-register modules in process thread | 1034 // De-register modules in process thread |
1035 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); | 1035 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); |
1036 | 1036 |
1037 // End of modules shutdown | 1037 // End of modules shutdown |
1038 } | 1038 } |
1039 | 1039 |
1040 int32_t Channel::Init() { | 1040 int32_t Channel::Init() { |
1041 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1041 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1042 "Channel::Init()"); | 1042 "Channel::Init()"); |
1043 | 1043 |
1044 channel_state_.Reset(); | 1044 channel_state_.Reset(); |
1045 | 1045 |
1046 // --- Initial sanity | 1046 // --- Initial sanity |
1047 | 1047 |
1048 if ((_engineStatisticsPtr == NULL) || (_moduleProcessThreadPtr == NULL)) { | 1048 if ((_engineStatisticsPtr == nullptr) || |
| 1049 (_moduleProcessThreadPtr == nullptr)) { |
1049 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 1050 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
1050 "Channel::Init() must call SetEngineInformation() first"); | 1051 "Channel::Init() must call SetEngineInformation() first"); |
1051 return -1; | 1052 return -1; |
1052 } | 1053 } |
1053 | 1054 |
1054 // --- Add modules to process thread (for periodic schedulation) | 1055 // --- Add modules to process thread (for periodic schedulation) |
1055 | 1056 |
1056 _moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get()); | 1057 _moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get()); |
1057 | 1058 |
1058 // --- ACM initialization | 1059 // --- ACM initialization |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1305 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1305 "Channel::DeRegisterVoiceEngineObserver()"); | 1306 "Channel::DeRegisterVoiceEngineObserver()"); |
1306 rtc::CritScope cs(&_callbackCritSect); | 1307 rtc::CritScope cs(&_callbackCritSect); |
1307 | 1308 |
1308 if (!_voiceEngineObserverPtr) { | 1309 if (!_voiceEngineObserverPtr) { |
1309 _engineStatisticsPtr->SetLastError( | 1310 _engineStatisticsPtr->SetLastError( |
1310 VE_INVALID_OPERATION, kTraceWarning, | 1311 VE_INVALID_OPERATION, kTraceWarning, |
1311 "DeRegisterVoiceEngineObserver() observer already disabled"); | 1312 "DeRegisterVoiceEngineObserver() observer already disabled"); |
1312 return 0; | 1313 return 0; |
1313 } | 1314 } |
1314 _voiceEngineObserverPtr = NULL; | 1315 _voiceEngineObserverPtr = nullptr; |
1315 return 0; | 1316 return 0; |
1316 } | 1317 } |
1317 | 1318 |
1318 int32_t Channel::GetSendCodec(CodecInst& codec) { | 1319 int32_t Channel::GetSendCodec(CodecInst& codec) { |
1319 auto send_codec = codec_manager_.GetCodecInst(); | 1320 auto send_codec = codec_manager_.GetCodecInst(); |
1320 if (send_codec) { | 1321 if (send_codec) { |
1321 codec = *send_codec; | 1322 codec = *send_codec; |
1322 return 0; | 1323 return 0; |
1323 } | 1324 } |
1324 return -1; | 1325 return -1; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 if (_transportPtr) { | 1624 if (_transportPtr) { |
1624 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1625 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1625 "DeRegisterExternalTransport() all transport is disabled"); | 1626 "DeRegisterExternalTransport() all transport is disabled"); |
1626 } else { | 1627 } else { |
1627 _engineStatisticsPtr->SetLastError( | 1628 _engineStatisticsPtr->SetLastError( |
1628 VE_INVALID_OPERATION, kTraceWarning, | 1629 VE_INVALID_OPERATION, kTraceWarning, |
1629 "DeRegisterExternalTransport() external transport already " | 1630 "DeRegisterExternalTransport() external transport already " |
1630 "disabled"); | 1631 "disabled"); |
1631 } | 1632 } |
1632 _externalTransport = false; | 1633 _externalTransport = false; |
1633 _transportPtr = NULL; | 1634 _transportPtr = nullptr; |
1634 return 0; | 1635 return 0; |
1635 } | 1636 } |
1636 | 1637 |
1637 int32_t Channel::ReceivedRTPPacket(const uint8_t* received_packet, | 1638 int32_t Channel::ReceivedRTPPacket(const uint8_t* received_packet, |
1638 size_t length, | 1639 size_t length, |
1639 const PacketTime& packet_time) { | 1640 const PacketTime& packet_time) { |
1640 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 1641 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
1641 "Channel::ReceivedRTPPacket()"); | 1642 "Channel::ReceivedRTPPacket()"); |
1642 | 1643 |
1643 // Store playout timestamp for the received RTP packet | 1644 // Store playout timestamp for the received RTP packet |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 bool in_order) const { | 1722 bool in_order) const { |
1722 // Retransmissions are handled separately if RTX is enabled. | 1723 // Retransmissions are handled separately if RTX is enabled. |
1723 if (rtp_payload_registry_->RtxEnabled()) | 1724 if (rtp_payload_registry_->RtxEnabled()) |
1724 return false; | 1725 return false; |
1725 StreamStatistician* statistician = | 1726 StreamStatistician* statistician = |
1726 rtp_receive_statistics_->GetStatistician(header.ssrc); | 1727 rtp_receive_statistics_->GetStatistician(header.ssrc); |
1727 if (!statistician) | 1728 if (!statistician) |
1728 return false; | 1729 return false; |
1729 // Check if this is a retransmission. | 1730 // Check if this is a retransmission. |
1730 int64_t min_rtt = 0; | 1731 int64_t min_rtt = 0; |
1731 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); | 1732 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), nullptr, nullptr, &min_rtt, |
| 1733 nullptr); |
1732 return !in_order && statistician->IsRetransmitOfOldPacket(header, min_rtt); | 1734 return !in_order && statistician->IsRetransmitOfOldPacket(header, min_rtt); |
1733 } | 1735 } |
1734 | 1736 |
1735 int32_t Channel::ReceivedRTCPPacket(const uint8_t* data, size_t length) { | 1737 int32_t Channel::ReceivedRTCPPacket(const uint8_t* data, size_t length) { |
1736 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 1738 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
1737 "Channel::ReceivedRTCPPacket()"); | 1739 "Channel::ReceivedRTCPPacket()"); |
1738 // Store playout timestamp for the received RTCP packet | 1740 // Store playout timestamp for the received RTCP packet |
1739 UpdatePlayoutTimestamp(true); | 1741 UpdatePlayoutTimestamp(true); |
1740 | 1742 |
1741 // Deliver RTCP packet to RTP/RTCP module for parsing | 1743 // Deliver RTCP packet to RTP/RTCP module for parsing |
(...skipping 20 matching lines...) Expand all Loading... |
1762 // Invoke audio encoders OnReceivedRtt(). | 1764 // Invoke audio encoders OnReceivedRtt(). |
1763 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1765 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
1764 if (*encoder) | 1766 if (*encoder) |
1765 (*encoder)->OnReceivedRtt(rtt); | 1767 (*encoder)->OnReceivedRtt(rtt); |
1766 }); | 1768 }); |
1767 | 1769 |
1768 uint32_t ntp_secs = 0; | 1770 uint32_t ntp_secs = 0; |
1769 uint32_t ntp_frac = 0; | 1771 uint32_t ntp_frac = 0; |
1770 uint32_t rtp_timestamp = 0; | 1772 uint32_t rtp_timestamp = 0; |
1771 if (0 != | 1773 if (0 != |
1772 _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, | 1774 _rtpRtcpModule->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, |
1773 &rtp_timestamp)) { | 1775 &rtp_timestamp)) { |
1774 // Waiting for RTCP. | 1776 // Waiting for RTCP. |
1775 return 0; | 1777 return 0; |
1776 } | 1778 } |
1777 | 1779 |
1778 { | 1780 { |
1779 rtc::CritScope lock(&ts_stats_lock_); | 1781 rtc::CritScope lock(&ts_stats_lock_); |
1780 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); | 1782 ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); |
1781 } | 1783 } |
1782 return 0; | 1784 return 0; |
(...skipping 17 matching lines...) Expand all Loading... |
1800 _engineStatisticsPtr->SetLastError( | 1802 _engineStatisticsPtr->SetLastError( |
1801 VE_ALREADY_PLAYING, kTraceError, | 1803 VE_ALREADY_PLAYING, kTraceError, |
1802 "StartPlayingFileLocally() is already playing"); | 1804 "StartPlayingFileLocally() is already playing"); |
1803 return -1; | 1805 return -1; |
1804 } | 1806 } |
1805 | 1807 |
1806 { | 1808 { |
1807 rtc::CritScope cs(&_fileCritSect); | 1809 rtc::CritScope cs(&_fileCritSect); |
1808 | 1810 |
1809 if (output_file_player_) { | 1811 if (output_file_player_) { |
1810 output_file_player_->RegisterModuleFileCallback(NULL); | 1812 output_file_player_->RegisterModuleFileCallback(nullptr); |
1811 output_file_player_.reset(); | 1813 output_file_player_.reset(); |
1812 } | 1814 } |
1813 | 1815 |
1814 output_file_player_ = FilePlayer::CreateFilePlayer( | 1816 output_file_player_ = FilePlayer::CreateFilePlayer( |
1815 _outputFilePlayerId, (const FileFormats)format); | 1817 _outputFilePlayerId, (const FileFormats)format); |
1816 | 1818 |
1817 if (!output_file_player_) { | 1819 if (!output_file_player_) { |
1818 _engineStatisticsPtr->SetLastError( | 1820 _engineStatisticsPtr->SetLastError( |
1819 VE_INVALID_ARGUMENT, kTraceError, | 1821 VE_INVALID_ARGUMENT, kTraceError, |
1820 "StartPlayingFileLocally() filePlayer format is not correct"); | 1822 "StartPlayingFileLocally() filePlayer format is not correct"); |
(...skipping 26 matching lines...) Expand all Loading... |
1847 FileFormats format, | 1849 FileFormats format, |
1848 int startPosition, | 1850 int startPosition, |
1849 float volumeScaling, | 1851 float volumeScaling, |
1850 int stopPosition, | 1852 int stopPosition, |
1851 const CodecInst* codecInst) { | 1853 const CodecInst* codecInst) { |
1852 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1854 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
1853 "Channel::StartPlayingFileLocally(format=%d," | 1855 "Channel::StartPlayingFileLocally(format=%d," |
1854 " volumeScaling=%5.3f, startPosition=%d, stopPosition=%d)", | 1856 " volumeScaling=%5.3f, startPosition=%d, stopPosition=%d)", |
1855 format, volumeScaling, startPosition, stopPosition); | 1857 format, volumeScaling, startPosition, stopPosition); |
1856 | 1858 |
1857 if (stream == NULL) { | 1859 if (stream == nullptr) { |
1858 _engineStatisticsPtr->SetLastError( | 1860 _engineStatisticsPtr->SetLastError( |
1859 VE_BAD_FILE, kTraceError, | 1861 VE_BAD_FILE, kTraceError, |
1860 "StartPlayingFileLocally() NULL as input stream"); | 1862 "StartPlayingFileLocally() null as input stream"); |
1861 return -1; | 1863 return -1; |
1862 } | 1864 } |
1863 | 1865 |
1864 if (channel_state_.Get().output_file_playing) { | 1866 if (channel_state_.Get().output_file_playing) { |
1865 _engineStatisticsPtr->SetLastError( | 1867 _engineStatisticsPtr->SetLastError( |
1866 VE_ALREADY_PLAYING, kTraceError, | 1868 VE_ALREADY_PLAYING, kTraceError, |
1867 "StartPlayingFileLocally() is already playing"); | 1869 "StartPlayingFileLocally() is already playing"); |
1868 return -1; | 1870 return -1; |
1869 } | 1871 } |
1870 | 1872 |
1871 { | 1873 { |
1872 rtc::CritScope cs(&_fileCritSect); | 1874 rtc::CritScope cs(&_fileCritSect); |
1873 | 1875 |
1874 // Destroy the old instance | 1876 // Destroy the old instance |
1875 if (output_file_player_) { | 1877 if (output_file_player_) { |
1876 output_file_player_->RegisterModuleFileCallback(NULL); | 1878 output_file_player_->RegisterModuleFileCallback(nullptr); |
1877 output_file_player_.reset(); | 1879 output_file_player_.reset(); |
1878 } | 1880 } |
1879 | 1881 |
1880 // Create the instance | 1882 // Create the instance |
1881 output_file_player_ = FilePlayer::CreateFilePlayer( | 1883 output_file_player_ = FilePlayer::CreateFilePlayer( |
1882 _outputFilePlayerId, (const FileFormats)format); | 1884 _outputFilePlayerId, (const FileFormats)format); |
1883 | 1885 |
1884 if (!output_file_player_) { | 1886 if (!output_file_player_) { |
1885 _engineStatisticsPtr->SetLastError( | 1887 _engineStatisticsPtr->SetLastError( |
1886 VE_INVALID_ARGUMENT, kTraceError, | 1888 VE_INVALID_ARGUMENT, kTraceError, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 | 1922 |
1921 { | 1923 { |
1922 rtc::CritScope cs(&_fileCritSect); | 1924 rtc::CritScope cs(&_fileCritSect); |
1923 | 1925 |
1924 if (output_file_player_->StopPlayingFile() != 0) { | 1926 if (output_file_player_->StopPlayingFile() != 0) { |
1925 _engineStatisticsPtr->SetLastError( | 1927 _engineStatisticsPtr->SetLastError( |
1926 VE_STOP_RECORDING_FAILED, kTraceError, | 1928 VE_STOP_RECORDING_FAILED, kTraceError, |
1927 "StopPlayingFile() could not stop playing"); | 1929 "StopPlayingFile() could not stop playing"); |
1928 return -1; | 1930 return -1; |
1929 } | 1931 } |
1930 output_file_player_->RegisterModuleFileCallback(NULL); | 1932 output_file_player_->RegisterModuleFileCallback(nullptr); |
1931 output_file_player_.reset(); | 1933 output_file_player_.reset(); |
1932 channel_state_.SetOutputFilePlaying(false); | 1934 channel_state_.SetOutputFilePlaying(false); |
1933 } | 1935 } |
1934 // _fileCritSect cannot be taken while calling | 1936 // _fileCritSect cannot be taken while calling |
1935 // SetAnonymousMixibilityStatus. Refer to comments in | 1937 // SetAnonymousMixibilityStatus. Refer to comments in |
1936 // StartPlayingFileLocally(const char* ...) for more details. | 1938 // StartPlayingFileLocally(const char* ...) for more details. |
1937 if (_outputMixerPtr->SetAnonymousMixabilityStatus(*this, false) != 0) { | 1939 if (_outputMixerPtr->SetAnonymousMixabilityStatus(*this, false) != 0) { |
1938 _engineStatisticsPtr->SetLastError( | 1940 _engineStatisticsPtr->SetLastError( |
1939 VE_AUDIO_CONF_MIX_MODULE_ERROR, kTraceError, | 1941 VE_AUDIO_CONF_MIX_MODULE_ERROR, kTraceError, |
1940 "StopPlayingFile() failed to stop participant from playing as" | 1942 "StopPlayingFile() failed to stop participant from playing as" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 | 1996 |
1995 if (channel_state_.Get().input_file_playing) { | 1997 if (channel_state_.Get().input_file_playing) { |
1996 _engineStatisticsPtr->SetLastError( | 1998 _engineStatisticsPtr->SetLastError( |
1997 VE_ALREADY_PLAYING, kTraceWarning, | 1999 VE_ALREADY_PLAYING, kTraceWarning, |
1998 "StartPlayingFileAsMicrophone() filePlayer is playing"); | 2000 "StartPlayingFileAsMicrophone() filePlayer is playing"); |
1999 return 0; | 2001 return 0; |
2000 } | 2002 } |
2001 | 2003 |
2002 // Destroy the old instance | 2004 // Destroy the old instance |
2003 if (input_file_player_) { | 2005 if (input_file_player_) { |
2004 input_file_player_->RegisterModuleFileCallback(NULL); | 2006 input_file_player_->RegisterModuleFileCallback(nullptr); |
2005 input_file_player_.reset(); | 2007 input_file_player_.reset(); |
2006 } | 2008 } |
2007 | 2009 |
2008 // Create the instance | 2010 // Create the instance |
2009 input_file_player_ = FilePlayer::CreateFilePlayer(_inputFilePlayerId, | 2011 input_file_player_ = FilePlayer::CreateFilePlayer(_inputFilePlayerId, |
2010 (const FileFormats)format); | 2012 (const FileFormats)format); |
2011 | 2013 |
2012 if (!input_file_player_) { | 2014 if (!input_file_player_) { |
2013 _engineStatisticsPtr->SetLastError( | 2015 _engineStatisticsPtr->SetLastError( |
2014 VE_INVALID_ARGUMENT, kTraceError, | 2016 VE_INVALID_ARGUMENT, kTraceError, |
(...skipping 23 matching lines...) Expand all Loading... |
2038 FileFormats format, | 2040 FileFormats format, |
2039 int startPosition, | 2041 int startPosition, |
2040 float volumeScaling, | 2042 float volumeScaling, |
2041 int stopPosition, | 2043 int stopPosition, |
2042 const CodecInst* codecInst) { | 2044 const CodecInst* codecInst) { |
2043 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2045 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2044 "Channel::StartPlayingFileAsMicrophone(format=%d, " | 2046 "Channel::StartPlayingFileAsMicrophone(format=%d, " |
2045 "volumeScaling=%5.3f, startPosition=%d, stopPosition=%d)", | 2047 "volumeScaling=%5.3f, startPosition=%d, stopPosition=%d)", |
2046 format, volumeScaling, startPosition, stopPosition); | 2048 format, volumeScaling, startPosition, stopPosition); |
2047 | 2049 |
2048 if (stream == NULL) { | 2050 if (stream == nullptr) { |
2049 _engineStatisticsPtr->SetLastError( | 2051 _engineStatisticsPtr->SetLastError( |
2050 VE_BAD_FILE, kTraceError, | 2052 VE_BAD_FILE, kTraceError, |
2051 "StartPlayingFileAsMicrophone NULL as input stream"); | 2053 "StartPlayingFileAsMicrophone null as input stream"); |
2052 return -1; | 2054 return -1; |
2053 } | 2055 } |
2054 | 2056 |
2055 rtc::CritScope cs(&_fileCritSect); | 2057 rtc::CritScope cs(&_fileCritSect); |
2056 | 2058 |
2057 if (channel_state_.Get().input_file_playing) { | 2059 if (channel_state_.Get().input_file_playing) { |
2058 _engineStatisticsPtr->SetLastError( | 2060 _engineStatisticsPtr->SetLastError( |
2059 VE_ALREADY_PLAYING, kTraceWarning, | 2061 VE_ALREADY_PLAYING, kTraceWarning, |
2060 "StartPlayingFileAsMicrophone() is playing"); | 2062 "StartPlayingFileAsMicrophone() is playing"); |
2061 return 0; | 2063 return 0; |
2062 } | 2064 } |
2063 | 2065 |
2064 // Destroy the old instance | 2066 // Destroy the old instance |
2065 if (input_file_player_) { | 2067 if (input_file_player_) { |
2066 input_file_player_->RegisterModuleFileCallback(NULL); | 2068 input_file_player_->RegisterModuleFileCallback(nullptr); |
2067 input_file_player_.reset(); | 2069 input_file_player_.reset(); |
2068 } | 2070 } |
2069 | 2071 |
2070 // Create the instance | 2072 // Create the instance |
2071 input_file_player_ = FilePlayer::CreateFilePlayer(_inputFilePlayerId, | 2073 input_file_player_ = FilePlayer::CreateFilePlayer(_inputFilePlayerId, |
2072 (const FileFormats)format); | 2074 (const FileFormats)format); |
2073 | 2075 |
2074 if (!input_file_player_) { | 2076 if (!input_file_player_) { |
2075 _engineStatisticsPtr->SetLastError( | 2077 _engineStatisticsPtr->SetLastError( |
2076 VE_INVALID_ARGUMENT, kTraceError, | 2078 VE_INVALID_ARGUMENT, kTraceError, |
(...skipping 29 matching lines...) Expand all Loading... |
2106 if (!channel_state_.Get().input_file_playing) { | 2108 if (!channel_state_.Get().input_file_playing) { |
2107 return 0; | 2109 return 0; |
2108 } | 2110 } |
2109 | 2111 |
2110 if (input_file_player_->StopPlayingFile() != 0) { | 2112 if (input_file_player_->StopPlayingFile() != 0) { |
2111 _engineStatisticsPtr->SetLastError( | 2113 _engineStatisticsPtr->SetLastError( |
2112 VE_STOP_RECORDING_FAILED, kTraceError, | 2114 VE_STOP_RECORDING_FAILED, kTraceError, |
2113 "StopPlayingFile() could not stop playing"); | 2115 "StopPlayingFile() could not stop playing"); |
2114 return -1; | 2116 return -1; |
2115 } | 2117 } |
2116 input_file_player_->RegisterModuleFileCallback(NULL); | 2118 input_file_player_->RegisterModuleFileCallback(nullptr); |
2117 input_file_player_.reset(); | 2119 input_file_player_.reset(); |
2118 channel_state_.SetInputFilePlaying(false); | 2120 channel_state_.SetInputFilePlaying(false); |
2119 | 2121 |
2120 return 0; | 2122 return 0; |
2121 } | 2123 } |
2122 | 2124 |
2123 int Channel::IsPlayingFileAsMicrophone() const { | 2125 int Channel::IsPlayingFileAsMicrophone() const { |
2124 return channel_state_.Get().input_file_playing; | 2126 return channel_state_.Get().input_file_playing; |
2125 } | 2127 } |
2126 | 2128 |
2127 int Channel::StartRecordingPlayout(const char* fileName, | 2129 int Channel::StartRecordingPlayout(const char* fileName, |
2128 const CodecInst* codecInst) { | 2130 const CodecInst* codecInst) { |
2129 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2131 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2130 "Channel::StartRecordingPlayout(fileName=%s)", fileName); | 2132 "Channel::StartRecordingPlayout(fileName=%s)", fileName); |
2131 | 2133 |
2132 if (_outputFileRecording) { | 2134 if (_outputFileRecording) { |
2133 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), | 2135 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), |
2134 "StartRecordingPlayout() is already recording"); | 2136 "StartRecordingPlayout() is already recording"); |
2135 return 0; | 2137 return 0; |
2136 } | 2138 } |
2137 | 2139 |
2138 FileFormats format; | 2140 FileFormats format; |
2139 const uint32_t notificationTime(0); // Not supported in VoE | 2141 const uint32_t notificationTime(0); // Not supported in VoE |
2140 CodecInst dummyCodec = {100, "L16", 16000, 320, 1, 320000}; | 2142 CodecInst dummyCodec = {100, "L16", 16000, 320, 1, 320000}; |
2141 | 2143 |
2142 if ((codecInst != NULL) && | 2144 if ((codecInst != nullptr) && |
2143 ((codecInst->channels < 1) || (codecInst->channels > 2))) { | 2145 ((codecInst->channels < 1) || (codecInst->channels > 2))) { |
2144 _engineStatisticsPtr->SetLastError( | 2146 _engineStatisticsPtr->SetLastError( |
2145 VE_BAD_ARGUMENT, kTraceError, | 2147 VE_BAD_ARGUMENT, kTraceError, |
2146 "StartRecordingPlayout() invalid compression"); | 2148 "StartRecordingPlayout() invalid compression"); |
2147 return (-1); | 2149 return (-1); |
2148 } | 2150 } |
2149 if (codecInst == NULL) { | 2151 if (codecInst == nullptr) { |
2150 format = kFileFormatPcm16kHzFile; | 2152 format = kFileFormatPcm16kHzFile; |
2151 codecInst = &dummyCodec; | 2153 codecInst = &dummyCodec; |
2152 } else if ((STR_CASE_CMP(codecInst->plname, "L16") == 0) || | 2154 } else if ((STR_CASE_CMP(codecInst->plname, "L16") == 0) || |
2153 (STR_CASE_CMP(codecInst->plname, "PCMU") == 0) || | 2155 (STR_CASE_CMP(codecInst->plname, "PCMU") == 0) || |
2154 (STR_CASE_CMP(codecInst->plname, "PCMA") == 0)) { | 2156 (STR_CASE_CMP(codecInst->plname, "PCMA") == 0)) { |
2155 format = kFileFormatWavFile; | 2157 format = kFileFormatWavFile; |
2156 } else { | 2158 } else { |
2157 format = kFileFormatCompressedFile; | 2159 format = kFileFormatCompressedFile; |
2158 } | 2160 } |
2159 | 2161 |
2160 rtc::CritScope cs(&_fileCritSect); | 2162 rtc::CritScope cs(&_fileCritSect); |
2161 | 2163 |
2162 // Destroy the old instance | 2164 // Destroy the old instance |
2163 if (output_file_recorder_) { | 2165 if (output_file_recorder_) { |
2164 output_file_recorder_->RegisterModuleFileCallback(NULL); | 2166 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
2165 output_file_recorder_.reset(); | 2167 output_file_recorder_.reset(); |
2166 } | 2168 } |
2167 | 2169 |
2168 output_file_recorder_ = FileRecorder::CreateFileRecorder( | 2170 output_file_recorder_ = FileRecorder::CreateFileRecorder( |
2169 _outputFileRecorderId, (const FileFormats)format); | 2171 _outputFileRecorderId, (const FileFormats)format); |
2170 if (!output_file_recorder_) { | 2172 if (!output_file_recorder_) { |
2171 _engineStatisticsPtr->SetLastError( | 2173 _engineStatisticsPtr->SetLastError( |
2172 VE_INVALID_ARGUMENT, kTraceError, | 2174 VE_INVALID_ARGUMENT, kTraceError, |
2173 "StartRecordingPlayout() fileRecorder format isnot correct"); | 2175 "StartRecordingPlayout() fileRecorder format isnot correct"); |
2174 return -1; | 2176 return -1; |
(...skipping 22 matching lines...) Expand all Loading... |
2197 if (_outputFileRecording) { | 2199 if (_outputFileRecording) { |
2198 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), | 2200 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), |
2199 "StartRecordingPlayout() is already recording"); | 2201 "StartRecordingPlayout() is already recording"); |
2200 return 0; | 2202 return 0; |
2201 } | 2203 } |
2202 | 2204 |
2203 FileFormats format; | 2205 FileFormats format; |
2204 const uint32_t notificationTime(0); // Not supported in VoE | 2206 const uint32_t notificationTime(0); // Not supported in VoE |
2205 CodecInst dummyCodec = {100, "L16", 16000, 320, 1, 320000}; | 2207 CodecInst dummyCodec = {100, "L16", 16000, 320, 1, 320000}; |
2206 | 2208 |
2207 if (codecInst != NULL && codecInst->channels != 1) { | 2209 if (codecInst != nullptr && codecInst->channels != 1) { |
2208 _engineStatisticsPtr->SetLastError( | 2210 _engineStatisticsPtr->SetLastError( |
2209 VE_BAD_ARGUMENT, kTraceError, | 2211 VE_BAD_ARGUMENT, kTraceError, |
2210 "StartRecordingPlayout() invalid compression"); | 2212 "StartRecordingPlayout() invalid compression"); |
2211 return (-1); | 2213 return (-1); |
2212 } | 2214 } |
2213 if (codecInst == NULL) { | 2215 if (codecInst == nullptr) { |
2214 format = kFileFormatPcm16kHzFile; | 2216 format = kFileFormatPcm16kHzFile; |
2215 codecInst = &dummyCodec; | 2217 codecInst = &dummyCodec; |
2216 } else if ((STR_CASE_CMP(codecInst->plname, "L16") == 0) || | 2218 } else if ((STR_CASE_CMP(codecInst->plname, "L16") == 0) || |
2217 (STR_CASE_CMP(codecInst->plname, "PCMU") == 0) || | 2219 (STR_CASE_CMP(codecInst->plname, "PCMU") == 0) || |
2218 (STR_CASE_CMP(codecInst->plname, "PCMA") == 0)) { | 2220 (STR_CASE_CMP(codecInst->plname, "PCMA") == 0)) { |
2219 format = kFileFormatWavFile; | 2221 format = kFileFormatWavFile; |
2220 } else { | 2222 } else { |
2221 format = kFileFormatCompressedFile; | 2223 format = kFileFormatCompressedFile; |
2222 } | 2224 } |
2223 | 2225 |
2224 rtc::CritScope cs(&_fileCritSect); | 2226 rtc::CritScope cs(&_fileCritSect); |
2225 | 2227 |
2226 // Destroy the old instance | 2228 // Destroy the old instance |
2227 if (output_file_recorder_) { | 2229 if (output_file_recorder_) { |
2228 output_file_recorder_->RegisterModuleFileCallback(NULL); | 2230 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
2229 output_file_recorder_.reset(); | 2231 output_file_recorder_.reset(); |
2230 } | 2232 } |
2231 | 2233 |
2232 output_file_recorder_ = FileRecorder::CreateFileRecorder( | 2234 output_file_recorder_ = FileRecorder::CreateFileRecorder( |
2233 _outputFileRecorderId, (const FileFormats)format); | 2235 _outputFileRecorderId, (const FileFormats)format); |
2234 if (!output_file_recorder_) { | 2236 if (!output_file_recorder_) { |
2235 _engineStatisticsPtr->SetLastError( | 2237 _engineStatisticsPtr->SetLastError( |
2236 VE_INVALID_ARGUMENT, kTraceError, | 2238 VE_INVALID_ARGUMENT, kTraceError, |
2237 "StartRecordingPlayout() fileRecorder format isnot correct"); | 2239 "StartRecordingPlayout() fileRecorder format isnot correct"); |
2238 return -1; | 2240 return -1; |
(...skipping 26 matching lines...) Expand all Loading... |
2265 } | 2267 } |
2266 | 2268 |
2267 rtc::CritScope cs(&_fileCritSect); | 2269 rtc::CritScope cs(&_fileCritSect); |
2268 | 2270 |
2269 if (output_file_recorder_->StopRecording() != 0) { | 2271 if (output_file_recorder_->StopRecording() != 0) { |
2270 _engineStatisticsPtr->SetLastError( | 2272 _engineStatisticsPtr->SetLastError( |
2271 VE_STOP_RECORDING_FAILED, kTraceError, | 2273 VE_STOP_RECORDING_FAILED, kTraceError, |
2272 "StopRecording() could not stop recording"); | 2274 "StopRecording() could not stop recording"); |
2273 return (-1); | 2275 return (-1); |
2274 } | 2276 } |
2275 output_file_recorder_->RegisterModuleFileCallback(NULL); | 2277 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
2276 output_file_recorder_.reset(); | 2278 output_file_recorder_.reset(); |
2277 _outputFileRecording = false; | 2279 _outputFileRecording = false; |
2278 | 2280 |
2279 return 0; | 2281 return 0; |
2280 } | 2282 } |
2281 | 2283 |
2282 void Channel::SetMixWithMicStatus(bool mix) { | 2284 void Channel::SetMixWithMicStatus(bool mix) { |
2283 rtc::CritScope cs(&_fileCritSect); | 2285 rtc::CritScope cs(&_fileCritSect); |
2284 _mixFileWithMicrophone = mix; | 2286 _mixFileWithMicrophone = mix; |
2285 } | 2287 } |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 if (_rtpRtcpModule->SetCNAME(cName) != 0) { | 2495 if (_rtpRtcpModule->SetCNAME(cName) != 0) { |
2494 _engineStatisticsPtr->SetLastError( | 2496 _engineStatisticsPtr->SetLastError( |
2495 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 2497 VE_RTP_RTCP_MODULE_ERROR, kTraceError, |
2496 "SetRTCP_CNAME() failed to set RTCP CNAME"); | 2498 "SetRTCP_CNAME() failed to set RTCP CNAME"); |
2497 return -1; | 2499 return -1; |
2498 } | 2500 } |
2499 return 0; | 2501 return 0; |
2500 } | 2502 } |
2501 | 2503 |
2502 int Channel::GetRemoteRTCP_CNAME(char cName[256]) { | 2504 int Channel::GetRemoteRTCP_CNAME(char cName[256]) { |
2503 if (cName == NULL) { | 2505 if (cName == nullptr) { |
2504 _engineStatisticsPtr->SetLastError( | 2506 _engineStatisticsPtr->SetLastError( |
2505 VE_INVALID_ARGUMENT, kTraceError, | 2507 VE_INVALID_ARGUMENT, kTraceError, |
2506 "GetRemoteRTCP_CNAME() invalid CNAME input buffer"); | 2508 "GetRemoteRTCP_CNAME() invalid CNAME input buffer"); |
2507 return -1; | 2509 return -1; |
2508 } | 2510 } |
2509 char cname[RTCP_CNAME_SIZE]; | 2511 char cname[RTCP_CNAME_SIZE]; |
2510 const uint32_t remoteSSRC = rtp_receiver_->SSRC(); | 2512 const uint32_t remoteSSRC = rtp_receiver_->SSRC(); |
2511 if (_rtpRtcpModule->RemoteCNAME(remoteSSRC, cname) != 0) { | 2513 if (_rtpRtcpModule->RemoteCNAME(remoteSSRC, cname) != 0) { |
2512 _engineStatisticsPtr->SetLastError( | 2514 _engineStatisticsPtr->SetLastError( |
2513 VE_CANNOT_RETRIEVE_CNAME, kTraceError, | 2515 VE_CANNOT_RETRIEVE_CNAME, kTraceError, |
(...skipping 26 matching lines...) Expand all Loading... |
2540 NTPHigh = senderInfo.NTPseconds; | 2542 NTPHigh = senderInfo.NTPseconds; |
2541 NTPLow = senderInfo.NTPfraction; | 2543 NTPLow = senderInfo.NTPfraction; |
2542 timestamp = senderInfo.RTPtimeStamp; | 2544 timestamp = senderInfo.RTPtimeStamp; |
2543 | 2545 |
2544 // --- Locally derived information | 2546 // --- Locally derived information |
2545 | 2547 |
2546 // This value is updated on each incoming RTCP packet (0 when no packet | 2548 // This value is updated on each incoming RTCP packet (0 when no packet |
2547 // has been received) | 2549 // has been received) |
2548 playoutTimestamp = playout_timestamp_rtcp_; | 2550 playoutTimestamp = playout_timestamp_rtcp_; |
2549 | 2551 |
2550 if (NULL != jitter || NULL != fractionLost) { | 2552 if (nullptr != jitter || nullptr != fractionLost) { |
2551 // Get all RTCP receiver report blocks that have been received on this | 2553 // Get all RTCP receiver report blocks that have been received on this |
2552 // channel. If we receive RTP packets from a remote source we know the | 2554 // channel. If we receive RTP packets from a remote source we know the |
2553 // remote SSRC and use the report block from him. | 2555 // remote SSRC and use the report block from him. |
2554 // Otherwise use the first report block. | 2556 // Otherwise use the first report block. |
2555 std::vector<RTCPReportBlock> remote_stats; | 2557 std::vector<RTCPReportBlock> remote_stats; |
2556 if (_rtpRtcpModule->RemoteRTCPStat(&remote_stats) != 0 || | 2558 if (_rtpRtcpModule->RemoteRTCPStat(&remote_stats) != 0 || |
2557 remote_stats.empty()) { | 2559 remote_stats.empty()) { |
2558 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 2560 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
2559 "GetRemoteRTCPData() failed to measure statistics due" | 2561 "GetRemoteRTCPData() failed to measure statistics due" |
2560 " to lack of received RTP and/or RTCP packets"); | 2562 " to lack of received RTP and/or RTCP packets"); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2593 const char* data, | 2595 const char* data, |
2594 unsigned short dataLengthInBytes) { | 2596 unsigned short dataLengthInBytes) { |
2595 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2597 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2596 "Channel::SendApplicationDefinedRTCPPacket()"); | 2598 "Channel::SendApplicationDefinedRTCPPacket()"); |
2597 if (!channel_state_.Get().sending) { | 2599 if (!channel_state_.Get().sending) { |
2598 _engineStatisticsPtr->SetLastError( | 2600 _engineStatisticsPtr->SetLastError( |
2599 VE_NOT_SENDING, kTraceError, | 2601 VE_NOT_SENDING, kTraceError, |
2600 "SendApplicationDefinedRTCPPacket() not sending"); | 2602 "SendApplicationDefinedRTCPPacket() not sending"); |
2601 return -1; | 2603 return -1; |
2602 } | 2604 } |
2603 if (NULL == data) { | 2605 if (nullptr == data) { |
2604 _engineStatisticsPtr->SetLastError( | 2606 _engineStatisticsPtr->SetLastError( |
2605 VE_INVALID_ARGUMENT, kTraceError, | 2607 VE_INVALID_ARGUMENT, kTraceError, |
2606 "SendApplicationDefinedRTCPPacket() invalid data value"); | 2608 "SendApplicationDefinedRTCPPacket() invalid data value"); |
2607 return -1; | 2609 return -1; |
2608 } | 2610 } |
2609 if (dataLengthInBytes % 4 != 0) { | 2611 if (dataLengthInBytes % 4 != 0) { |
2610 _engineStatisticsPtr->SetLastError( | 2612 _engineStatisticsPtr->SetLastError( |
2611 VE_INVALID_ARGUMENT, kTraceError, | 2613 VE_INVALID_ARGUMENT, kTraceError, |
2612 "SendApplicationDefinedRTCPPacket() invalid length value"); | 2614 "SendApplicationDefinedRTCPPacket() invalid length value"); |
2613 return -1; | 2615 return -1; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 averageJitterMs = stats.rtcp.jitter / (playoutFrequency / 1000); | 2659 averageJitterMs = stats.rtcp.jitter / (playoutFrequency / 1000); |
2658 } | 2660 } |
2659 | 2661 |
2660 discardedPackets = _numberOfDiscardedPackets; | 2662 discardedPackets = _numberOfDiscardedPackets; |
2661 | 2663 |
2662 return 0; | 2664 return 0; |
2663 } | 2665 } |
2664 | 2666 |
2665 int Channel::GetRemoteRTCPReportBlocks( | 2667 int Channel::GetRemoteRTCPReportBlocks( |
2666 std::vector<ReportBlock>* report_blocks) { | 2668 std::vector<ReportBlock>* report_blocks) { |
2667 if (report_blocks == NULL) { | 2669 if (report_blocks == nullptr) { |
2668 _engineStatisticsPtr->SetLastError( | 2670 _engineStatisticsPtr->SetLastError( |
2669 VE_INVALID_ARGUMENT, kTraceError, | 2671 VE_INVALID_ARGUMENT, kTraceError, |
2670 "GetRemoteRTCPReportBlock()s invalid report_blocks."); | 2672 "GetRemoteRTCPReportBlock()s invalid report_blocks."); |
2671 return -1; | 2673 return -1; |
2672 } | 2674 } |
2673 | 2675 |
2674 // Get the report blocks from the latest received RTCP Sender or Receiver | 2676 // Get the report blocks from the latest received RTCP Sender or Receiver |
2675 // Report. Each element in the vector contains the sender's SSRC and a | 2677 // Report. Each element in the vector contains the sender's SSRC and a |
2676 // report block according to RFC 3550. | 2678 // report block according to RFC 3550. |
2677 std::vector<RTCPReportBlock> rtcp_report_blocks; | 2679 std::vector<RTCPReportBlock> rtcp_report_blocks; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 rtc::CritScope lock(&assoc_send_channel_lock_); | 2889 rtc::CritScope lock(&assoc_send_channel_lock_); |
2888 associate_send_channel_ = channel; | 2890 associate_send_channel_ = channel; |
2889 } | 2891 } |
2890 | 2892 |
2891 void Channel::DisassociateSendChannel(int channel_id) { | 2893 void Channel::DisassociateSendChannel(int channel_id) { |
2892 rtc::CritScope lock(&assoc_send_channel_lock_); | 2894 rtc::CritScope lock(&assoc_send_channel_lock_); |
2893 Channel* channel = associate_send_channel_.channel(); | 2895 Channel* channel = associate_send_channel_.channel(); |
2894 if (channel && channel->ChannelId() == channel_id) { | 2896 if (channel && channel->ChannelId() == channel_id) { |
2895 // If this channel is associated with a send channel of the specified | 2897 // If this channel is associated with a send channel of the specified |
2896 // Channel ID, disassociate with it. | 2898 // Channel ID, disassociate with it. |
2897 ChannelOwner ref(NULL); | 2899 ChannelOwner ref(nullptr); |
2898 associate_send_channel_ = ref; | 2900 associate_send_channel_ = ref; |
2899 } | 2901 } |
2900 } | 2902 } |
2901 | 2903 |
2902 void Channel::SetRtcEventLog(RtcEventLog* event_log) { | 2904 void Channel::SetRtcEventLog(RtcEventLog* event_log) { |
2903 event_log_proxy_->SetEventLog(event_log); | 2905 event_log_proxy_->SetEventLog(event_log); |
2904 } | 2906 } |
2905 | 2907 |
2906 void Channel::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { | 2908 void Channel::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { |
2907 rtcp_rtt_stats_proxy_->SetRtcpRttStats(rtcp_rtt_stats); | 2909 rtcp_rtt_stats_proxy_->SetRtcpRttStats(rtcp_rtt_stats); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 | 2967 |
2966 if (kPlaybackPerChannel == type) { | 2968 if (kPlaybackPerChannel == type) { |
2967 if (!_outputExternalMediaCallbackPtr) { | 2969 if (!_outputExternalMediaCallbackPtr) { |
2968 _engineStatisticsPtr->SetLastError( | 2970 _engineStatisticsPtr->SetLastError( |
2969 VE_INVALID_OPERATION, kTraceWarning, | 2971 VE_INVALID_OPERATION, kTraceWarning, |
2970 "Channel::DeRegisterExternalMediaProcessing() " | 2972 "Channel::DeRegisterExternalMediaProcessing() " |
2971 "output external media already disabled"); | 2973 "output external media already disabled"); |
2972 return 0; | 2974 return 0; |
2973 } | 2975 } |
2974 _outputExternalMedia = false; | 2976 _outputExternalMedia = false; |
2975 _outputExternalMediaCallbackPtr = NULL; | 2977 _outputExternalMediaCallbackPtr = nullptr; |
2976 } else if (kRecordingPerChannel == type) { | 2978 } else if (kRecordingPerChannel == type) { |
2977 if (!_inputExternalMediaCallbackPtr) { | 2979 if (!_inputExternalMediaCallbackPtr) { |
2978 _engineStatisticsPtr->SetLastError( | 2980 _engineStatisticsPtr->SetLastError( |
2979 VE_INVALID_OPERATION, kTraceWarning, | 2981 VE_INVALID_OPERATION, kTraceWarning, |
2980 "Channel::DeRegisterExternalMediaProcessing() " | 2982 "Channel::DeRegisterExternalMediaProcessing() " |
2981 "input external media already disabled"); | 2983 "input external media already disabled"); |
2982 return 0; | 2984 return 0; |
2983 } | 2985 } |
2984 channel_state_.SetInputExternalMedia(false); | 2986 channel_state_.SetInputExternalMedia(false); |
2985 _inputExternalMediaCallbackPtr = NULL; | 2987 _inputExternalMediaCallbackPtr = nullptr; |
2986 } | 2988 } |
2987 | 2989 |
2988 return 0; | 2990 return 0; |
2989 } | 2991 } |
2990 | 2992 |
2991 int Channel::SetExternalMixing(bool enabled) { | 2993 int Channel::SetExternalMixing(bool enabled) { |
2992 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 2994 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
2993 "Channel::SetExternalMixing(enabled=%d)", enabled); | 2995 "Channel::SetExternalMixing(enabled=%d)", enabled); |
2994 | 2996 |
2995 if (channel_state_.Get().playing) { | 2997 if (channel_state_.Get().playing) { |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3324 int64_t min_rtt = 0; | 3326 int64_t min_rtt = 0; |
3325 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 3327 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
3326 0) { | 3328 0) { |
3327 return 0; | 3329 return 0; |
3328 } | 3330 } |
3329 return rtt; | 3331 return rtt; |
3330 } | 3332 } |
3331 | 3333 |
3332 } // namespace voe | 3334 } // namespace voe |
3333 } // namespace webrtc | 3335 } // namespace webrtc |
OLD | NEW |