OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // default and still meets the contraints. | 243 // default and still meets the contraints. |
244 const cricket::VideoFormat& GetBestCaptureFormat( | 244 const cricket::VideoFormat& GetBestCaptureFormat( |
245 const std::vector<cricket::VideoFormat>& formats) { | 245 const std::vector<cricket::VideoFormat>& formats) { |
246 ASSERT(formats.size() > 0); | 246 ASSERT(formats.size() > 0); |
247 | 247 |
248 int default_area = kDefaultFormat.width * kDefaultFormat.height; | 248 int default_area = kDefaultFormat.width * kDefaultFormat.height; |
249 | 249 |
250 std::vector<cricket::VideoFormat>::const_iterator it = formats.begin(); | 250 std::vector<cricket::VideoFormat>::const_iterator it = formats.begin(); |
251 std::vector<cricket::VideoFormat>::const_iterator best_it = formats.begin(); | 251 std::vector<cricket::VideoFormat>::const_iterator best_it = formats.begin(); |
252 int best_diff_area = std::abs(default_area - it->width * it->height); | 252 int best_diff_area = std::abs(default_area - it->width * it->height); |
253 int64 best_diff_interval = kDefaultFormat.interval; | 253 int64_t best_diff_interval = kDefaultFormat.interval; |
254 for (; it != formats.end(); ++it) { | 254 for (; it != formats.end(); ++it) { |
255 int diff_area = std::abs(default_area - it->width * it->height); | 255 int diff_area = std::abs(default_area - it->width * it->height); |
256 int64 diff_interval = std::abs(kDefaultFormat.interval - it->interval); | 256 int64_t diff_interval = std::abs(kDefaultFormat.interval - it->interval); |
257 if (diff_area < best_diff_area || | 257 if (diff_area < best_diff_area || |
258 (diff_area == best_diff_area && diff_interval < best_diff_interval)) { | 258 (diff_area == best_diff_area && diff_interval < best_diff_interval)) { |
259 best_diff_area = diff_area; | 259 best_diff_area = diff_area; |
260 best_diff_interval = diff_interval; | 260 best_diff_interval = diff_interval; |
261 best_it = it; | 261 best_it = it; |
262 } | 262 } |
263 } | 263 } |
264 return *best_it; | 264 return *best_it; |
265 } | 265 } |
266 | 266 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 460 } |
461 | 461 |
462 void VideoSource::SetState(SourceState new_state) { | 462 void VideoSource::SetState(SourceState new_state) { |
463 if (VERIFY(state_ != new_state)) { | 463 if (VERIFY(state_ != new_state)) { |
464 state_ = new_state; | 464 state_ = new_state; |
465 FireOnChanged(); | 465 FireOnChanged(); |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 } // namespace webrtc | 469 } // namespace webrtc |
OLD | NEW |