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

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

Issue 1779063003: Refactor VideoTracks to forward all sinks to its source (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed unused code. Created 4 years, 9 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) 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 VideoSinkWants VideoBroadcaster::wants() const { 59 VideoSinkWants VideoBroadcaster::wants() const {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 60 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 rtc::CritScope cs(&sinks_and_wants_lock_); 61 rtc::CritScope cs(&sinks_and_wants_lock_);
62 return current_wants_; 62 return current_wants_;
63 } 63 }
64 64
65 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) { 65 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
66 rtc::CritScope cs(&sinks_and_wants_lock_); 66 rtc::CritScope cs(&sinks_and_wants_lock_);
67 for (auto& sink_pair : sinks_) { 67 for (auto& sink_pair : sinks_) {
68 sink_pair.sink->OnFrame(frame); 68 if (sink_pair.wants.black_frames) {
69 sink_pair.sink->OnFrame(GetBlackFrame(frame));
70 } else {
71 sink_pair.sink->OnFrame(frame);
72 }
69 } 73 }
70 } 74 }
71 75
72 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair( 76 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair(
73 const VideoSinkInterface<cricket::VideoFrame>* sink) { 77 const VideoSinkInterface<cricket::VideoFrame>* sink) {
74 auto sink_pair_it = std::find_if( 78 auto sink_pair_it = std::find_if(
75 sinks_.begin(), sinks_.end(), 79 sinks_.begin(), sinks_.end(),
76 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; }); 80 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; });
77 if (sink_pair_it != sinks_.end()) { 81 if (sink_pair_it != sinks_.end()) {
78 return &*sink_pair_it; 82 return &*sink_pair_it;
(...skipping 26 matching lines...) Expand all
105 } 109 }
106 } 110 }
107 111
108 if (wants.max_pixel_count && wants.max_pixel_count_step_up && 112 if (wants.max_pixel_count && wants.max_pixel_count_step_up &&
109 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) { 113 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) {
110 wants.max_pixel_count_step_up = Optional<int>(); 114 wants.max_pixel_count_step_up = Optional<int>();
111 } 115 }
112 current_wants_ = wants; 116 current_wants_ = wants;
113 } 117 }
114 118
119 const cricket::VideoFrame& VideoBroadcaster::GetBlackFrame(
120 const cricket::VideoFrame& frame) {
121 if (black_frame_ && black_frame_->GetWidth() == frame.GetWidth() &&
122 black_frame_->GetHeight() == frame.GetHeight() &&
123 black_frame_->GetVideoRotation() == frame.GetVideoRotation()) {
124 black_frame_->SetTimeStamp(frame.GetTimeStamp());
125 return *black_frame_;
126 }
127 black_frame_.reset(new cricket::WebRtcVideoFrame(
128 new rtc::RefCountedObject<webrtc::I420Buffer>(
129 static_cast<int>(frame.GetWidth()),
130 static_cast<int>(frame.GetHeight())),
131 frame.GetTimeStamp(), frame.GetVideoRotation()));
132 black_frame_->SetToBlack();
133 return *black_frame_;
134 }
135
115 } // namespace rtc 136 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698