xref: /aosp_15_r20/external/webrtc/api/video/video_adaptation_counters.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2020 The WebRTC Project Authors. All rights reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_adaptation_counters.h"
12*d9f75844SAndroid Build Coastguard Worker 
13*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/strings/string_builder.h"
14*d9f75844SAndroid Build Coastguard Worker 
15*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
16*d9f75844SAndroid Build Coastguard Worker 
operator ==(const VideoAdaptationCounters & rhs) const17*d9f75844SAndroid Build Coastguard Worker bool VideoAdaptationCounters::operator==(
18*d9f75844SAndroid Build Coastguard Worker     const VideoAdaptationCounters& rhs) const {
19*d9f75844SAndroid Build Coastguard Worker   return fps_adaptations == rhs.fps_adaptations &&
20*d9f75844SAndroid Build Coastguard Worker          resolution_adaptations == rhs.resolution_adaptations;
21*d9f75844SAndroid Build Coastguard Worker }
22*d9f75844SAndroid Build Coastguard Worker 
operator !=(const VideoAdaptationCounters & rhs) const23*d9f75844SAndroid Build Coastguard Worker bool VideoAdaptationCounters::operator!=(
24*d9f75844SAndroid Build Coastguard Worker     const VideoAdaptationCounters& rhs) const {
25*d9f75844SAndroid Build Coastguard Worker   return !(rhs == *this);
26*d9f75844SAndroid Build Coastguard Worker }
27*d9f75844SAndroid Build Coastguard Worker 
operator +(const VideoAdaptationCounters & other) const28*d9f75844SAndroid Build Coastguard Worker VideoAdaptationCounters VideoAdaptationCounters::operator+(
29*d9f75844SAndroid Build Coastguard Worker     const VideoAdaptationCounters& other) const {
30*d9f75844SAndroid Build Coastguard Worker   return VideoAdaptationCounters(
31*d9f75844SAndroid Build Coastguard Worker       resolution_adaptations + other.resolution_adaptations,
32*d9f75844SAndroid Build Coastguard Worker       fps_adaptations + other.fps_adaptations);
33*d9f75844SAndroid Build Coastguard Worker }
34*d9f75844SAndroid Build Coastguard Worker 
ToString() const35*d9f75844SAndroid Build Coastguard Worker std::string VideoAdaptationCounters::ToString() const {
36*d9f75844SAndroid Build Coastguard Worker   rtc::StringBuilder ss;
37*d9f75844SAndroid Build Coastguard Worker   ss << "{ res=" << resolution_adaptations << " fps=" << fps_adaptations
38*d9f75844SAndroid Build Coastguard Worker      << " }";
39*d9f75844SAndroid Build Coastguard Worker   return ss.Release();
40*d9f75844SAndroid Build Coastguard Worker }
41*d9f75844SAndroid Build Coastguard Worker 
42*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
43