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

Side by Side Diff: webrtc/audio/audio_send_stream.cc

Issue 2979833002: Add a histogram metric tracking for how long audio RTP packets are sent (Closed)
Patch Set: Adjust for comments. Created 3 years, 5 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
OLDNEW
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
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 namespace { 44 namespace {
45 void CallEncoder(const std::unique_ptr<voe::ChannelProxy>& channel_proxy, 45 void CallEncoder(const std::unique_ptr<voe::ChannelProxy>& channel_proxy,
46 rtc::FunctionView<void(AudioEncoder*)> lambda) { 46 rtc::FunctionView<void(AudioEncoder*)> lambda) {
47 channel_proxy->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder_ptr) { 47 channel_proxy->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder_ptr) {
48 RTC_DCHECK(encoder_ptr); 48 RTC_DCHECK(encoder_ptr);
49 lambda(encoder_ptr->get()); 49 lambda(encoder_ptr->get());
50 }); 50 });
51 } 51 }
52 } // namespace 52 } // namespace
53 53
54 // TODO(saza): Move this declaration further down when we can use
55 // std::make_unique.
56 class AudioSendStream::TimedTransport : public Transport {
57 public:
58 TimedTransport(Transport* transport, TimeInterval* time_interval)
59 : transport_(transport), lifetime_(time_interval) {}
60 bool SendRtp(const uint8_t* packet,
61 size_t length,
62 const PacketOptions& options) {
63 if (lifetime_) {
64 lifetime_->Extend();
65 }
66 return transport_->SendRtp(packet, length, options);
67 }
68 bool SendRtcp(const uint8_t* packet, size_t length) {
69 return transport_->SendRtcp(packet, length);
70 }
71 ~TimedTransport() {}
72
73 private:
74 Transport* transport_;
75 TimeInterval* lifetime_;
76 };
77
54 AudioSendStream::AudioSendStream( 78 AudioSendStream::AudioSendStream(
55 const webrtc::AudioSendStream::Config& config, 79 const webrtc::AudioSendStream::Config& config,
56 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, 80 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
57 rtc::TaskQueue* worker_queue, 81 rtc::TaskQueue* worker_queue,
58 RtpTransportControllerSendInterface* transport, 82 RtpTransportControllerSendInterface* transport,
59 BitrateAllocator* bitrate_allocator, 83 BitrateAllocator* bitrate_allocator,
60 RtcEventLog* event_log, 84 RtcEventLog* event_log,
61 RtcpRttStats* rtcp_rtt_stats, 85 RtcpRttStats* rtcp_rtt_stats,
62 const rtc::Optional<RtpState>& suspended_rtp_state) 86 const rtc::Optional<RtpState>& suspended_rtp_state)
63 : worker_queue_(worker_queue), 87 : worker_queue_(worker_queue),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 new_config.rtp.nack.rtp_history_ms) { 154 new_config.rtp.nack.rtp_history_ms) {
131 channel_proxy->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0, 155 channel_proxy->SetNACKStatus(new_config.rtp.nack.rtp_history_ms != 0,
132 new_config.rtp.nack.rtp_history_ms / 20); 156 new_config.rtp.nack.rtp_history_ms / 20);
133 } 157 }
134 158
135 if (first_time || 159 if (first_time ||
136 new_config.send_transport != old_config.send_transport) { 160 new_config.send_transport != old_config.send_transport) {
137 if (old_config.send_transport) { 161 if (old_config.send_transport) {
138 channel_proxy->DeRegisterExternalTransport(); 162 channel_proxy->DeRegisterExternalTransport();
139 } 163 }
140 164 if (new_config.send_transport) {
141 channel_proxy->RegisterExternalTransport(new_config.send_transport); 165 stream->timed_send_transport_adapter_.reset(new TimedTransport(
166 new_config.send_transport, &stream->active_lifetime_));
167 } else {
168 stream->timed_send_transport_adapter_.reset(nullptr);
169 }
170 channel_proxy->RegisterExternalTransport(
171 stream->timed_send_transport_adapter_.get());
142 } 172 }
143 173
144 // RFC 5285: Each distinct extension MUST have a unique ID. The value 0 is 174 // RFC 5285: Each distinct extension MUST have a unique ID. The value 0 is
145 // reserved for padding and MUST NOT be used as a local identifier. 175 // reserved for padding and MUST NOT be used as a local identifier.
146 // So it should be safe to use 0 here to indicate "not configured". 176 // So it should be safe to use 0 here to indicate "not configured".
147 struct ExtensionIds { 177 struct ExtensionIds {
148 int audio_level = 0; 178 int audio_level = 0;
149 int transport_sequence_number = 0; 179 int transport_sequence_number = 0;
150 }; 180 };
151 181
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 414 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
385 transport_->send_side_cc()->SetTransportOverhead( 415 transport_->send_side_cc()->SetTransportOverhead(
386 transport_overhead_per_packet); 416 transport_overhead_per_packet);
387 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); 417 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet);
388 } 418 }
389 419
390 RtpState AudioSendStream::GetRtpState() const { 420 RtpState AudioSendStream::GetRtpState() const {
391 return rtp_rtcp_module_->GetRtpState(); 421 return rtp_rtcp_module_->GetRtpState();
392 } 422 }
393 423
424 const TimeInterval& AudioSendStream::GetActiveLifetime() const {
425 return active_lifetime_;
426 }
427
394 VoiceEngine* AudioSendStream::voice_engine() const { 428 VoiceEngine* AudioSendStream::voice_engine() const {
395 internal::AudioState* audio_state = 429 internal::AudioState* audio_state =
396 static_cast<internal::AudioState*>(audio_state_.get()); 430 static_cast<internal::AudioState*>(audio_state_.get());
397 VoiceEngine* voice_engine = audio_state->voice_engine(); 431 VoiceEngine* voice_engine = audio_state->voice_engine();
398 RTC_DCHECK(voice_engine); 432 RTC_DCHECK(voice_engine);
399 return voice_engine; 433 return voice_engine;
400 } 434 }
401 435
402 // Apply current codec settings to a single voe::Channel used for sending. 436 // Apply current codec settings to a single voe::Channel used for sending.
403 bool AudioSendStream::SetupSendCodec(AudioSendStream* stream, 437 bool AudioSendStream::SetupSendCodec(AudioSendStream* stream,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 if (rtp_rtcp_module_->RegisterSendPayload(codec) != 0) { 644 if (rtp_rtcp_module_->RegisterSendPayload(codec) != 0) {
611 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to " 645 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to "
612 "RTP/RTCP module"; 646 "RTP/RTCP module";
613 } 647 }
614 } 648 }
615 } 649 }
616 650
617 651
618 } // namespace internal 652 } // namespace internal
619 } // namespace webrtc 653 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698