Chromium Code Reviews| 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_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | |
| 9 #include <string> | 8 #include <string> |
| 10 #include <vector> | 9 #include <vector> |
| 11 | 10 |
| 12 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 13 #include "content/common/media/media_devices.mojom.h" | 12 #include "content/common/media/media_devices.mojom.h" |
| 14 #include "media/capture/video_capture_types.h" | 13 #include "media/capture/video_capture_types.h" |
| 15 | 14 |
| 16 namespace blink { | 15 namespace blink { |
| 17 class WebString; | 16 class WebString; |
| 18 class WebMediaConstraints; | 17 class WebMediaConstraints; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace content { | 20 namespace content { |
| 22 | 21 |
| 23 // Calculates and returns videoKind value for |format|. | 22 // Calculates and returns videoKind value for |format|. |
| 24 // See https://w3c.github.io/mediacapture-depth. | 23 // See https://w3c.github.io/mediacapture-depth. |
| 25 blink::WebString CONTENT_EXPORT | 24 blink::WebString CONTENT_EXPORT |
| 26 GetVideoKindForFormat(const media::VideoCaptureFormat& format); | 25 GetVideoKindForFormat(const media::VideoCaptureFormat& format); |
| 27 | 26 |
| 28 struct CONTENT_EXPORT VideoCaptureCapabilities { | 27 struct CONTENT_EXPORT VideoDeviceCaptureCapabilities { |
| 29 VideoCaptureCapabilities(); | 28 VideoDeviceCaptureCapabilities(); |
| 30 VideoCaptureCapabilities(VideoCaptureCapabilities&& other); | 29 VideoDeviceCaptureCapabilities(VideoDeviceCaptureCapabilities&& other); |
| 31 ~VideoCaptureCapabilities(); | 30 ~VideoDeviceCaptureCapabilities(); |
| 32 VideoCaptureCapabilities& operator=(VideoCaptureCapabilities&& other); | 31 VideoDeviceCaptureCapabilities& operator=( |
| 32 VideoDeviceCaptureCapabilities&& other); | |
| 33 | 33 |
| 34 // Each field is independent of each other. | 34 // Each field is independent of each other. |
| 35 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> device_capabilities; | 35 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> device_capabilities; |
| 36 std::vector<media::PowerLineFrequency> power_line_capabilities; | 36 std::vector<media::PowerLineFrequency> power_line_capabilities; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class CONTENT_EXPORT VideoCaptureSourceSettings { | 39 struct CONTENT_EXPORT VideoDeviceCaptureSourceSelectionResult { |
| 40 public: | 40 VideoDeviceCaptureSourceSelectionResult(); |
| 41 VideoCaptureSourceSettings(); | 41 VideoDeviceCaptureSourceSelectionResult( |
| 42 VideoCaptureSourceSettings(const VideoCaptureSourceSettings& other); | 42 const VideoDeviceCaptureSourceSelectionResult& other); |
| 43 VideoCaptureSourceSettings(VideoCaptureSourceSettings&& other); | 43 VideoDeviceCaptureSourceSelectionResult( |
| 44 VideoCaptureSourceSettings(const std::string& device_id, | 44 VideoDeviceCaptureSourceSelectionResult&& other); |
| 45 const media::VideoCaptureFormat& format, | 45 ~VideoDeviceCaptureSourceSelectionResult(); |
| 46 ::mojom::FacingMode facing_mode, | 46 VideoDeviceCaptureSourceSelectionResult& operator=( |
| 47 media::PowerLineFrequency power_line_frequency); | 47 const VideoDeviceCaptureSourceSelectionResult& other); |
| 48 ~VideoCaptureSourceSettings(); | 48 VideoDeviceCaptureSourceSelectionResult& operator=( |
| 49 VideoCaptureSourceSettings& operator=( | 49 VideoDeviceCaptureSourceSelectionResult&& other); |
| 50 const VideoCaptureSourceSettings& other); | |
| 51 VideoCaptureSourceSettings& operator=(VideoCaptureSourceSettings&& other); | |
| 52 | 50 |
| 53 // Accessors for easier interaction with blink constraint classes. | 51 bool HasValue() const { return failed_constraint_name == nullptr; } |
| 54 blink::WebString GetFacingMode() const; | |
| 55 long GetPowerLineFrequency() const; | |
| 56 long GetWidth() const; | |
| 57 long GetHeight() const; | |
| 58 double GetFrameRate() const; | |
| 59 blink::WebString GetDeviceId() const; | |
| 60 blink::WebString GetVideoKind() const; | |
| 61 | 52 |
| 62 const media::VideoCaptureFormat& format() const { return format_; } | 53 // Convenience accessors for fields embedded in |capture_params|. |
| 63 const std::string& device_id() const { return device_id_; } | 54 const media::VideoCaptureFormat& Format() const { |
| 64 ::mojom::FacingMode facing_mode() const { return facing_mode_; } | 55 return capture_params.requested_format; |
| 65 media::PowerLineFrequency power_line_frequency() const { | 56 } |
| 66 return power_line_frequency_; | 57 int Width() const { |
| 58 return capture_params.requested_format.frame_size.width(); | |
| 59 } | |
| 60 int Height() const { | |
| 61 return capture_params.requested_format.frame_size.width(); | |
| 62 } | |
| 63 float FrameRate() const { return capture_params.requested_format.frame_rate; } | |
| 64 media::PowerLineFrequency PowerLineFrequency() const { | |
| 65 return capture_params.power_line_frequency; | |
| 67 } | 66 } |
|
hbos_chromium
2017/02/24 11:28:57
Here you use names like Width() but in VideoDevice
Guido Urdaneta
2017/02/24 13:13:44
As discussed offline, the Get ones are not just ac
| |
| 68 | 67 |
| 69 private: | |
| 70 std::string device_id_; | |
| 71 media::VideoCaptureFormat format_; | |
| 72 ::mojom::FacingMode facing_mode_; | |
| 73 media::PowerLineFrequency power_line_frequency_; | |
| 74 }; | |
| 75 | |
| 76 struct CONTENT_EXPORT VideoCaptureSourceSelectionResult { | |
| 77 VideoCaptureSourceSelectionResult(); | |
| 78 VideoCaptureSourceSelectionResult( | |
| 79 const VideoCaptureSourceSelectionResult& other); | |
| 80 VideoCaptureSourceSelectionResult(VideoCaptureSourceSelectionResult&& other); | |
| 81 ~VideoCaptureSourceSelectionResult(); | |
| 82 VideoCaptureSourceSelectionResult& operator=( | |
| 83 const VideoCaptureSourceSelectionResult& other); | |
| 84 VideoCaptureSourceSelectionResult& operator=( | |
| 85 VideoCaptureSourceSelectionResult&& other); | |
| 86 | |
| 87 bool has_value() const { return failed_constraint_name == nullptr; } | |
| 88 | |
| 89 VideoCaptureSourceSettings settings; | |
| 90 const char* failed_constraint_name; | 68 const char* failed_constraint_name; |
| 69 std::string device_id; | |
| 70 ::mojom::FacingMode facing_mode; | |
| 71 media::VideoCaptureParams capture_params; | |
| 91 }; | 72 }; |
| 92 | 73 |
| 93 // This function performs source and source-settings selection based on | 74 // This function performs source and source-settings selection based on |
| 94 // the given |capabilities| and |constraints|. | 75 // the given |capabilities| and |constraints|. |
| 95 // Chromium performs constraint resolution in two steps. First, a source and its | 76 // Chromium performs constraint resolution in two steps. First, a source and its |
| 96 // settings are selected; then a track is created, connected to the source, and | 77 // settings are selected; then a track is created, connected to the source, and |
| 97 // finally the track settings are selected. This function implements an | 78 // finally the track settings are selected. This function implements an |
| 98 // algorithm for the first step. Sources are not a user-visible concept, so the | 79 // algorithm for the first step. Sources are not a user-visible concept, so the |
| 99 // spec only specifies an algorithm for track settings. | 80 // spec only specifies an algorithm for track settings. |
| 100 // This algorithm for sources is compatible with the spec algorithm for tracks, | 81 // This algorithm for sources is compatible with the spec algorithm for tracks, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // native resolution of 1200x1200, while C2 has a native resolution of | 126 // native resolution of 1200x1200, while C2 has a native resolution of |
| 146 // 2000x2000, then C1 is better because it can support the ideal value with | 127 // 2000x2000, then C1 is better because it can support the ideal value with |
| 147 // lower resource usage. Both C1 and C2 are better than a candidate C3 with | 128 // lower resource usage. Both C1 and C2 are better than a candidate C3 with |
| 148 // a native resolution of 999x999, since C3 has a nonzero distance to the | 129 // a native resolution of 999x999, since C3 has a nonzero distance to the |
| 149 // ideal value and thus has worse fitness according to step 2, even if C3's | 130 // ideal value and thus has worse fitness according to step 2, even if C3's |
| 150 // native fitness is better than C1's and C2's. | 131 // native fitness is better than C1's and C2's. |
| 151 // 5. C1 is better than C2 if its settings are closer to certain default | 132 // 5. C1 is better than C2 if its settings are closer to certain default |
| 152 // settings that include the device ID, power-line frequency, resolution, and | 133 // settings that include the device ID, power-line frequency, resolution, and |
| 153 // frame rate, in that order. Note that there is no default facing mode or | 134 // frame rate, in that order. Note that there is no default facing mode or |
| 154 // aspect ratio. | 135 // aspect ratio. |
| 155 VideoCaptureSourceSelectionResult CONTENT_EXPORT | 136 VideoDeviceCaptureSourceSelectionResult CONTENT_EXPORT |
| 156 SelectVideoCaptureSourceSettings(const VideoCaptureCapabilities& capabilities, | 137 SelectVideoDeviceCaptureSourceSettings( |
| 157 const blink::WebMediaConstraints& constraints); | 138 const VideoDeviceCaptureCapabilities& capabilities, |
| 139 const blink::WebMediaConstraints& constraints); | |
| 158 | 140 |
| 159 } // namespace content | 141 } // namespace content |
| 160 | 142 |
| 161 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_SOURCE_H_ | 143 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ |
| OLD | NEW |