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

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

Issue 2685673003: Define RtpTransportControllerSendInterface. (Closed)
Patch Set: Fix dependency problem. Add accessors transport_feedback_observer and packet_sender. Created 3 years, 9 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 #include "webrtc/video/video_send_stream.h" 10 #include "webrtc/video/video_send_stream.h"
11 11
12 #include <algorithm> 12 #include <algorithm>
13 #include <cmath> 13 #include <cmath>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/checks.h" 19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/file.h" 20 #include "webrtc/base/file.h"
21 #include "webrtc/base/location.h" 21 #include "webrtc/base/location.h"
22 #include "webrtc/base/logging.h" 22 #include "webrtc/base/logging.h"
23 #include "webrtc/base/trace_event.h" 23 #include "webrtc/base/trace_event.h"
24 #include "webrtc/base/weak_ptr.h" 24 #include "webrtc/base/weak_ptr.h"
25 #include "webrtc/call/rtp_transport_controller.h"
25 #include "webrtc/common_types.h" 26 #include "webrtc/common_types.h"
26 #include "webrtc/common_video/include/video_bitrate_allocator.h" 27 #include "webrtc/common_video/include/video_bitrate_allocator.h"
27 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 28 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
28 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 29 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
29 #include "webrtc/modules/pacing/packet_router.h" 30 #include "webrtc/modules/pacing/packet_router.h"
30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
31 #include "webrtc/modules/utility/include/process_thread.h" 32 #include "webrtc/modules/utility/include/process_thread.h"
32 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" 33 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
33 #include "webrtc/system_wrappers/include/field_trial.h" 34 #include "webrtc/system_wrappers/include/field_trial.h"
34 #include "webrtc/video/call_stats.h" 35 #include "webrtc/video/call_stats.h"
36 #include "webrtc/video/payload_router.h"
35 #include "webrtc/video/vie_remb.h" 37 #include "webrtc/video/vie_remb.h"
36 #include "webrtc/video_send_stream.h" 38 #include "webrtc/video_send_stream.h"
37 39
38 namespace webrtc { 40 namespace webrtc {
39 41
40 static const int kMinSendSidePacketHistorySize = 600; 42 static const int kMinSendSidePacketHistorySize = 600;
41 namespace { 43 namespace {
42 44
43 // We don't do MTU discovery, so assume that we have the standard ethernet MTU. 45 // We don't do MTU discovery, so assume that we have the standard ethernet MTU.
44 const size_t kPathMTU = 1500; 46 const size_t kPathMTU = 1500;
45 47
46 std::vector<RtpRtcp*> CreateRtpRtcpModules( 48 std::vector<RtpRtcp*> CreateRtpRtcpModules(
47 Transport* outgoing_transport, 49 Transport* outgoing_transport,
48 RtcpIntraFrameObserver* intra_frame_callback, 50 RtcpIntraFrameObserver* intra_frame_callback,
49 RtcpBandwidthObserver* bandwidth_callback, 51 RtcpBandwidthObserver* bandwidth_callback,
50 TransportFeedbackObserver* transport_feedback_callback, 52 RtpTransportControllerSendInterface* transport,
51 RtcpRttStats* rtt_stats, 53 RtcpRttStats* rtt_stats,
52 RtpPacketSender* paced_sender,
53 TransportSequenceNumberAllocator* transport_sequence_number_allocator,
54 FlexfecSender* flexfec_sender, 54 FlexfecSender* flexfec_sender,
55 SendStatisticsProxy* stats_proxy, 55 SendStatisticsProxy* stats_proxy,
56 SendDelayStats* send_delay_stats, 56 SendDelayStats* send_delay_stats,
57 RtcEventLog* event_log, 57 RtcEventLog* event_log,
58 RateLimiter* retransmission_rate_limiter, 58 RateLimiter* retransmission_rate_limiter,
59 OverheadObserver* overhead_observer, 59 OverheadObserver* overhead_observer,
60 size_t num_modules) { 60 size_t num_modules) {
61 RTC_DCHECK_GT(num_modules, 0); 61 RTC_DCHECK_GT(num_modules, 0);
62 RtpRtcp::Configuration configuration; 62 RtpRtcp::Configuration configuration;
63 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; 63 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics;
64 configuration.audio = false; 64 configuration.audio = false;
65 configuration.receiver_only = false; 65 configuration.receiver_only = false;
66 configuration.flexfec_sender = flexfec_sender; 66 configuration.flexfec_sender = flexfec_sender;
67 configuration.receive_statistics = null_receive_statistics; 67 configuration.receive_statistics = null_receive_statistics;
68 configuration.outgoing_transport = outgoing_transport; 68 configuration.outgoing_transport = outgoing_transport;
69 configuration.intra_frame_callback = intra_frame_callback; 69 configuration.intra_frame_callback = intra_frame_callback;
70 configuration.bandwidth_callback = bandwidth_callback; 70 configuration.bandwidth_callback = bandwidth_callback;
71 configuration.transport_feedback_callback = transport_feedback_callback; 71 configuration.transport_feedback_callback =
72 transport->transport_feedback_observer();
72 configuration.rtt_stats = rtt_stats; 73 configuration.rtt_stats = rtt_stats;
73 configuration.rtcp_packet_type_counter_observer = stats_proxy; 74 configuration.rtcp_packet_type_counter_observer = stats_proxy;
74 configuration.paced_sender = paced_sender; 75 configuration.paced_sender = transport->packet_sender();
75 configuration.transport_sequence_number_allocator = 76 configuration.transport_sequence_number_allocator =
76 transport_sequence_number_allocator; 77 transport->packet_router();
77 configuration.send_bitrate_observer = stats_proxy; 78 configuration.send_bitrate_observer = stats_proxy;
78 configuration.send_frame_count_observer = stats_proxy; 79 configuration.send_frame_count_observer = stats_proxy;
79 configuration.send_side_delay_observer = stats_proxy; 80 configuration.send_side_delay_observer = stats_proxy;
80 configuration.send_packet_observer = send_delay_stats; 81 configuration.send_packet_observer = send_delay_stats;
81 configuration.event_log = event_log; 82 configuration.event_log = event_log;
82 configuration.retransmission_rate_limiter = retransmission_rate_limiter; 83 configuration.retransmission_rate_limiter = retransmission_rate_limiter;
83 configuration.overhead_observer = overhead_observer; 84 configuration.overhead_observer = overhead_observer;
84 std::vector<RtpRtcp*> modules; 85 std::vector<RtpRtcp*> modules;
85 for (size_t i = 0; i < num_modules; ++i) { 86 for (size_t i = 0; i < num_modules; ++i) {
86 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); 87 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // arbitrary thread. 319 // arbitrary thread.
319 class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, 320 class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver,
320 public webrtc::OverheadObserver, 321 public webrtc::OverheadObserver,
321 public webrtc::VCMProtectionCallback, 322 public webrtc::VCMProtectionCallback,
322 public ViEEncoder::EncoderSink, 323 public ViEEncoder::EncoderSink,
323 public VideoBitrateAllocationObserver { 324 public VideoBitrateAllocationObserver {
324 public: 325 public:
325 VideoSendStreamImpl(SendStatisticsProxy* stats_proxy, 326 VideoSendStreamImpl(SendStatisticsProxy* stats_proxy,
326 rtc::TaskQueue* worker_queue, 327 rtc::TaskQueue* worker_queue,
327 CallStats* call_stats, 328 CallStats* call_stats,
328 CongestionController* congestion_controller, 329 RtpTransportControllerSendInterface* transport,
329 PacketRouter* packet_router,
330 BitrateAllocator* bitrate_allocator, 330 BitrateAllocator* bitrate_allocator,
331 SendDelayStats* send_delay_stats, 331 SendDelayStats* send_delay_stats,
332 VieRemb* remb,
333 ViEEncoder* vie_encoder, 332 ViEEncoder* vie_encoder,
334 RtcEventLog* event_log, 333 RtcEventLog* event_log,
335 const VideoSendStream::Config* config, 334 const VideoSendStream::Config* config,
336 int initial_encoder_max_bitrate, 335 int initial_encoder_max_bitrate,
337 std::map<uint32_t, RtpState> suspended_ssrcs); 336 std::map<uint32_t, RtpState> suspended_ssrcs);
338 ~VideoSendStreamImpl() override; 337 ~VideoSendStreamImpl() override;
339 338
340 // RegisterProcessThread register |module_process_thread| with those objects 339 // RegisterProcessThread register |module_process_thread| with those objects
341 // that use it. Registration has to happen on the thread were 340 // that use it. Registration has to happen on the thread were
342 // |module_process_thread| was created (libjingle's worker thread). 341 // |module_process_thread| was created (libjingle's worker thread).
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 403
405 ProcessThread* module_process_thread_; 404 ProcessThread* module_process_thread_;
406 rtc::ThreadChecker module_process_thread_checker_; 405 rtc::ThreadChecker module_process_thread_checker_;
407 rtc::TaskQueue* const worker_queue_; 406 rtc::TaskQueue* const worker_queue_;
408 407
409 rtc::CriticalSection encoder_activity_crit_sect_; 408 rtc::CriticalSection encoder_activity_crit_sect_;
410 CheckEncoderActivityTask* check_encoder_activity_task_ 409 CheckEncoderActivityTask* check_encoder_activity_task_
411 GUARDED_BY(encoder_activity_crit_sect_); 410 GUARDED_BY(encoder_activity_crit_sect_);
412 411
413 CallStats* const call_stats_; 412 CallStats* const call_stats_;
414 CongestionController* const congestion_controller_; 413 RtpTransportControllerSendInterface* const transport_;
415 PacketRouter* const packet_router_;
416 BitrateAllocator* const bitrate_allocator_; 414 BitrateAllocator* const bitrate_allocator_;
417 VieRemb* const remb_;
418 415
419 // TODO(brandtr): Consider moving this to a new FlexfecSendStream class. 416 // TODO(brandtr): Consider moving this to a new FlexfecSendStream class.
420 std::unique_ptr<FlexfecSender> flexfec_sender_; 417 std::unique_ptr<FlexfecSender> flexfec_sender_;
421 418
422 rtc::CriticalSection ivf_writers_crit_; 419 rtc::CriticalSection ivf_writers_crit_;
423 std::unique_ptr<IvfFileWriter> file_writers_[kMaxSimulcastStreams] GUARDED_BY( 420 std::unique_ptr<IvfFileWriter> file_writers_[kMaxSimulcastStreams] GUARDED_BY(
424 ivf_writers_crit_); 421 ivf_writers_crit_);
425 422
426 int max_padding_bitrate_; 423 int max_padding_bitrate_;
427 int encoder_min_bitrate_bps_; 424 int encoder_min_bitrate_bps_;
(...skipping 25 matching lines...) Expand all
453 // TODO(tommi): See if there's a more elegant way to create a task that creates 450 // TODO(tommi): See if there's a more elegant way to create a task that creates
454 // an object on the correct task queue. 451 // an object on the correct task queue.
455 class VideoSendStream::ConstructionTask : public rtc::QueuedTask { 452 class VideoSendStream::ConstructionTask : public rtc::QueuedTask {
456 public: 453 public:
457 ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream, 454 ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream,
458 rtc::Event* done_event, 455 rtc::Event* done_event,
459 SendStatisticsProxy* stats_proxy, 456 SendStatisticsProxy* stats_proxy,
460 ViEEncoder* vie_encoder, 457 ViEEncoder* vie_encoder,
461 ProcessThread* module_process_thread, 458 ProcessThread* module_process_thread,
462 CallStats* call_stats, 459 CallStats* call_stats,
463 CongestionController* congestion_controller, 460 RtpTransportControllerSendInterface* transport,
464 PacketRouter* packet_router,
465 BitrateAllocator* bitrate_allocator, 461 BitrateAllocator* bitrate_allocator,
466 SendDelayStats* send_delay_stats, 462 SendDelayStats* send_delay_stats,
467 VieRemb* remb,
468 RtcEventLog* event_log, 463 RtcEventLog* event_log,
469 const VideoSendStream::Config* config, 464 const VideoSendStream::Config* config,
470 int initial_encoder_max_bitrate, 465 int initial_encoder_max_bitrate,
471 const std::map<uint32_t, RtpState>& suspended_ssrcs) 466 const std::map<uint32_t, RtpState>& suspended_ssrcs)
472 : send_stream_(send_stream), 467 : send_stream_(send_stream),
473 done_event_(done_event), 468 done_event_(done_event),
474 stats_proxy_(stats_proxy), 469 stats_proxy_(stats_proxy),
475 vie_encoder_(vie_encoder), 470 vie_encoder_(vie_encoder),
476 call_stats_(call_stats), 471 call_stats_(call_stats),
477 congestion_controller_(congestion_controller), 472 transport_(transport),
478 packet_router_(packet_router),
479 bitrate_allocator_(bitrate_allocator), 473 bitrate_allocator_(bitrate_allocator),
480 send_delay_stats_(send_delay_stats), 474 send_delay_stats_(send_delay_stats),
481 remb_(remb),
482 event_log_(event_log), 475 event_log_(event_log),
483 config_(config), 476 config_(config),
484 initial_encoder_max_bitrate_(initial_encoder_max_bitrate), 477 initial_encoder_max_bitrate_(initial_encoder_max_bitrate),
485 suspended_ssrcs_(suspended_ssrcs) {} 478 suspended_ssrcs_(suspended_ssrcs) {}
486 479
487 ~ConstructionTask() override { done_event_->Set(); } 480 ~ConstructionTask() override { done_event_->Set(); }
488 481
489 private: 482 private:
490 bool Run() override { 483 bool Run() override {
491 send_stream_->reset(new VideoSendStreamImpl( 484 send_stream_->reset(new VideoSendStreamImpl(
492 stats_proxy_, rtc::TaskQueue::Current(), call_stats_, 485 stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_,
493 congestion_controller_, packet_router_, bitrate_allocator_, 486 bitrate_allocator_, send_delay_stats_, vie_encoder_, event_log_,
494 send_delay_stats_, remb_, vie_encoder_, event_log_, config_, 487 config_, initial_encoder_max_bitrate_, std::move(suspended_ssrcs_)));
495 initial_encoder_max_bitrate_, std::move(suspended_ssrcs_)));
496 return true; 488 return true;
497 } 489 }
498 490
499 std::unique_ptr<VideoSendStreamImpl>* const send_stream_; 491 std::unique_ptr<VideoSendStreamImpl>* const send_stream_;
500 rtc::Event* const done_event_; 492 rtc::Event* const done_event_;
501 SendStatisticsProxy* const stats_proxy_; 493 SendStatisticsProxy* const stats_proxy_;
502 ViEEncoder* const vie_encoder_; 494 ViEEncoder* const vie_encoder_;
503 CallStats* const call_stats_; 495 CallStats* const call_stats_;
504 CongestionController* const congestion_controller_; 496 RtpTransportControllerSendInterface* const transport_;
505 PacketRouter* const packet_router_;
506 BitrateAllocator* const bitrate_allocator_; 497 BitrateAllocator* const bitrate_allocator_;
507 SendDelayStats* const send_delay_stats_; 498 SendDelayStats* const send_delay_stats_;
508 VieRemb* const remb_;
509 RtcEventLog* const event_log_; 499 RtcEventLog* const event_log_;
510 const VideoSendStream::Config* config_; 500 const VideoSendStream::Config* config_;
511 int initial_encoder_max_bitrate_; 501 int initial_encoder_max_bitrate_;
512 std::map<uint32_t, RtpState> suspended_ssrcs_; 502 std::map<uint32_t, RtpState> suspended_ssrcs_;
513 }; 503 };
514 504
515 class VideoSendStream::DestructAndGetRtpStateTask : public rtc::QueuedTask { 505 class VideoSendStream::DestructAndGetRtpStateTask : public rtc::QueuedTask {
516 public: 506 public:
517 DestructAndGetRtpStateTask(VideoSendStream::RtpStateMap* state_map, 507 DestructAndGetRtpStateTask(VideoSendStream::RtpStateMap* state_map,
518 std::unique_ptr<VideoSendStreamImpl> send_stream, 508 std::unique_ptr<VideoSendStreamImpl> send_stream,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 rtc::WeakPtr<VideoSendStreamImpl> send_stream_; 599 rtc::WeakPtr<VideoSendStreamImpl> send_stream_;
610 std::vector<VideoStream> streams_; 600 std::vector<VideoStream> streams_;
611 int min_transmit_bitrate_bps_; 601 int min_transmit_bitrate_bps_;
612 }; 602 };
613 603
614 VideoSendStream::VideoSendStream( 604 VideoSendStream::VideoSendStream(
615 int num_cpu_cores, 605 int num_cpu_cores,
616 ProcessThread* module_process_thread, 606 ProcessThread* module_process_thread,
617 rtc::TaskQueue* worker_queue, 607 rtc::TaskQueue* worker_queue,
618 CallStats* call_stats, 608 CallStats* call_stats,
619 CongestionController* congestion_controller, 609 RtpTransportControllerSendInterface* transport,
620 PacketRouter* packet_router,
621 BitrateAllocator* bitrate_allocator, 610 BitrateAllocator* bitrate_allocator,
622 SendDelayStats* send_delay_stats, 611 SendDelayStats* send_delay_stats,
623 VieRemb* remb,
624 RtcEventLog* event_log, 612 RtcEventLog* event_log,
625 VideoSendStream::Config config, 613 VideoSendStream::Config config,
626 VideoEncoderConfig encoder_config, 614 VideoEncoderConfig encoder_config,
627 const std::map<uint32_t, RtpState>& suspended_ssrcs) 615 const std::map<uint32_t, RtpState>& suspended_ssrcs)
628 : worker_queue_(worker_queue), 616 : worker_queue_(worker_queue),
629 thread_sync_event_(false /* manual_reset */, false), 617 thread_sync_event_(false /* manual_reset */, false),
630 stats_proxy_(Clock::GetRealTimeClock(), 618 stats_proxy_(Clock::GetRealTimeClock(),
631 config, 619 config,
632 encoder_config.content_type), 620 encoder_config.content_type),
633 config_(std::move(config)), 621 config_(std::move(config)),
634 content_type_(encoder_config.content_type) { 622 content_type_(encoder_config.content_type) {
635 vie_encoder_.reset(new ViEEncoder( 623 vie_encoder_.reset(new ViEEncoder(
636 num_cpu_cores, &stats_proxy_, config_.encoder_settings, 624 num_cpu_cores, &stats_proxy_, config_.encoder_settings,
637 config_.pre_encode_callback, config_.post_encode_callback)); 625 config_.pre_encode_callback, config_.post_encode_callback));
638 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( 626 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
639 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), 627 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(),
640 module_process_thread, call_stats, congestion_controller, packet_router, 628 module_process_thread, call_stats, transport, bitrate_allocator,
641 bitrate_allocator, send_delay_stats, remb, event_log, &config_, 629 send_delay_stats, event_log, &config_, encoder_config.max_bitrate_bps,
642 encoder_config.max_bitrate_bps, suspended_ssrcs))); 630 suspended_ssrcs)));
643 631
644 // Wait for ConstructionTask to complete so that |send_stream_| can be used. 632 // Wait for ConstructionTask to complete so that |send_stream_| can be used.
645 // |module_process_thread| must be registered and deregistered on the thread 633 // |module_process_thread| must be registered and deregistered on the thread
646 // it was created on. 634 // it was created on.
647 thread_sync_event_.Wait(rtc::Event::kForever); 635 thread_sync_event_.Wait(rtc::Event::kForever);
648 send_stream_->RegisterProcessThread(module_process_thread); 636 send_stream_->RegisterProcessThread(module_process_thread);
649 // TODO(sprang): Enable this also for regular video calls if it works well. 637 // TODO(sprang): Enable this also for regular video calls if it works well.
650 if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) { 638 if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) {
651 // Only signal target bitrate for screenshare streams, for now. 639 // Only signal target bitrate for screenshare streams, for now.
652 vie_encoder_->SetBitrateObserver(send_stream_.get()); 640 vie_encoder_->SetBitrateObserver(send_stream_.get());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 void VideoSendStream::EnableEncodedFrameRecording( 731 void VideoSendStream::EnableEncodedFrameRecording(
744 const std::vector<rtc::PlatformFile>& files, 732 const std::vector<rtc::PlatformFile>& files,
745 size_t byte_limit) { 733 size_t byte_limit) {
746 send_stream_->EnableEncodedFrameRecording(files, byte_limit); 734 send_stream_->EnableEncodedFrameRecording(files, byte_limit);
747 } 735 }
748 736
749 VideoSendStreamImpl::VideoSendStreamImpl( 737 VideoSendStreamImpl::VideoSendStreamImpl(
750 SendStatisticsProxy* stats_proxy, 738 SendStatisticsProxy* stats_proxy,
751 rtc::TaskQueue* worker_queue, 739 rtc::TaskQueue* worker_queue,
752 CallStats* call_stats, 740 CallStats* call_stats,
753 CongestionController* congestion_controller, 741 RtpTransportControllerSendInterface* transport,
754 PacketRouter* packet_router,
755 BitrateAllocator* bitrate_allocator, 742 BitrateAllocator* bitrate_allocator,
756 SendDelayStats* send_delay_stats, 743 SendDelayStats* send_delay_stats,
757 VieRemb* remb,
758 ViEEncoder* vie_encoder, 744 ViEEncoder* vie_encoder,
759 RtcEventLog* event_log, 745 RtcEventLog* event_log,
760 const VideoSendStream::Config* config, 746 const VideoSendStream::Config* config,
761 int initial_encoder_max_bitrate, 747 int initial_encoder_max_bitrate,
762 std::map<uint32_t, RtpState> suspended_ssrcs) 748 std::map<uint32_t, RtpState> suspended_ssrcs)
763 : send_side_bwe_with_overhead_( 749 : send_side_bwe_with_overhead_(
764 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), 750 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
765 stats_proxy_(stats_proxy), 751 stats_proxy_(stats_proxy),
766 config_(config), 752 config_(config),
767 suspended_ssrcs_(std::move(suspended_ssrcs)), 753 suspended_ssrcs_(std::move(suspended_ssrcs)),
768 module_process_thread_(nullptr), 754 module_process_thread_(nullptr),
769 worker_queue_(worker_queue), 755 worker_queue_(worker_queue),
770 check_encoder_activity_task_(nullptr), 756 check_encoder_activity_task_(nullptr),
771 call_stats_(call_stats), 757 call_stats_(call_stats),
772 congestion_controller_(congestion_controller), 758 transport_(transport),
773 packet_router_(packet_router),
774 bitrate_allocator_(bitrate_allocator), 759 bitrate_allocator_(bitrate_allocator),
775 remb_(remb),
776 flexfec_sender_(MaybeCreateFlexfecSender(*config_)), 760 flexfec_sender_(MaybeCreateFlexfecSender(*config_)),
777 max_padding_bitrate_(0), 761 max_padding_bitrate_(0),
778 encoder_min_bitrate_bps_(0), 762 encoder_min_bitrate_bps_(0),
779 encoder_max_bitrate_bps_(initial_encoder_max_bitrate), 763 encoder_max_bitrate_bps_(initial_encoder_max_bitrate),
780 encoder_target_rate_bps_(0), 764 encoder_target_rate_bps_(0),
781 vie_encoder_(vie_encoder), 765 vie_encoder_(vie_encoder),
782 encoder_feedback_(Clock::GetRealTimeClock(), 766 encoder_feedback_(Clock::GetRealTimeClock(),
783 config_->rtp.ssrcs, 767 config_->rtp.ssrcs,
784 vie_encoder), 768 vie_encoder),
785 protection_bitrate_calculator_(Clock::GetRealTimeClock(), this), 769 protection_bitrate_calculator_(Clock::GetRealTimeClock(), this),
786 bandwidth_observer_(congestion_controller_->GetBitrateController() 770 bandwidth_observer_(transport->congestion_controller()
771 ->GetBitrateController()
787 ->CreateRtcpBandwidthObserver()), 772 ->CreateRtcpBandwidthObserver()),
788 rtp_rtcp_modules_(CreateRtpRtcpModules( 773 rtp_rtcp_modules_(CreateRtpRtcpModules(
789 config_->send_transport, 774 config_->send_transport,
790 &encoder_feedback_, 775 &encoder_feedback_,
791 bandwidth_observer_.get(), 776 bandwidth_observer_.get(),
792 congestion_controller_, 777 transport,
793 call_stats_->rtcp_rtt_stats(), 778 call_stats_->rtcp_rtt_stats(),
794 congestion_controller_->pacer(),
795 packet_router_,
796 flexfec_sender_.get(), 779 flexfec_sender_.get(),
797 stats_proxy_, 780 stats_proxy_,
798 send_delay_stats, 781 send_delay_stats,
799 event_log, 782 event_log,
800 congestion_controller_->GetRetransmissionRateLimiter(), 783 transport->congestion_controller()->GetRetransmissionRateLimiter(),
801 this, 784 this,
802 config_->rtp.ssrcs.size())), 785 config_->rtp.ssrcs.size())),
803 payload_router_(rtp_rtcp_modules_, 786 payload_router_(rtp_rtcp_modules_,
804 config_->encoder_settings.payload_type), 787 config_->encoder_settings.payload_type),
805 weak_ptr_factory_(this), 788 weak_ptr_factory_(this),
806 overhead_bytes_per_packet_(0), 789 overhead_bytes_per_packet_(0),
807 transport_overhead_bytes_per_packet_(0) { 790 transport_overhead_bytes_per_packet_(0) {
808 RTC_DCHECK_RUN_ON(worker_queue_); 791 RTC_DCHECK_RUN_ON(worker_queue_);
809 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString(); 792 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString();
810 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); 793 weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
811 module_process_thread_checker_.DetachFromThread(); 794 module_process_thread_checker_.DetachFromThread();
812 795
813 RTC_DCHECK(!config_->rtp.ssrcs.empty()); 796 RTC_DCHECK(!config_->rtp.ssrcs.empty());
814 RTC_DCHECK(call_stats_); 797 RTC_DCHECK(call_stats_);
815 RTC_DCHECK(congestion_controller_); 798 RTC_DCHECK(transport_);
816 RTC_DCHECK(remb_); 799 RTC_DCHECK(transport_->congestion_controller());
800 RTC_DCHECK(transport_->remb());
817 801
818 congestion_controller_->EnablePeriodicAlrProbing( 802 transport->congestion_controller()->EnablePeriodicAlrProbing(
819 config_->periodic_alr_bandwidth_probing); 803 config_->periodic_alr_bandwidth_probing);
820 804
821 // RTP/RTCP initialization. 805 // RTP/RTCP initialization.
822 806
823 // We add the highest spatial layer first to ensure it'll be prioritized 807 // We add the highest spatial layer first to ensure it'll be prioritized
824 // when sending padding, with the hope that the packet rate will be smaller, 808 // when sending padding, with the hope that the packet rate will be smaller,
825 // and that it's more important to protect than the lower layers. 809 // and that it's more important to protect than the lower layers.
826 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 810 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
827 packet_router_->AddRtpModule(rtp_rtcp); 811 transport->packet_router()->AddRtpModule(rtp_rtcp);
828 812
829 for (size_t i = 0; i < config_->rtp.extensions.size(); ++i) { 813 for (size_t i = 0; i < config_->rtp.extensions.size(); ++i) {
830 const std::string& extension = config_->rtp.extensions[i].uri; 814 const std::string& extension = config_->rtp.extensions[i].uri;
831 int id = config_->rtp.extensions[i].id; 815 int id = config_->rtp.extensions[i].id;
832 // One-byte-extension local identifiers are in the range 1-14 inclusive. 816 // One-byte-extension local identifiers are in the range 1-14 inclusive.
833 RTC_DCHECK_GE(id, 1); 817 RTC_DCHECK_GE(id, 1);
834 RTC_DCHECK_LE(id, 14); 818 RTC_DCHECK_LE(id, 14);
835 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); 819 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension));
836 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 820 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
837 RTC_CHECK_EQ(0, rtp_rtcp->RegisterSendRtpHeaderExtension( 821 RTC_CHECK_EQ(0, rtp_rtcp->RegisterSendRtpHeaderExtension(
838 StringToRtpExtensionType(extension), id)); 822 StringToRtpExtensionType(extension), id));
839 } 823 }
840 } 824 }
841 825
842 remb_->AddRembSender(rtp_rtcp_modules_[0]); 826 transport->remb()->AddRembSender(rtp_rtcp_modules_[0]);
843 rtp_rtcp_modules_[0]->SetREMBStatus(true); 827 rtp_rtcp_modules_[0]->SetREMBStatus(true);
844 828
845 ConfigureProtection(); 829 ConfigureProtection();
846 ConfigureSsrcs(); 830 ConfigureSsrcs();
847 831
848 // TODO(pbos): Should we set CNAME on all RTP modules? 832 // TODO(pbos): Should we set CNAME on all RTP modules?
849 rtp_rtcp_modules_.front()->SetCNAME(config_->rtp.c_name.c_str()); 833 rtp_rtcp_modules_.front()->SetCNAME(config_->rtp.c_name.c_str());
850 834
851 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 835 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
852 rtp_rtcp->RegisterRtcpStatisticsCallback(stats_proxy_); 836 rtp_rtcp->RegisterRtcpStatisticsCallback(stats_proxy_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 module_process_thread_->DeRegisterModule(rtp_rtcp); 877 module_process_thread_->DeRegisterModule(rtp_rtcp);
894 } 878 }
895 879
896 VideoSendStreamImpl::~VideoSendStreamImpl() { 880 VideoSendStreamImpl::~VideoSendStreamImpl() {
897 RTC_DCHECK_RUN_ON(worker_queue_); 881 RTC_DCHECK_RUN_ON(worker_queue_);
898 RTC_DCHECK(!payload_router_.IsActive()) 882 RTC_DCHECK(!payload_router_.IsActive())
899 << "VideoSendStreamImpl::Stop not called"; 883 << "VideoSendStreamImpl::Stop not called";
900 LOG(LS_INFO) << "~VideoSendStreamInternal: " << config_->ToString(); 884 LOG(LS_INFO) << "~VideoSendStreamInternal: " << config_->ToString();
901 885
902 rtp_rtcp_modules_[0]->SetREMBStatus(false); 886 rtp_rtcp_modules_[0]->SetREMBStatus(false);
903 remb_->RemoveRembSender(rtp_rtcp_modules_[0]); 887 transport_->remb()->RemoveRembSender(rtp_rtcp_modules_[0]);
904 888
905 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 889 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
906 packet_router_->RemoveRtpModule(rtp_rtcp); 890 transport_->packet_router()->RemoveRtpModule(rtp_rtcp);
907 delete rtp_rtcp; 891 delete rtp_rtcp;
908 } 892 }
909 } 893 }
910 894
911 bool VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { 895 bool VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) {
912 // Runs on a network thread. 896 // Runs on a network thread.
913 RTC_DCHECK(!worker_queue_->IsCurrent()); 897 RTC_DCHECK(!worker_queue_->IsCurrent());
914 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 898 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
915 rtp_rtcp->IncomingRtcpPacket(packet, length); 899 rtp_rtcp->IncomingRtcpPacket(packet, length);
916 return true; 900 return true;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 1311
1328 void VideoSendStreamImpl::SetTransportOverhead( 1312 void VideoSendStreamImpl::SetTransportOverhead(
1329 size_t transport_overhead_bytes_per_packet) { 1313 size_t transport_overhead_bytes_per_packet) {
1330 if (transport_overhead_bytes_per_packet >= static_cast<int>(kPathMTU)) { 1314 if (transport_overhead_bytes_per_packet >= static_cast<int>(kPathMTU)) {
1331 LOG(LS_ERROR) << "Transport overhead exceeds size of ethernet frame"; 1315 LOG(LS_ERROR) << "Transport overhead exceeds size of ethernet frame";
1332 return; 1316 return;
1333 } 1317 }
1334 1318
1335 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; 1319 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet;
1336 1320
1337 congestion_controller_->SetTransportOverhead( 1321 transport_->congestion_controller()->SetTransportOverhead(
1338 transport_overhead_bytes_per_packet_); 1322 transport_overhead_bytes_per_packet_);
1339 1323
1340 size_t rtp_packet_size = 1324 size_t rtp_packet_size =
1341 std::min(config_->rtp.max_packet_size, 1325 std::min(config_->rtp.max_packet_size,
1342 kPathMTU - transport_overhead_bytes_per_packet_); 1326 kPathMTU - transport_overhead_bytes_per_packet_);
1343 1327
1344 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 1328 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
1345 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); 1329 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size);
1346 } 1330 }
1347 } 1331 }
1348 1332
1349 } // namespace internal 1333 } // namespace internal
1350 } // namespace webrtc 1334 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698