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 | 10 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 522 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
523 rtp_rtcp->IncomingRtcpPacket(packet, length); | 523 rtp_rtcp->IncomingRtcpPacket(packet, length); |
524 return true; | 524 return true; |
525 } | 525 } |
526 | 526 |
527 void VideoSendStream::Start() { | 527 void VideoSendStream::Start() { |
528 if (payload_router_.active()) | 528 if (payload_router_.active()) |
529 return; | 529 return; |
530 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Start"); | 530 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Start"); |
531 payload_router_.set_active(true); | 531 payload_router_.set_active(true); |
532 vie_encoder_.OnBitrateUpdated( | |
533 protection_bitrate_calculator_.GetEncoderTargetRate(), 0, 0); | |
pbos-webrtc
2016/06/16 13:16:28
What does it mean to put bogus values for fraction
perkj_webrtc
2016/06/16 18:42:18
There is no guarantee that the rtt and packet loss
| |
532 // Was not already started, trigger a keyframe. | 534 // Was not already started, trigger a keyframe. |
533 vie_encoder_.SendKeyFrame(); | 535 vie_encoder_.SendKeyFrame(); |
534 vie_encoder_.Start(); | |
535 } | 536 } |
536 | 537 |
537 void VideoSendStream::Stop() { | 538 void VideoSendStream::Stop() { |
538 if (!payload_router_.active()) | 539 if (!payload_router_.active()) |
539 return; | 540 return; |
540 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); | 541 TRACE_EVENT_INSTANT0("webrtc", "VideoSendStream::Stop"); |
541 vie_encoder_.Pause(); | 542 vie_encoder_.OnBitrateUpdated(0, 0, 0); |
542 payload_router_.set_active(false); | 543 payload_router_.set_active(false); |
543 } | 544 } |
544 | 545 |
545 VideoCaptureInput* VideoSendStream::Input() { | 546 VideoCaptureInput* VideoSendStream::Input() { |
546 return &input_; | 547 return &input_; |
547 } | 548 } |
548 | 549 |
549 bool VideoSendStream::EncoderThreadFunction(void* obj) { | 550 bool VideoSendStream::EncoderThreadFunction(void* obj) { |
550 static_cast<VideoSendStream*>(obj)->EncoderProcess(); | 551 static_cast<VideoSendStream*>(obj)->EncoderProcess(); |
551 // We're done, return false to abort. | 552 // We're done, return false to abort. |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 | 844 |
844 void VideoSendStream::OnBitrateUpdated(uint32_t bitrate_bps, | 845 void VideoSendStream::OnBitrateUpdated(uint32_t bitrate_bps, |
845 uint8_t fraction_loss, | 846 uint8_t fraction_loss, |
846 int64_t rtt) { | 847 int64_t rtt) { |
847 payload_router_.SetTargetSendBitrate(bitrate_bps); | 848 payload_router_.SetTargetSendBitrate(bitrate_bps); |
848 // Get the encoder target rate. It is the estimated network rate - | 849 // Get the encoder target rate. It is the estimated network rate - |
849 // protection overhead. | 850 // protection overhead. |
850 uint32_t encoder_target_rate = protection_bitrate_calculator_.SetTargetRates( | 851 uint32_t encoder_target_rate = protection_bitrate_calculator_.SetTargetRates( |
851 bitrate_bps, stats_proxy_.GetSendFrameRate(), fraction_loss, rtt); | 852 bitrate_bps, stats_proxy_.GetSendFrameRate(), fraction_loss, rtt); |
852 | 853 |
854 if (!payload_router_.active()) | |
855 return; // The send stream is currently not started. | |
pbos-webrtc
2016/06/16 13:16:28
Should the last fraction_loss and rtt be stored?
perkj_webrtc
2016/06/16 18:42:18
I dont' think they actually make sense. But we cou
| |
853 vie_encoder_.OnBitrateUpdated(encoder_target_rate, fraction_loss, rtt); | 856 vie_encoder_.OnBitrateUpdated(encoder_target_rate, fraction_loss, rtt); |
854 } | 857 } |
855 | 858 |
856 int VideoSendStream::ProtectionRequest(const FecProtectionParams* delta_params, | 859 int VideoSendStream::ProtectionRequest(const FecProtectionParams* delta_params, |
857 const FecProtectionParams* key_params, | 860 const FecProtectionParams* key_params, |
858 uint32_t* sent_video_rate_bps, | 861 uint32_t* sent_video_rate_bps, |
859 uint32_t* sent_nack_rate_bps, | 862 uint32_t* sent_nack_rate_bps, |
860 uint32_t* sent_fec_rate_bps) { | 863 uint32_t* sent_fec_rate_bps) { |
861 *sent_video_rate_bps = 0; | 864 *sent_video_rate_bps = 0; |
862 *sent_nack_rate_bps = 0; | 865 *sent_nack_rate_bps = 0; |
863 *sent_fec_rate_bps = 0; | 866 *sent_fec_rate_bps = 0; |
864 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 867 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
865 uint32_t not_used = 0; | 868 uint32_t not_used = 0; |
866 uint32_t module_video_rate = 0; | 869 uint32_t module_video_rate = 0; |
867 uint32_t module_fec_rate = 0; | 870 uint32_t module_fec_rate = 0; |
868 uint32_t module_nack_rate = 0; | 871 uint32_t module_nack_rate = 0; |
869 rtp_rtcp->SetFecParameters(delta_params, key_params); | 872 rtp_rtcp->SetFecParameters(delta_params, key_params); |
870 rtp_rtcp->BitrateSent(¬_used, &module_video_rate, &module_fec_rate, | 873 rtp_rtcp->BitrateSent(¬_used, &module_video_rate, &module_fec_rate, |
871 &module_nack_rate); | 874 &module_nack_rate); |
872 *sent_video_rate_bps += module_video_rate; | 875 *sent_video_rate_bps += module_video_rate; |
873 *sent_nack_rate_bps += module_nack_rate; | 876 *sent_nack_rate_bps += module_nack_rate; |
874 *sent_fec_rate_bps += module_fec_rate; | 877 *sent_fec_rate_bps += module_fec_rate; |
875 } | 878 } |
876 return 0; | 879 return 0; |
877 } | 880 } |
878 | 881 |
879 } // namespace internal | 882 } // namespace internal |
880 } // namespace webrtc | 883 } // namespace webrtc |
OLD | NEW |