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

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: switched to int. Found bug in adapter... 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
(...skipping 15 matching lines...) Expand all
26 26
27 SinkPair* sink_pair = FindSinkPair(sink); 27 SinkPair* sink_pair = FindSinkPair(sink);
28 if (!sink_pair) { 28 if (!sink_pair) {
29 sinks_.push_back(SinkPair(sink, wants)); 29 sinks_.push_back(SinkPair(sink, wants));
30 } else { 30 } else {
31 sink_pair->wants = wants; 31 sink_pair->wants = wants;
32 } 32 }
33 33
34 // Rotation must be applied by the source if one sink wants it. 34 // Rotation must be applied by the source if one sink wants it.
35 current_wants_.rotation_applied = false; 35 current_wants_.rotation_applied = false;
36 current_wants_.max_number_of_pixels = std::numeric_limits<int>::max();
pthatcher1 2016/02/17 23:05:56 Would it make more sense to use an Optional<int>?
perkj_webrtc 2016/02/18 13:22:46 In the interface yes.. but maybe the implementatio
36 for (auto& sink_pair : sinks_) { 37 for (auto& sink_pair : sinks_) {
37 current_wants_.rotation_applied |= sink_pair.wants.rotation_applied; 38 current_wants_.rotation_applied |= sink_pair.wants.rotation_applied;
39
40 if (current_wants_.max_number_of_pixels >
41 sink_pair.wants.max_number_of_pixels) {
42 current_wants_.max_number_of_pixels =
43 sink_pair.wants.max_number_of_pixels;
44 }
pthatcher1 2016/02/17 23:05:56 We should document that a local preview sink/rende
perkj_webrtc 2016/02/18 13:22:46 This is not intended to change the current behavio
38 } 45 }
39 } 46 }
40 47
41 void VideoBroadcaster::RemoveSink( 48 void VideoBroadcaster::RemoveSink(
42 VideoSinkInterface<cricket::VideoFrame>* sink) { 49 VideoSinkInterface<cricket::VideoFrame>* sink) {
43 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 50 RTC_DCHECK(thread_checker_.CalledOnValidThread());
44 RTC_DCHECK(sink != nullptr); 51 RTC_DCHECK(sink != nullptr);
45 RTC_DCHECK(FindSinkPair(sink)); 52 RTC_DCHECK(FindSinkPair(sink));
46 53
47 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(), 54 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(),
48 [sink](const SinkPair& sink_pair) { 55 [sink](const SinkPair& sink_pair) {
49 return sink_pair.sink == sink; 56 return sink_pair.sink == sink;
50 }), 57 }),
51 sinks_.end()); 58 sinks_.end());
52 } 59 }
53 60
54 bool VideoBroadcaster::frame_wanted() const { 61 bool VideoBroadcaster::frame_wanted() const {
55 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 62 RTC_DCHECK(thread_checker_.CalledOnValidThread());
56 return !sinks_.empty(); 63 return !sinks_.empty();
57 } 64 }
58 65
59 VideoSinkWants VideoBroadcaster::wants() const { 66 VideoSinkWants VideoBroadcaster::wants() const {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 67 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 return current_wants_; 68 return current_wants_;
62 } 69 }
63 70
64 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) { 71 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
65 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 72 RTC_DCHECK(thread_checker_.CalledOnValidThread());
73 width_ = frame.GetWidth();
74 height_ = frame.GetHeight();
66 for (auto& sink_pair : sinks_) { 75 for (auto& sink_pair : sinks_) {
67 sink_pair.sink->OnFrame(frame); 76 sink_pair.sink->OnFrame(frame);
68 } 77 }
69 } 78 }
70 79
71 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair( 80 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair(
72 const VideoSinkInterface<cricket::VideoFrame>* sink) { 81 const VideoSinkInterface<cricket::VideoFrame>* sink) {
73 auto sink_pair_it = std::find_if( 82 auto sink_pair_it = std::find_if(
74 sinks_.begin(), sinks_.end(), 83 sinks_.begin(), sinks_.end(),
75 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; }); 84 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; });
76 if (sink_pair_it != sinks_.end()) { 85 if (sink_pair_it != sinks_.end()) {
77 return &*sink_pair_it; 86 return &*sink_pair_it;
78 } 87 }
79 return nullptr; 88 return nullptr;
80 } 89 }
81 90
82 } // namespace rtc 91 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698