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 RTCPCONFIG_H
18 #define RTCPCONFIG_H
19 
20 #include <binder/Parcel.h>
21 #include <binder/Parcelable.h>
22 #include <binder/Status.h>
23 #include <stdint.h>
24 
25 namespace android
26 {
27 
28 namespace telephony
29 {
30 
31 namespace imsmedia
32 {
33 
34 /** Native representation of android.telephony.imsmedia.RtcpConfig */
35 
36 /**
37  * The class represents RTCP (Real Time Control Protocol) configurations.
38  */
39 class RtcpConfig : public Parcelable
40 {
41 public:
42     enum RtcpXrBlockType
43     {
44         /**
45          * RTCP XR (extended report) types are not specified,
46          * See RFC 3611 section 4
47          */
48         FLAG_RTCPXR_NONE = 0,
49         /**
50          * RTCP XR type Loss RLE Report Block as specified in
51          * RFC 3611 section 4.1
52          */
53         FLAG_RTCPXR_LOSS_RLE_REPORT_BLOCK = 1 << 0,
54         /**
55          * RTCP XR type Duplicate RLE Report Block as specified in
56          * RFC 3611 section 4.2
57          */
58         FLAG_RTCPXR_DUPLICATE_RLE_REPORT_BLOCK = 1 << 1,
59         /**
60          * RTCP XR type Packet Receipt Times Report Block as specified in
61          * RFC 3611 section 4.3
62          */
63         FLAG_RTCPXR_PACKET_RECEIPT_TIMES_REPORT_BLOCK = 1 << 2,
64         /**
65          * RTCP XR type Receiver Reference Time Report Block as specified in
66          * RFC 3611 section 4.4
67          */
68         FLAG_RTCPXR_RECEIVER_REFERENCE_TIME_REPORT_BLOCK = 1 << 3,
69         /**
70          * RTCP XR type DLRR Report Block as specified in
71          * RFC 3611 section 4.5
72          */
73         FLAG_RTCPXR_DLRR_REPORT_BLOCK = 1 << 4,
74         /**
75          * RTCP XR type Statistics Summary Report Block as specified in
76          * RFC 3611 section 4.6
77          */
78         FLAG_RTCPXR_STATISTICS_SUMMARY_REPORT_BLOCK = 1 << 5,
79         /**
80          * RTCP XR type VoIP Metrics Report Block as specified in
81          * RFC 3611 section 4.7
82          */
83         FLAG_RTCPXR_VOIP_METRICS_REPORT_BLOCK = 1 << 6,
84     };
85 
86     // Default RtcpConfig
87     const int32_t kTransmitPort = 0;
88     const int32_t kIntervalSec = 0;
89     const int32_t kRtcpXrBlockTypes = FLAG_RTCPXR_NONE;
90 
91     RtcpConfig();
92     RtcpConfig(const RtcpConfig& config);
93     virtual ~RtcpConfig();
94     RtcpConfig& operator=(const RtcpConfig& config);
95     bool operator==(const RtcpConfig& config) const;
96     bool operator!=(const RtcpConfig& config) const;
97     virtual status_t writeToParcel(Parcel* parcel) const;
98     virtual status_t readFromParcel(const Parcel* in);
99     void setCanonicalName(const String8& name);
100     String8 getCanonicalName();
101     void setTransmitPort(const int32_t port);
102     int32_t getTransmitPort();
103     void setIntervalSec(const int32_t interval);
104     int32_t getIntervalSec();
105     void setRtcpXrBlockTypes(const int32_t type);
106     int32_t getRtcpXrBlockTypes();
107     void setDefaultRtcpConfig();
108 
109 private:
110     /** Canonical name that will be sent to all session participants */
111     String8 canonicalName;
112 
113     /** UDP port number for sending outgoing RTCP packets */
114     int32_t transmitPort;
115 
116     /**
117      * RTCP transmit interval in seconds. The value 0 indicates that RTCP
118      * reports shall not be sent to the other party.
119      */
120     int32_t intervalSec;
121 
122     /** Bitmask of RTCP-XR blocks to enable as in RtcpXrReportBlockType */
123     int32_t rtcpXrBlockTypes;
124 };
125 
126 }  // namespace imsmedia
127 
128 }  // namespace telephony
129 
130 }  // namespace android
131 
132 #endif