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

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

Issue 1695263002: Move direct use of VideoCapturer::VideoAdapter to VideoSinkWants. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed test for screencast from videocapturer 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
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
11 #include "webrtc/media/base/videobroadcaster.h" 11 #include "webrtc/media/base/videobroadcaster.h"
12 12
13 #include <limits>
14
13 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
14 16
15 namespace rtc { 17 namespace rtc {
16 18
17 VideoBroadcaster::VideoBroadcaster() { 19 VideoBroadcaster::VideoBroadcaster() {
18 thread_checker_.DetachFromThread(); 20 thread_checker_.DetachFromThread();
19 } 21 }
20 22
21 void VideoBroadcaster::AddOrUpdateSink( 23 void VideoBroadcaster::AddOrUpdateSink(
22 VideoSinkInterface<cricket::VideoFrame>* sink, 24 VideoSinkInterface<cricket::VideoFrame>* sink,
23 const VideoSinkWants& wants) { 25 const VideoSinkWants& wants) {
24 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 26 RTC_DCHECK(thread_checker_.CalledOnValidThread());
25 RTC_DCHECK(sink != nullptr); 27 RTC_DCHECK(sink != nullptr);
26 28
27 SinkPair* sink_pair = FindSinkPair(sink); 29 SinkPair* sink_pair = FindSinkPair(sink);
28 if (!sink_pair) { 30 if (!sink_pair) {
29 sinks_.push_back(SinkPair(sink, wants)); 31 sinks_.push_back(SinkPair(sink, wants));
30 } else { 32 } else {
31 sink_pair->wants = wants; 33 sink_pair->wants = wants;
32 } 34 }
33 35 UpdateWants();
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 } 36 }
40 37
41 void VideoBroadcaster::RemoveSink( 38 void VideoBroadcaster::RemoveSink(
42 VideoSinkInterface<cricket::VideoFrame>* sink) { 39 VideoSinkInterface<cricket::VideoFrame>* sink) {
43 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 40 RTC_DCHECK(thread_checker_.CalledOnValidThread());
44 RTC_DCHECK(sink != nullptr); 41 RTC_DCHECK(sink != nullptr);
45 RTC_DCHECK(FindSinkPair(sink)); 42 RTC_DCHECK(FindSinkPair(sink));
46 43
47 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(), 44 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(),
48 [sink](const SinkPair& sink_pair) { 45 [sink](const SinkPair& sink_pair) {
49 return sink_pair.sink == sink; 46 return sink_pair.sink == sink;
50 }), 47 }),
51 sinks_.end()); 48 sinks_.end());
49 UpdateWants();
52 } 50 }
53 51
54 bool VideoBroadcaster::frame_wanted() const { 52 bool VideoBroadcaster::frame_wanted() const {
55 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 53 RTC_DCHECK(thread_checker_.CalledOnValidThread());
56 return !sinks_.empty(); 54 return !sinks_.empty();
57 } 55 }
58 56
59 VideoSinkWants VideoBroadcaster::wants() const { 57 VideoSinkWants VideoBroadcaster::wants() const {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 58 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 return current_wants_; 59 return current_wants_;
(...skipping 10 matching lines...) Expand all
72 const VideoSinkInterface<cricket::VideoFrame>* sink) { 70 const VideoSinkInterface<cricket::VideoFrame>* sink) {
73 auto sink_pair_it = std::find_if( 71 auto sink_pair_it = std::find_if(
74 sinks_.begin(), sinks_.end(), 72 sinks_.begin(), sinks_.end(),
75 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; }); 73 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; });
76 if (sink_pair_it != sinks_.end()) { 74 if (sink_pair_it != sinks_.end()) {
77 return &*sink_pair_it; 75 return &*sink_pair_it;
78 } 76 }
79 return nullptr; 77 return nullptr;
80 } 78 }
81 79
80 void VideoBroadcaster::UpdateWants() {
81 RTC_DCHECK(thread_checker_.CalledOnValidThread());
82
83 VideoSinkWants wants;
84 wants.rotation_applied = false;
85 for (auto& sink : sinks_) {
86 // wants.rotation_applied == ANY(sink.wants.rotation_applied)
87 if (sink.wants.rotation_applied) {
88 wants.rotation_applied = true;
89 }
90 // wants.max_pixel_count == MIN(sink.wants.max_pixel_count)
91 if (sink.wants.max_pixel_count &&
92 (!wants.max_pixel_count ||
93 (*sink.wants.max_pixel_count < *wants.max_pixel_count))) {
94 wants.max_pixel_count = sink.wants.max_pixel_count;
95 }
96 // wants.max_pixel_count_step_up == MIN(sink.wants.max_pixel_count_step_up)
97 if (sink.wants.max_pixel_count_step_up &&
98 (!wants.max_pixel_count_step_up ||
99 (*sink.wants.max_pixel_count_step_up <
100 *wants.max_pixel_count_step_up))) {
101 wants.max_pixel_count_step_up = sink.wants.max_pixel_count_step_up;
102 }
103 }
104
105 if (wants.max_pixel_count && wants.max_pixel_count_step_up &&
106 *wants.max_pixel_count_step_up >= *wants.max_pixel_count) {
107 wants.max_pixel_count_step_up = Optional<int>();
108 }
109 current_wants_ = wants;
110 }
111
82 } // namespace rtc 112 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698