Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: content/renderer/media/media_stream_constraints_util_video_device.h

Issue 2751643003: Minor refactoring of SelectSettings results for consistency. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/logging.h"
11 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
12 #include "content/common/media/media_devices.mojom.h" 13 #include "content/common/media/media_devices.mojom.h"
13 #include "media/capture/video_capture_types.h" 14 #include "media/capture/video_capture_types.h"
14 #include "third_party/webrtc/base/optional.h" 15 #include "third_party/webrtc/base/optional.h"
15 16
16 namespace blink { 17 namespace blink {
17 class WebString; 18 class WebString;
18 class WebMediaConstraints; 19 class WebMediaConstraints;
19 } 20 }
20 21
(...skipping 10 matching lines...) Expand all
31 ~VideoDeviceCaptureCapabilities(); 32 ~VideoDeviceCaptureCapabilities();
32 VideoDeviceCaptureCapabilities& operator=( 33 VideoDeviceCaptureCapabilities& operator=(
33 VideoDeviceCaptureCapabilities&& other); 34 VideoDeviceCaptureCapabilities&& other);
34 35
35 // Each field is independent of each other. 36 // Each field is independent of each other.
36 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> device_capabilities; 37 std::vector<::mojom::VideoInputDeviceCapabilitiesPtr> device_capabilities;
37 std::vector<media::PowerLineFrequency> power_line_capabilities; 38 std::vector<media::PowerLineFrequency> power_line_capabilities;
38 std::vector<rtc::Optional<bool>> noise_reduction_capabilities; 39 std::vector<rtc::Optional<bool>> noise_reduction_capabilities;
39 }; 40 };
40 41
41 struct CONTENT_EXPORT VideoDeviceCaptureSourceSelectionResult { 42 class CONTENT_EXPORT VideoDeviceCaptureSourceSelectionResult {
43 public:
44 // Creates a result without value and with an empty failed constraint name.
42 VideoDeviceCaptureSourceSelectionResult(); 45 VideoDeviceCaptureSourceSelectionResult();
46
47 // Creates a result without value and with the given |failed_constraint_name|.
48 // Does not take ownership of |failed_constraint_name|, so it must be null or
49 // point to a string that remains accessible.
50 explicit VideoDeviceCaptureSourceSelectionResult(
51 const char* failed_constraint_name);
52
53 // Creates a result with the given values.
43 VideoDeviceCaptureSourceSelectionResult( 54 VideoDeviceCaptureSourceSelectionResult(
55 const std::string& device_id,
56 ::mojom::FacingMode facing_mode_,
57 media::VideoCaptureParams capture_params_,
58 rtc::Optional<bool> noise_reduction_);
59
60 VideoDeviceCaptureSourceSelectionResult(
61 const VideoDeviceCaptureSourceSelectionResult& other);
62 VideoDeviceCaptureSourceSelectionResult& operator=(
44 const VideoDeviceCaptureSourceSelectionResult& other); 63 const VideoDeviceCaptureSourceSelectionResult& other);
45 VideoDeviceCaptureSourceSelectionResult( 64 VideoDeviceCaptureSourceSelectionResult(
46 VideoDeviceCaptureSourceSelectionResult&& other); 65 VideoDeviceCaptureSourceSelectionResult&& other);
47 ~VideoDeviceCaptureSourceSelectionResult();
48 VideoDeviceCaptureSourceSelectionResult& operator=(
49 const VideoDeviceCaptureSourceSelectionResult& other);
50 VideoDeviceCaptureSourceSelectionResult& operator=( 66 VideoDeviceCaptureSourceSelectionResult& operator=(
51 VideoDeviceCaptureSourceSelectionResult&& other); 67 VideoDeviceCaptureSourceSelectionResult&& other);
68 ~VideoDeviceCaptureSourceSelectionResult();
52 69
53 bool HasValue() const { return failed_constraint_name == nullptr; } 70 bool HasValue() const { return failed_constraint_name_ == nullptr; }
54 71
55 // Convenience accessors for fields embedded in |capture_params|. 72 // Convenience accessors for fields embedded in |capture_params|.
56 const media::VideoCaptureFormat& Format() const { 73 const media::VideoCaptureFormat& Format() const {
57 return capture_params.requested_format; 74 return capture_params_.requested_format;
58 } 75 }
59 int Width() const { 76 int Width() const {
60 return capture_params.requested_format.frame_size.width(); 77 DCHECK(HasValue());
78 return capture_params_.requested_format.frame_size.width();
61 } 79 }
62 int Height() const { 80 int Height() const {
63 return capture_params.requested_format.frame_size.height(); 81 DCHECK(HasValue());
82 return capture_params_.requested_format.frame_size.height();
64 } 83 }
65 float FrameRate() const { return capture_params.requested_format.frame_rate; } 84 float FrameRate() const {
85 DCHECK(HasValue());
86 return capture_params_.requested_format.frame_rate;
87 }
66 media::PowerLineFrequency PowerLineFrequency() const { 88 media::PowerLineFrequency PowerLineFrequency() const {
67 return capture_params.power_line_frequency; 89 DCHECK(HasValue());
90 return capture_params_.power_line_frequency;
68 } 91 }
69 92
70 const char* failed_constraint_name; 93 // Other accessors.
71 std::string device_id; 94 const char* failed_constraint_name() const { return failed_constraint_name_; }
72 ::mojom::FacingMode facing_mode; 95
73 media::VideoCaptureParams capture_params; 96 const std::string& device_id() const {
74 rtc::Optional<bool> noise_reduction; 97 DCHECK(HasValue());
98 return device_id_;
99 }
100
101 ::mojom::FacingMode facing_mode() const {
102 DCHECK(HasValue());
103 return facing_mode_;
104 }
105
106 const media::VideoCaptureParams& capture_params() const {
107 DCHECK(HasValue());
108 return capture_params_;
109 }
110
111 const rtc::Optional<bool>& noise_reduction() const {
112 DCHECK(HasValue());
113 return noise_reduction_;
114 }
115
116 private:
117 const char* failed_constraint_name_;
118 std::string device_id_;
119 ::mojom::FacingMode facing_mode_;
120 media::VideoCaptureParams capture_params_;
121 rtc::Optional<bool> noise_reduction_;
75 }; 122 };
76 123
77 // This function performs source and source-settings selection based on 124 // This function performs source and source-settings selection based on
78 // the given |capabilities| and |constraints|. 125 // the given |capabilities| and |constraints|.
79 // Chromium performs constraint resolution in two steps. First, a source and its 126 // Chromium performs constraint resolution in two steps. First, a source and its
80 // settings are selected; then a track is created, connected to the source, and 127 // settings are selected; then a track is created, connected to the source, and
81 // finally the track settings are selected. This function implements an 128 // finally the track settings are selected. This function implements an
82 // algorithm for the first step. Sources are not a user-visible concept, so the 129 // algorithm for the first step. Sources are not a user-visible concept, so the
83 // spec only specifies an algorithm for track settings. 130 // spec only specifies an algorithm for track settings.
84 // This algorithm for sources is compatible with the spec algorithm for tracks, 131 // This algorithm for sources is compatible with the spec algorithm for tracks,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // reduction, resolution, and frame rate, in that order. Note that there is 184 // reduction, resolution, and frame rate, in that order. Note that there is
138 // no default facing mode or aspect ratio. 185 // no default facing mode or aspect ratio.
139 VideoDeviceCaptureSourceSelectionResult CONTENT_EXPORT 186 VideoDeviceCaptureSourceSelectionResult CONTENT_EXPORT
140 SelectVideoDeviceCaptureSourceSettings( 187 SelectVideoDeviceCaptureSourceSettings(
141 const VideoDeviceCaptureCapabilities& capabilities, 188 const VideoDeviceCaptureCapabilities& capabilities,
142 const blink::WebMediaConstraints& constraints); 189 const blink::WebMediaConstraints& constraints);
143 190
144 } // namespace content 191 } // namespace content
145 192
146 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_ 193 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698