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

Side by Side Diff: webrtc/media/base/videobroadcaster.cc

Issue 2029273004: New static method I420Buffer::SetToBlack. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add missing SetToBlack call. Created 4 years, 6 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/media/base/videobroadcaster.h ('k') | webrtc/media/base/videobroadcaster_unittest.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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 VideoSinkWants VideoBroadcaster::wants() const { 47 VideoSinkWants VideoBroadcaster::wants() const {
48 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 48 RTC_DCHECK(thread_checker_.CalledOnValidThread());
49 rtc::CritScope cs(&sinks_and_wants_lock_); 49 rtc::CritScope cs(&sinks_and_wants_lock_);
50 return current_wants_; 50 return current_wants_;
51 } 51 }
52 52
53 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) { 53 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
54 rtc::CritScope cs(&sinks_and_wants_lock_); 54 rtc::CritScope cs(&sinks_and_wants_lock_);
55 for (auto& sink_pair : sink_pairs()) { 55 for (auto& sink_pair : sink_pairs()) {
56 if (sink_pair.wants.black_frames) { 56 if (sink_pair.wants.black_frames) {
57 sink_pair.sink->OnFrame(GetBlackFrame(frame)); 57 sink_pair.sink->OnFrame(cricket::WebRtcVideoFrame(
58 GetBlackFrameBuffer(frame.width(), frame.height()),
59 frame.rotation(), frame.timestamp_us()));
58 } else { 60 } else {
59 sink_pair.sink->OnFrame(frame); 61 sink_pair.sink->OnFrame(frame);
60 } 62 }
61 } 63 }
62 } 64 }
63 65
64 void VideoBroadcaster::UpdateWants() { 66 void VideoBroadcaster::UpdateWants() {
65 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 67 RTC_DCHECK(thread_checker_.CalledOnValidThread());
66 68
67 VideoSinkWants wants; 69 VideoSinkWants wants;
(...skipping 18 matching lines...) Expand all
86 } 88 }
87 } 89 }
88 90
89 if (wants.max_pixel_count && wants.max_pixel_count_step_up && 91 if (wants.max_pixel_count && wants.max_pixel_count_step_up &&
90 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) { 92 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) {
91 wants.max_pixel_count_step_up = Optional<int>(); 93 wants.max_pixel_count_step_up = Optional<int>();
92 } 94 }
93 current_wants_ = wants; 95 current_wants_ = wants;
94 } 96 }
95 97
96 const cricket::VideoFrame& VideoBroadcaster::GetBlackFrame( 98 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>&
97 const cricket::VideoFrame& frame) { 99 VideoBroadcaster::GetBlackFrameBuffer(int width, int height) {
98 if (black_frame_ && black_frame_->width() == frame.width() && 100 if (!black_frame_buffer_ || black_frame_buffer_->width() != width ||
99 black_frame_->height() == frame.height() && 101 black_frame_buffer_->height() != height) {
100 black_frame_->rotation() == frame.rotation()) { 102 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
101 black_frame_->set_timestamp_us(frame.timestamp_us()); 103 new RefCountedObject<webrtc::I420Buffer>(width, height);
102 return *black_frame_; 104 buffer->SetToBlack();
105 black_frame_buffer_ = buffer;
103 } 106 }
104 black_frame_.reset(new cricket::WebRtcVideoFrame( 107
105 new rtc::RefCountedObject<webrtc::I420Buffer>(frame.width(), 108 return black_frame_buffer_;
106 frame.height()),
107 frame.rotation(), frame.timestamp_us()));
108 black_frame_->SetToBlack();
109 return *black_frame_;
110 } 109 }
111 110
112 } // namespace rtc 111 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/media/base/videobroadcaster.h ('k') | webrtc/media/base/videobroadcaster_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698