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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/videobroadcaster.cc
diff --git a/webrtc/media/base/videobroadcaster.cc b/webrtc/media/base/videobroadcaster.cc
index 20e8c976c74d50248904a8a8955db0a5c31a7495..ef5c49b4a188a416641bd2af7ea04885f31842d5 100644
--- a/webrtc/media/base/videobroadcaster.cc
+++ b/webrtc/media/base/videobroadcaster.cc
@@ -54,7 +54,9 @@ void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
rtc::CritScope cs(&sinks_and_wants_lock_);
for (auto& sink_pair : sink_pairs()) {
if (sink_pair.wants.black_frames) {
- sink_pair.sink->OnFrame(GetBlackFrame(frame));
+ sink_pair.sink->OnFrame(cricket::WebRtcVideoFrame(
+ GetBlackFrameBuffer(frame.width(), frame.height()),
+ frame.rotation(), frame.timestamp_us()));
} else {
sink_pair.sink->OnFrame(frame);
}
@@ -93,20 +95,17 @@ void VideoBroadcaster::UpdateWants() {
current_wants_ = wants;
}
-const cricket::VideoFrame& VideoBroadcaster::GetBlackFrame(
- const cricket::VideoFrame& frame) {
- if (black_frame_ && black_frame_->width() == frame.width() &&
- black_frame_->height() == frame.height() &&
- black_frame_->rotation() == frame.rotation()) {
- black_frame_->set_timestamp_us(frame.timestamp_us());
- return *black_frame_;
+const rtc::scoped_refptr<webrtc::VideoFrameBuffer>&
+VideoBroadcaster::GetBlackFrameBuffer(int width, int height) {
+ if (!black_frame_buffer_ || black_frame_buffer_->width() != width ||
+ black_frame_buffer_->height() != height) {
+ rtc::scoped_refptr<webrtc::I420Buffer> buffer =
+ new RefCountedObject<webrtc::I420Buffer>(width, height);
+ buffer->SetToBlack();
+ black_frame_buffer_ = buffer;
}
- black_frame_.reset(new cricket::WebRtcVideoFrame(
- new rtc::RefCountedObject<webrtc::I420Buffer>(frame.width(),
- frame.height()),
- frame.rotation(), frame.timestamp_us()));
- black_frame_->SetToBlack();
- return *black_frame_;
+
+ return black_frame_buffer_;
}
} // namespace rtc
« 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