UniMRCP
1.3.0
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
libs
mpf
include
mpf_rtcp_packet.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2014 Arsen Chaloyan
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
* $Id: mpf_rtcp_packet.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17
*/
18
19
#ifndef MPF_RTCP_PACKET_H
20
#define MPF_RTCP_PACKET_H
21
22
/**
23
* @file mpf_rtcp_packet.h
24
* @brief RTCP Packet Definition
25
*/
26
27
#include "
mpf_rtp_stat.h
"
28
29
APT_BEGIN_EXTERN_C
30
31
32
/** RTCP payload (packet) types */
33
typedef
enum
{
34
RTCP_SR = 200,
35
RTCP_RR = 201,
36
RTCP_SDES = 202,
37
RTCP_BYE = 203,
38
RTCP_APP = 204
39
}
rtcp_type_e
;
40
41
/** RTCP SDES types */
42
typedef
enum
{
43
RTCP_SDES_END = 0,
44
RTCP_SDES_CNAME = 1,
45
RTCP_SDES_NAME = 2,
46
RTCP_SDES_EMAIL = 3,
47
RTCP_SDES_PHONE = 4,
48
RTCP_SDES_LOC = 5,
49
RTCP_SDES_TOOL = 6,
50
RTCP_SDES_NOTE = 7,
51
RTCP_SDES_PRIV = 8
52
}
rtcp_sdes_type_e
;
53
54
/** RTCP header declaration */
55
typedef
struct
rtcp_header_t
rtcp_header_t
;
56
/** RTCP packet declaration */
57
typedef
struct
rtcp_packet_t
rtcp_packet_t
;
58
/** SDES item declaration*/
59
typedef
struct
rtcp_sdes_item_t
rtcp_sdes_item_t
;
60
61
62
/** RTCP header */
63
struct
rtcp_header_t
{
64
#if (APR_IS_BIGENDIAN == 1)
65
/** protocol version */
66
unsigned
int
version
: 2;
67
/** padding flag */
68
unsigned
int
padding
: 1;
69
/** varies by packet type */
70
unsigned
int
count
: 5;
71
/** packet type */
72
unsigned
int
pt
: 8;
73
#else
74
/** varies by packet type */
75
unsigned
int
count
: 5;
76
/** padding flag */
77
unsigned
int
padding
: 1;
78
/** protocol version */
79
unsigned
int
version
: 2;
80
/** packet type */
81
unsigned
int
pt
: 8;
82
#endif
83
84
/** packet length in words, w/o this word */
85
unsigned
int
length
: 16;
86
};
87
88
/** SDES item */
89
struct
rtcp_sdes_item_t
{
90
/** type of item (rtcp_sdes_type_t) */
91
apr_byte_t
type
;
92
/** length of item (in octets) */
93
apr_byte_t
length
;
94
/** text, not null-terminated */
95
char
data
[1];
96
};
97
98
/** RTCP packet */
99
struct
rtcp_packet_t
{
100
/** common header */
101
rtcp_header_t
header
;
102
/** union of RTCP reports */
103
union
{
104
/** sender report (SR) */
105
struct
{
106
/** sr stat */
107
rtcp_sr_stat_t
sr_stat
;
108
/** variable-length list rr stats */
109
rtcp_rr_stat_t
rr_stat
[1];
110
} sr;
111
112
/** reception report (RR) */
113
struct
{
114
/** receiver generating this report */
115
apr_uint32_t
ssrc
;
116
/** variable-length list rr stats */
117
rtcp_rr_stat_t
rr_stat
[1];
118
} rr;
119
120
/** source description (SDES) */
121
struct
{
122
/** first SSRC/CSRC */
123
apr_uint32_t
ssrc
;
124
/** list of SDES items */
125
rtcp_sdes_item_t
item
[1];
126
} sdes;
127
128
/** BYE */
129
struct
{
130
/** list of sources */
131
apr_uint32_t
ssrc
[1];
132
/* optional length of reason string (in octets) */
133
apr_byte_t length;
134
/* optional reason string, not null-terminated */
135
char
data[1];
136
} bye;
137
} r;
138
};
139
140
/** Initialize RTCP header */
141
static
APR_INLINE
void
rtcp_header_init(
rtcp_header_t
*header,
rtcp_type_e
pt)
142
{
143
header->
version
=
RTP_VERSION
;
144
header->
padding
= 0;
145
header->
count
= 0;
146
header->
pt
= pt;
147
header->
length
= 0;
148
}
149
150
static
APR_INLINE
void
rtcp_header_length_set(
rtcp_header_t
*header, apr_size_t length)
151
{
152
header->
length
= htons((apr_uint16_t)length / 4 - 1);
153
}
154
155
static
APR_INLINE
void
rtcp_sr_hton(
rtcp_sr_stat_t
*sr_stat)
156
{
157
sr_stat->
ssrc
= htonl(sr_stat->
ssrc
);
158
sr_stat->
ntp_sec
= htonl(sr_stat->
ntp_sec
);
159
sr_stat->
ntp_frac
= htonl(sr_stat->
ntp_frac
);
160
sr_stat->
rtp_ts
= htonl(sr_stat->
rtp_ts
);
161
sr_stat->
sent_packets
= htonl(sr_stat->
sent_packets
);
162
sr_stat->
sent_octets
= htonl(sr_stat->
sent_octets
);
163
}
164
165
static
APR_INLINE
void
rtcp_sr_ntoh(
rtcp_sr_stat_t
*sr_stat)
166
{
167
sr_stat->
ssrc
= ntohl(sr_stat->
ssrc
);
168
sr_stat->
ntp_sec
= ntohl(sr_stat->
ntp_sec
);
169
sr_stat->
ntp_frac
= ntohl(sr_stat->
ntp_frac
);
170
sr_stat->
rtp_ts
= ntohl(sr_stat->
rtp_ts
);
171
sr_stat->
sent_packets
= ntohl(sr_stat->
sent_packets
);
172
sr_stat->
sent_octets
= ntohl(sr_stat->
sent_octets
);
173
}
174
175
static
APR_INLINE
void
rtcp_rr_hton(
rtcp_rr_stat_t
*rr_stat)
176
{
177
rr_stat->
ssrc
= htonl(rr_stat->
ssrc
);
178
rr_stat->
last_seq
= htonl(rr_stat->
last_seq
);
179
rr_stat->
jitter
= htonl(rr_stat->
jitter
);
180
181
#if (APR_IS_BIGENDIAN == 0)
182
rr_stat->
lost
= ((rr_stat->
lost
>> 16) & 0x000000ff) |
183
(rr_stat->
lost
& 0x0000ff00) |
184
((rr_stat->
lost
<< 16) & 0x00ff0000);
185
#endif
186
}
187
188
static
APR_INLINE
void
rtcp_rr_ntoh(
rtcp_rr_stat_t
*rr_stat)
189
{
190
rr_stat->
ssrc
= ntohl(rr_stat->
ssrc
);
191
rr_stat->
last_seq
= ntohl(rr_stat->
last_seq
);
192
rr_stat->
jitter
= ntohl(rr_stat->
jitter
);
193
194
#if (APR_IS_BIGENDIAN == 0)
195
rr_stat->
lost
= ((rr_stat->
lost
>> 16) & 0x000000ff) |
196
(rr_stat->
lost
& 0x0000ff00) |
197
((rr_stat->
lost
<< 16) & 0x00ff0000);
198
#endif
199
}
200
201
APT_END_EXTERN_C
202
203
#endif
/* MPF_RTCP_PACKET_H */
Generated on Mon Feb 2 2015 19:41:38 for UniMRCP by
1.8.3.1