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

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

Issue 2981513002: Wire up RTP keep-alive in ortc api. (Closed)
Patch Set: deps, again Created 3 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
« no previous file with comments | « webrtc/video/video_send_stream.h ('k') | webrtc/video/video_send_stream_tests.cc » ('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) 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 #include "webrtc/video/video_send_stream.h" 10 #include "webrtc/video/video_send_stream.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 rtc::TaskQueue* worker_queue, 340 rtc::TaskQueue* worker_queue,
341 CallStats* call_stats, 341 CallStats* call_stats,
342 RtpTransportControllerSendInterface* transport, 342 RtpTransportControllerSendInterface* transport,
343 BitrateAllocator* bitrate_allocator, 343 BitrateAllocator* bitrate_allocator,
344 SendDelayStats* send_delay_stats, 344 SendDelayStats* send_delay_stats,
345 VideoStreamEncoder* video_stream_encoder, 345 VideoStreamEncoder* video_stream_encoder,
346 RtcEventLog* event_log, 346 RtcEventLog* event_log,
347 const VideoSendStream::Config* config, 347 const VideoSendStream::Config* config,
348 int initial_encoder_max_bitrate, 348 int initial_encoder_max_bitrate,
349 std::map<uint32_t, RtpState> suspended_ssrcs, 349 std::map<uint32_t, RtpState> suspended_ssrcs,
350 VideoEncoderConfig::ContentType content_type, 350 VideoEncoderConfig::ContentType content_type);
351 const RtpKeepAliveConfig& keepalive_config);
352 ~VideoSendStreamImpl() override; 351 ~VideoSendStreamImpl() override;
353 352
354 // RegisterProcessThread register |module_process_thread| with those objects 353 // RegisterProcessThread register |module_process_thread| with those objects
355 // that use it. Registration has to happen on the thread were 354 // that use it. Registration has to happen on the thread were
356 // |module_process_thread| was created (libjingle's worker thread). 355 // |module_process_thread| was created (libjingle's worker thread).
357 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue, 356 // TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue,
358 // maybe |worker_queue|. 357 // maybe |worker_queue|.
359 void RegisterProcessThread(ProcessThread* module_process_thread); 358 void RegisterProcessThread(ProcessThread* module_process_thread);
360 void DeRegisterProcessThread(); 359 void DeRegisterProcessThread();
361 360
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 VideoStreamEncoder* video_stream_encoder, 471 VideoStreamEncoder* video_stream_encoder,
473 ProcessThread* module_process_thread, 472 ProcessThread* module_process_thread,
474 CallStats* call_stats, 473 CallStats* call_stats,
475 RtpTransportControllerSendInterface* transport, 474 RtpTransportControllerSendInterface* transport,
476 BitrateAllocator* bitrate_allocator, 475 BitrateAllocator* bitrate_allocator,
477 SendDelayStats* send_delay_stats, 476 SendDelayStats* send_delay_stats,
478 RtcEventLog* event_log, 477 RtcEventLog* event_log,
479 const VideoSendStream::Config* config, 478 const VideoSendStream::Config* config,
480 int initial_encoder_max_bitrate, 479 int initial_encoder_max_bitrate,
481 const std::map<uint32_t, RtpState>& suspended_ssrcs, 480 const std::map<uint32_t, RtpState>& suspended_ssrcs,
482 VideoEncoderConfig::ContentType content_type, 481 VideoEncoderConfig::ContentType content_type)
483 const RtpKeepAliveConfig& keepalive_config)
484 : send_stream_(send_stream), 482 : send_stream_(send_stream),
485 done_event_(done_event), 483 done_event_(done_event),
486 stats_proxy_(stats_proxy), 484 stats_proxy_(stats_proxy),
487 video_stream_encoder_(video_stream_encoder), 485 video_stream_encoder_(video_stream_encoder),
488 call_stats_(call_stats), 486 call_stats_(call_stats),
489 transport_(transport), 487 transport_(transport),
490 bitrate_allocator_(bitrate_allocator), 488 bitrate_allocator_(bitrate_allocator),
491 send_delay_stats_(send_delay_stats), 489 send_delay_stats_(send_delay_stats),
492 event_log_(event_log), 490 event_log_(event_log),
493 config_(config), 491 config_(config),
494 initial_encoder_max_bitrate_(initial_encoder_max_bitrate), 492 initial_encoder_max_bitrate_(initial_encoder_max_bitrate),
495 suspended_ssrcs_(suspended_ssrcs), 493 suspended_ssrcs_(suspended_ssrcs),
496 content_type_(content_type), 494 content_type_(content_type) {}
497 keepalive_config_(keepalive_config) {}
498 495
499 ~ConstructionTask() override { done_event_->Set(); } 496 ~ConstructionTask() override { done_event_->Set(); }
500 497
501 private: 498 private:
502 bool Run() override { 499 bool Run() override {
503 send_stream_->reset(new VideoSendStreamImpl( 500 send_stream_->reset(new VideoSendStreamImpl(
504 stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_, 501 stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_,
505 bitrate_allocator_, send_delay_stats_, video_stream_encoder_, 502 bitrate_allocator_, send_delay_stats_, video_stream_encoder_,
506 event_log_, config_, initial_encoder_max_bitrate_, 503 event_log_, config_, initial_encoder_max_bitrate_,
507 std::move(suspended_ssrcs_), content_type_, keepalive_config_)); 504 std::move(suspended_ssrcs_), content_type_));
508 return true; 505 return true;
509 } 506 }
510 507
511 std::unique_ptr<VideoSendStreamImpl>* const send_stream_; 508 std::unique_ptr<VideoSendStreamImpl>* const send_stream_;
512 rtc::Event* const done_event_; 509 rtc::Event* const done_event_;
513 SendStatisticsProxy* const stats_proxy_; 510 SendStatisticsProxy* const stats_proxy_;
514 VideoStreamEncoder* const video_stream_encoder_; 511 VideoStreamEncoder* const video_stream_encoder_;
515 CallStats* const call_stats_; 512 CallStats* const call_stats_;
516 RtpTransportControllerSendInterface* const transport_; 513 RtpTransportControllerSendInterface* const transport_;
517 BitrateAllocator* const bitrate_allocator_; 514 BitrateAllocator* const bitrate_allocator_;
518 SendDelayStats* const send_delay_stats_; 515 SendDelayStats* const send_delay_stats_;
519 RtcEventLog* const event_log_; 516 RtcEventLog* const event_log_;
520 const VideoSendStream::Config* config_; 517 const VideoSendStream::Config* config_;
521 int initial_encoder_max_bitrate_; 518 int initial_encoder_max_bitrate_;
522 std::map<uint32_t, RtpState> suspended_ssrcs_; 519 std::map<uint32_t, RtpState> suspended_ssrcs_;
523 const VideoEncoderConfig::ContentType content_type_; 520 const VideoEncoderConfig::ContentType content_type_;
524 const RtpKeepAliveConfig& keepalive_config_;
525 }; 521 };
526 522
527 class VideoSendStream::DestructAndGetRtpStateTask : public rtc::QueuedTask { 523 class VideoSendStream::DestructAndGetRtpStateTask : public rtc::QueuedTask {
528 public: 524 public:
529 DestructAndGetRtpStateTask(VideoSendStream::RtpStateMap* state_map, 525 DestructAndGetRtpStateTask(VideoSendStream::RtpStateMap* state_map,
530 std::unique_ptr<VideoSendStreamImpl> send_stream, 526 std::unique_ptr<VideoSendStreamImpl> send_stream,
531 rtc::Event* done_event) 527 rtc::Event* done_event)
532 : state_map_(state_map), 528 : state_map_(state_map),
533 send_stream_(std::move(send_stream)), 529 send_stream_(std::move(send_stream)),
534 done_event_(done_event) {} 530 done_event_(done_event) {}
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 int num_cpu_cores, 623 int num_cpu_cores,
628 ProcessThread* module_process_thread, 624 ProcessThread* module_process_thread,
629 rtc::TaskQueue* worker_queue, 625 rtc::TaskQueue* worker_queue,
630 CallStats* call_stats, 626 CallStats* call_stats,
631 RtpTransportControllerSendInterface* transport, 627 RtpTransportControllerSendInterface* transport,
632 BitrateAllocator* bitrate_allocator, 628 BitrateAllocator* bitrate_allocator,
633 SendDelayStats* send_delay_stats, 629 SendDelayStats* send_delay_stats,
634 RtcEventLog* event_log, 630 RtcEventLog* event_log,
635 VideoSendStream::Config config, 631 VideoSendStream::Config config,
636 VideoEncoderConfig encoder_config, 632 VideoEncoderConfig encoder_config,
637 const std::map<uint32_t, RtpState>& suspended_ssrcs, 633 const std::map<uint32_t, RtpState>& suspended_ssrcs)
638 const RtpKeepAliveConfig& keepalive_config)
639 : worker_queue_(worker_queue), 634 : worker_queue_(worker_queue),
640 thread_sync_event_(false /* manual_reset */, false), 635 thread_sync_event_(false /* manual_reset */, false),
641 stats_proxy_(Clock::GetRealTimeClock(), 636 stats_proxy_(Clock::GetRealTimeClock(),
642 config, 637 config,
643 encoder_config.content_type), 638 encoder_config.content_type),
644 config_(std::move(config)), 639 config_(std::move(config)),
645 content_type_(encoder_config.content_type) { 640 content_type_(encoder_config.content_type) {
646 video_stream_encoder_.reset( 641 video_stream_encoder_.reset(
647 new VideoStreamEncoder(num_cpu_cores, &stats_proxy_, 642 new VideoStreamEncoder(num_cpu_cores, &stats_proxy_,
648 config_.encoder_settings, 643 config_.encoder_settings,
649 config_.pre_encode_callback, 644 config_.pre_encode_callback,
650 config_.post_encode_callback, 645 config_.post_encode_callback,
651 std::unique_ptr<OveruseFrameDetector>())); 646 std::unique_ptr<OveruseFrameDetector>()));
652 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( 647 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
653 &send_stream_, &thread_sync_event_, &stats_proxy_, 648 &send_stream_, &thread_sync_event_, &stats_proxy_,
654 video_stream_encoder_.get(), module_process_thread, call_stats, transport, 649 video_stream_encoder_.get(), module_process_thread, call_stats, transport,
655 bitrate_allocator, send_delay_stats, event_log, &config_, 650 bitrate_allocator, send_delay_stats, event_log, &config_,
656 encoder_config.max_bitrate_bps, suspended_ssrcs, 651 encoder_config.max_bitrate_bps, suspended_ssrcs,
657 encoder_config.content_type, keepalive_config))); 652 encoder_config.content_type)));
658 653
659 // Wait for ConstructionTask to complete so that |send_stream_| can be used. 654 // Wait for ConstructionTask to complete so that |send_stream_| can be used.
660 // |module_process_thread| must be registered and deregistered on the thread 655 // |module_process_thread| must be registered and deregistered on the thread
661 // it was created on. 656 // it was created on.
662 thread_sync_event_.Wait(rtc::Event::kForever); 657 thread_sync_event_.Wait(rtc::Event::kForever);
663 send_stream_->RegisterProcessThread(module_process_thread); 658 send_stream_->RegisterProcessThread(module_process_thread);
664 // TODO(sprang): Enable this also for regular video calls if it works well. 659 // TODO(sprang): Enable this also for regular video calls if it works well.
665 if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) { 660 if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) {
666 // Only signal target bitrate for screenshare streams, for now. 661 // Only signal target bitrate for screenshare streams, for now.
667 video_stream_encoder_->SetBitrateObserver(send_stream_.get()); 662 video_stream_encoder_->SetBitrateObserver(send_stream_.get());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 rtc::TaskQueue* worker_queue, 762 rtc::TaskQueue* worker_queue,
768 CallStats* call_stats, 763 CallStats* call_stats,
769 RtpTransportControllerSendInterface* transport, 764 RtpTransportControllerSendInterface* transport,
770 BitrateAllocator* bitrate_allocator, 765 BitrateAllocator* bitrate_allocator,
771 SendDelayStats* send_delay_stats, 766 SendDelayStats* send_delay_stats,
772 VideoStreamEncoder* video_stream_encoder, 767 VideoStreamEncoder* video_stream_encoder,
773 RtcEventLog* event_log, 768 RtcEventLog* event_log,
774 const VideoSendStream::Config* config, 769 const VideoSendStream::Config* config,
775 int initial_encoder_max_bitrate, 770 int initial_encoder_max_bitrate,
776 std::map<uint32_t, RtpState> suspended_ssrcs, 771 std::map<uint32_t, RtpState> suspended_ssrcs,
777 VideoEncoderConfig::ContentType content_type, 772 VideoEncoderConfig::ContentType content_type)
778 const RtpKeepAliveConfig& keepalive_config)
779 : send_side_bwe_with_overhead_( 773 : send_side_bwe_with_overhead_(
780 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), 774 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
781 stats_proxy_(stats_proxy), 775 stats_proxy_(stats_proxy),
782 config_(config), 776 config_(config),
783 suspended_ssrcs_(std::move(suspended_ssrcs)), 777 suspended_ssrcs_(std::move(suspended_ssrcs)),
784 module_process_thread_(nullptr), 778 module_process_thread_(nullptr),
785 worker_queue_(worker_queue), 779 worker_queue_(worker_queue),
786 check_encoder_activity_task_(nullptr), 780 check_encoder_activity_task_(nullptr),
787 call_stats_(call_stats), 781 call_stats_(call_stats),
788 transport_(transport), 782 transport_(transport),
(...skipping 17 matching lines...) Expand all
806 bandwidth_observer_.get(), 800 bandwidth_observer_.get(),
807 transport, 801 transport,
808 call_stats_->rtcp_rtt_stats(), 802 call_stats_->rtcp_rtt_stats(),
809 flexfec_sender_.get(), 803 flexfec_sender_.get(),
810 stats_proxy_, 804 stats_proxy_,
811 send_delay_stats, 805 send_delay_stats,
812 event_log, 806 event_log,
813 transport->send_side_cc()->GetRetransmissionRateLimiter(), 807 transport->send_side_cc()->GetRetransmissionRateLimiter(),
814 this, 808 this,
815 config_->rtp.ssrcs.size(), 809 config_->rtp.ssrcs.size(),
816 keepalive_config)), 810 transport->keepalive_config())),
817 payload_router_(rtp_rtcp_modules_, 811 payload_router_(rtp_rtcp_modules_,
818 config_->encoder_settings.payload_type), 812 config_->encoder_settings.payload_type),
819 weak_ptr_factory_(this), 813 weak_ptr_factory_(this),
820 overhead_bytes_per_packet_(0), 814 overhead_bytes_per_packet_(0),
821 transport_overhead_bytes_per_packet_(0) { 815 transport_overhead_bytes_per_packet_(0) {
822 RTC_DCHECK_RUN_ON(worker_queue_); 816 RTC_DCHECK_RUN_ON(worker_queue_);
823 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString(); 817 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString();
824 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); 818 weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
825 module_process_thread_checker_.DetachFromThread(); 819 module_process_thread_checker_.DetachFromThread();
826 820
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 std::min(config_->rtp.max_packet_size, 1370 std::min(config_->rtp.max_packet_size,
1377 kPathMTU - transport_overhead_bytes_per_packet_); 1371 kPathMTU - transport_overhead_bytes_per_packet_);
1378 1372
1379 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 1373 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
1380 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); 1374 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size);
1381 } 1375 }
1382 } 1376 }
1383 1377
1384 } // namespace internal 1378 } // namespace internal
1385 } // namespace webrtc 1379 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream.h ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698