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

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

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: rebased Created 4 years, 2 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
« no previous file with comments | « webrtc/video/video_quality_test.cc ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 thread_sync_event_(false /* manual_reset */, false), 514 thread_sync_event_(false /* manual_reset */, false),
515 stats_proxy_(Clock::GetRealTimeClock(), 515 stats_proxy_(Clock::GetRealTimeClock(),
516 config, 516 config,
517 encoder_config.content_type), 517 encoder_config.content_type),
518 config_(std::move(config)) { 518 config_(std::move(config)) {
519 vie_encoder_.reset( 519 vie_encoder_.reset(
520 new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings, 520 new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings,
521 config_.pre_encode_callback, config_.overuse_callback, 521 config_.pre_encode_callback, config_.overuse_callback,
522 config_.post_encode_callback)); 522 config_.post_encode_callback));
523 523
524 // TODO(perkj): Remove vector<VideoStreams> from VideoEncoderConfig and
525 // replace with max_bitrate. The VideoStream should be created by ViEEncoder
526 // when the video resolution is known.
527 int initial_max_encoder_bitrate = 0;
528 for (const auto& stream : encoder_config.streams)
529 initial_max_encoder_bitrate += stream.max_bitrate_bps;
530
531 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( 524 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
532 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), 525 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(),
533 module_process_thread, call_stats, congestion_controller, 526 module_process_thread, call_stats, congestion_controller,
534 bitrate_allocator, send_delay_stats, remb, event_log, &config_, 527 bitrate_allocator, send_delay_stats, remb, event_log, &config_,
535 initial_max_encoder_bitrate, suspended_ssrcs))); 528 encoder_config.max_bitrate_bps, suspended_ssrcs)));
536 529
537 // Wait for ConstructionTask to complete so that |send_stream_| can be used. 530 // Wait for ConstructionTask to complete so that |send_stream_| can be used.
538 // |module_process_thread| must be registered and deregistered on the thread 531 // |module_process_thread| must be registered and deregistered on the thread
539 // it was created on. 532 // it was created on.
540 thread_sync_event_.Wait(rtc::Event::kForever); 533 thread_sync_event_.Wait(rtc::Event::kForever);
541 send_stream_->RegisterProcessThread(module_process_thread); 534 send_stream_->RegisterProcessThread(module_process_thread);
542 535
543 vie_encoder_->RegisterProcessThread(module_process_thread); 536 vie_encoder_->RegisterProcessThread(module_process_thread);
544 537
545 ReconfigureVideoEncoder(std::move(encoder_config)); 538 ReconfigureVideoEncoder(std::move(encoder_config));
(...skipping 26 matching lines...) Expand all
572 worker_queue_->PostTask([send_stream] { send_stream->Stop(); }); 565 worker_queue_->PostTask([send_stream] { send_stream->Stop(); });
573 } 566 }
574 567
575 void VideoSendStream::SetSource( 568 void VideoSendStream::SetSource(
576 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { 569 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
577 RTC_DCHECK_RUN_ON(&thread_checker_); 570 RTC_DCHECK_RUN_ON(&thread_checker_);
578 vie_encoder_->SetSource(source); 571 vie_encoder_->SetSource(source);
579 } 572 }
580 573
581 void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) { 574 void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
582 // ReconfigureVideoEncoder will be called on the thread that deliverers video 575 // TODO(perkj): Some test cases in VideoSendStreamTest call
583 // frames. We must change the encoder settings immediately so that 576 // ReconfigureVideoEncoder from the network thread.
584 // the codec settings matches the next frame. 577 // RTC_DCHECK_RUN_ON(&thread_checker_);
585 // TODO(perkj): Move logic for reconfiguration the encoder due to frame size
586 // change from WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame to
587 // be internally handled by ViEEncoder.
588 vie_encoder_->ConfigureEncoder(std::move(config), 578 vie_encoder_->ConfigureEncoder(std::move(config),
589 config_.rtp.max_packet_size); 579 config_.rtp.max_packet_size);
590 } 580 }
591 581
592 VideoSendStream::Stats VideoSendStream::GetStats() { 582 VideoSendStream::Stats VideoSendStream::GetStats() {
593 // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from 583 // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from
594 // a network thread. See comment in Call::GetStats(). 584 // a network thread. See comment in Call::GetStats().
595 // RTC_DCHECK_RUN_ON(&thread_checker_); 585 // RTC_DCHECK_RUN_ON(&thread_checker_);
596 return stats_proxy_.GetStats(); 586 return stats_proxy_.GetStats();
597 } 587 }
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 &module_nack_rate); 1098 &module_nack_rate);
1109 *sent_video_rate_bps += module_video_rate; 1099 *sent_video_rate_bps += module_video_rate;
1110 *sent_nack_rate_bps += module_nack_rate; 1100 *sent_nack_rate_bps += module_nack_rate;
1111 *sent_fec_rate_bps += module_fec_rate; 1101 *sent_fec_rate_bps += module_fec_rate;
1112 } 1102 }
1113 return 0; 1103 return 0;
1114 } 1104 }
1115 1105
1116 } // namespace internal 1106 } // namespace internal
1117 } // namespace webrtc 1107 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_quality_test.cc ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698