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

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

Issue 2667423004: Remove the unused and untested functions from VoERTP_RTCP. (Closed)
Patch Set: rebase Created 3 years, 10 months 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') | webrtc/voice_engine/include/voe_rtp_rtcp.h » ('j') | 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
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 capture_time_ms, bytes, retransmission); 281 capture_time_ms, bytes, retransmission);
282 } 282 }
283 } 283 }
284 284
285 private: 285 private:
286 rtc::ThreadChecker thread_checker_; 286 rtc::ThreadChecker thread_checker_;
287 rtc::CriticalSection crit_; 287 rtc::CriticalSection crit_;
288 RtpPacketSender* rtp_packet_sender_ GUARDED_BY(&crit_); 288 RtpPacketSender* rtp_packet_sender_ GUARDED_BY(&crit_);
289 }; 289 };
290 290
291 // Extend the default RTCP statistics struct with max_jitter, defined as the
292 // maximum jitter value seen in an RTCP report block.
293 struct ChannelStatistics : public RtcpStatistics {
294 ChannelStatistics() : rtcp(), max_jitter(0) {}
295
296 RtcpStatistics rtcp;
297 uint32_t max_jitter;
298 };
299
300 // Statistics callback, called at each generation of a new RTCP report block.
301 class StatisticsProxy : public RtcpStatisticsCallback {
302 public:
303 StatisticsProxy(uint32_t ssrc) : ssrc_(ssrc) {}
304 virtual ~StatisticsProxy() {}
305
306 void StatisticsUpdated(const RtcpStatistics& statistics,
307 uint32_t ssrc) override {
308 if (ssrc != ssrc_)
309 return;
310
311 rtc::CritScope cs(&stats_lock_);
312 stats_.rtcp = statistics;
313 if (statistics.jitter > stats_.max_jitter) {
314 stats_.max_jitter = statistics.jitter;
315 }
316 }
317
318 void CNameChanged(const char* cname, uint32_t ssrc) override {}
319
320 ChannelStatistics GetStats() {
321 rtc::CritScope cs(&stats_lock_);
322 return stats_;
323 }
324
325 private:
326 // StatisticsUpdated calls are triggered from threads in the RTP module,
327 // while GetStats calls can be triggered from the public voice engine API,
328 // hence synchronization is needed.
329 rtc::CriticalSection stats_lock_;
330 const uint32_t ssrc_;
331 ChannelStatistics stats_;
332 };
333
334 class VoERtcpObserver : public RtcpBandwidthObserver { 291 class VoERtcpObserver : public RtcpBandwidthObserver {
335 public: 292 public:
336 explicit VoERtcpObserver(Channel* owner) 293 explicit VoERtcpObserver(Channel* owner)
337 : owner_(owner), bandwidth_observer_(nullptr) {} 294 : owner_(owner), bandwidth_observer_(nullptr) {}
338 virtual ~VoERtcpObserver() {} 295 virtual ~VoERtcpObserver() {}
339 296
340 void SetBandwidthObserver(RtcpBandwidthObserver* bandwidth_observer) { 297 void SetBandwidthObserver(RtcpBandwidthObserver* bandwidth_observer) {
341 rtc::CritScope lock(&crit_); 298 rtc::CritScope lock(&crit_);
342 bandwidth_observer_ = bandwidth_observer; 299 bandwidth_observer_ = bandwidth_observer;
343 } 300 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 " payloadType=%u, audioChannel=%" PRIuS ")", 525 " payloadType=%u, audioChannel=%" PRIuS ")",
569 payloadSize, rtpHeader->header.payloadType, 526 payloadSize, rtpHeader->header.payloadType,
570 rtpHeader->type.Audio.channel); 527 rtpHeader->type.Audio.channel);
571 528
572 if (!channel_state_.Get().playing) { 529 if (!channel_state_.Get().playing) {
573 // Avoid inserting into NetEQ when we are not playing. Count the 530 // Avoid inserting into NetEQ when we are not playing. Count the
574 // packet as discarded. 531 // packet as discarded.
575 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 532 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
576 "received packet is discarded since playing is not" 533 "received packet is discarded since playing is not"
577 " activated"); 534 " activated");
578 _numberOfDiscardedPackets++;
579 return 0; 535 return 0;
580 } 536 }
581 537
582 // Push the incoming payload (parsed and ready for decoding) into the ACM 538 // Push the incoming payload (parsed and ready for decoding) into the ACM
583 if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) != 539 if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) !=
584 0) { 540 0) {
585 _engineStatisticsPtr->SetLastError( 541 _engineStatisticsPtr->SetLastError(
586 VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, 542 VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning,
587 "Channel::OnReceivedPayloadData() unable to push data to the ACM"); 543 "Channel::OnReceivedPayloadData() unable to push data to the ACM");
588 return -1; 544 return -1;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025), 863 _outputFilePlayerId(VoEModuleId(instanceId, channelId) + 1025),
908 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026), 864 _outputFileRecorderId(VoEModuleId(instanceId, channelId) + 1026),
909 _outputFileRecording(false), 865 _outputFileRecording(false),
910 _outputExternalMedia(false), 866 _outputExternalMedia(false),
911 _inputExternalMediaCallbackPtr(NULL), 867 _inputExternalMediaCallbackPtr(NULL),
912 _outputExternalMediaCallbackPtr(NULL), 868 _outputExternalMediaCallbackPtr(NULL),
913 _timeStamp(0), // This is just an offset, RTP module will add it's own 869 _timeStamp(0), // This is just an offset, RTP module will add it's own
914 // random offset 870 // random offset
915 ntp_estimator_(Clock::GetRealTimeClock()), 871 ntp_estimator_(Clock::GetRealTimeClock()),
916 playout_timestamp_rtp_(0), 872 playout_timestamp_rtp_(0),
917 playout_timestamp_rtcp_(0),
918 playout_delay_ms_(0), 873 playout_delay_ms_(0),
919 _numberOfDiscardedPackets(0),
920 send_sequence_number_(0), 874 send_sequence_number_(0),
921 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), 875 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()),
922 capture_start_rtp_time_stamp_(-1), 876 capture_start_rtp_time_stamp_(-1),
923 capture_start_ntp_time_ms_(-1), 877 capture_start_ntp_time_ms_(-1),
924 _engineStatisticsPtr(NULL), 878 _engineStatisticsPtr(NULL),
925 _outputMixerPtr(NULL), 879 _outputMixerPtr(NULL),
926 _transmitMixerPtr(NULL), 880 _transmitMixerPtr(NULL),
927 _moduleProcessThreadPtr(NULL), 881 _moduleProcessThreadPtr(NULL),
928 _audioDeviceModulePtr(NULL), 882 _audioDeviceModulePtr(NULL),
929 _voiceEngineObserverPtr(NULL), 883 _voiceEngineObserverPtr(NULL),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 seq_num_allocator_proxy_.get(); 928 seq_num_allocator_proxy_.get();
975 configuration.transport_feedback_callback = feedback_observer_proxy_.get(); 929 configuration.transport_feedback_callback = feedback_observer_proxy_.get();
976 } 930 }
977 configuration.event_log = &(*event_log_proxy_); 931 configuration.event_log = &(*event_log_proxy_);
978 configuration.rtt_stats = &(*rtcp_rtt_stats_proxy_); 932 configuration.rtt_stats = &(*rtcp_rtt_stats_proxy_);
979 configuration.retransmission_rate_limiter = 933 configuration.retransmission_rate_limiter =
980 retransmission_rate_limiter_.get(); 934 retransmission_rate_limiter_.get();
981 935
982 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration)); 936 _rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration));
983 _rtpRtcpModule->SetSendingMediaStatus(false); 937 _rtpRtcpModule->SetSendingMediaStatus(false);
984
985 statistics_proxy_.reset(new StatisticsProxy(_rtpRtcpModule->SSRC()));
986 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(
987 statistics_proxy_.get());
988 } 938 }
989 939
990 Channel::~Channel() { 940 Channel::~Channel() {
991 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL); 941 rtp_receive_statistics_->RegisterRtcpStatisticsCallback(NULL);
992 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), 942 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
993 "Channel::~Channel() - dtor"); 943 "Channel::~Channel() - dtor");
994 944
995 if (_outputExternalMedia) { 945 if (_outputExternalMedia) {
996 DeRegisterExternalMediaProcessing(kPlaybackPerChannel); 946 DeRegisterExternalMediaProcessing(kPlaybackPerChannel);
997 } 947 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { 1222 if (_rtpRtcpModule->SetSendingStatus(false) == -1) {
1273 _engineStatisticsPtr->SetLastError( 1223 _engineStatisticsPtr->SetLastError(
1274 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, 1224 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning,
1275 "StartSend() RTP/RTCP failed to stop sending"); 1225 "StartSend() RTP/RTCP failed to stop sending");
1276 } 1226 }
1277 _rtpRtcpModule->SetSendingMediaStatus(false); 1227 _rtpRtcpModule->SetSendingMediaStatus(false);
1278 1228
1279 return 0; 1229 return 0;
1280 } 1230 }
1281 1231
1282 void Channel::ResetDiscardedPacketCount() {
1283 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1284 "Channel::ResetDiscardedPacketCount()");
1285 _numberOfDiscardedPackets = 0;
1286 }
1287
1288 int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) { 1232 int32_t Channel::RegisterVoiceEngineObserver(VoiceEngineObserver& observer) {
1289 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 1233 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
1290 "Channel::RegisterVoiceEngineObserver()"); 1234 "Channel::RegisterVoiceEngineObserver()");
1291 rtc::CritScope cs(&_callbackCritSect); 1235 rtc::CritScope cs(&_callbackCritSect);
1292 1236
1293 if (_voiceEngineObserverPtr) { 1237 if (_voiceEngineObserverPtr) {
1294 _engineStatisticsPtr->SetLastError( 1238 _engineStatisticsPtr->SetLastError(
1295 VE_INVALID_OPERATION, kTraceError, 1239 VE_INVALID_OPERATION, kTraceError,
1296 "RegisterVoiceEngineObserver() observer already enabled"); 1240 "RegisterVoiceEngineObserver() observer already enabled");
1297 return -1; 1241 return -1;
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 if (_rtpRtcpModule->RemoteCNAME(remoteSSRC, cname) != 0) { 2455 if (_rtpRtcpModule->RemoteCNAME(remoteSSRC, cname) != 0) {
2512 _engineStatisticsPtr->SetLastError( 2456 _engineStatisticsPtr->SetLastError(
2513 VE_CANNOT_RETRIEVE_CNAME, kTraceError, 2457 VE_CANNOT_RETRIEVE_CNAME, kTraceError,
2514 "GetRemoteRTCP_CNAME() failed to retrieve remote RTCP CNAME"); 2458 "GetRemoteRTCP_CNAME() failed to retrieve remote RTCP CNAME");
2515 return -1; 2459 return -1;
2516 } 2460 }
2517 strcpy(cName, cname); 2461 strcpy(cName, cname);
2518 return 0; 2462 return 0;
2519 } 2463 }
2520 2464
2521 int Channel::GetRemoteRTCPData(unsigned int& NTPHigh,
2522 unsigned int& NTPLow,
2523 unsigned int& timestamp,
2524 unsigned int& playoutTimestamp,
2525 unsigned int* jitter,
2526 unsigned short* fractionLost) {
2527 // --- Information from sender info in received Sender Reports
2528
2529 RTCPSenderInfo senderInfo;
2530 if (_rtpRtcpModule->RemoteRTCPStat(&senderInfo) != 0) {
2531 _engineStatisticsPtr->SetLastError(
2532 VE_RTP_RTCP_MODULE_ERROR, kTraceError,
2533 "GetRemoteRTCPData() failed to retrieve sender info for remote "
2534 "side");
2535 return -1;
2536 }
2537
2538 // We only utilize 12 out of 20 bytes in the sender info (ignores packet
2539 // and octet count)
2540 NTPHigh = senderInfo.NTPseconds;
2541 NTPLow = senderInfo.NTPfraction;
2542 timestamp = senderInfo.RTPtimeStamp;
2543
2544 // --- Locally derived information
2545
2546 // This value is updated on each incoming RTCP packet (0 when no packet
2547 // has been received)
2548 playoutTimestamp = playout_timestamp_rtcp_;
2549
2550 if (NULL != jitter || NULL != fractionLost) {
2551 // 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
2553 // remote SSRC and use the report block from him.
2554 // Otherwise use the first report block.
2555 std::vector<RTCPReportBlock> remote_stats;
2556 if (_rtpRtcpModule->RemoteRTCPStat(&remote_stats) != 0 ||
2557 remote_stats.empty()) {
2558 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
2559 "GetRemoteRTCPData() failed to measure statistics due"
2560 " to lack of received RTP and/or RTCP packets");
2561 return -1;
2562 }
2563
2564 uint32_t remoteSSRC = rtp_receiver_->SSRC();
2565 std::vector<RTCPReportBlock>::const_iterator it = remote_stats.begin();
2566 for (; it != remote_stats.end(); ++it) {
2567 if (it->remoteSSRC == remoteSSRC)
2568 break;
2569 }
2570
2571 if (it == remote_stats.end()) {
2572 // If we have not received any RTCP packets from this SSRC it probably
2573 // means that we have not received any RTP packets.
2574 // Use the first received report block instead.
2575 it = remote_stats.begin();
2576 remoteSSRC = it->remoteSSRC;
2577 }
2578
2579 if (jitter) {
2580 *jitter = it->jitter;
2581 }
2582
2583 if (fractionLost) {
2584 *fractionLost = it->fractionLost;
2585 }
2586 }
2587 return 0;
2588 }
2589
2590 int Channel::SendApplicationDefinedRTCPPacket( 2465 int Channel::SendApplicationDefinedRTCPPacket(
2591 unsigned char subType, 2466 unsigned char subType,
2592 unsigned int name, 2467 unsigned int name,
2593 const char* data, 2468 const char* data,
2594 unsigned short dataLengthInBytes) { 2469 unsigned short dataLengthInBytes) {
2595 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 2470 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
2596 "Channel::SendApplicationDefinedRTCPPacket()"); 2471 "Channel::SendApplicationDefinedRTCPPacket()");
2597 if (!channel_state_.Get().sending) { 2472 if (!channel_state_.Get().sending) {
2598 _engineStatisticsPtr->SetLastError( 2473 _engineStatisticsPtr->SetLastError(
2599 VE_NOT_SENDING, kTraceError, 2474 VE_NOT_SENDING, kTraceError,
(...skipping 24 matching lines...) Expand all
2624 if (_rtpRtcpModule->SetRTCPApplicationSpecificData( 2499 if (_rtpRtcpModule->SetRTCPApplicationSpecificData(
2625 subType, name, (const unsigned char*)data, dataLengthInBytes) != 0) { 2500 subType, name, (const unsigned char*)data, dataLengthInBytes) != 0) {
2626 _engineStatisticsPtr->SetLastError( 2501 _engineStatisticsPtr->SetLastError(
2627 VE_SEND_ERROR, kTraceError, 2502 VE_SEND_ERROR, kTraceError,
2628 "SendApplicationDefinedRTCPPacket() failed to send RTCP packet"); 2503 "SendApplicationDefinedRTCPPacket() failed to send RTCP packet");
2629 return -1; 2504 return -1;
2630 } 2505 }
2631 return 0; 2506 return 0;
2632 } 2507 }
2633 2508
2634 int Channel::GetRTPStatistics(unsigned int& averageJitterMs,
2635 unsigned int& maxJitterMs,
2636 unsigned int& discardedPackets) {
2637 // The jitter statistics is updated for each received RTP packet and is
2638 // based on received packets.
2639 if (_rtpRtcpModule->RTCP() == RtcpMode::kOff) {
2640 // If RTCP is off, there is no timed thread in the RTCP module regularly
2641 // generating new stats, trigger the update manually here instead.
2642 StreamStatistician* statistician =
2643 rtp_receive_statistics_->GetStatistician(rtp_receiver_->SSRC());
2644 if (statistician) {
2645 // Don't use returned statistics, use data from proxy instead so that
2646 // max jitter can be fetched atomically.
2647 RtcpStatistics s;
2648 statistician->GetStatistics(&s, true);
2649 }
2650 }
2651
2652 ChannelStatistics stats = statistics_proxy_->GetStats();
2653 const int32_t playoutFrequency = audio_coding_->PlayoutFrequency();
2654 if (playoutFrequency > 0) {
2655 // Scale RTP statistics given the current playout frequency
2656 maxJitterMs = stats.max_jitter / (playoutFrequency / 1000);
2657 averageJitterMs = stats.rtcp.jitter / (playoutFrequency / 1000);
2658 }
2659
2660 discardedPackets = _numberOfDiscardedPackets;
2661
2662 return 0;
2663 }
2664
2665 int Channel::GetRemoteRTCPReportBlocks( 2509 int Channel::GetRemoteRTCPReportBlocks(
2666 std::vector<ReportBlock>* report_blocks) { 2510 std::vector<ReportBlock>* report_blocks) {
2667 if (report_blocks == NULL) { 2511 if (report_blocks == NULL) {
2668 _engineStatisticsPtr->SetLastError( 2512 _engineStatisticsPtr->SetLastError(
2669 VE_INVALID_ARGUMENT, kTraceError, 2513 VE_INVALID_ARGUMENT, kTraceError,
2670 "GetRemoteRTCPReportBlock()s invalid report_blocks."); 2514 "GetRemoteRTCPReportBlock()s invalid report_blocks.");
2671 return -1; 2515 return -1;
2672 } 2516 }
2673 2517
2674 // Get the report blocks from the latest received RTCP Sender or Receiver 2518 // Get the report blocks from the latest received RTCP Sender or Receiver
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
3212 3056
3213 // Remove the playout delay. 3057 // Remove the playout delay.
3214 playout_timestamp -= (delay_ms * (GetRtpTimestampRateHz() / 1000)); 3058 playout_timestamp -= (delay_ms * (GetRtpTimestampRateHz() / 1000));
3215 3059
3216 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), 3060 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId),
3217 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu", 3061 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu",
3218 playout_timestamp); 3062 playout_timestamp);
3219 3063
3220 { 3064 {
3221 rtc::CritScope lock(&video_sync_lock_); 3065 rtc::CritScope lock(&video_sync_lock_);
3222 if (rtcp) { 3066 if (!rtcp) {
3223 playout_timestamp_rtcp_ = playout_timestamp;
3224 } else {
3225 playout_timestamp_rtp_ = playout_timestamp; 3067 playout_timestamp_rtp_ = playout_timestamp;
3226 } 3068 }
3227 playout_delay_ms_ = delay_ms; 3069 playout_delay_ms_ = delay_ms;
3228 } 3070 }
3229 } 3071 }
3230 3072
3231 void Channel::RegisterReceiveCodecsToRTPModule() { 3073 void Channel::RegisterReceiveCodecsToRTPModule() {
3232 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), 3074 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
3233 "Channel::RegisterReceiveCodecsToRTPModule()"); 3075 "Channel::RegisterReceiveCodecsToRTPModule()");
3234 3076
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3324 int64_t min_rtt = 0; 3166 int64_t min_rtt = 0;
3325 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != 3167 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) !=
3326 0) { 3168 0) {
3327 return 0; 3169 return 0;
3328 } 3170 }
3329 return rtt; 3171 return rtt;
3330 } 3172 }
3331 3173
3332 } // namespace voe 3174 } // namespace voe
3333 } // namespace webrtc 3175 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/channel.h ('k') | webrtc/voice_engine/include/voe_rtp_rtcp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698