| OLD | NEW |
| 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 Loading... |
| 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(cricket::WebRtcVideoFrame( | 57 sink_pair.sink->OnFrame(GetBlackFrame(frame)); |
| 58 GetBlackFrameBuffer(frame.width(), frame.height()), | |
| 59 frame.rotation(), frame.timestamp_us())); | |
| 60 } else { | 58 } else { |
| 61 sink_pair.sink->OnFrame(frame); | 59 sink_pair.sink->OnFrame(frame); |
| 62 } | 60 } |
| 63 } | 61 } |
| 64 } | 62 } |
| 65 | 63 |
| 66 void VideoBroadcaster::UpdateWants() { | 64 void VideoBroadcaster::UpdateWants() { |
| 67 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 65 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 68 | 66 |
| 69 VideoSinkWants wants; | 67 VideoSinkWants wants; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 } | 86 } |
| 89 } | 87 } |
| 90 | 88 |
| 91 if (wants.max_pixel_count && wants.max_pixel_count_step_up && | 89 if (wants.max_pixel_count && wants.max_pixel_count_step_up && |
| 92 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) { | 90 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) { |
| 93 wants.max_pixel_count_step_up = Optional<int>(); | 91 wants.max_pixel_count_step_up = Optional<int>(); |
| 94 } | 92 } |
| 95 current_wants_ = wants; | 93 current_wants_ = wants; |
| 96 } | 94 } |
| 97 | 95 |
| 98 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& | 96 const cricket::VideoFrame& VideoBroadcaster::GetBlackFrame( |
| 99 VideoBroadcaster::GetBlackFrameBuffer(int width, int height) { | 97 const cricket::VideoFrame& frame) { |
| 100 if (!black_frame_buffer_ || black_frame_buffer_->width() != width || | 98 if (black_frame_ && black_frame_->width() == frame.width() && |
| 101 black_frame_buffer_->height() != height) { | 99 black_frame_->height() == frame.height() && |
| 102 rtc::scoped_refptr<webrtc::I420Buffer> buffer = | 100 black_frame_->rotation() == frame.rotation()) { |
| 103 new RefCountedObject<webrtc::I420Buffer>(width, height); | 101 black_frame_->set_timestamp_us(frame.timestamp_us()); |
| 104 buffer->SetToBlack(); | 102 return *black_frame_; |
| 105 black_frame_buffer_ = buffer; | |
| 106 } | 103 } |
| 107 | 104 black_frame_.reset(new cricket::WebRtcVideoFrame( |
| 108 return black_frame_buffer_; | 105 new rtc::RefCountedObject<webrtc::I420Buffer>(frame.width(), |
| 106 frame.height()), |
| 107 frame.rotation(), frame.timestamp_us())); |
| 108 black_frame_->SetToBlack(); |
| 109 return *black_frame_; |
| 109 } | 110 } |
| 110 | 111 |
| 111 } // namespace rtc | 112 } // namespace rtc |
| OLD | NEW |