00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: mpf_rtp_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef MPF_RTP_DESCRIPTOR_H 00020 #define MPF_RTP_DESCRIPTOR_H 00021 00022 /** 00023 * @file mpf_rtp_descriptor.h 00024 * @brief MPF RTP Stream Descriptor 00025 */ 00026 00027 #include <apr_network_io.h> 00028 #include "apt_string.h" 00029 #include "mpf_stream_descriptor.h" 00030 00031 APT_BEGIN_EXTERN_C 00032 00033 /** RTP media descriptor declaration */ 00034 typedef struct mpf_rtp_media_descriptor_t mpf_rtp_media_descriptor_t; 00035 /** RTP stream descriptor declaration */ 00036 typedef struct mpf_rtp_stream_descriptor_t mpf_rtp_stream_descriptor_t; 00037 /** RTP termination descriptor declaration */ 00038 typedef struct mpf_rtp_termination_descriptor_t mpf_rtp_termination_descriptor_t; 00039 /** RTP configuration declaration */ 00040 typedef struct mpf_rtp_config_t mpf_rtp_config_t; 00041 /** RTP settings declaration */ 00042 typedef struct mpf_rtp_settings_t mpf_rtp_settings_t; 00043 /** Jitter buffer configuration declaration */ 00044 typedef struct mpf_jb_config_t mpf_jb_config_t; 00045 00046 /** MPF media state */ 00047 typedef enum { 00048 MPF_MEDIA_DISABLED, /**< disabled media */ 00049 MPF_MEDIA_ENABLED /**< enabled media */ 00050 } mpf_media_state_e; 00051 00052 /** RTP media (local/remote) descriptor */ 00053 struct mpf_rtp_media_descriptor_t { 00054 /** Media state (disabled/enabled)*/ 00055 mpf_media_state_e state; 00056 /** Ip address */ 00057 apt_str_t ip; 00058 /** External (NAT) Ip address */ 00059 apt_str_t ext_ip; 00060 /** Port */ 00061 apr_port_t port; 00062 /** Stream mode (send/receive) */ 00063 mpf_stream_direction_e direction; 00064 /** Packetization time */ 00065 apr_uint16_t ptime; 00066 /** Codec list */ 00067 mpf_codec_list_t codec_list; 00068 /** Media identifier */ 00069 apr_size_t mid; 00070 /** Position, order in SDP message (0,1,...) */ 00071 apr_size_t id; 00072 }; 00073 00074 /** RTP stream descriptor */ 00075 struct mpf_rtp_stream_descriptor_t { 00076 /** Stream capabilities */ 00077 mpf_stream_capabilities_t *capabilities; 00078 /** Local media descriptor */ 00079 mpf_rtp_media_descriptor_t *local; 00080 /** Remote media descriptor */ 00081 mpf_rtp_media_descriptor_t *remote; 00082 /** Settings loaded from config */ 00083 mpf_rtp_settings_t *settings; 00084 }; 00085 00086 /** RTP termination descriptor */ 00087 struct mpf_rtp_termination_descriptor_t { 00088 /** Audio stream descriptor */ 00089 mpf_rtp_stream_descriptor_t audio; 00090 /** Video stream descriptor */ 00091 mpf_rtp_stream_descriptor_t video; 00092 }; 00093 00094 /** Jitter buffer configuration */ 00095 struct mpf_jb_config_t { 00096 /** Min playout delay in msec (used in case of adaptive jitter buffer) */ 00097 apr_size_t min_playout_delay; 00098 /** Initial playout delay in msec */ 00099 apr_size_t initial_playout_delay; 00100 /** Max playout delay in msec (used in case of adaptive jitter buffer) */ 00101 apr_size_t max_playout_delay; 00102 /** Static - 0, adaptive - 1 jitter buffer */ 00103 apr_byte_t adaptive; 00104 }; 00105 00106 /** RTCP BYE transmission policy */ 00107 typedef enum { 00108 RTCP_BYE_DISABLE, /**< disable RTCP BYE transmission */ 00109 RTCP_BYE_PER_SESSION, /**< transmit RTCP BYE at the end of session */ 00110 RTCP_BYE_PER_TALKSPURT /**< transmit RTCP BYE at the end of each talkspurt (input) */ 00111 } rtcp_bye_policy_e; 00112 00113 /** RTP factory config */ 00114 struct mpf_rtp_config_t { 00115 /** Local IP address to bind to */ 00116 apt_str_t ip; 00117 /** External (NAT) IP address */ 00118 apt_str_t ext_ip; 00119 /** Min RTP port */ 00120 apr_port_t rtp_port_min; 00121 /** Max RTP port */ 00122 apr_port_t rtp_port_max; 00123 /** Current RTP port */ 00124 apr_port_t rtp_port_cur; 00125 }; 00126 00127 /** RTP settings */ 00128 struct mpf_rtp_settings_t { 00129 /** Packetization time */ 00130 apr_uint16_t ptime; 00131 /** Codec list */ 00132 mpf_codec_list_t codec_list; 00133 /** Preference in offer/anwser: 1 - own(local) preference, 0 - remote preference */ 00134 apt_bool_t own_preferrence; 00135 /** Enable/disable RTCP support */ 00136 apt_bool_t rtcp; 00137 /** RTCP BYE policy */ 00138 rtcp_bye_policy_e rtcp_bye_policy; 00139 /** RTCP report transmission interval */ 00140 apr_uint16_t rtcp_tx_interval; 00141 /** RTCP rx resolution (timeout to check for a new RTCP message) */ 00142 apr_uint16_t rtcp_rx_resolution; 00143 /** Jitter buffer config */ 00144 mpf_jb_config_t jb_config; 00145 }; 00146 00147 /** Initialize media descriptor */ 00148 static APR_INLINE void mpf_rtp_media_descriptor_init(mpf_rtp_media_descriptor_t *media) 00149 { 00150 media->state = MPF_MEDIA_DISABLED; 00151 apt_string_reset(&media->ip); 00152 apt_string_reset(&media->ext_ip); 00153 media->port = 0; 00154 media->direction = STREAM_DIRECTION_NONE; 00155 media->ptime = 0; 00156 mpf_codec_list_reset(&media->codec_list); 00157 media->mid = 0; 00158 media->id = 0; 00159 } 00160 00161 /** Initialize stream descriptor */ 00162 static APR_INLINE void mpf_rtp_stream_descriptor_init(mpf_rtp_stream_descriptor_t *descriptor) 00163 { 00164 descriptor->capabilities = NULL; 00165 descriptor->local = NULL; 00166 descriptor->remote = NULL; 00167 } 00168 00169 /** Initialize RTP termination descriptor */ 00170 static APR_INLINE void mpf_rtp_termination_descriptor_init(mpf_rtp_termination_descriptor_t *rtp_descriptor) 00171 { 00172 mpf_rtp_stream_descriptor_init(&rtp_descriptor->audio); 00173 mpf_rtp_stream_descriptor_init(&rtp_descriptor->video); 00174 } 00175 00176 /** Initialize JB config */ 00177 static APR_INLINE void mpf_jb_config_init(mpf_jb_config_t *jb_config) 00178 { 00179 jb_config->adaptive = 0; 00180 jb_config->initial_playout_delay = 0; 00181 jb_config->min_playout_delay = 0; 00182 jb_config->max_playout_delay = 0; 00183 } 00184 00185 /** Allocate RTP config */ 00186 static APR_INLINE mpf_rtp_config_t* mpf_rtp_config_alloc(apr_pool_t *pool) 00187 { 00188 mpf_rtp_config_t *rtp_config = (mpf_rtp_config_t*)apr_palloc(pool,sizeof(mpf_rtp_config_t)); 00189 apt_string_reset(&rtp_config->ip); 00190 apt_string_reset(&rtp_config->ext_ip); 00191 rtp_config->rtp_port_cur = 0; 00192 rtp_config->rtp_port_min = 0; 00193 rtp_config->rtp_port_max = 0; 00194 return rtp_config; 00195 } 00196 00197 /** Allocate RTP settings */ 00198 static APR_INLINE mpf_rtp_settings_t* mpf_rtp_settings_alloc(apr_pool_t *pool) 00199 { 00200 mpf_rtp_settings_t *rtp_settings = (mpf_rtp_settings_t*)apr_palloc(pool,sizeof(mpf_rtp_settings_t)); 00201 rtp_settings->ptime = 0; 00202 mpf_codec_list_init(&rtp_settings->codec_list,0,pool); 00203 rtp_settings->own_preferrence = FALSE; 00204 rtp_settings->rtcp = FALSE; 00205 rtp_settings->rtcp_bye_policy = RTCP_BYE_DISABLE; 00206 rtp_settings->rtcp_tx_interval = 0; 00207 rtp_settings->rtcp_rx_resolution = 0; 00208 mpf_jb_config_init(&rtp_settings->jb_config); 00209 return rtp_settings; 00210 } 00211 00212 00213 APT_END_EXTERN_C 00214 00215 #endif /* MPF_RTP_DESCRIPTOR_H */
1.6.2