Changeset a5a265ad837cfcff4f231f1cf2c7d692577f75af
- Timestamp:
- 04/29/07 11:22:04
(1 year ago)
- Author:
- Jean-Paul Saman <jpsaman@videolan.org>
- git-committer:
- Jean-Paul Saman <jpsaman@videolan.org> 1177838524 +0000
- git-parent:
[1e9bb01789991135c548aff9deae9db9c2f3b63c]
- git-author:
- Jean-Paul Saman <jpsaman@videolan.org> 1177838524 +0000
- Message:
Numerous compile fixes.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r4d243c1 |
ra5a265a |
|
| 2 | 2 | * rtcp.c: RTP/RTCP source file |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2005 M2X |
|---|
| | 4 | * Copyright (C) 2005-2007 M2X |
|---|
| 5 | 5 | * |
|---|
| 6 | 6 | * $Id$ |
|---|
| … | … | |
| 34 | 34 | #include "rtcp.h" |
|---|
| 35 | 35 | |
|---|
| 36 | | static void send_RTCP( vlc_object_t *p_this, rtcp_event_t rtcp_event ) |
|---|
| 37 | | { |
|---|
| 38 | | /* FIXME: higher level functions that should be in another file */ |
|---|
| 39 | | } |
|---|
| 40 | | |
|---|
| 41 | | static void rtcp_schedule( vlc_object_t *p_this, uint64_t i_sched, rtcp_event_t rtcp_event ) |
|---|
| 42 | | { |
|---|
| 43 | | /* FIXME: higher level functions that should be in another file */ |
|---|
| 44 | | } |
|---|
| | 36 | void send_RTCP( vlc_object_t *p_this, rtcp_event_t ); |
|---|
| | 37 | void rtcp_schedule( vlc_object_t *p_this, mtime_t, rtcp_event_t ); |
|---|
| 45 | 38 | |
|---|
| 46 | 39 | /* SDES support functions */ |
|---|
| … | … | |
| 51 | 44 | p_item = (rtcp_SDES_item_t *) malloc( sizeof( rtcp_SDES_item_t ) ); |
|---|
| 52 | 45 | if( !p_item ) |
|---|
| 53 | | return VLC_EGENERIC; |
|---|
| | 46 | return VLC_ENOMEM; |
|---|
| 54 | 47 | p_item->u_type = i_item; |
|---|
| 55 | 48 | p_item->psz_data = strdup( psz_name ); |
|---|
| … | … | |
| 84 | 77 | p_client = (rtcp_client_t*) malloc( sizeof(rtcp_client_t) ); |
|---|
| 85 | 78 | if( !p_client ) |
|---|
| 86 | | return VLC_EGENERIC; |
|---|
| | 79 | return VLC_ENOMEM; |
|---|
| 87 | 80 | p_client->i_index = p_rtcp->i_clients + 1; |
|---|
| 88 | 81 | p_client->b_deleted = VLC_FALSE; |
|---|
| … | … | |
| 110 | 103 | p_rtcp->i_next_date; |
|---|
| 111 | 104 | p_rtcp->u_clients--; |
|---|
| | 105 | /* BYE message is sent by rtcp_destroy_client() */ |
|---|
| 112 | 106 | } |
|---|
| 113 | 107 | vlc_mutex_unlock( &p_rtcp->object_lock ); |
|---|
| … | … | |
| 139 | 133 | } |
|---|
| 140 | 134 | |
|---|
| | 135 | /* Close communication with clients and release allocated objects */ |
|---|
| | 136 | int rtcp_destroy_clients( vlc_object_t *p_this ) |
|---|
| | 137 | { |
|---|
| | 138 | rtcp_t *p_rtcp = (rtcp_t *) p_this; |
|---|
| | 139 | uint32_t i = 0; |
|---|
| | 140 | |
|---|
| | 141 | for( i=0; i < p_rtcp->i_clients; i++ ) |
|---|
| | 142 | { |
|---|
| | 143 | rtcp_pkt_t *pkt = NULL; |
|---|
| | 144 | rtcp_client_t *p_old = p_rtcp->pp_clients[i]; |
|---|
| | 145 | |
|---|
| | 146 | p_rtcp->pf_del_client( p_this, p_old->u_ssrc ); |
|---|
| | 147 | pkt = rtcp_pkt_new( p_this, RTCP_BYE ); |
|---|
| | 148 | if( pkt ) |
|---|
| | 149 | { |
|---|
| | 150 | block_t *p_block = NULL; |
|---|
| | 151 | p_block = rtcp_encode_BYE( p_this, pkt, strdup("server is leaving") ); |
|---|
| | 152 | /* FIXME: |
|---|
| | 153 | * if( p_block ) |
|---|
| | 154 | * send_RTCP( p_this, p_block ); |
|---|
| | 155 | */ |
|---|
| | 156 | } |
|---|
| | 157 | |
|---|
| | 158 | } |
|---|
| | 159 | /* wait till all clients have been signalled */ |
|---|
| | 160 | while( p_rtcp->i_clients != 0 ) |
|---|
| | 161 | { |
|---|
| | 162 | p_rtcp->pf_cleanup_clients( p_this ); |
|---|
| | 163 | msleep( 500 ); |
|---|
| | 164 | } |
|---|
| | 165 | return VLC_SUCCESS; |
|---|
| | 166 | } |
|---|
| | 167 | |
|---|
| 141 | 168 | /* rtcp_find_client should be called with the object lock held. |
|---|
| 142 | 169 | * vlc_mutex_lock( &p_rtcp->obj_lock ); |
|---|
| … | … | |
| 163 | 190 | *-------------------------------------------------------------------------- |
|---|
| 164 | 191 | */ |
|---|
| 165 | | uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, |
|---|
| | 192 | uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, uint32_t u_ssrc, |
|---|
| 166 | 193 | vlc_bool_t b_sender, vlc_bool_t b_first ) |
|---|
| 167 | 194 | { |
|---|
| … | … | |
| 175 | 202 | int n = p_rtcp->i_clients; |
|---|
| 176 | 203 | |
|---|
| 177 | | int u_ssrc = 0; /* FIXME: how to know which client we look for?? */ |
|---|
| 178 | | |
|---|
| 179 | 204 | if( b_first ) |
|---|
| 180 | 205 | i_rtcp_min = (i_rtcp_min >> 1); |
|---|
| … | … | |
| 195 | 220 | /* calculate average time between reports */ |
|---|
| 196 | 221 | p_client = p_rtcp->pf_find_client( p_this, u_ssrc, &i_pos ); |
|---|
| 197 | | if( !p_client ) |
|---|
| 198 | | return -1; |
|---|
| | 222 | if( !p_client ) |
|---|
| | 223 | return -1; |
|---|
| 199 | 224 | |
|---|
| 200 | 225 | i_interval = p_client->p_stats->u_avg_pkt_size * ( n / i_bandwidth ); |
|---|
| … | … | |
| 211 | 236 | *-------------------------------------------------------------------------- |
|---|
| 212 | 237 | */ |
|---|
| 213 | | void rtcp_expire( vlc_object_t *p_this, rtcp_event_t rtcp_event, |
|---|
| 214 | | uint64_t u_bandwidth, vlc_bool_t b_sender, vlc_bool_t *b_first ) |
|---|
| 215 | | { |
|---|
| 216 | | rtcp_t *p_rtcp = (rtcp_t *) p_this; |
|---|
| 217 | | rtcp_client_t *p_client = NULL; |
|---|
| | 238 | void rtcp_expire( vlc_object_t *p_this, rtcp_event_t rtcp_event, uint64_t u_bandwidth, |
|---|
| | 239 | uint32_t u_ssrc, vlc_bool_t b_sender, vlc_bool_t *b_first ) |
|---|
| | 240 | { |
|---|
| | 241 | rtcp_t *p_rtcp = (rtcp_t *) p_this; |
|---|
| | 242 | rtcp_client_t *p_client = NULL; |
|---|
| 218 | 243 | rtcp_stats_t *p_stats = NULL; |
|---|
| 219 | 244 | mtime_t i_interval = 0; |
|---|
| 220 | 245 | uint32_t i_pos = 0; |
|---|
| 221 | 246 | |
|---|
| 222 | | int u_ssrc = 0; /* FIXME: how to know which client we look for?? */ |
|---|
| 223 | | |
|---|
| 224 | 247 | p_client = p_rtcp->pf_find_client( p_this, u_ssrc, &i_pos ); |
|---|
| 225 | | if( !p_client ) |
|---|
| 226 | | return; |
|---|
| | 248 | if( !p_client ) |
|---|
| | 249 | return; |
|---|
| 227 | 250 | p_stats = (rtcp_stats_t*) p_client->p_stats; |
|---|
| 228 | 251 | i_interval = (mtime_t) rtcp_interval( p_this, u_bandwidth, |
|---|
| 229 | | b_sender, *b_first ); |
|---|
| | 252 | u_ssrc, b_sender, *b_first ); |
|---|
| 230 | 253 | p_rtcp->i_next_date = p_rtcp->i_last_date + i_interval; |
|---|
| 231 | 254 | |
|---|
| … | … | |
| 255 | 278 | p_rtcp->i_last_date = p_rtcp->i_date; |
|---|
| 256 | 279 | i_interval = rtcp_interval( p_this, u_bandwidth, |
|---|
| 257 | | b_sender, *b_first ); |
|---|
| | 280 | u_ssrc, b_sender, *b_first ); |
|---|
| 258 | 281 | rtcp_schedule( p_this, p_rtcp->i_next_date + i_interval, rtcp_event ); |
|---|
| 259 | 282 | *b_first = VLC_FALSE; |
|---|
| … | … | |
| 990 | 1013 | uint32_t i_count = strlen( psz_reason ); |
|---|
| 991 | 1014 | uint8_t u_octet = i_count / 8; /* Octect count ??*/ |
|---|
| 992 | | uint32_t i_pos, i_pad, i_padding; |
|---|
| | 1015 | int32_t i_pos, i_pad, i_padding; |
|---|
| 993 | 1016 | |
|---|
| 994 | 1017 | if( p_pkt->u_payload_type != RTCP_BYE ) |
|---|
| … | … | |
| 1013 | 1036 | //FIXME: bs_write( s, 8, p_item->u_type ); |
|---|
| 1014 | 1037 | bs_write( s, 8, u_octet ); |
|---|
| 1015 | | |
|---|
| | 1038 | |
|---|
| 1016 | 1039 | for( i_pos = 0; i_pos < i_count; i_pos++ ) |
|---|
| 1017 | 1040 | { |
|---|
| r4d243c1 |
ra5a265a |
|
| 2 | 2 | * rtcp.h: RTP/RTCP headerfile |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | | * Copyright (C) 2005 M2X |
|---|
| | 4 | * Copyright (C) 2005-2007 M2X |
|---|
| 5 | 5 | * |
|---|
| 6 | 6 | * $Id$ |
|---|
| … | … | |
| 145 | 145 | typedef struct rtcp_client_t |
|---|
| 146 | 146 | { |
|---|
| | 147 | int fd; /*< socket descriptor of rtcp stream */ |
|---|
| | 148 | |
|---|
| 147 | 149 | uint32_t i_index; |
|---|
| 148 | 150 | uint32_t u_ssrc; /*< channel name */ |
|---|
| … | … | |
| 166 | 168 | VLC_COMMON_MEMBERS |
|---|
| 167 | 169 | |
|---|
| 168 | | int fd; /*< socket descriptor of rtcp stream */ |
|---|
| 169 | | |
|---|
| 170 | 170 | uint32_t u_clients; /*< number of clients connected */ |
|---|
| 171 | 171 | uint32_t u_active; /*< number of active senders */ |
|---|
| … | … | |
| 183 | 183 | bs_t *bs; /*< bitstream decoding data pointer */ |
|---|
| 184 | 184 | |
|---|
| | 185 | /* functions */ |
|---|
| 185 | 186 | int (*pf_add_client)( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos ); |
|---|
| 186 | 187 | int (*pf_del_client)( vlc_object_t *p_this, uint32_t u_ssrc ); |
|---|
| 187 | 188 | int (*pf_find_client)( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos ); |
|---|
| 188 | | |
|---|
| | 189 | int (*pf_cleanup_clients)( vlc_object_t *p_this ); |
|---|
| | 190 | int (*pf_destroy_clients)( vlc_object_t *p_this ); |
|---|
| 189 | 191 | } rtcp_t; |
|---|
| 190 | 192 | |
|---|
| … | … | |
| 193 | 195 | /* Should be called with vlc_mutex_lock( &p_this->objec_lock ) held */ |
|---|
| 194 | 196 | int rtcp_find_client( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos ); |
|---|
| 195 | | |
|---|
| | 197 | int rtcp_cleanup_clients( vlc_object_t *p_this ); |
|---|
| | 198 | int rtcp_destroy_clients( vlc_object_t *p_this ); |
|---|
| 196 | 199 | |
|---|
| 197 | 200 | /** |
|---|
| … | … | |
| 222 | 225 | * rtcp_pkt_new - Encode RTCP packet |
|---|
| 223 | 226 | * Create a new RTCP packet of type 'type' |
|---|
| 224 | | * Arguments |
|---|
| | 227 | * Arguments: |
|---|
| 225 | 228 | * \param type type of RTCP packet @see |
|---|
| 226 | 229 | */ |
|---|
| … | … | |
| 241 | 244 | * \param p_this VLC_OBJECT of type rtcp_t |
|---|
| 242 | 245 | * \param u_bandwith bandwidth of RTP connection |
|---|
| | 246 | * \param u_ssrc client to sent or receive from |
|---|
| 243 | 247 | * \param b_sender are we the sender or the receiver |
|---|
| 244 | 248 | * \param b_first the first time this function is called use only half |
|---|
| 245 | 249 | * of the initial waiting time |
|---|
| 246 | 250 | */ |
|---|
| 247 | | uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, |
|---|
| | 251 | uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, uint32_t u_ssrc, |
|---|
| 248 | 252 | vlc_bool_t b_sender, vlc_bool_t b_first ); |
|---|
| 249 | 253 | |
|---|
| … | … | |
| 251 | 255 | * rtcp_expire |
|---|
| 252 | 256 | * Decides to sent an RTCP report or a BYE record |
|---|
| | 257 | * Arguments: |
|---|
| 253 | 258 | * \param p_this VLC_OBJECT of type rtcp_t |
|---|
| 254 | 259 | * \param u_bandwith bandwidth of RTP connection |
|---|
| | 260 | * \param u_ssrc client to sent or receive from |
|---|
| 255 | 261 | * \param rtcp_event type of event received |
|---|
| 256 | 262 | * \param b_sender are we the sender or the receiver |
|---|
| … | … | |
| 259 | 265 | * it will return *b_first = VLC_FALSE; |
|---|
| 260 | 266 | */ |
|---|
| 261 | | void rtcp_expire( vlc_object_t *p_this, rtcp_event_t rtcp_event, |
|---|
| 262 | | uint64_t u_bandwidth, vlc_bool_t b_sender, vlc_bool_t *b_first ); |
|---|
| | 267 | void rtcp_expire( vlc_object_t *p_this, rtcp_event_t rtcp_event, uint64_t u_bandwidth, |
|---|
| | 268 | uint32_t u_ssrc, vlc_bool_t b_sender, vlc_bool_t *b_first ); |
|---|
| 263 | 269 | |
|---|
| 264 | 270 | /** |
|---|
| … | … | |
| 266 | 272 | * Determine what to do on the received Sender Report, decode it |
|---|
| 267 | 273 | * or leave the channel (BYE record). |
|---|
| | 274 | * Arguments: |
|---|
| 268 | 275 | * \param p_this VLC_OBJECT of type rtcp_t |
|---|
| 269 | 276 | * \param p_pkt RTCP packet that was received |
|---|