Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "webrtc/media/base/videobroadcaster.h" | |
| 12 | |
| 13 #include "webrtc/base/checks.h" | |
| 14 | |
| 15 namespace rtc { | |
| 16 | |
| 17 VideoBroadcaster::VideoBroadcaster() { | |
| 18 thread_checker_.DetachFromThread(); | |
|
nisse-webrtc
2016/02/09 14:10:54
Might need a comment. From the docs, this seems to
perkj_webrtc
2016/02/10 10:54:36
I think this is common enough to not do it. thread
| |
| 19 } | |
| 20 | |
| 21 void VideoBroadcaster::AddOrUpdateSink( | |
| 22 VideoSinkInterface<cricket::VideoFrame>* sink, | |
| 23 const VideoWants& hints) { | |
| 24 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 25 RTC_DCHECK(sink != nullptr); | |
| 26 auto lambda = [sink](const SinkPair& sink_pair) { | |
|
nisse-webrtc
2016/02/09 14:10:54
If the function is named, please use a descriptive
pthatcher1
2016/02/09 17:13:41
Or just put it inline:
auto sink_pair_it = std::f
perkj_webrtc
2016/02/10 10:54:36
use FindSinkPair
perkj_webrtc
2016/02/10 10:54:36
Done.
| |
| 27 return sink_pair.first == sink; | |
| 28 }; | |
| 29 | |
| 30 auto sink_pair_it = std::find_if(sinks_.begin(), sinks_.end(), lambda); | |
| 31 if (sink_pair_it == sinks_.end()) { | |
| 32 sinks_.push_back(SinkPair(sink, hints)); | |
| 33 } else { | |
| 34 sink_pair_it->second = hints; | |
| 35 } | |
| 36 | |
| 37 // Rotation must be applied by the source if one sink request it. | |
|
pthatcher1
2016/02/09 17:13:41
request it => wants it
perkj_webrtc
2016/02/10 10:54:36
Done.
| |
| 38 current_hints_.rotation_applied = false; | |
| 39 for (auto& sink_pair : sinks_) { | |
| 40 current_hints_.rotation_applied |= sink_pair.second.rotation_applied; | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 void VideoBroadcaster::RemoveSink( | |
| 45 VideoSinkInterface<cricket::VideoFrame>* sink) { | |
| 46 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 47 RTC_DCHECK(sink != nullptr); | |
| 48 auto lambda = [sink](const SinkPair& sink_pair) { | |
|
nisse-webrtc
2016/02/09 14:10:54
Same function here.
pthatcher1
2016/02/09 17:13:41
It might be worth making a private method like:
S
perkj_webrtc
2016/02/10 10:54:36
Good idea.
| |
| 49 return sink_pair.first == sink; | |
| 50 }; | |
| 51 RTC_DCHECK(std::find_if(sinks_.begin(), sinks_.end(), lambda) != | |
| 52 sinks_.end()); | |
| 53 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(), lambda), | |
| 54 sinks_.end()); | |
| 55 } | |
| 56 | |
| 57 bool VideoBroadcaster::frame_wanted() const { | |
| 58 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 59 return !sinks_.empty(); | |
| 60 } | |
| 61 | |
| 62 VideoWants VideoBroadcaster::sink_wants() const { | |
|
pthatcher1
2016/02/09 17:13:41
Why not just wants()? If not wants(), then at lea
perkj_webrtc
2016/02/10 10:54:36
Done.
| |
| 63 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 64 return current_hints_; | |
| 65 } | |
| 66 | |
| 67 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) { | |
| 68 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 69 for (auto& sink : sinks_) { | |
| 70 sink.first->OnFrame(frame); | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 } // namespace rtc | |
| OLD | NEW |