| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 VideoAdapter::~VideoAdapter() {} | 126 VideoAdapter::~VideoAdapter() {} |
| 127 | 127 |
| 128 void VideoAdapter::SetExpectedInputFrameInterval(int64_t interval) { | 128 void VideoAdapter::SetExpectedInputFrameInterval(int64_t interval) { |
| 129 // TODO(perkj): Consider measuring input frame rate instead. | 129 // TODO(perkj): Consider measuring input frame rate instead. |
| 130 // Frame rate typically varies depending on lighting. | 130 // Frame rate typically varies depending on lighting. |
| 131 rtc::CritScope cs(&critical_section_); | 131 rtc::CritScope cs(&critical_section_); |
| 132 input_interval_ = interval; | 132 input_interval_ = interval; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void VideoAdapter::AdaptFrameResolution(int in_width, | 135 bool VideoAdapter::AdaptFrameResolution(int in_width, |
| 136 int in_height, | 136 int in_height, |
| 137 int* cropped_width, | 137 int* cropped_width, |
| 138 int* cropped_height, | 138 int* cropped_height, |
| 139 int* out_width, | 139 int* out_width, |
| 140 int* out_height) { | 140 int* out_height) { |
| 141 rtc::CritScope cs(&critical_section_); | 141 rtc::CritScope cs(&critical_section_); |
| 142 ++frames_in_; | 142 ++frames_in_; |
| 143 | 143 |
| 144 // The max output pixel count is the minimum of the requests from | 144 // The max output pixel count is the minimum of the requests from |
| 145 // OnOutputFormatRequest and OnResolutionRequest. | 145 // OnOutputFormatRequest and OnResolutionRequest. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 << " / in " << frames_in_ | 178 << " / in " << frames_in_ |
| 179 << " Changes: " << adaption_changes_ | 179 << " Changes: " << adaption_changes_ |
| 180 << " Input: " << in_width | 180 << " Input: " << in_width |
| 181 << "x" << in_height | 181 << "x" << in_height |
| 182 << " i" << input_interval_ | 182 << " i" << input_interval_ |
| 183 << " Output: i" | 183 << " Output: i" |
| 184 << (requested_format_ ? requested_format_->interval : 0); | 184 << (requested_format_ ? requested_format_->interval : 0); |
| 185 } | 185 } |
| 186 | 186 |
| 187 // Drop frame. | 187 // Drop frame. |
| 188 *cropped_width = 0; | 188 return false; |
| 189 *cropped_height = 0; | |
| 190 *out_width = 0; | |
| 191 *out_height = 0; | |
| 192 return; | |
| 193 } | 189 } |
| 194 | 190 |
| 195 // Calculate how the input should be cropped. | 191 // Calculate how the input should be cropped. |
| 196 if (!requested_format_ || | 192 if (!requested_format_ || |
| 197 requested_format_->width == 0 || requested_format_->height == 0) { | 193 requested_format_->width == 0 || requested_format_->height == 0) { |
| 198 *cropped_width = in_width; | 194 *cropped_width = in_width; |
| 199 *cropped_height = in_height; | 195 *cropped_height = in_height; |
| 200 } else { | 196 } else { |
| 201 // Adjust |requested_format_| orientation to match input. | 197 // Adjust |requested_format_| orientation to match input. |
| 202 if ((in_width > in_height) != | 198 if ((in_width > in_height) != |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 << frames_out_ << " / in " << frames_in_ | 235 << frames_out_ << " / in " << frames_in_ |
| 240 << " Changes: " << adaption_changes_ << " Input: " << in_width | 236 << " Changes: " << adaption_changes_ << " Input: " << in_width |
| 241 << "x" << in_height << " i" << input_interval_ | 237 << "x" << in_height << " i" << input_interval_ |
| 242 << " Scale: " << scale.numerator << "/" << scale.denominator | 238 << " Scale: " << scale.numerator << "/" << scale.denominator |
| 243 << " Output: " << *out_width << "x" << *out_height << " i" | 239 << " Output: " << *out_width << "x" << *out_height << " i" |
| 244 << (requested_format_ ? requested_format_->interval : 0); | 240 << (requested_format_ ? requested_format_->interval : 0); |
| 245 } | 241 } |
| 246 | 242 |
| 247 previous_width_ = *out_width; | 243 previous_width_ = *out_width; |
| 248 previous_height_ = *out_height; | 244 previous_height_ = *out_height; |
| 245 |
| 246 return true; |
| 249 } | 247 } |
| 250 | 248 |
| 251 void VideoAdapter::OnOutputFormatRequest(const VideoFormat& format) { | 249 void VideoAdapter::OnOutputFormatRequest(const VideoFormat& format) { |
| 252 rtc::CritScope cs(&critical_section_); | 250 rtc::CritScope cs(&critical_section_); |
| 253 requested_format_ = rtc::Optional<VideoFormat>(format); | 251 requested_format_ = rtc::Optional<VideoFormat>(format); |
| 254 interval_next_frame_ = 0; | 252 interval_next_frame_ = 0; |
| 255 } | 253 } |
| 256 | 254 |
| 257 void VideoAdapter::OnResolutionRequest( | 255 void VideoAdapter::OnResolutionRequest( |
| 258 rtc::Optional<int> max_pixel_count, | 256 rtc::Optional<int> max_pixel_count, |
| 259 rtc::Optional<int> max_pixel_count_step_up) { | 257 rtc::Optional<int> max_pixel_count_step_up) { |
| 260 rtc::CritScope cs(&critical_section_); | 258 rtc::CritScope cs(&critical_section_); |
| 261 resolution_request_max_pixel_count_ = | 259 resolution_request_max_pixel_count_ = |
| 262 max_pixel_count.value_or(std::numeric_limits<int>::max()); | 260 max_pixel_count.value_or(std::numeric_limits<int>::max()); |
| 263 resolution_request_max_pixel_count_step_up_ = | 261 resolution_request_max_pixel_count_step_up_ = |
| 264 max_pixel_count_step_up.value_or(0); | 262 max_pixel_count_step_up.value_or(0); |
| 265 } | 263 } |
| 266 | 264 |
| 267 } // namespace cricket | 265 } // namespace cricket |
| OLD | NEW |