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

Side by Side Diff: webrtc/video/call.cc

Issue 1267683002: Hooked up RtcEventLog. It lives in Voice Engine and pointers are propagated to ACM and Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed Henrik's review comments. Created 5 years, 4 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 14 matching lines...) Expand all
25 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 25 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
26 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 26 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
27 #include "webrtc/modules/video_render/include/video_render.h" 27 #include "webrtc/modules/video_render/include/video_render.h"
28 #include "webrtc/system_wrappers/interface/cpu_info.h" 28 #include "webrtc/system_wrappers/interface/cpu_info.h"
29 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" 29 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
30 #include "webrtc/system_wrappers/interface/logging.h" 30 #include "webrtc/system_wrappers/interface/logging.h"
31 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" 31 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
32 #include "webrtc/system_wrappers/interface/trace.h" 32 #include "webrtc/system_wrappers/interface/trace.h"
33 #include "webrtc/system_wrappers/interface/trace_event.h" 33 #include "webrtc/system_wrappers/interface/trace_event.h"
34 #include "webrtc/video/audio_receive_stream.h" 34 #include "webrtc/video/audio_receive_stream.h"
35 #include "webrtc/video/rtc_event_log.h"
35 #include "webrtc/video/video_receive_stream.h" 36 #include "webrtc/video/video_receive_stream.h"
36 #include "webrtc/video/video_send_stream.h" 37 #include "webrtc/video/video_send_stream.h"
38 #include "webrtc/voice_engine/include/voe_codec.h"
37 39
38 namespace webrtc { 40 namespace webrtc {
39 41
40 const int Call::Config::kDefaultStartBitrateBps = 300000; 42 const int Call::Config::kDefaultStartBitrateBps = 300000;
41 43
42 namespace internal { 44 namespace internal {
43 45
44 class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver { 46 class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver {
45 public: 47 public:
46 explicit CpuOveruseObserverProxy(LoadObserver* overuse_callback) 48 explicit CpuOveruseObserverProxy(LoadObserver* overuse_callback)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 GUARDED_BY(receive_crit_); 138 GUARDED_BY(receive_crit_);
137 139
138 rtc::scoped_ptr<RWLockWrapper> send_crit_; 140 rtc::scoped_ptr<RWLockWrapper> send_crit_;
139 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); 141 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
140 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); 142 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
141 143
142 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_; 144 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_;
143 145
144 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; 146 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
145 147
148 RtcEventLog* event_log_;
149
146 DISALLOW_COPY_AND_ASSIGN(Call); 150 DISALLOW_COPY_AND_ASSIGN(Call);
147 }; 151 };
148 } // namespace internal 152 } // namespace internal
149 153
150 Call* Call::Create(const Call::Config& config) { 154 Call* Call::Create(const Call::Config& config) {
151 return new internal::Call(config); 155 return new internal::Call(config);
152 } 156 }
153 157
154 namespace internal { 158 namespace internal {
155 159
156 Call::Call(const Call::Config& config) 160 Call::Call(const Call::Config& config)
157 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), 161 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
158 module_process_thread_(ProcessThread::Create()), 162 module_process_thread_(ProcessThread::Create()),
159 channel_group_(new ChannelGroup(module_process_thread_.get())), 163 channel_group_(new ChannelGroup(module_process_thread_.get())),
160 next_channel_id_(0), 164 next_channel_id_(0),
161 config_(config), 165 config_(config),
162 network_enabled_(true), 166 network_enabled_(true),
163 transport_adapter_(nullptr), 167 transport_adapter_(nullptr),
164 receive_crit_(RWLockWrapper::CreateRWLock()), 168 receive_crit_(RWLockWrapper::CreateRWLock()),
165 send_crit_(RWLockWrapper::CreateRWLock()) { 169 send_crit_(RWLockWrapper::CreateRWLock()),
170 event_log_(nullptr) {
166 DCHECK(config.send_transport != nullptr); 171 DCHECK(config.send_transport != nullptr);
167 172
168 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); 173 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
169 DCHECK_GE(config.bitrate_config.start_bitrate_bps, 174 DCHECK_GE(config.bitrate_config.start_bitrate_bps,
170 config.bitrate_config.min_bitrate_bps); 175 config.bitrate_config.min_bitrate_bps);
171 if (config.bitrate_config.max_bitrate_bps != -1) { 176 if (config.bitrate_config.max_bitrate_bps != -1) {
172 DCHECK_GE(config.bitrate_config.max_bitrate_bps, 177 DCHECK_GE(config.bitrate_config.max_bitrate_bps,
173 config.bitrate_config.start_bitrate_bps); 178 config.bitrate_config.start_bitrate_bps);
174 } 179 }
180 if (config.voice_engine) {
181 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine);
182 if (voe_codec) {
183 event_log_ = voe_codec->GetEventLog();
184 voe_codec->Release();
185 }
186 }
175 187
176 Trace::CreateTrace(); 188 Trace::CreateTrace();
177 module_process_thread_->Start(); 189 module_process_thread_->Start();
178 190
179 if (config.overuse_callback) { 191 if (config.overuse_callback) {
180 overuse_observer_proxy_.reset( 192 overuse_observer_proxy_.reset(
181 new CpuOveruseObserverProxy(config.overuse_callback)); 193 new CpuOveruseObserverProxy(config.overuse_callback));
182 } 194 }
183 195
184 SetBitrateControllerConfig(config_.bitrate_config); 196 SetBitrateControllerConfig(config_.bitrate_config);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // This needs to be taken before send_crit_ as both locks need to be held 273 // This needs to be taken before send_crit_ as both locks need to be held
262 // while changing network state. 274 // while changing network state.
263 rtc::CritScope lock(&network_enabled_crit_); 275 rtc::CritScope lock(&network_enabled_crit_);
264 WriteLockScoped write_lock(*send_crit_); 276 WriteLockScoped write_lock(*send_crit_);
265 for (uint32_t ssrc : config.rtp.ssrcs) { 277 for (uint32_t ssrc : config.rtp.ssrcs) {
266 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); 278 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
267 video_send_ssrcs_[ssrc] = send_stream; 279 video_send_ssrcs_[ssrc] = send_stream;
268 } 280 }
269 video_send_streams_.insert(send_stream); 281 video_send_streams_.insert(send_stream);
270 282
283 if (event_log_)
284 event_log_->LogVideoSendStreamConfig(config);
285
271 if (!network_enabled_) 286 if (!network_enabled_)
272 send_stream->SignalNetworkState(kNetworkDown); 287 send_stream->SignalNetworkState(kNetworkDown);
273 return send_stream; 288 return send_stream;
274 } 289 }
275 290
276 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { 291 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
277 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); 292 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream");
278 DCHECK(send_stream != nullptr); 293 DCHECK(send_stream != nullptr);
279 294
280 send_stream->Stop(); 295 send_stream->Stop();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 config.rtp.rtx.begin(); 342 config.rtp.rtx.begin();
328 if (it != config.rtp.rtx.end()) 343 if (it != config.rtp.rtx.end())
329 video_receive_ssrcs_[it->second.ssrc] = receive_stream; 344 video_receive_ssrcs_[it->second.ssrc] = receive_stream;
330 video_receive_streams_.insert(receive_stream); 345 video_receive_streams_.insert(receive_stream);
331 346
332 ConfigureSync(config.sync_group); 347 ConfigureSync(config.sync_group);
333 348
334 if (!network_enabled_) 349 if (!network_enabled_)
335 receive_stream->SignalNetworkState(kNetworkDown); 350 receive_stream->SignalNetworkState(kNetworkDown);
336 351
352 if (event_log_)
353 event_log_->LogVideoReceiveStreamConfig(config);
354
337 return receive_stream; 355 return receive_stream;
338 } 356 }
339 357
340 void Call::DestroyVideoReceiveStream( 358 void Call::DestroyVideoReceiveStream(
341 webrtc::VideoReceiveStream* receive_stream) { 359 webrtc::VideoReceiveStream* receive_stream) {
342 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); 360 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream");
343 DCHECK(receive_stream != nullptr); 361 DCHECK(receive_stream != nullptr);
344 VideoReceiveStream* receive_stream_impl = nullptr; 362 VideoReceiveStream* receive_stream_impl = nullptr;
345 { 363 {
346 WriteLockScoped write_lock(*receive_crit_); 364 WriteLockScoped write_lock(*receive_crit_);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that 510 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that
493 // there's no receiver of the packet. 511 // there's no receiver of the packet.
494 bool rtcp_delivered = false; 512 bool rtcp_delivered = false;
495 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { 513 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
496 ReadLockScoped read_lock(*receive_crit_); 514 ReadLockScoped read_lock(*receive_crit_);
497 for (VideoReceiveStream* stream : video_receive_streams_) { 515 for (VideoReceiveStream* stream : video_receive_streams_) {
498 if (stream->DeliverRtcp(packet, length)) 516 if (stream->DeliverRtcp(packet, length))
499 rtcp_delivered = true; 517 rtcp_delivered = true;
500 } 518 }
501 } 519 }
520 bool already_logged = false;
521 if (rtcp_delivered && event_log_) {
522 event_log_->LogRtcpPacket(true, media_type, packet, length);
523 already_logged = true;
524 }
502 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { 525 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
503 ReadLockScoped read_lock(*send_crit_); 526 ReadLockScoped read_lock(*send_crit_);
504 for (VideoSendStream* stream : video_send_streams_) { 527 for (VideoSendStream* stream : video_send_streams_) {
505 if (stream->DeliverRtcp(packet, length)) 528 if (stream->DeliverRtcp(packet, length))
506 rtcp_delivered = true; 529 rtcp_delivered = true;
507 } 530 }
508 } 531 }
532 if (rtcp_delivered && !already_logged && event_log_)
533 event_log_->LogRtcpPacket(false, media_type, packet, length);
509 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; 534 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR;
510 } 535 }
511 536
512 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, 537 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
513 const uint8_t* packet, 538 const uint8_t* packet,
514 size_t length) { 539 size_t length) {
515 // Minimum RTP header size. 540 // Minimum RTP header size.
516 if (length < 12) 541 if (length < 12)
517 return DELIVERY_PACKET_ERROR; 542 return DELIVERY_PACKET_ERROR;
518 543
519 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); 544 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
520 545
546 // TODO(ivoc): This should be updated once the splitting of the header is done
547 // in the RtcEventLog.
548 if (event_log_)
549 event_log_->LogRtpHeader(true, media_type, packet, 20, length);
521 ReadLockScoped read_lock(*receive_crit_); 550 ReadLockScoped read_lock(*receive_crit_);
522 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { 551 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) {
523 auto it = audio_receive_ssrcs_.find(ssrc); 552 auto it = audio_receive_ssrcs_.find(ssrc);
524 if (it != audio_receive_ssrcs_.end()) { 553 if (it != audio_receive_ssrcs_.end()) {
525 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK 554 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK
526 : DELIVERY_PACKET_ERROR; 555 : DELIVERY_PACKET_ERROR;
527 } 556 }
528 } 557 }
529 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { 558 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
530 auto it = video_receive_ssrcs_.find(ssrc); 559 auto it = video_receive_ssrcs_.find(ssrc);
531 if (it != video_receive_ssrcs_.end()) { 560 if (it != video_receive_ssrcs_.end()) {
532 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK 561 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK
533 : DELIVERY_PACKET_ERROR; 562 : DELIVERY_PACKET_ERROR;
534 } 563 }
535 } 564 }
536 return DELIVERY_UNKNOWN_SSRC; 565 return DELIVERY_UNKNOWN_SSRC;
537 } 566 }
538 567
539 PacketReceiver::DeliveryStatus Call::DeliverPacket(MediaType media_type, 568 PacketReceiver::DeliveryStatus Call::DeliverPacket(MediaType media_type,
540 const uint8_t* packet, 569 const uint8_t* packet,
541 size_t length) { 570 size_t length) {
542 if (RtpHeaderParser::IsRtcp(packet, length)) 571 if (RtpHeaderParser::IsRtcp(packet, length))
543 return DeliverRtcp(media_type, packet, length); 572 return DeliverRtcp(media_type, packet, length);
544 573
545 return DeliverRtp(media_type, packet, length); 574 return DeliverRtp(media_type, packet, length);
546 } 575 }
547 576
548 } // namespace internal 577 } // namespace internal
549 } // namespace webrtc 578 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698