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

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

Issue 1441673002: Move BitrateAllocator from BitrateController logic to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 1 month 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
11 #include "webrtc/video/video_send_stream.h" 11 #include "webrtc/video/video_send_stream.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/trace_event.h" 20 #include "webrtc/base/trace_event.h"
21 #include "webrtc/call/congestion_controller.h" 21 #include "webrtc/call/congestion_controller.h"
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
23 #include "webrtc/modules/pacing/include/packet_router.h" 24 #include "webrtc/modules/pacing/include/packet_router.h"
24 #include "webrtc/video/video_capture_input.h" 25 #include "webrtc/video/video_capture_input.h"
25 #include "webrtc/video_engine/call_stats.h" 26 #include "webrtc/video_engine/call_stats.h"
26 #include "webrtc/video_engine/encoder_state_feedback.h" 27 #include "webrtc/video_engine/encoder_state_feedback.h"
27 #include "webrtc/video_engine/payload_router.h" 28 #include "webrtc/video_engine/payload_router.h"
28 #include "webrtc/video_engine/vie_channel.h" 29 #include "webrtc/video_engine/vie_channel.h"
29 #include "webrtc/video_engine/vie_encoder.h" 30 #include "webrtc/video_engine/vie_encoder.h"
30 #include "webrtc/video_send_stream.h" 31 #include "webrtc/video_send_stream.h"
31 32
32 namespace webrtc { 33 namespace webrtc {
33 34
34 class BitrateAllocator;
35 class PacedSender; 35 class PacedSender;
36 class RtcpIntraFrameObserver; 36 class RtcpIntraFrameObserver;
37 class TransportFeedbackObserver; 37 class TransportFeedbackObserver;
38 38
39 std::string 39 std::string
40 VideoSendStream::Config::EncoderSettings::ToString() const { 40 VideoSendStream::Config::EncoderSettings::ToString() const {
41 std::stringstream ss; 41 std::stringstream ss;
42 ss << "{payload_name: " << payload_name; 42 ss << "{payload_name: " << payload_name;
43 ss << ", payload_type: " << payload_type; 43 ss << ", payload_type: " << payload_type;
44 ss << ", encoder: " << (encoder != nullptr ? "(VideoEncoder)" : "nullptr"); 44 ss << ", encoder: " << (encoder != nullptr ? "(VideoEncoder)" : "nullptr");
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ss << '}'; 106 ss << '}';
107 return ss.str(); 107 return ss.str();
108 } 108 }
109 109
110 namespace internal { 110 namespace internal {
111 VideoSendStream::VideoSendStream( 111 VideoSendStream::VideoSendStream(
112 int num_cpu_cores, 112 int num_cpu_cores,
113 ProcessThread* module_process_thread, 113 ProcessThread* module_process_thread,
114 CallStats* call_stats, 114 CallStats* call_stats,
115 CongestionController* congestion_controller, 115 CongestionController* congestion_controller,
116 BitrateAllocator* bitrate_allocator,
116 const VideoSendStream::Config& config, 117 const VideoSendStream::Config& config,
117 const VideoEncoderConfig& encoder_config, 118 const VideoEncoderConfig& encoder_config,
118 const std::map<uint32_t, RtpState>& suspended_ssrcs) 119 const std::map<uint32_t, RtpState>& suspended_ssrcs)
119 : stats_proxy_(Clock::GetRealTimeClock(), config), 120 : stats_proxy_(Clock::GetRealTimeClock(), config),
120 transport_adapter_(config.send_transport), 121 transport_adapter_(config.send_transport),
121 encoded_frame_proxy_(config.post_encode_callback), 122 encoded_frame_proxy_(config.post_encode_callback),
122 config_(config), 123 config_(config),
123 suspended_ssrcs_(suspended_ssrcs), 124 suspended_ssrcs_(suspended_ssrcs),
124 module_process_thread_(module_process_thread), 125 module_process_thread_(module_process_thread),
125 call_stats_(call_stats), 126 call_stats_(call_stats),
(...skipping 11 matching lines...) Expand all
137 congestion_controller_->GetTransportFeedbackObserver(); 138 congestion_controller_->GetTransportFeedbackObserver();
138 break; 139 break;
139 } 140 }
140 } 141 }
141 142
142 const std::vector<uint32_t>& ssrcs = config.rtp.ssrcs; 143 const std::vector<uint32_t>& ssrcs = config.rtp.ssrcs;
143 144
144 vie_encoder_.reset(new ViEEncoder( 145 vie_encoder_.reset(new ViEEncoder(
145 num_cpu_cores, module_process_thread_, &stats_proxy_, 146 num_cpu_cores, module_process_thread_, &stats_proxy_,
146 config.pre_encode_callback, congestion_controller_->pacer(), 147 config.pre_encode_callback, congestion_controller_->pacer(),
147 congestion_controller_->bitrate_allocator())); 148 bitrate_allocator));
148 RTC_CHECK(vie_encoder_->Init()); 149 RTC_CHECK(vie_encoder_->Init());
149 150
150 vie_channel_.reset(new ViEChannel( 151 vie_channel_.reset(new ViEChannel(
151 num_cpu_cores, config.send_transport, module_process_thread_, 152 num_cpu_cores, config.send_transport, module_process_thread_,
152 encoder_feedback_->GetRtcpIntraFrameObserver(), 153 encoder_feedback_->GetRtcpIntraFrameObserver(),
153 congestion_controller_->GetBitrateController()-> 154 congestion_controller_->GetBitrateController()->
154 CreateRtcpBandwidthObserver(), 155 CreateRtcpBandwidthObserver(),
155 transport_feedback_observer, 156 transport_feedback_observer,
156 congestion_controller_->GetRemoteBitrateEstimator(false), 157 congestion_controller_->GetRemoteBitrateEstimator(false),
157 call_stats_->rtcp_rtt_stats(), congestion_controller_->pacer(), 158 call_stats_->rtcp_rtt_stats(), congestion_controller_->pacer(),
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 uint32_t jitter; 526 uint32_t jitter;
526 int64_t rtt_ms; 527 int64_t rtt_ms;
527 if (vie_channel_->GetSendRtcpStatistics(&frac_lost, &cumulative_lost, 528 if (vie_channel_->GetSendRtcpStatistics(&frac_lost, &cumulative_lost,
528 &extended_max_sequence_number, 529 &extended_max_sequence_number,
529 &jitter, &rtt_ms) == 0) { 530 &jitter, &rtt_ms) == 0) {
530 return rtt_ms; 531 return rtt_ms;
531 } 532 }
532 return -1; 533 return -1;
533 } 534 }
534 535
536 int VideoSendStream::GetPaddingNeededBps() const {
537 return vie_encoder_->GetPaddingNeededBps();
538 }
539
535 bool VideoSendStream::SetSendCodec(VideoCodec video_codec) { 540 bool VideoSendStream::SetSendCodec(VideoCodec video_codec) {
536 static const int kEncoderMinBitrate = 30; 541 static const int kEncoderMinBitrate = 30;
537 if (video_codec.maxBitrate == 0) { 542 if (video_codec.maxBitrate == 0) {
538 // Unset max bitrate -> cap to one bit per pixel. 543 // Unset max bitrate -> cap to one bit per pixel.
539 video_codec.maxBitrate = 544 video_codec.maxBitrate =
540 (video_codec.width * video_codec.height * video_codec.maxFramerate) / 545 (video_codec.width * video_codec.height * video_codec.maxFramerate) /
541 1000; 546 1000;
542 } 547 }
543 548
544 if (video_codec.minBitrate < kEncoderMinBitrate) 549 if (video_codec.minBitrate < kEncoderMinBitrate)
(...skipping 21 matching lines...) Expand all
566 vie_encoder_->SetSsrcs(used_ssrcs); 571 vie_encoder_->SetSsrcs(used_ssrcs);
567 572
568 // Restart the media flow 573 // Restart the media flow
569 vie_encoder_->Restart(); 574 vie_encoder_->Restart();
570 575
571 return true; 576 return true;
572 } 577 }
573 578
574 } // namespace internal 579 } // namespace internal
575 } // namespace webrtc 580 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698