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

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: Added dummy capturerenderadapter.cc 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
« no previous file with comments | « webrtc/media/base/videobroadcaster.h ('k') | webrtc/media/base/videocapturer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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::AddOrUpdateSink(
22 VideoSinkInterface<cricket::VideoFrame>* sink,
23 const VideoSinkWants& wants) {
24 RTC_DCHECK(thread_checker_.CalledOnValidThread());
25 RTC_DCHECK(sink != nullptr);
26
27 SinkPair* sink_pair = FindSinkPair(sink);
28 if (!sink_pair) {
29 sinks_.push_back(SinkPair(sink, wants));
30 } else {
31 sink_pair->wants = wants;
32 }
33
34 // Rotation must be applied by the source if one sink wants it.
35 current_wants_.rotation_applied = false;
36 for (auto& sink_pair : sinks_) {
37 current_wants_.rotation_applied |= sink_pair.wants.rotation_applied;
38 }
39 }
40
41 void VideoBroadcaster::RemoveSink(
42 VideoSinkInterface<cricket::VideoFrame>* sink) {
43 RTC_DCHECK(thread_checker_.CalledOnValidThread());
44 RTC_DCHECK(sink != nullptr);
45 RTC_DCHECK(FindSinkPair(sink));
46
47 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(),
48 [sink](const SinkPair& sink_pair) {
49 return sink_pair.sink == sink;
50 }),
51 sinks_.end());
52 }
53
54 bool VideoBroadcaster::frame_wanted() const {
55 RTC_DCHECK(thread_checker_.CalledOnValidThread());
56 return !sinks_.empty();
57 }
58
59 VideoSinkWants VideoBroadcaster::wants() const {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 return current_wants_;
62 }
63
64 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
65 RTC_DCHECK(thread_checker_.CalledOnValidThread());
66 for (auto& sink_pair : sinks_) {
67 sink_pair.sink->OnFrame(frame);
68 }
69 }
70
71 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair(
72 const VideoSinkInterface<cricket::VideoFrame>* sink) {
73 auto sink_pair_it = std::find_if(
74 sinks_.begin(), sinks_.end(),
75 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; });
76 if (sink_pair_it != sinks_.end()) {
77 return &*sink_pair_it;
78 }
79 return nullptr;
80 }
81
82 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/media/base/videobroadcaster.h ('k') | webrtc/media/base/videocapturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698