| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
| 11 #include "webrtc/audio/audio_receive_stream.h" | 11 #include "webrtc/audio/audio_receive_stream.h" |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "webrtc/audio/audio_state.h" |
| 15 #include "webrtc/audio/conversion.h" | 16 #include "webrtc/audio/conversion.h" |
| 16 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 19 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 19 #include "webrtc/system_wrappers/include/tick_util.h" | 20 #include "webrtc/system_wrappers/include/tick_util.h" |
| 20 #include "webrtc/voice_engine/include/voe_base.h" | 21 #include "webrtc/voice_engine/include/voe_base.h" |
| 21 #include "webrtc/voice_engine/include/voe_codec.h" | 22 #include "webrtc/voice_engine/include/voe_codec.h" |
| 22 #include "webrtc/voice_engine/include/voe_neteq_stats.h" | 23 #include "webrtc/voice_engine/include/voe_neteq_stats.h" |
| 23 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 24 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 24 #include "webrtc/voice_engine/include/voe_video_sync.h" | 25 #include "webrtc/voice_engine/include/voe_video_sync.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 ss << ", combined_audio_video_bwe: " | 56 ss << ", combined_audio_video_bwe: " |
| 56 << (combined_audio_video_bwe ? "true" : "false"); | 57 << (combined_audio_video_bwe ? "true" : "false"); |
| 57 ss << '}'; | 58 ss << '}'; |
| 58 return ss.str(); | 59 return ss.str(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 namespace internal { | 62 namespace internal { |
| 62 AudioReceiveStream::AudioReceiveStream( | 63 AudioReceiveStream::AudioReceiveStream( |
| 63 RemoteBitrateEstimator* remote_bitrate_estimator, | 64 RemoteBitrateEstimator* remote_bitrate_estimator, |
| 64 const webrtc::AudioReceiveStream::Config& config, | 65 const webrtc::AudioReceiveStream::Config& config, |
| 65 VoiceEngine* voice_engine) | 66 AudioState* audio_state) |
| 66 : remote_bitrate_estimator_(remote_bitrate_estimator), | 67 : remote_bitrate_estimator_(remote_bitrate_estimator), |
| 67 config_(config), | 68 config_(config), |
| 68 voice_engine_(voice_engine), | 69 audio_state_(audio_state), |
| 69 voe_base_(voice_engine), | |
| 70 rtp_header_parser_(RtpHeaderParser::Create()) { | 70 rtp_header_parser_(RtpHeaderParser::Create()) { |
| 71 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); | 71 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); |
| 72 RTC_DCHECK(config.voe_channel_id != -1); | 72 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| 73 RTC_DCHECK(remote_bitrate_estimator_ != nullptr); | 73 RTC_DCHECK(remote_bitrate_estimator_); |
| 74 RTC_DCHECK(voice_engine_ != nullptr); | 74 RTC_DCHECK(audio_state_); |
| 75 RTC_DCHECK(rtp_header_parser_ != nullptr); | 75 RTC_DCHECK(rtp_header_parser_); |
| 76 for (const auto& ext : config.rtp.extensions) { | 76 for (const auto& ext : config.rtp.extensions) { |
| 77 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 77 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
| 78 RTC_DCHECK_GE(ext.id, 1); | 78 RTC_DCHECK_GE(ext.id, 1); |
| 79 RTC_DCHECK_LE(ext.id, 14); | 79 RTC_DCHECK_LE(ext.id, 14); |
| 80 if (ext.name == RtpExtension::kAudioLevel) { | 80 if (ext.name == RtpExtension::kAudioLevel) { |
| 81 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 81 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
| 82 kRtpExtensionAudioLevel, ext.id)); | 82 kRtpExtensionAudioLevel, ext.id)); |
| 83 } else if (ext.name == RtpExtension::kAbsSendTime) { | 83 } else if (ext.name == RtpExtension::kAbsSendTime) { |
| 84 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 84 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
| 85 kRtpExtensionAbsoluteSendTime, ext.id)); | 85 kRtpExtensionAbsoluteSendTime, ext.id)); |
| 86 } else if (ext.name == RtpExtension::kTransportSequenceNumber) { | 86 } else if (ext.name == RtpExtension::kTransportSequenceNumber) { |
| 87 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 87 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
| 88 kRtpExtensionTransportSequenceNumber, ext.id)); | 88 kRtpExtensionTransportSequenceNumber, ext.id)); |
| 89 } else { | 89 } else { |
| 90 RTC_NOTREACHED() << "Unsupported RTP extension."; | 90 RTC_NOTREACHED() << "Unsupported RTP extension."; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 AudioReceiveStream::~AudioReceiveStream() { | 95 AudioReceiveStream::~AudioReceiveStream() { |
| 96 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 96 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 97 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); | 97 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { | 100 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { |
| 101 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 101 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 102 webrtc::AudioReceiveStream::Stats stats; | 102 webrtc::AudioReceiveStream::Stats stats; |
| 103 stats.remote_ssrc = config_.rtp.remote_ssrc; | 103 stats.remote_ssrc = config_.rtp.remote_ssrc; |
| 104 ScopedVoEInterface<VoECodec> codec(voice_engine_); | 104 VoiceEngine* voice_engine = audio_state_->voice_engine(); |
| 105 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine_); | 105 ScopedVoEInterface<VoECodec> codec(voice_engine); |
| 106 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine_); | 106 ScopedVoEInterface<VoENetEqStats> neteq(voice_engine); |
| 107 ScopedVoEInterface<VoEVideoSync> sync(voice_engine_); | 107 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine); |
| 108 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine_); | 108 ScopedVoEInterface<VoEVideoSync> sync(voice_engine); |
| 109 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine); |
| 109 unsigned int ssrc = 0; | 110 unsigned int ssrc = 0; |
| 110 webrtc::CallStatistics call_stats = {0}; | 111 webrtc::CallStatistics call_stats = {0}; |
| 111 webrtc::CodecInst codec_inst = {0}; | 112 webrtc::CodecInst codec_inst = {0}; |
| 112 // Only collect stats if we have seen some traffic with the SSRC. | 113 // Only collect stats if we have seen some traffic with the SSRC. |
| 113 if (rtp->GetRemoteSSRC(config_.voe_channel_id, ssrc) == -1 || | 114 if (rtp->GetRemoteSSRC(config_.voe_channel_id, ssrc) == -1 || |
| 114 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1 || | 115 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1 || |
| 115 codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { | 116 codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { |
| 116 return stats; | 117 return stats; |
| 117 } | 118 } |
| 118 | 119 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 if (packet_time.timestamp >= 0) | 218 if (packet_time.timestamp >= 0) |
| 218 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | 219 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
| 219 size_t payload_size = length - header.headerLength; | 220 size_t payload_size = length - header.headerLength; |
| 220 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, | 221 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, |
| 221 header, false); | 222 header, false); |
| 222 } | 223 } |
| 223 return true; | 224 return true; |
| 224 } | 225 } |
| 225 } // namespace internal | 226 } // namespace internal |
| 226 } // namespace webrtc | 227 } // namespace webrtc |
| OLD | NEW |