xref: /aosp_15_r20/external/webrtc/api/video/video_adaptation_counters.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2020 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_VIDEO_ADAPTATION_COUNTERS_H_
12 #define API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
13 
14 #include <string>
15 
16 #include "rtc_base/checks.h"
17 
18 namespace webrtc {
19 
20 // Counts the number of adaptations have resulted due to resource overuse.
21 // Today we can adapt resolution and fps.
22 struct VideoAdaptationCounters {
VideoAdaptationCountersVideoAdaptationCounters23   VideoAdaptationCounters() : resolution_adaptations(0), fps_adaptations(0) {}
VideoAdaptationCountersVideoAdaptationCounters24   VideoAdaptationCounters(int resolution_adaptations, int fps_adaptations)
25       : resolution_adaptations(resolution_adaptations),
26         fps_adaptations(fps_adaptations) {
27     RTC_DCHECK_GE(resolution_adaptations, 0);
28     RTC_DCHECK_GE(fps_adaptations, 0);
29   }
30 
TotalVideoAdaptationCounters31   int Total() const { return fps_adaptations + resolution_adaptations; }
32 
33   bool operator==(const VideoAdaptationCounters& rhs) const;
34   bool operator!=(const VideoAdaptationCounters& rhs) const;
35 
36   VideoAdaptationCounters operator+(const VideoAdaptationCounters& other) const;
37 
38   std::string ToString() const;
39 
40   int resolution_adaptations;
41   int fps_adaptations;
42 };
43 
44 }  // namespace webrtc
45 
46 #endif  // API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
47