UniMRCP  1.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mpf_rtp_descriptor.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_rtp_descriptor.h 2136 2014-07-04 06:33:36Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MPF_RTP_DESCRIPTOR_H
20 #define MPF_RTP_DESCRIPTOR_H
21 
22 /**
23  * @file mpf_rtp_descriptor.h
24  * @brief MPF RTP Stream Descriptor
25  */
26 
27 #include <apr_network_io.h>
28 #include "apt_string.h"
29 #include "mpf_stream_descriptor.h"
30 
32 
33 /** RTP media descriptor declaration */
35 /** RTP stream descriptor declaration */
37 /** RTP termination descriptor declaration */
39 /** RTP configuration declaration */
41 /** RTP settings declaration */
43 /** Jitter buffer configuration declaration */
45 
46 /** MPF media state */
47 typedef enum {
48  MPF_MEDIA_DISABLED, /**< disabled media */
49  MPF_MEDIA_ENABLED /**< enabled media */
51 
52 /** RTP media (local/remote) descriptor */
54  /** Media state (disabled/enabled)*/
56  /** Ip address */
58  /** External (NAT) Ip address */
60  /** Port */
61  apr_port_t port;
62  /** Stream mode (send/receive) */
64  /** Packetization time */
65  apr_uint16_t ptime;
66  /** Codec list */
68  /** Media identifier */
69  apr_size_t mid;
70  /** Position, order in SDP message (0,1,...) */
71  apr_size_t id;
72 };
73 
74 /** RTP stream descriptor */
76  /** Stream capabilities */
78  /** Local media descriptor */
80  /** Remote media descriptor */
82  /** Settings loaded from config */
84 };
85 
86 /** RTP termination descriptor */
88  /** Audio stream descriptor */
90  /** Video stream descriptor */
92 };
93 
94 /** Jitter buffer configuration */
96  /** Min playout delay in msec */
97  apr_uint32_t min_playout_delay;
98  /** Initial playout delay in msec */
99  apr_uint32_t initial_playout_delay;
100  /** Max playout delay in msec */
101  apr_uint32_t max_playout_delay;
102  /** Mode of operation of the jitter buffer: static - 0, adaptive - 1 */
103  apr_byte_t adaptive;
104  /** Enable/disable time skew detection */
106 };
107 
108 /** RTCP BYE transmission policy */
109 typedef enum {
110  RTCP_BYE_DISABLE, /**< disable RTCP BYE transmission */
111  RTCP_BYE_PER_SESSION, /**< transmit RTCP BYE at the end of session */
112  RTCP_BYE_PER_TALKSPURT /**< transmit RTCP BYE at the end of each talkspurt (input) */
114 
115 /** RTP factory config */
117  /** Local IP address to bind to */
119  /** External (NAT) IP address */
121  /** Min RTP port */
122  apr_port_t rtp_port_min;
123  /** Max RTP port */
124  apr_port_t rtp_port_max;
125  /** Current RTP port */
126  apr_port_t rtp_port_cur;
127 };
128 
129 /** RTP settings */
131  /** Packetization time */
132  apr_uint16_t ptime;
133  /** Codec list */
135  /** Preference in offer/anwser: 1 - own(local) preference, 0 - remote preference */
137  /** Enable/disable RTCP support */
139  /** RTCP BYE policy */
141  /** RTCP report transmission interval */
142  apr_uint16_t rtcp_tx_interval;
143  /** RTCP rx resolution (timeout to check for a new RTCP message) */
144  apr_uint16_t rtcp_rx_resolution;
145  /** Jitter buffer config */
147 };
148 
149 /** Initialize media descriptor */
150 static APR_INLINE void mpf_rtp_media_descriptor_init(mpf_rtp_media_descriptor_t *media)
151 {
152  media->state = MPF_MEDIA_DISABLED;
153  apt_string_reset(&media->ip);
154  apt_string_reset(&media->ext_ip);
155  media->port = 0;
157  media->ptime = 0;
158  mpf_codec_list_reset(&media->codec_list);
159  media->mid = 0;
160  media->id = 0;
161 }
162 
163 /** Initialize stream descriptor */
164 static APR_INLINE void mpf_rtp_stream_descriptor_init(mpf_rtp_stream_descriptor_t *descriptor)
165 {
166  descriptor->capabilities = NULL;
167  descriptor->local = NULL;
168  descriptor->remote = NULL;
169  descriptor->settings = NULL;
170 }
171 
172 /** Initialize RTP termination descriptor */
173 static APR_INLINE void mpf_rtp_termination_descriptor_init(mpf_rtp_termination_descriptor_t *rtp_descriptor)
174 {
175  mpf_rtp_stream_descriptor_init(&rtp_descriptor->audio);
176  mpf_rtp_stream_descriptor_init(&rtp_descriptor->video);
177 }
178 
179 /** Initialize JB config */
180 static APR_INLINE void mpf_jb_config_init(mpf_jb_config_t *jb_config)
181 {
182  jb_config->adaptive = 0;
183  jb_config->initial_playout_delay = 0;
184  jb_config->min_playout_delay = 0;
185  jb_config->max_playout_delay = 0;
186  jb_config->time_skew_detection = 1;
187 }
188 
189 /** Allocate RTP config */
190 static APR_INLINE mpf_rtp_config_t* mpf_rtp_config_alloc(apr_pool_t *pool)
191 {
192  mpf_rtp_config_t *rtp_config = (mpf_rtp_config_t*)apr_palloc(pool,sizeof(mpf_rtp_config_t));
193  apt_string_reset(&rtp_config->ip);
194  apt_string_reset(&rtp_config->ext_ip);
195  rtp_config->rtp_port_cur = 0;
196  rtp_config->rtp_port_min = 0;
197  rtp_config->rtp_port_max = 0;
198  return rtp_config;
199 }
200 
201 /** Allocate RTP settings */
202 static APR_INLINE mpf_rtp_settings_t* mpf_rtp_settings_alloc(apr_pool_t *pool)
203 {
204  mpf_rtp_settings_t *rtp_settings = (mpf_rtp_settings_t*)apr_palloc(pool,sizeof(mpf_rtp_settings_t));
205  rtp_settings->ptime = 0;
206  mpf_codec_list_init(&rtp_settings->codec_list,0,pool);
207  rtp_settings->own_preferrence = FALSE;
208  rtp_settings->rtcp = FALSE;
209  rtp_settings->rtcp_bye_policy = RTCP_BYE_DISABLE;
210  rtp_settings->rtcp_tx_interval = 0;
211  rtp_settings->rtcp_rx_resolution = 0;
212  mpf_jb_config_init(&rtp_settings->jb_config);
213  return rtp_settings;
214 }
215 
216 
218 
219 #endif /* MPF_RTP_DESCRIPTOR_H */