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

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

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: Fix build on Win 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
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 thread_sync_event_(false /* manual_reset */, false), 509 thread_sync_event_(false /* manual_reset */, false),
510 stats_proxy_(Clock::GetRealTimeClock(), 510 stats_proxy_(Clock::GetRealTimeClock(),
511 config, 511 config,
512 encoder_config.content_type), 512 encoder_config.content_type),
513 config_(std::move(config)) { 513 config_(std::move(config)) {
514 vie_encoder_.reset( 514 vie_encoder_.reset(
515 new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings, 515 new ViEEncoder(num_cpu_cores, &stats_proxy_, config_.encoder_settings,
516 config_.pre_encode_callback, config_.overuse_callback, 516 config_.pre_encode_callback, config_.overuse_callback,
517 config_.post_encode_callback)); 517 config_.post_encode_callback));
518 518
519 // TODO(perkj): Remove vector<VideoStreams> from VideoEncoderConfig and
520 // replace with max_bitrate. The VideoStream should be created by ViEEncoder
521 // when the video resolution is known.
522 int initial_max_encoder_bitrate = 0;
523 for (const auto& stream : encoder_config.streams)
524 initial_max_encoder_bitrate += stream.max_bitrate_bps;
525
526 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask( 519 worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(new ConstructionTask(
527 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(), 520 &send_stream_, &thread_sync_event_, &stats_proxy_, vie_encoder_.get(),
528 module_process_thread, call_stats, congestion_controller, 521 module_process_thread, call_stats, congestion_controller,
529 bitrate_allocator, send_delay_stats, remb, event_log, &config_, 522 bitrate_allocator, send_delay_stats, remb, event_log, &config_,
530 initial_max_encoder_bitrate, suspended_ssrcs))); 523 encoder_config.max_bitrate_bps, suspended_ssrcs)));
531 524
532 // 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.
533 // |module_process_thread| must be registered and deregistered on the thread 526 // |module_process_thread| must be registered and deregistered on the thread
534 // it was created on. 527 // it was created on.
535 thread_sync_event_.Wait(rtc::Event::kForever); 528 thread_sync_event_.Wait(rtc::Event::kForever);
536 send_stream_->RegisterProcessThread(module_process_thread); 529 send_stream_->RegisterProcessThread(module_process_thread);
537 530
538 vie_encoder_->RegisterProcessThread(module_process_thread); 531 vie_encoder_->RegisterProcessThread(module_process_thread);
539 532
540 ReconfigureVideoEncoder(std::move(encoder_config)); 533 ReconfigureVideoEncoder(std::move(encoder_config));
(...skipping 26 matching lines...) Expand all
567 worker_queue_->PostTask([send_stream] { send_stream->Stop(); }); 560 worker_queue_->PostTask([send_stream] { send_stream->Stop(); });
568 } 561 }
569 562
570 void VideoSendStream::SetSource( 563 void VideoSendStream::SetSource(
571 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) { 564 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) {
572 RTC_DCHECK_RUN_ON(&thread_checker_); 565 RTC_DCHECK_RUN_ON(&thread_checker_);
573 vie_encoder_->SetSource(source); 566 vie_encoder_->SetSource(source);
574 } 567 }
575 568
576 void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) { 569 void VideoSendStream::ReconfigureVideoEncoder(VideoEncoderConfig config) {
577 // ReconfigureVideoEncoder will be called on the thread that deliverers video 570 // TODO(perkj): Some test cases in VideoSendStreamTest call
578 // frames. We must change the encoder settings immediately so that 571 // ReconfigureVideoEncoder from the network thread.
579 // the codec settings matches the next frame. 572 // RTC_DCHECK_RUN_ON(&thread_checker_);
580 // TODO(perkj): Move logic for reconfiguration the encoder due to frame size
581 // change from WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame to
582 // be internally handled by ViEEncoder.
583 vie_encoder_->ConfigureEncoder(std::move(config), 573 vie_encoder_->ConfigureEncoder(std::move(config),
584 config_.rtp.max_packet_size); 574 config_.rtp.max_packet_size);
585 } 575 }
586 576
587 VideoSendStream::Stats VideoSendStream::GetStats() { 577 VideoSendStream::Stats VideoSendStream::GetStats() {
588 // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from 578 // TODO(perkj, solenberg): Some test cases in EndToEndTest call GetStats from
589 // a network thread. See comment in Call::GetStats(). 579 // a network thread. See comment in Call::GetStats().
590 // RTC_DCHECK_RUN_ON(&thread_checker_); 580 // RTC_DCHECK_RUN_ON(&thread_checker_);
591 return stats_proxy_.GetStats(); 581 return stats_proxy_.GetStats();
592 } 582 }
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 &module_nack_rate); 1075 &module_nack_rate);
1086 *sent_video_rate_bps += module_video_rate; 1076 *sent_video_rate_bps += module_video_rate;
1087 *sent_nack_rate_bps += module_nack_rate; 1077 *sent_nack_rate_bps += module_nack_rate;
1088 *sent_fec_rate_bps += module_fec_rate; 1078 *sent_fec_rate_bps += module_fec_rate;
1089 } 1079 }
1090 return 0; 1080 return 0;
1091 } 1081 }
1092 1082
1093 } // namespace internal 1083 } // namespace internal
1094 } // namespace webrtc 1084 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698