OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/common/media/media_devices.mojom.h" | 12 #include "content/common/media/media_devices.mojom.h" |
13 #include "media/capture/video_capture_types.h" | 13 #include "media/capture/video_capture_types.h" |
| 14 #include "third_party/webrtc/base/optional.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 class WebString; | 17 class WebString; |
17 class WebMediaConstraints; | 18 class WebMediaConstraints; |
18 } | 19 } |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 // Calculates and returns videoKind value for |format|. | 23 // Calculates and returns videoKind value for |format|. |
23 // See https://w3c.github.io/mediacapture-depth. | 24 // See https://w3c.github.io/mediacapture-depth. |
24 blink::WebString CONTENT_EXPORT | 25 blink::WebString CONTENT_EXPORT |
25 GetVideoKindForFormat(const media::VideoCaptureFormat& format); | 26 GetVideoKindForFormat(const media::VideoCaptureFormat& format); |
26 | 27 |
27 struct CONTENT_EXPORT VideoDeviceCaptureCapabilities { | 28 struct CONTENT_EXPORT VideoDeviceCaptureCapabilities { |
28 VideoDeviceCaptureCapabilities(); | 29 VideoDeviceCaptureCapabilities(); |
29 VideoDeviceCaptureCapabilities(VideoDeviceCaptureCapabilities&& other); | 30 VideoDeviceCaptureCapabilities(VideoDeviceCaptureCapabilities&& other); |
30 ~VideoDeviceCaptureCapabilities(); | 31 ~VideoDeviceCaptureCapabilities(); |
31 VideoDeviceCaptureCapabilities& operator=( | 32 VideoDeviceCaptureCapabilities& operator=( |
32 VideoDeviceCaptureCapabilities&& other); | 33 VideoDeviceCaptureCapabilities&& other); |
33 | 34 |
34 // Each field is independent of each other. | 35 // Each field is independent of each other. |
35 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> device_capabilities; | 36 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> device_capabilities; |
36 std::vector<media::PowerLineFrequency> power_line_capabilities; | 37 std::vector<media::PowerLineFrequency> power_line_capabilities; |
| 38 std::vector<rtc::Optional<bool>> noise_reduction_capabilities; |
37 }; | 39 }; |
38 | 40 |
39 struct CONTENT_EXPORT VideoDeviceCaptureSourceSelectionResult { | 41 struct CONTENT_EXPORT VideoDeviceCaptureSourceSelectionResult { |
40 VideoDeviceCaptureSourceSelectionResult(); | 42 VideoDeviceCaptureSourceSelectionResult(); |
41 VideoDeviceCaptureSourceSelectionResult( | 43 VideoDeviceCaptureSourceSelectionResult( |
42 const VideoDeviceCaptureSourceSelectionResult& other); | 44 const VideoDeviceCaptureSourceSelectionResult& other); |
43 VideoDeviceCaptureSourceSelectionResult( | 45 VideoDeviceCaptureSourceSelectionResult( |
44 VideoDeviceCaptureSourceSelectionResult&& other); | 46 VideoDeviceCaptureSourceSelectionResult&& other); |
45 ~VideoDeviceCaptureSourceSelectionResult(); | 47 ~VideoDeviceCaptureSourceSelectionResult(); |
46 VideoDeviceCaptureSourceSelectionResult& operator=( | 48 VideoDeviceCaptureSourceSelectionResult& operator=( |
(...skipping 15 matching lines...) Expand all Loading... |
62 } | 64 } |
63 float FrameRate() const { return capture_params.requested_format.frame_rate; } | 65 float FrameRate() const { return capture_params.requested_format.frame_rate; } |
64 media::PowerLineFrequency PowerLineFrequency() const { | 66 media::PowerLineFrequency PowerLineFrequency() const { |
65 return capture_params.power_line_frequency; | 67 return capture_params.power_line_frequency; |
66 } | 68 } |
67 | 69 |
68 const char* failed_constraint_name; | 70 const char* failed_constraint_name; |
69 std::string device_id; | 71 std::string device_id; |
70 ::mojom::FacingMode facing_mode; | 72 ::mojom::FacingMode facing_mode; |
71 media::VideoCaptureParams capture_params; | 73 media::VideoCaptureParams capture_params; |
| 74 rtc::Optional<bool> noise_reduction; |
72 }; | 75 }; |
73 | 76 |
74 // This function performs source and source-settings selection based on | 77 // This function performs source and source-settings selection based on |
75 // the given |capabilities| and |constraints|. | 78 // the given |capabilities| and |constraints|. |
76 // Chromium performs constraint resolution in two steps. First, a source and its | 79 // Chromium performs constraint resolution in two steps. First, a source and its |
77 // settings are selected; then a track is created, connected to the source, and | 80 // settings are selected; then a track is created, connected to the source, and |
78 // finally the track settings are selected. This function implements an | 81 // finally the track settings are selected. This function implements an |
79 // algorithm for the first step. Sources are not a user-visible concept, so the | 82 // algorithm for the first step. Sources are not a user-visible concept, so the |
80 // spec only specifies an algorithm for track settings. | 83 // spec only specifies an algorithm for track settings. |
81 // This algorithm for sources is compatible with the spec algorithm for tracks, | 84 // This algorithm for sources is compatible with the spec algorithm for tracks, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // constraint set. | 126 // constraint set. |
124 // 4. C1 is better than C2 if its native settings have a smaller fitness | 127 // 4. C1 is better than C2 if its native settings have a smaller fitness |
125 // distance. For example, if the ideal resolution is 1000x1000 and C1 has a | 128 // distance. For example, if the ideal resolution is 1000x1000 and C1 has a |
126 // native resolution of 1200x1200, while C2 has a native resolution of | 129 // native resolution of 1200x1200, while C2 has a native resolution of |
127 // 2000x2000, then C1 is better because it can support the ideal value with | 130 // 2000x2000, then C1 is better because it can support the ideal value with |
128 // lower resource usage. Both C1 and C2 are better than a candidate C3 with | 131 // lower resource usage. Both C1 and C2 are better than a candidate C3 with |
129 // a native resolution of 999x999, since C3 has a nonzero distance to the | 132 // a native resolution of 999x999, since C3 has a nonzero distance to the |
130 // ideal value and thus has worse fitness according to step 2, even if C3's | 133 // ideal value and thus has worse fitness according to step 2, even if C3's |
131 // native fitness is better than C1's and C2's. | 134 // native fitness is better than C1's and C2's. |
132 // 5. C1 is better than C2 if its settings are closer to certain default | 135 // 5. C1 is better than C2 if its settings are closer to certain default |
133 // settings that include the device ID, power-line frequency, resolution, and | 136 // settings that include the device ID, power-line frequency, noise |
134 // frame rate, in that order. Note that there is no default facing mode or | 137 // reduction, resolution, and frame rate, in that order. Note that there is |
135 // aspect ratio. | 138 // no default facing mode or aspect ratio. |
136 VideoDeviceCaptureSourceSelectionResult CONTENT_EXPORT | 139 VideoDeviceCaptureSourceSelectionResult CONTENT_EXPORT |
137 SelectVideoDeviceCaptureSourceSettings( | 140 SelectVideoDeviceCaptureSourceSettings( |
138 const VideoDeviceCaptureCapabilities& capabilities, | 141 const VideoDeviceCaptureCapabilities& capabilities, |
139 const blink::WebMediaConstraints& constraints); | 142 const blink::WebMediaConstraints& constraints); |
140 | 143 |
141 } // namespace content | 144 } // namespace content |
142 | 145 |
143 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ | 146 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ |
OLD | NEW |