| 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_CONTENT_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_CONTENT_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_CONTENT_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_CONTENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | |
| 11 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 12 #include "media/capture/video_capture_types.h" | 11 #include "content/renderer/media/media_stream_constraints_util.h" |
| 13 #include "third_party/webrtc/base/optional.h" | 12 #include "third_party/webrtc/base/optional.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 class WebMediaConstraints; | 15 class WebMediaConstraints; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace content { | 18 namespace content { |
| 20 | 19 |
| 21 class CONTENT_EXPORT VideoContentCaptureSourceSelectionResult { | 20 CONTENT_EXPORT extern const int kDefaultScreenCastWidth; |
| 22 public: | 21 CONTENT_EXPORT extern const int kDefaultScreenCastHeight; |
| 23 // Creates a result without value and with an empty failed constraint name. | 22 CONTENT_EXPORT extern const double kDefaultScreenCastFrameRate; |
| 24 VideoContentCaptureSourceSelectionResult(); | 23 CONTENT_EXPORT extern const int kMinScreenCastDimension; |
| 24 CONTENT_EXPORT extern const int kMaxScreenCastDimension; |
| 25 | 25 |
| 26 // Creates a result without value and with the given |failed_constraint_name|. | 26 // This function performs source, source-settings and track-settings selection |
| 27 // Does not take ownership of |failed_constraint_name|, so it must be null or | 27 // for content video capture based on the given |constraints|. |
| 28 // point to a string that remains accessible. | 28 VideoCaptureSettings CONTENT_EXPORT SelectSettingsVideoContentCapture( |
| 29 explicit VideoContentCaptureSourceSelectionResult( | |
| 30 const char* failed_constraint_name); | |
| 31 | |
| 32 // Creates a result with the given values. | |
| 33 VideoContentCaptureSourceSelectionResult( | |
| 34 std::string device_id, | |
| 35 const rtc::Optional<bool>& noise_reduction, | |
| 36 media::VideoCaptureParams capture_params); | |
| 37 | |
| 38 VideoContentCaptureSourceSelectionResult( | |
| 39 const VideoContentCaptureSourceSelectionResult& other); | |
| 40 VideoContentCaptureSourceSelectionResult& operator=( | |
| 41 const VideoContentCaptureSourceSelectionResult& other); | |
| 42 VideoContentCaptureSourceSelectionResult( | |
| 43 VideoContentCaptureSourceSelectionResult&& other); | |
| 44 VideoContentCaptureSourceSelectionResult& operator=( | |
| 45 VideoContentCaptureSourceSelectionResult&& other); | |
| 46 ~VideoContentCaptureSourceSelectionResult(); | |
| 47 | |
| 48 bool HasValue() const { return failed_constraint_name_ == nullptr; } | |
| 49 | |
| 50 // Accessors. | |
| 51 const char* failed_constraint_name() const { return failed_constraint_name_; } | |
| 52 const std::string& device_id() const { | |
| 53 DCHECK(HasValue()); | |
| 54 return device_id_; | |
| 55 } | |
| 56 const rtc::Optional<bool>& noise_reduction() const { | |
| 57 DCHECK(HasValue()); | |
| 58 return noise_reduction_; | |
| 59 } | |
| 60 media::VideoCaptureParams capture_params() const { | |
| 61 DCHECK(HasValue()); | |
| 62 return capture_params_; | |
| 63 } | |
| 64 | |
| 65 // Convenience accessors for fields embedded in the |capture_params_| field. | |
| 66 int Height() const; | |
| 67 int Width() const; | |
| 68 float FrameRate() const; | |
| 69 media::ResolutionChangePolicy ResolutionChangePolicy() const; | |
| 70 | |
| 71 private: | |
| 72 const char* failed_constraint_name_; | |
| 73 std::string device_id_; | |
| 74 rtc::Optional<bool> noise_reduction_; | |
| 75 media::VideoCaptureParams capture_params_; | |
| 76 }; | |
| 77 | |
| 78 // This function performs source and source-settings selection for content | |
| 79 // video capture based on the given |constraints|. | |
| 80 VideoContentCaptureSourceSelectionResult CONTENT_EXPORT | |
| 81 SelectVideoContentCaptureSourceSettings( | |
| 82 const blink::WebMediaConstraints& constraints); | 29 const blink::WebMediaConstraints& constraints); |
| 83 | 30 |
| 84 } // namespace content | 31 } // namespace content |
| 85 | 32 |
| 86 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_CONTENT_H_ | 33 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_VIDEO_CONTENT_H_ |
| OLD | NEW |