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

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: 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, rtc::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 rtc::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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
141 channel_proxy->RegisterExternalTransport(new_config.send_transport); 165 stream->timed_send_transport_adapter_ =
ossu 2017/07/14 11:13:15 I think you can do .reset(new TimedTransport(...))
saza WebRTC 2017/07/17 14:27:29 Done.
166 std::unique_ptr<TimedTransport>(new TimedTransport(
167 new_config.send_transport, &stream->active_lifetime_));
168 channel_proxy->RegisterExternalTransport(
169 stream->timed_send_transport_adapter_.get());
142 } 170 }
143 171
144 // RFC 5285: Each distinct extension MUST have a unique ID. The value 0 is 172 // 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. 173 // 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". 174 // So it should be safe to use 0 here to indicate "not configured".
147 struct ExtensionIds { 175 struct ExtensionIds {
148 int audio_level = 0; 176 int audio_level = 0;
149 int transport_sequence_number = 0; 177 int transport_sequence_number = 0;
150 }; 178 };
151 179
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 409 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
382 transport_->send_side_cc()->SetTransportOverhead( 410 transport_->send_side_cc()->SetTransportOverhead(
383 transport_overhead_per_packet); 411 transport_overhead_per_packet);
384 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); 412 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet);
385 } 413 }
386 414
387 RtpState AudioSendStream::GetRtpState() const { 415 RtpState AudioSendStream::GetRtpState() const {
388 return rtp_rtcp_module_->GetRtpState(); 416 return rtp_rtcp_module_->GetRtpState();
389 } 417 }
390 418
419 const rtc::TimeInterval* AudioSendStream::GetActiveLifetime() const {
420 return &active_lifetime_;
421 }
422
391 VoiceEngine* AudioSendStream::voice_engine() const { 423 VoiceEngine* AudioSendStream::voice_engine() const {
392 internal::AudioState* audio_state = 424 internal::AudioState* audio_state =
393 static_cast<internal::AudioState*>(audio_state_.get()); 425 static_cast<internal::AudioState*>(audio_state_.get());
394 VoiceEngine* voice_engine = audio_state->voice_engine(); 426 VoiceEngine* voice_engine = audio_state->voice_engine();
395 RTC_DCHECK(voice_engine); 427 RTC_DCHECK(voice_engine);
396 return voice_engine; 428 return voice_engine;
397 } 429 }
398 430
399 // Apply current codec settings to a single voe::Channel used for sending. 431 // Apply current codec settings to a single voe::Channel used for sending.
400 bool AudioSendStream::SetupSendCodec(AudioSendStream* stream, 432 bool AudioSendStream::SetupSendCodec(AudioSendStream* stream,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (rtp_rtcp_module_->RegisterSendPayload(codec) != 0) { 639 if (rtp_rtcp_module_->RegisterSendPayload(codec) != 0) {
608 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to " 640 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to "
609 "RTP/RTCP module"; 641 "RTP/RTCP module";
610 } 642 }
611 } 643 }
612 } 644 }
613 645
614 646
615 } // namespace internal 647 } // namespace internal
616 } // namespace webrtc 648 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698