resolution.h (1130B)
1 /* 2 * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef API_VIDEO_RESOLUTION_H_ 12 #define API_VIDEO_RESOLUTION_H_ 13 14 #include <utility> 15 16 #include "rtc_base/system/rtc_export.h" 17 18 namespace webrtc { 19 20 // A struct representing a video resolution in pixels. 21 struct RTC_EXPORT Resolution { 22 int width = 0; 23 int height = 0; 24 25 // Helper methods. 26 int PixelCount() const { return width * height; } 27 std::pair<int, int> ToPair() const { return std::make_pair(width, height); } 28 }; 29 30 inline bool operator==(const Resolution& lhs, const Resolution& rhs) { 31 return lhs.width == rhs.width && lhs.height == rhs.height; 32 } 33 34 inline bool operator!=(const Resolution& lhs, const Resolution& rhs) { 35 return !(lhs == rhs); 36 } 37 38 } // namespace webrtc 39 40 #endif // API_VIDEO_RESOLUTION_H_