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

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: Added from_width && from_height in resolution change req. 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_.resolution_request.change =
37 VideoSinkWants::ResolutionRequest::NONE;
36 for (auto& sink_pair : sinks_) { 38 for (auto& sink_pair : sinks_) {
37 current_wants_.rotation_applied |= sink_pair.wants.rotation_applied; 39 current_wants_.rotation_applied |= sink_pair.wants.rotation_applied;
40
41 if (sink_pair.wants.resolution_request.change ==
42 VideoSinkWants::ResolutionRequest::UP &&
43 current_wants_.resolution_request.change !=
44 VideoSinkWants::ResolutionRequest::DOWN &&
45 sink_pair.wants.resolution_request.from_width >= width_ &&
46 sink_pair.wants.resolution_request.from_height >= height_) {
47 current_wants_.resolution_request = sink_pair.wants.resolution_request;
48 }
49
50 if (sink_pair.wants.resolution_request.change ==
51 VideoSinkWants::ResolutionRequest::DOWN &&
52 sink_pair.wants.resolution_request.from_width <= width_ &&
53 sink_pair.wants.resolution_request.from_height <= height_) {
54 current_wants_.resolution_request = sink_pair.wants.resolution_request;
55 }
38 } 56 }
39 } 57 }
40 58
41 void VideoBroadcaster::RemoveSink( 59 void VideoBroadcaster::RemoveSink(
42 VideoSinkInterface<cricket::VideoFrame>* sink) { 60 VideoSinkInterface<cricket::VideoFrame>* sink) {
43 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 61 RTC_DCHECK(thread_checker_.CalledOnValidThread());
44 RTC_DCHECK(sink != nullptr); 62 RTC_DCHECK(sink != nullptr);
45 RTC_DCHECK(FindSinkPair(sink)); 63 RTC_DCHECK(FindSinkPair(sink));
46 64
47 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(), 65 sinks_.erase(std::remove_if(sinks_.begin(), sinks_.end(),
48 [sink](const SinkPair& sink_pair) { 66 [sink](const SinkPair& sink_pair) {
49 return sink_pair.sink == sink; 67 return sink_pair.sink == sink;
50 }), 68 }),
51 sinks_.end()); 69 sinks_.end());
52 } 70 }
53 71
54 bool VideoBroadcaster::frame_wanted() const { 72 bool VideoBroadcaster::frame_wanted() const {
55 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 73 RTC_DCHECK(thread_checker_.CalledOnValidThread());
56 return !sinks_.empty(); 74 return !sinks_.empty();
57 } 75 }
58 76
59 VideoSinkWants VideoBroadcaster::wants() const { 77 VideoSinkWants VideoBroadcaster::wants() const {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 78 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 return current_wants_; 79 return current_wants_;
62 } 80 }
63 81
64 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) { 82 void VideoBroadcaster::OnFrame(const cricket::VideoFrame& frame) {
65 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 83 RTC_DCHECK(thread_checker_.CalledOnValidThread());
84 width_ = frame.GetWidth();
85 height_ = frame.GetHeight();
66 for (auto& sink_pair : sinks_) { 86 for (auto& sink_pair : sinks_) {
67 sink_pair.sink->OnFrame(frame); 87 sink_pair.sink->OnFrame(frame);
68 } 88 }
69 } 89 }
70 90
71 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair( 91 VideoBroadcaster::SinkPair* VideoBroadcaster::FindSinkPair(
72 const VideoSinkInterface<cricket::VideoFrame>* sink) { 92 const VideoSinkInterface<cricket::VideoFrame>* sink) {
73 auto sink_pair_it = std::find_if( 93 auto sink_pair_it = std::find_if(
74 sinks_.begin(), sinks_.end(), 94 sinks_.begin(), sinks_.end(),
75 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; }); 95 [sink](const SinkPair& sink_pair) { return sink_pair.sink == sink; });
76 if (sink_pair_it != sinks_.end()) { 96 if (sink_pair_it != sinks_.end()) {
77 return &*sink_pair_it; 97 return &*sink_pair_it;
78 } 98 }
79 return nullptr; 99 return nullptr;
80 } 100 }
81 101
82 } // namespace rtc 102 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698