| 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" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 std::string VideoSendStream::Stats::ToString(int64_t time_ms) const { | 155 std::string VideoSendStream::Stats::ToString(int64_t time_ms) const { |
| 156 std::stringstream ss; | 156 std::stringstream ss; |
| 157 ss << "VideoSendStream stats: " << time_ms << ", {"; | 157 ss << "VideoSendStream stats: " << time_ms << ", {"; |
| 158 ss << "input_fps: " << input_frame_rate << ", "; | 158 ss << "input_fps: " << input_frame_rate << ", "; |
| 159 ss << "encode_fps: " << encode_frame_rate << ", "; | 159 ss << "encode_fps: " << encode_frame_rate << ", "; |
| 160 ss << "encode_ms: " << avg_encode_time_ms << ", "; | 160 ss << "encode_ms: " << avg_encode_time_ms << ", "; |
| 161 ss << "encode_usage_perc: " << encode_usage_percent << ", "; | 161 ss << "encode_usage_perc: " << encode_usage_percent << ", "; |
| 162 ss << "target_bps: " << target_media_bitrate_bps << ", "; | 162 ss << "target_bps: " << target_media_bitrate_bps << ", "; |
| 163 ss << "media_bps: " << media_bitrate_bps << ", "; | 163 ss << "media_bps: " << media_bitrate_bps << ", "; |
| 164 ss << "preffered_media_bitrate_bps: " << preffered_media_bitrate_bps << ", "; |
| 164 ss << "suspended: " << (suspended ? "true" : "false") << ", "; | 165 ss << "suspended: " << (suspended ? "true" : "false") << ", "; |
| 165 ss << "bw_adapted: " << (bw_limited_resolution ? "true" : "false"); | 166 ss << "bw_adapted: " << (bw_limited_resolution ? "true" : "false"); |
| 166 ss << '}'; | 167 ss << '}'; |
| 167 for (const auto& substream : substreams) { | 168 for (const auto& substream : substreams) { |
| 168 if (!substream.second.is_rtx) { | 169 if (!substream.second.is_rtx) { |
| 169 ss << " {ssrc: " << substream.first << ", "; | 170 ss << " {ssrc: " << substream.first << ", "; |
| 170 ss << substream.second.ToString(); | 171 ss << substream.second.ToString(); |
| 171 ss << '}'; | 172 ss << '}'; |
| 172 } | 173 } |
| 173 } | 174 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 thread_sync_event_(false /* manual_reset */, false), | 509 thread_sync_event_(false /* manual_reset */, false), |
| 509 stats_proxy_(Clock::GetRealTimeClock(), | 510 stats_proxy_(Clock::GetRealTimeClock(), |
| 510 config, | 511 config, |
| 511 encoder_config.content_type), | 512 encoder_config.content_type), |
| 512 config_(std::move(config)) { | 513 config_(std::move(config)) { |
| 513 vie_encoder_.reset( | 514 vie_encoder_.reset( |
| 514 new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings, | 515 new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings, |
| 515 config_.pre_encode_callback, config_.overuse_callback, | 516 config_.pre_encode_callback, config_.overuse_callback, |
| 516 config_.post_encode_callback)); | 517 config_.post_encode_callback)); |
| 517 | 518 |
| 518 // TODO(perkj): Remove vector<VideoStreams> from VideoEncoderConfig and | |
| 519 // replace with max_bitrate. The VideoStream should be created by ViEEncoder | |
| 520 // when the video resolution is known. | |
| 521 int initial_max_encoder_bitrate = 0; | |
| 522 for (const auto& stream : encoder_config.streams) | |
| 523 initial_max_encoder_bitrate += stream.max_bitrate_bps; | |
| 524 | |
| 525 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( | 519 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( |
| 526 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), | 520 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), |
| 527 module_process_thread, call_stats, congestion_controller, | 521 module_process_thread, call_stats, congestion_controller, |
| 528 bitrate_allocator, send_delay_stats, remb, event_log, &config_, | 522 bitrate_allocator, send_delay_stats, remb, event_log, &config_, |
| 529 initial_max_encoder_bitrate, suspended_ssrcs))); | 523 encoder_config.max_bitrate_bps, suspended_ssrcs))); |
| 530 | 524 |
| 531 // Wait for ConstructionTask to complete so that |send_stream_| can be used. | 525 // Wait for ConstructionTask to complete so that |send_stream_| can be used. |
| 532 // |module_process_thread| must be registered and deregistered on the thread | 526 // |module_process_thread| must be registered and deregistered on the thread |
| 533 // it was created on. | 527 // it was created on. |
| 534 thread_sync_event_.Wait(rtc::Event::kForever); | 528 thread_sync_event_.Wait(rtc::Event::kForever); |
| 535 send_stream_->RegisterProcessThread(module_process_thread); | 529 send_stream_->RegisterProcessThread(module_process_thread); |
| 536 | 530 |
| 537 vie_encoder_->RegisterProcessThread(module_process_thread); | 531 vie_encoder_->RegisterProcessThread(module_process_thread); |
| 538 | 532 |
| 539 ReconfigureVideoEncoder(std::move(encoder_config)); | 533 ReconfigureVideoEncoder(std::move(encoder_config)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 566 worker_queue_->PostTask([send_stream] { send_stream->Stop(); }); | 560 worker_queue_->PostTask([send_stream] { send_stream->Stop(); }); |
| 567 } | 561 } |
| 568 | 562 |
| 569 void VideoSendStream::SetSource( | 563 void VideoSendStream::SetSource( |
| 570 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { | 564 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { |
| 571 RTC_DCHECK_RUN_ON(&thread_checker_); | 565 RTC_DCHECK_RUN_ON(&thread_checker_); |
| 572 vie_encoder_->SetSource(source); | 566 vie_encoder_->SetSource(source); |
| 573 } | 567 } |
| 574 | 568 |
| 575 void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) { | 569 void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) { |
| 576 // ReconfigureVideoEncoder will be called on the thread that deliverers video | 570 // TODO(perkj): Some test cases in VideoSendStreamTest call |
| 577 // frames. We must change the encoder settings immediately so that | 571 // ReconfigureVideoEncoder from the network thread. |
| 578 // the codec settings matches the next frame. | 572 // RTC_DCHECK_RUN_ON(&thread_checker_); |
| 579 // TODO(perkj): Move logic for reconfiguration the encoder due to frame size | |
| 580 // change from WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame to | |
| 581 // be internally handled by ViEEncoder. | |
| 582 vie_encoder_->ConfigureEncoder(std::move(config), | 573 vie_encoder_->ConfigureEncoder(std::move(config), |
| 583 config_.rtp.max_packet_size); | 574 config_.rtp.max_packet_size); |
| 584 } | 575 } |
| 585 | 576 |
| 586 VideoSendStream::Stats VideoSendStream::GetStats() { | 577 VideoSendStream::Stats VideoSendStream::GetStats() { |
| 587 // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from | 578 // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from |
| 588 // a network thread. See comment in Call::GetStats(). | 579 // a network thread. See comment in Call::GetStats(). |
| 589 // RTC_DCHECK_RUN_ON(&thread_checker_); | 580 // RTC_DCHECK_RUN_ON(&thread_checker_); |
| 590 return stats_proxy_.GetStats(); | 581 return stats_proxy_.GetStats(); |
| 591 } | 582 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 &module_nack_rate); | 1075 &module_nack_rate); |
| 1085 *sent_video_rate_bps += module_video_rate; | 1076 *sent_video_rate_bps += module_video_rate; |
| 1086 *sent_nack_rate_bps += module_nack_rate; | 1077 *sent_nack_rate_bps += module_nack_rate; |
| 1087 *sent_fec_rate_bps += module_fec_rate; | 1078 *sent_fec_rate_bps += module_fec_rate; |
| 1088 } | 1079 } |
| 1089 return 0; | 1080 return 0; |
| 1090 } | 1081 } |
| 1091 | 1082 |
| 1092 } // namespace internal | 1083 } // namespace internal |
| 1093 } // namespace webrtc | 1084 } // namespace webrtc |
| OLD | NEW |