OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/video/capture/win/capability_list_win.h" | 5 #include "media/video/capture/win/capability_list_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // requested resolution and the camera capability. | 64 // requested resolution and the camera capability. |
65 for (Capabilities::const_iterator it = capabilities_.begin(); | 65 for (Capabilities::const_iterator it = capabilities_.begin(); |
66 it != capabilities_.end(); ++it) { | 66 it != capabilities_.end(); ++it) { |
67 ResolutionDiff diff; | 67 ResolutionDiff diff; |
68 diff.capability = &(*it); | 68 diff.capability = &(*it); |
69 diff.diff_width = it->supported_format.frame_size.width() - requested_width; | 69 diff.diff_width = it->supported_format.frame_size.width() - requested_width; |
70 diff.diff_height = | 70 diff.diff_height = |
71 it->supported_format.frame_size.height() - requested_height; | 71 it->supported_format.frame_size.height() - requested_height; |
72 // The 1000 allows using integer arithmetic for f.i. 29.971 fps. | 72 // The 1000 allows using integer arithmetic for f.i. 29.971 fps. |
73 diff.diff_frame_rate = | 73 diff.diff_frame_rate = |
74 1000 * ((static_cast<float>(it->frame_rate_numerator) / | 74 1000 * (it->supported_format.frame_rate - requested_frame_rate); |
75 it->frame_rate_denominator) - | |
76 requested_frame_rate); | |
77 diff_list.push_back(diff); | 75 diff_list.push_back(diff); |
78 } | 76 } |
79 | 77 |
80 // Sort the best height candidates. | 78 // Sort the best height candidates. |
81 diff_list.sort(&CompareHeight); | 79 diff_list.sort(&CompareHeight); |
82 int best_diff = diff_list.front().diff_height; | 80 int best_diff = diff_list.front().diff_height; |
83 for (std::list<ResolutionDiff>::iterator it = diff_list.begin(); | 81 for (std::list<ResolutionDiff>::iterator it = diff_list.begin(); |
84 it != diff_list.end(); ++it) { | 82 it != diff_list.end(); ++it) { |
85 if (it->diff_height != best_diff) { | 83 if (it->diff_height != best_diff) { |
86 // Remove all candidates but the best. | 84 // Remove all candidates but the best. |
(...skipping 23 matching lines...) Expand all Loading... |
110 diff_list.erase(it, diff_list.end()); | 108 diff_list.erase(it, diff_list.end()); |
111 break; | 109 break; |
112 } | 110 } |
113 } | 111 } |
114 | 112 |
115 // Decide the best color format. | 113 // Decide the best color format. |
116 diff_list.sort(&CompareColor); | 114 diff_list.sort(&CompareColor); |
117 return *diff_list.front().capability; | 115 return *diff_list.front().capability; |
118 } | 116 } |
119 | 117 |
| 118 void CapabilityList::CapabilitiesToVideoCaptureFormats( |
| 119 VideoCaptureFormats* formats) const { |
| 120 for (Capabilities::const_iterator it = capabilities_.begin(); |
| 121 it != capabilities_.end(); ++it) { |
| 122 formats->push_back(it->supported_format); |
| 123 } |
| 124 } |
| 125 |
120 } // namespace media | 126 } // namespace media |
OLD | NEW |