1 /**
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MEDIA_QUALITY_THRESHOLD_H
18 #define MEDIA_QUALITY_THRESHOLD_H
19 
20 #include <binder/Parcel.h>
21 #include <binder/Parcelable.h>
22 #include <binder/Status.h>
23 #include <stdint.h>
24 #include <vector>
25 
26 namespace android
27 {
28 
29 namespace telephony
30 {
31 
32 namespace imsmedia
33 {
34 
35 /** Native representation of android.telephony.imsmedia.MediaQualityThreshold */
36 class MediaQualityThreshold : public Parcelable
37 {
38 public:
39     MediaQualityThreshold();
40     MediaQualityThreshold(const MediaQualityThreshold& threshold);
41     virtual ~MediaQualityThreshold();
42     MediaQualityThreshold& operator=(const MediaQualityThreshold& threshold);
43     bool operator==(const MediaQualityThreshold& threshold) const;
44     bool operator!=(const MediaQualityThreshold& threshold) const;
45     virtual status_t writeToParcel(Parcel* parcel) const;
46     virtual status_t readFromParcel(const Parcel* in);
47     void setRtpInactivityTimerMillis(std::vector<int32_t> times);
48     std::vector<int32_t> getRtpInactivityTimerMillis() const;
49     void setRtcpInactivityTimerMillis(int32_t time);
50     int32_t getRtcpInactivityTimerMillis() const;
51     void setRtpHysteresisTimeInMillis(int32_t time);
52     int32_t getRtpHysteresisTimeInMillis() const;
53     void setRtpPacketLossDurationMillis(int32_t time);
54     int32_t getRtpPacketLossDurationMillis() const;
55     void setRtpPacketLossRate(std::vector<int32_t> rates);
56     std::vector<int32_t> getRtpPacketLossRate() const;
57     void setRtpJitterMillis(std::vector<int32_t> jitters);
58     std::vector<int32_t> getRtpJitterMillis() const;
59     void setNotifyCurrentStatus(bool status);
60     bool getNotifyCurrentStatus() const;
61     void setVideoBitrateBps(int32_t bitrate);
62     int32_t getVideoBitrateBps() const;
63 
64 private:
65     /** The timer in milliseconds for monitoring RTP inactivity */
66     std::vector<int32_t> mRtpInactivityTimerMillis;
67     /** The timer in milliseconds for monitoring RTCP inactivity */
68     int32_t mRtcpInactivityTimerMillis;
69     /**
70      * Set the threshold hysteresis time for packet loss and jitter. This has a goal to prevent
71      * frequent ping-pong notification. So whenever a notifier needs to report the cross of
72      * threshold in opposite direction, this hysteresis timer should be respected.
73      */
74     int32_t mRtpHysteresisTimeInMillis;
75     /** Set the duration in milliseconds for monitoring the RTP packet loss rate */
76     int32_t mRtpPacketLossDurationMillis;
77     /**
78      * Packet loss rate in percentage of (total number of packets lost) /
79      * (total number of packets expected) during rtpPacketLossDurationMs
80      */
81     std::vector<int32_t> mRtpPacketLossRate;
82     /** RTP jitter threshold in milliseconds */
83     std::vector<int32_t> mRtpJitterMillis;
84     /**
85      * A flag indicating whether the client needs to be notify the current media quality status
86      * right after threshold is being set. True means the media stack should notify the client
87      * of the current status.
88      */
89     bool mNotifyCurrentStatus;
90 
91     /**
92      * The receiving bitrate threshold in bps for video call. If it is not zero, bitrate
93      * notification event is triggered when the receiving frame bitrate is less than the
94      * threshold.
95      */
96     int mVideoBitrateBps;
97 };
98 
99 }  // namespace imsmedia
100 
101 }  // namespace telephony
102 
103 }  // namespace android
104 
105 #endif