video_adaptation_counters.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
  11. #define API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_
  12. #include <string>
  13. #include "rtc_base/checks.h"
  14. namespace webrtc {
  15. // Counts the number of adaptations have resulted due to resource overuse.
  16. // Today we can adapt resolution and fps.
  17. struct VideoAdaptationCounters {
  18. VideoAdaptationCounters() : resolution_adaptations(0), fps_adaptations(0) {}
  19. VideoAdaptationCounters(int resolution_adaptations, int fps_adaptations)
  20. : resolution_adaptations(resolution_adaptations),
  21. fps_adaptations(fps_adaptations) {
  22. RTC_DCHECK_GE(resolution_adaptations, 0);
  23. RTC_DCHECK_GE(fps_adaptations, 0);
  24. }
  25. int Total() const { return fps_adaptations + resolution_adaptations; }
  26. bool operator==(const VideoAdaptationCounters& rhs) const;
  27. bool operator!=(const VideoAdaptationCounters& rhs) const;
  28. VideoAdaptationCounters operator+(const VideoAdaptationCounters& other) const;
  29. std::string ToString() const;
  30. int resolution_adaptations;
  31. int fps_adaptations;
  32. };
  33. } // namespace webrtc
  34. #endif // API_VIDEO_VIDEO_ADAPTATION_COUNTERS_H_