OLD | NEW |
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_send.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/send_side_congestion_cont
roller.h" | 29 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont
roller.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 Loading... |
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 SendSideCongestionController* send_side_cc, | 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, | 332 VieRemb* remb, |
333 ViEEncoder* vie_encoder, | 333 ViEEncoder* vie_encoder, |
334 RtcEventLog* event_log, | 334 RtcEventLog* event_log, |
335 const VideoSendStream::Config* config, | 335 const VideoSendStream::Config* config, |
336 int initial_encoder_max_bitrate, | 336 int initial_encoder_max_bitrate, |
337 std::map<uint32_t, RtpState> suspended_ssrcs); | 337 std::map<uint32_t, RtpState> suspended_ssrcs); |
338 ~VideoSendStreamImpl() override; | 338 ~VideoSendStreamImpl() override; |
339 | 339 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 404 |
405 ProcessThread* module_process_thread_; | 405 ProcessThread* module_process_thread_; |
406 rtc::ThreadChecker module_process_thread_checker_; | 406 rtc::ThreadChecker module_process_thread_checker_; |
407 rtc::TaskQueue* const worker_queue_; | 407 rtc::TaskQueue* const worker_queue_; |
408 | 408 |
409 rtc::CriticalSection encoder_activity_crit_sect_; | 409 rtc::CriticalSection encoder_activity_crit_sect_; |
410 CheckEncoderActivityTask* check_encoder_activity_task_ | 410 CheckEncoderActivityTask* check_encoder_activity_task_ |
411 GUARDED_BY(encoder_activity_crit_sect_); | 411 GUARDED_BY(encoder_activity_crit_sect_); |
412 | 412 |
413 CallStats* const call_stats_; | 413 CallStats* const call_stats_; |
414 SendSideCongestionController* const send_side_cc_; | 414 RtpTransportControllerSendInterface* const transport_; |
415 PacketRouter* const packet_router_; | |
416 BitrateAllocator* const bitrate_allocator_; | 415 BitrateAllocator* const bitrate_allocator_; |
417 VieRemb* const remb_; | 416 VieRemb* const remb_; |
418 | 417 |
419 // TODO(brandtr): Move ownership to PayloadRouter. | 418 // TODO(brandtr): Move ownership to PayloadRouter. |
420 std::unique_ptr<FlexfecSender> flexfec_sender_; | 419 std::unique_ptr<FlexfecSender> flexfec_sender_; |
421 | 420 |
422 rtc::CriticalSection ivf_writers_crit_; | 421 rtc::CriticalSection ivf_writers_crit_; |
423 std::unique_ptr<IvfFileWriter> file_writers_[kMaxSimulcastStreams] GUARDED_BY( | 422 std::unique_ptr<IvfFileWriter> file_writers_[kMaxSimulcastStreams] GUARDED_BY( |
424 ivf_writers_crit_); | 423 ivf_writers_crit_); |
425 | 424 |
(...skipping 27 matching lines...) Expand all Loading... |
453 // TODO(tommi): See if there's a more elegant way to create a task that creates | 452 // TODO(tommi): See if there's a more elegant way to create a task that creates |
454 // an object on the correct task queue. | 453 // an object on the correct task queue. |
455 class VideoSendStream::ConstructionTask : public rtc::QueuedTask { | 454 class VideoSendStream::ConstructionTask : public rtc::QueuedTask { |
456 public: | 455 public: |
457 ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream, | 456 ConstructionTask(std::unique_ptr<VideoSendStreamImpl>* send_stream, |
458 rtc::Event* done_event, | 457 rtc::Event* done_event, |
459 SendStatisticsProxy* stats_proxy, | 458 SendStatisticsProxy* stats_proxy, |
460 ViEEncoder* vie_encoder, | 459 ViEEncoder* vie_encoder, |
461 ProcessThread* module_process_thread, | 460 ProcessThread* module_process_thread, |
462 CallStats* call_stats, | 461 CallStats* call_stats, |
463 SendSideCongestionController* send_side_cc, | 462 RtpTransportControllerSendInterface* transport, |
464 PacketRouter* packet_router, | |
465 BitrateAllocator* bitrate_allocator, | 463 BitrateAllocator* bitrate_allocator, |
466 SendDelayStats* send_delay_stats, | 464 SendDelayStats* send_delay_stats, |
467 VieRemb* remb, | 465 VieRemb* remb, |
468 RtcEventLog* event_log, | 466 RtcEventLog* event_log, |
469 const VideoSendStream::Config* config, | 467 const VideoSendStream::Config* config, |
470 int initial_encoder_max_bitrate, | 468 int initial_encoder_max_bitrate, |
471 const std::map<uint32_t, RtpState>& suspended_ssrcs) | 469 const std::map<uint32_t, RtpState>& suspended_ssrcs) |
472 : send_stream_(send_stream), | 470 : send_stream_(send_stream), |
473 done_event_(done_event), | 471 done_event_(done_event), |
474 stats_proxy_(stats_proxy), | 472 stats_proxy_(stats_proxy), |
475 vie_encoder_(vie_encoder), | 473 vie_encoder_(vie_encoder), |
476 call_stats_(call_stats), | 474 call_stats_(call_stats), |
477 send_side_cc_(send_side_cc), | 475 transport_(transport), |
478 packet_router_(packet_router), | |
479 bitrate_allocator_(bitrate_allocator), | 476 bitrate_allocator_(bitrate_allocator), |
480 send_delay_stats_(send_delay_stats), | 477 send_delay_stats_(send_delay_stats), |
481 remb_(remb), | 478 remb_(remb), |
482 event_log_(event_log), | 479 event_log_(event_log), |
483 config_(config), | 480 config_(config), |
484 initial_encoder_max_bitrate_(initial_encoder_max_bitrate), | 481 initial_encoder_max_bitrate_(initial_encoder_max_bitrate), |
485 suspended_ssrcs_(suspended_ssrcs) {} | 482 suspended_ssrcs_(suspended_ssrcs) {} |
486 | 483 |
487 ~ConstructionTask() override { done_event_->Set(); } | 484 ~ConstructionTask() override { done_event_->Set(); } |
488 | 485 |
489 private: | 486 private: |
490 bool Run() override { | 487 bool Run() override { |
491 send_stream_->reset(new VideoSendStreamImpl( | 488 send_stream_->reset(new VideoSendStreamImpl( |
492 stats_proxy_, rtc::TaskQueue::Current(), call_stats_, send_side_cc_, | 489 stats_proxy_, rtc::TaskQueue::Current(), call_stats_, transport_, |
493 packet_router_, bitrate_allocator_, send_delay_stats_, remb_, | 490 bitrate_allocator_, send_delay_stats_, remb_, vie_encoder_, event_log_, |
494 vie_encoder_, event_log_, config_, initial_encoder_max_bitrate_, | 491 config_, initial_encoder_max_bitrate_, std::move(suspended_ssrcs_))); |
495 std::move(suspended_ssrcs_))); | |
496 return true; | 492 return true; |
497 } | 493 } |
498 | 494 |
499 std::unique_ptr<VideoSendStreamImpl>* const send_stream_; | 495 std::unique_ptr<VideoSendStreamImpl>* const send_stream_; |
500 rtc::Event* const done_event_; | 496 rtc::Event* const done_event_; |
501 SendStatisticsProxy* const stats_proxy_; | 497 SendStatisticsProxy* const stats_proxy_; |
502 ViEEncoder* const vie_encoder_; | 498 ViEEncoder* const vie_encoder_; |
503 CallStats* const call_stats_; | 499 CallStats* const call_stats_; |
504 SendSideCongestionController* const send_side_cc_; | 500 RtpTransportControllerSendInterface* const transport_; |
505 PacketRouter* const packet_router_; | |
506 BitrateAllocator* const bitrate_allocator_; | 501 BitrateAllocator* const bitrate_allocator_; |
507 SendDelayStats* const send_delay_stats_; | 502 SendDelayStats* const send_delay_stats_; |
508 VieRemb* const remb_; | 503 VieRemb* const remb_; |
509 RtcEventLog* const event_log_; | 504 RtcEventLog* const event_log_; |
510 const VideoSendStream::Config* config_; | 505 const VideoSendStream::Config* config_; |
511 int initial_encoder_max_bitrate_; | 506 int initial_encoder_max_bitrate_; |
512 std::map<uint32_t, RtpState> suspended_ssrcs_; | 507 std::map<uint32_t, RtpState> suspended_ssrcs_; |
513 }; | 508 }; |
514 | 509 |
515 class VideoSendStream::DestructAndGetRtpStateTask : public rtc::QueuedTask { | 510 class VideoSendStream::DestructAndGetRtpStateTask : public rtc::QueuedTask { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 rtc::WeakPtr<VideoSendStreamImpl> send_stream_; | 604 rtc::WeakPtr<VideoSendStreamImpl> send_stream_; |
610 std::vector<VideoStream> streams_; | 605 std::vector<VideoStream> streams_; |
611 int min_transmit_bitrate_bps_; | 606 int min_transmit_bitrate_bps_; |
612 }; | 607 }; |
613 | 608 |
614 VideoSendStream::VideoSendStream( | 609 VideoSendStream::VideoSendStream( |
615 int num_cpu_cores, | 610 int num_cpu_cores, |
616 ProcessThread* module_process_thread, | 611 ProcessThread* module_process_thread, |
617 rtc::TaskQueue* worker_queue, | 612 rtc::TaskQueue* worker_queue, |
618 CallStats* call_stats, | 613 CallStats* call_stats, |
619 SendSideCongestionController* send_side_cc, | 614 RtpTransportControllerSendInterface* transport, |
620 PacketRouter* packet_router, | |
621 BitrateAllocator* bitrate_allocator, | 615 BitrateAllocator* bitrate_allocator, |
622 SendDelayStats* send_delay_stats, | 616 SendDelayStats* send_delay_stats, |
623 VieRemb* remb, | 617 VieRemb* remb, |
624 RtcEventLog* event_log, | 618 RtcEventLog* event_log, |
625 VideoSendStream::Config config, | 619 VideoSendStream::Config config, |
626 VideoEncoderConfig encoder_config, | 620 VideoEncoderConfig encoder_config, |
627 const std::map<uint32_t, RtpState>& suspended_ssrcs) | 621 const std::map<uint32_t, RtpState>& suspended_ssrcs) |
628 : worker_queue_(worker_queue), | 622 : worker_queue_(worker_queue), |
629 thread_sync_event_(false /* manual_reset */, false), | 623 thread_sync_event_(false /* manual_reset */, false), |
630 stats_proxy_(Clock::GetRealTimeClock(), | 624 stats_proxy_(Clock::GetRealTimeClock(), |
631 config, | 625 config, |
632 encoder_config.content_type), | 626 encoder_config.content_type), |
633 config_(std::move(config)), | 627 config_(std::move(config)), |
634 content_type_(encoder_config.content_type) { | 628 content_type_(encoder_config.content_type) { |
635 vie_encoder_.reset(new ViEEncoder( | 629 vie_encoder_.reset(new ViEEncoder( |
636 num_cpu_cores, &stats_proxy_, config_.encoder_settings, | 630 num_cpu_cores, &stats_proxy_, config_.encoder_settings, |
637 config_.pre_encode_callback, config_.post_encode_callback)); | 631 config_.pre_encode_callback, config_.post_encode_callback)); |
638 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( | 632 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( |
639 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), | 633 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), |
640 module_process_thread, call_stats, send_side_cc, packet_router, | 634 module_process_thread, call_stats, transport, bitrate_allocator, |
641 bitrate_allocator, send_delay_stats, remb, event_log, &config_, | 635 send_delay_stats, remb, event_log, &config_, |
642 encoder_config.max_bitrate_bps, suspended_ssrcs))); | 636 encoder_config.max_bitrate_bps, suspended_ssrcs))); |
643 | 637 |
644 // Wait for ConstructionTask to complete so that |send_stream_| can be used. | 638 // Wait for ConstructionTask to complete so that |send_stream_| can be used. |
645 // |module_process_thread| must be registered and deregistered on the thread | 639 // |module_process_thread| must be registered and deregistered on the thread |
646 // it was created on. | 640 // it was created on. |
647 thread_sync_event_.Wait(rtc::Event::kForever); | 641 thread_sync_event_.Wait(rtc::Event::kForever); |
648 send_stream_->RegisterProcessThread(module_process_thread); | 642 send_stream_->RegisterProcessThread(module_process_thread); |
649 // TODO(sprang): Enable this also for regular video calls if it works well. | 643 // TODO(sprang): Enable this also for regular video calls if it works well. |
650 if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) { | 644 if (encoder_config.content_type == VideoEncoderConfig::ContentType::kScreen) { |
651 // Only signal target bitrate for screenshare streams, for now. | 645 // Only signal target bitrate for screenshare streams, for now. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 void VideoSendStream::EnableEncodedFrameRecording( | 737 void VideoSendStream::EnableEncodedFrameRecording( |
744 const std::vector<rtc::PlatformFile>& files, | 738 const std::vector<rtc::PlatformFile>& files, |
745 size_t byte_limit) { | 739 size_t byte_limit) { |
746 send_stream_->EnableEncodedFrameRecording(files, byte_limit); | 740 send_stream_->EnableEncodedFrameRecording(files, byte_limit); |
747 } | 741 } |
748 | 742 |
749 VideoSendStreamImpl::VideoSendStreamImpl( | 743 VideoSendStreamImpl::VideoSendStreamImpl( |
750 SendStatisticsProxy* stats_proxy, | 744 SendStatisticsProxy* stats_proxy, |
751 rtc::TaskQueue* worker_queue, | 745 rtc::TaskQueue* worker_queue, |
752 CallStats* call_stats, | 746 CallStats* call_stats, |
753 SendSideCongestionController* send_side_cc, | 747 RtpTransportControllerSendInterface* transport, |
754 PacketRouter* packet_router, | |
755 BitrateAllocator* bitrate_allocator, | 748 BitrateAllocator* bitrate_allocator, |
756 SendDelayStats* send_delay_stats, | 749 SendDelayStats* send_delay_stats, |
757 VieRemb* remb, | 750 VieRemb* remb, |
758 ViEEncoder* vie_encoder, | 751 ViEEncoder* vie_encoder, |
759 RtcEventLog* event_log, | 752 RtcEventLog* event_log, |
760 const VideoSendStream::Config* config, | 753 const VideoSendStream::Config* config, |
761 int initial_encoder_max_bitrate, | 754 int initial_encoder_max_bitrate, |
762 std::map<uint32_t, RtpState> suspended_ssrcs) | 755 std::map<uint32_t, RtpState> suspended_ssrcs) |
763 : send_side_bwe_with_overhead_( | 756 : send_side_bwe_with_overhead_( |
764 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), | 757 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), |
765 stats_proxy_(stats_proxy), | 758 stats_proxy_(stats_proxy), |
766 config_(config), | 759 config_(config), |
767 suspended_ssrcs_(std::move(suspended_ssrcs)), | 760 suspended_ssrcs_(std::move(suspended_ssrcs)), |
768 module_process_thread_(nullptr), | 761 module_process_thread_(nullptr), |
769 worker_queue_(worker_queue), | 762 worker_queue_(worker_queue), |
770 check_encoder_activity_task_(nullptr), | 763 check_encoder_activity_task_(nullptr), |
771 call_stats_(call_stats), | 764 call_stats_(call_stats), |
772 send_side_cc_(send_side_cc), | 765 transport_(transport), |
773 packet_router_(packet_router), | |
774 bitrate_allocator_(bitrate_allocator), | 766 bitrate_allocator_(bitrate_allocator), |
775 remb_(remb), | 767 remb_(remb), |
776 flexfec_sender_(MaybeCreateFlexfecSender(*config_)), | 768 flexfec_sender_(MaybeCreateFlexfecSender(*config_)), |
777 max_padding_bitrate_(0), | 769 max_padding_bitrate_(0), |
778 encoder_min_bitrate_bps_(0), | 770 encoder_min_bitrate_bps_(0), |
779 encoder_max_bitrate_bps_(initial_encoder_max_bitrate), | 771 encoder_max_bitrate_bps_(initial_encoder_max_bitrate), |
780 encoder_target_rate_bps_(0), | 772 encoder_target_rate_bps_(0), |
781 vie_encoder_(vie_encoder), | 773 vie_encoder_(vie_encoder), |
782 encoder_feedback_(Clock::GetRealTimeClock(), | 774 encoder_feedback_(Clock::GetRealTimeClock(), |
783 config_->rtp.ssrcs, | 775 config_->rtp.ssrcs, |
784 vie_encoder), | 776 vie_encoder), |
785 protection_bitrate_calculator_(Clock::GetRealTimeClock(), this), | 777 protection_bitrate_calculator_(Clock::GetRealTimeClock(), this), |
786 bandwidth_observer_( | 778 bandwidth_observer_(transport->send_side_cc() |
787 send_side_cc_->GetBitrateController()->CreateRtcpBandwidthObserver()), | 779 ->GetBitrateController() |
788 rtp_rtcp_modules_( | 780 ->CreateRtcpBandwidthObserver()), |
789 CreateRtpRtcpModules(config_->send_transport, | 781 rtp_rtcp_modules_(CreateRtpRtcpModules( |
790 &encoder_feedback_, | 782 config_->send_transport, |
791 bandwidth_observer_.get(), | 783 &encoder_feedback_, |
792 send_side_cc_, | 784 bandwidth_observer_.get(), |
793 call_stats_->rtcp_rtt_stats(), | 785 transport, |
794 send_side_cc_->pacer(), | 786 call_stats_->rtcp_rtt_stats(), |
795 packet_router_, | 787 flexfec_sender_.get(), |
796 flexfec_sender_.get(), | 788 stats_proxy_, |
797 stats_proxy_, | 789 send_delay_stats, |
798 send_delay_stats, | 790 event_log, |
799 event_log, | 791 transport->send_side_cc()->GetRetransmissionRateLimiter(), |
800 send_side_cc_->GetRetransmissionRateLimiter(), | 792 this, |
801 this, | 793 config_->rtp.ssrcs.size())), |
802 config_->rtp.ssrcs.size())), | |
803 payload_router_(rtp_rtcp_modules_, | 794 payload_router_(rtp_rtcp_modules_, |
804 config_->encoder_settings.payload_type), | 795 config_->encoder_settings.payload_type), |
805 weak_ptr_factory_(this), | 796 weak_ptr_factory_(this), |
806 overhead_bytes_per_packet_(0), | 797 overhead_bytes_per_packet_(0), |
807 transport_overhead_bytes_per_packet_(0) { | 798 transport_overhead_bytes_per_packet_(0) { |
808 RTC_DCHECK_RUN_ON(worker_queue_); | 799 RTC_DCHECK_RUN_ON(worker_queue_); |
809 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString(); | 800 LOG(LS_INFO) << "VideoSendStreamInternal: " << config_->ToString(); |
810 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); | 801 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); |
811 module_process_thread_checker_.DetachFromThread(); | 802 module_process_thread_checker_.DetachFromThread(); |
812 | 803 |
813 RTC_DCHECK(!config_->rtp.ssrcs.empty()); | 804 RTC_DCHECK(!config_->rtp.ssrcs.empty()); |
814 RTC_DCHECK(call_stats_); | 805 RTC_DCHECK(call_stats_); |
815 RTC_DCHECK(send_side_cc_); | |
816 RTC_DCHECK(remb_); | 806 RTC_DCHECK(remb_); |
| 807 RTC_DCHECK(transport_); |
| 808 RTC_DCHECK(transport_->send_side_cc()); |
817 | 809 |
818 send_side_cc_->EnablePeriodicAlrProbing( | 810 transport->send_side_cc()->EnablePeriodicAlrProbing( |
819 config_->periodic_alr_bandwidth_probing); | 811 config_->periodic_alr_bandwidth_probing); |
820 | 812 |
821 // RTP/RTCP initialization. | 813 // RTP/RTCP initialization. |
822 | 814 |
823 // We add the highest spatial layer first to ensure it'll be prioritized | 815 // 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, | 816 // 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. | 817 // and that it's more important to protect than the lower layers. |
826 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 818 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
827 packet_router_->AddRtpModule(rtp_rtcp); | 819 transport->packet_router()->AddRtpModule(rtp_rtcp); |
828 | 820 |
829 for (size_t i = 0; i < config_->rtp.extensions.size(); ++i) { | 821 for (size_t i = 0; i < config_->rtp.extensions.size(); ++i) { |
830 const std::string& extension = config_->rtp.extensions[i].uri; | 822 const std::string& extension = config_->rtp.extensions[i].uri; |
831 int id = config_->rtp.extensions[i].id; | 823 int id = config_->rtp.extensions[i].id; |
832 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 824 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
833 RTC_DCHECK_GE(id, 1); | 825 RTC_DCHECK_GE(id, 1); |
834 RTC_DCHECK_LE(id, 14); | 826 RTC_DCHECK_LE(id, 14); |
835 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); | 827 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); |
836 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 828 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
837 RTC_CHECK_EQ(0, rtp_rtcp->RegisterSendRtpHeaderExtension( | 829 RTC_CHECK_EQ(0, rtp_rtcp->RegisterSendRtpHeaderExtension( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 VideoSendStreamImpl::~VideoSendStreamImpl() { | 888 VideoSendStreamImpl::~VideoSendStreamImpl() { |
897 RTC_DCHECK_RUN_ON(worker_queue_); | 889 RTC_DCHECK_RUN_ON(worker_queue_); |
898 RTC_DCHECK(!payload_router_.IsActive()) | 890 RTC_DCHECK(!payload_router_.IsActive()) |
899 << "VideoSendStreamImpl::Stop not called"; | 891 << "VideoSendStreamImpl::Stop not called"; |
900 LOG(LS_INFO) << "~VideoSendStreamInternal: " << config_->ToString(); | 892 LOG(LS_INFO) << "~VideoSendStreamInternal: " << config_->ToString(); |
901 | 893 |
902 rtp_rtcp_modules_[0]->SetREMBStatus(false); | 894 rtp_rtcp_modules_[0]->SetREMBStatus(false); |
903 remb_->RemoveRembSender(rtp_rtcp_modules_[0]); | 895 remb_->RemoveRembSender(rtp_rtcp_modules_[0]); |
904 | 896 |
905 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 897 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
906 packet_router_->RemoveRtpModule(rtp_rtcp); | 898 transport_->packet_router()->RemoveRtpModule(rtp_rtcp); |
907 delete rtp_rtcp; | 899 delete rtp_rtcp; |
908 } | 900 } |
909 } | 901 } |
910 | 902 |
911 bool VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { | 903 bool VideoSendStreamImpl::DeliverRtcp(const uint8_t* packet, size_t length) { |
912 // Runs on a network thread. | 904 // Runs on a network thread. |
913 RTC_DCHECK(!worker_queue_->IsCurrent()); | 905 RTC_DCHECK(!worker_queue_->IsCurrent()); |
914 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 906 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
915 rtp_rtcp->IncomingRtcpPacket(packet, length); | 907 rtp_rtcp->IncomingRtcpPacket(packet, length); |
916 return true; | 908 return true; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 | 1319 |
1328 void VideoSendStreamImpl::SetTransportOverhead( | 1320 void VideoSendStreamImpl::SetTransportOverhead( |
1329 size_t transport_overhead_bytes_per_packet) { | 1321 size_t transport_overhead_bytes_per_packet) { |
1330 if (transport_overhead_bytes_per_packet >= static_cast<int>(kPathMTU)) { | 1322 if (transport_overhead_bytes_per_packet >= static_cast<int>(kPathMTU)) { |
1331 LOG(LS_ERROR) << "Transport overhead exceeds size of ethernet frame"; | 1323 LOG(LS_ERROR) << "Transport overhead exceeds size of ethernet frame"; |
1332 return; | 1324 return; |
1333 } | 1325 } |
1334 | 1326 |
1335 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; | 1327 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; |
1336 | 1328 |
1337 send_side_cc_->SetTransportOverhead(transport_overhead_bytes_per_packet_); | 1329 transport_->send_side_cc()->SetTransportOverhead( |
| 1330 transport_overhead_bytes_per_packet_); |
1338 | 1331 |
1339 size_t rtp_packet_size = | 1332 size_t rtp_packet_size = |
1340 std::min(config_->rtp.max_packet_size, | 1333 std::min(config_->rtp.max_packet_size, |
1341 kPathMTU - transport_overhead_bytes_per_packet_); | 1334 kPathMTU - transport_overhead_bytes_per_packet_); |
1342 | 1335 |
1343 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 1336 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
1344 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); | 1337 rtp_rtcp->SetMaxRtpPacketSize(rtp_packet_size); |
1345 } | 1338 } |
1346 } | 1339 } |
1347 | 1340 |
1348 } // namespace internal | 1341 } // namespace internal |
1349 } // namespace webrtc | 1342 } // namespace webrtc |
OLD | NEW |