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

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

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Created 4 years, 10 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
(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();
19 }
20
21 void VideoBroadCaster::AddSink(VideoSinkInterface<cricket::VideoFrame>* sink) {
22 RTC_DCHECK(thread_checker_.CalledOnValidThread());
23 RTC_DCHECK(sink != nullptr);
24 RTC_DCHECK(std::find(sinks_.begin(), sinks_.end(), sink) == sinks_.end());
25 sinks_.push_back(sink);
26 }
27
28 void VideoBroadCaster::AddOrUpdateSink(
29 VideoSinkInterface<cricket::VideoFrame>* sink,
30 const VideoSinkHints& hints) {
31 RTC_DCHECK(thread_checker_.CalledOnValidThread());
32 RTC_DCHECK(sink != nullptr);
33 if (std::find(sinks_.begin(), sinks_.end(), sink) == sinks_.end()) {
34 sinks_.push_back(sink);
35 }
36
37 // TODO(perkj): Handle different sinks with different hints.
38 RTC_DCHECK(current_hints_.first == nullptr || current_hints_.first == sink);
39
40 current_hints_.first = sink;
41 if (hints != current_hints_.second) {
42 current_hints_.second = hints;
43 }
44 }
45
46 void VideoBroadCaster::RemoveSink(
47 VideoSinkInterface<cricket::VideoFrame>* sink) {
48 RTC_DCHECK(thread_checker_.CalledOnValidThread());
49 RTC_DCHECK(sink != nullptr);
50 RTC_DCHECK(std::find(sinks_.begin(), sinks_.end(), sink) != sinks_.end());
51 sinks_.erase(std::remove(sinks_.begin(), sinks_.end(), sink), sinks_.end());
52 if (current_hints_.first == sink)
53 current_hints_.first = nullptr;
pthatcher1 2016/02/08 20:59:39 {}s please
perkj_webrtc 2016/02/09 13:23:57 Acknowledged.
54 }
55
56 bool VideoBroadCaster::FrameWillBeDelivered() const {
57 RTC_DCHECK(thread_checker_.CalledOnValidThread());
58 return !sinks_.empty();
59 }
60
61 VideoSinkHints VideoBroadCaster::DerivedHints() const {
62 RTC_DCHECK(thread_checker_.CalledOnValidThread());
63 return current_hints_.second;
64 }
65
66 void VideoBroadCaster::OnFrame(const cricket::VideoFrame& frame) {
67 RTC_DCHECK(thread_checker_.CalledOnValidThread());
68 for (auto* sink : sinks_) {
69 sink->OnFrame(frame);
70 }
71 }
72
73 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698