]> git.sesse.net Git - vlc/blob - modules/mux/rtp/rtcp.h
Structures and functions for RTCP support. BIG FAT WARNING >>>> This code is untested...
[vlc] / modules / mux / rtp / rtcp.h
1 /*****************************************************************************
2  * rtcp.h: RTP/RTCP headerfile
3  *****************************************************************************
4  * Copyright (C) 2005 M2X
5  *
6  * $Id$
7  *
8  * Authors: Jean-Paul Saman <jpsaman #_at_# videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #ifndef _RTCP_H
26 #define _RTCP_H 1
27
28 /* RTCP packet types */
29 #define RTCP_SR     200
30 #define RTCP_RR     201
31 #define RTCP_SDES   202
32 #define RTCP_BYE    203
33 #define RTCP_APP    204
34 /* End of RTCP packet types */
35
36 /* RTCP Info */
37 #define RTCP_INFO_CNAME 1
38 #define RTCP_INFO_NAME  2
39 #define RTCP_INFO_EMAIL 3
40 #define RTCP_INFO_PHONE 4
41 #define RTCP_INFO_LOC   5
42 #define RTCP_INFO_TOOL  6
43 #define RTCP_INFO_NOTE  7
44 #define RTCP_INFO_PRIV  8
45 /* End of RTCP Info */
46
47 #define RTCP_HEADER_LEN 3
48
49 typedef struct
50 {
51     unsigned int u_ssrc;
52     unsigned int ntp_timestampH;
53     unsigned int ntp_timestampL;
54     unsigned int rtp_timestamp;
55     unsigned int u_pkt_count;
56     unsigned int u_octet_count;
57 } rtcp_SR;
58
59 typedef struct _RTCP_header_RR
60 {
61     unsigned int u_ssrc;
62 } rtcp_RR;
63
64 typedef struct
65 {
66     unsigned long u_ssrc;
67     unsigned char u_fract_lost;
68     unsigned char u_pck_lost[3];
69     unsigned int  u_highest_seq_no;
70     unsigned int  u_jitter;
71     unsigned int  u_last_SR;
72     unsigned int  u_delay_last_SR;
73 } rtcp_report_block_SR;
74
75 typedef struct
76 {
77     unsigned int  u_ssrc;
78     unsigned char u_attr_name;
79     unsigned char u_length;
80     char          *p_data;
81 } rtcp_SDES;
82
83 typedef struct
84 {
85     unsigned int  u_ssrc;
86     unsigned char u_length;
87 } rtcp_BYE;
88
89 typedef struct
90 {
91     unsigned char u_length;
92     char          *p_data;
93 } rtcp_APP;
94
95 /**
96  * structure rtcp_stats_t
97  */
98 typedef struct
99 {
100     unsigned int  u_RR_received;   /*< RR records received */
101     unsigned int  u_SR_received;   /*< SR records received */
102     unsigned long l_dest_SSRC;     /*< SSRC */
103     unsigned int  u_pkt_count;     /*< count of packets received */
104     unsigned int  u_octet_count;   /*< ? */
105     unsigned int  u_pkt_lost;      /*< count of packets lost */
106     unsigned int  u_fract_lost;    /*< count of fractional packets lost */
107     unsigned int  u_highest_seq_no;/*< highest sequence number found */
108     unsigned int  u_jitter;        /*< jitter calculated */
109     unsigned int  u_last_SR;       /*< last SR record received */
110     unsigned int  u_last_RR;       /*< last RR record received */
111     mtime_t u_delay_since_last_SR; /*< delay since last SR record received */
112     mtime_t u_delay_since_last_RR; /*< delay since last RR record received */
113 } rtcp_stats_t;
114
115 typedef struct {
116     int fd;                 /*< socket descriptor of rtcp stream */
117
118     unsigned int u_count;        /*< packet count */
119     unsigned int u_version;      /*< RTCP version number */
120     unsigned int u_length;       /*< lenght of packet */
121     unsigned int u_payload_type; /*< type of RTCP payload */
122     rtcp_stats_t stats;          /*< RTCP statistics */
123
124     union {
125         rtcp_SR sr;         /*< SR record */
126         rtcp_RR rr;         /*< RR record */
127         rtcp_SDES sdes;     /*< SDES record */
128         rtcp_BYE bye;       /*< BYE record */
129         rtcp_APP app;       /*< APP record */
130     } report;
131
132     /*int (*pf_connect)( void *p_userdata, char *p_server, int i_port );
133     int (*pf_disconnect)( void *p_userdata );
134     int (*pf_read)( void *p_userdata, uint8_t *p_buffer, int i_buffer );
135     int (*pf_write)( void *p_userdata, uint8_t *p_buffer, int i_buffer );*/
136 } rtcp_t;
137
138
139 /**
140  * Decode RTCP packet
141  * Decode incoming RTCP packet and inspect the records types.
142  */
143 int rtcp_decode( vlc_object_t *p_this, rtcp_t *p_rtcp, block_t *p_block );
144 //VLC_EXPORT( int, rtcp_decode, ( rtcp_t *p_rtcp, block_t *p_block ) );
145 block_t *rtcp_encode( vlc_object_t *p_this, int type );
146
147 #endif /* RTCP_H */