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

Side by Side Diff: webrtc/voice_engine/channel.cc

Issue 2535523002: Refactor RMSLevel and give it new functionality (Closed)
Patch Set: Rename to RmsLevel Created 4 years 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
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "webrtc/voice_engine/channel.h" 11 #include "webrtc/voice_engine/channel.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/base/array_view.h"
16 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
17 #include "webrtc/base/criticalsection.h" 18 #include "webrtc/base/criticalsection.h"
18 #include "webrtc/base/format_macros.h" 19 #include "webrtc/base/format_macros.h"
19 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
20 #include "webrtc/base/rate_limiter.h" 21 #include "webrtc/base/rate_limiter.h"
21 #include "webrtc/base/thread_checker.h" 22 #include "webrtc/base/thread_checker.h"
22 #include "webrtc/base/timeutils.h" 23 #include "webrtc/base/timeutils.h"
23 #include "webrtc/config.h" 24 #include "webrtc/config.h"
24 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 25 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
25 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" 26 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 const RTPFragmentationHeader* fragmentation) { 358 const RTPFragmentationHeader* fragmentation) {
358 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 359 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
359 "Channel::SendData(frameType=%u, payloadType=%u, timeStamp=%u," 360 "Channel::SendData(frameType=%u, payloadType=%u, timeStamp=%u,"
360 " payloadSize=%" PRIuS ", fragmentation=0x%x)", 361 " payloadSize=%" PRIuS ", fragmentation=0x%x)",
361 frameType, payloadType, timeStamp, payloadSize, fragmentation); 362 frameType, payloadType, timeStamp, payloadSize, fragmentation);
362 363
363 if (_includeAudioLevelIndication) { 364 if (_includeAudioLevelIndication) {
364 // Store current audio level in the RTP/RTCP module. 365 // Store current audio level in the RTP/RTCP module.
365 // The level will be used in combination with voice-activity state 366 // The level will be used in combination with voice-activity state
366 // (frameType) to add an RTP header extension 367 // (frameType) to add an RTP header extension
367 _rtpRtcpModule->SetAudioLevel(rms_level_.RMS()); 368 _rtpRtcpModule->SetAudioLevel(rms_level_.Average());
368 } 369 }
369 370
370 // Push data from ACM to RTP/RTCP-module to deliver audio frame for 371 // Push data from ACM to RTP/RTCP-module to deliver audio frame for
371 // packetization. 372 // packetization.
372 // This call will trigger Transport::SendPacket() from the RTP/RTCP module. 373 // This call will trigger Transport::SendPacket() from the RTP/RTCP module.
373 if (!_rtpRtcpModule->SendOutgoingData( 374 if (!_rtpRtcpModule->SendOutgoingData(
374 (FrameType&)frameType, payloadType, timeStamp, 375 (FrameType&)frameType, payloadType, timeStamp,
375 // Leaving the time when this frame was 376 // Leaving the time when this frame was
376 // received from the capture device as 377 // received from the capture device as
377 // undefined for voice for now. 378 // undefined for voice for now.
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 _audioFrame.samples_per_channel_, _audioFrame.sample_rate_hz_, 2758 _audioFrame.samples_per_channel_, _audioFrame.sample_rate_hz_,
2758 isStereo); 2759 isStereo);
2759 } 2760 }
2760 } 2761 }
2761 2762
2762 if (_includeAudioLevelIndication) { 2763 if (_includeAudioLevelIndication) {
2763 size_t length = 2764 size_t length =
2764 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_; 2765 _audioFrame.samples_per_channel_ * _audioFrame.num_channels_;
2765 RTC_CHECK_LE(length, sizeof(_audioFrame.data_)); 2766 RTC_CHECK_LE(length, sizeof(_audioFrame.data_));
2766 if (is_muted && previous_frame_muted_) { 2767 if (is_muted && previous_frame_muted_) {
2767 rms_level_.ProcessMuted(length); 2768 rms_level_.AnalyzeMuted(length);
2768 } else { 2769 } else {
2769 rms_level_.Process(_audioFrame.data_, length); 2770 rms_level_.Analyze(
2771 rtc::ArrayView<const int16_t>(_audioFrame.data_, length));
2770 } 2772 }
2771 } 2773 }
2772 previous_frame_muted_ = is_muted; 2774 previous_frame_muted_ = is_muted;
2773 2775
2774 return 0; 2776 return 0;
2775 } 2777 }
2776 2778
2777 uint32_t Channel::EncodeAndSend() { 2779 uint32_t Channel::EncodeAndSend() {
2778 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 2780 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
2779 "Channel::EncodeAndSend()"); 2781 "Channel::EncodeAndSend()");
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3228 int64_t min_rtt = 0; 3230 int64_t min_rtt = 0;
3229 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3231 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3230 0) { 3232 0) {
3231 return 0; 3233 return 0;
3232 } 3234 }
3233 return rtt; 3235 return rtt;
3234 } 3236 }
3235 3237
3236 } // namespace voe 3238 } // namespace voe
3237 } // namespace webrtc 3239 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698