Changeset a5a265ad837cfcff4f231f1cf2c7d692577f75af

Show
Ignore:
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
  • modules/mux/rtp/rtcp.c

    r4d243c1 ra5a265a  
    22 * rtcp.c: RTP/RTCP source file 
    33 ***************************************************************************** 
    4  * Copyright (C) 2005 M2X 
     4 * Copyright (C) 2005-2007 M2X 
    55 * 
    66 * $Id$ 
     
    3434#include "rtcp.h" 
    3535 
    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 
     36void send_RTCP( vlc_object_t *p_this, rtcp_event_t ); 
     37void rtcp_schedule( vlc_object_t *p_this, mtime_t, rtcp_event_t ); 
    4538 
    4639/* SDES support functions */ 
     
    5144    p_item = (rtcp_SDES_item_t *) malloc( sizeof( rtcp_SDES_item_t ) ); 
    5245    if( !p_item ) 
    53         return VLC_EGENERIC
     46        return VLC_ENOMEM
    5447    p_item->u_type = i_item; 
    5548    p_item->psz_data = strdup( psz_name ); 
     
    8477    p_client = (rtcp_client_t*) malloc( sizeof(rtcp_client_t) ); 
    8578    if( !p_client ) 
    86         return VLC_EGENERIC
     79        return VLC_ENOMEM
    8780    p_client->i_index = p_rtcp->i_clients + 1; 
    8881    p_client->b_deleted = VLC_FALSE; 
     
    110103                           p_rtcp->i_next_date; 
    111104        p_rtcp->u_clients--; 
     105        /* BYE message is sent by rtcp_destroy_client() */ 
    112106    } 
    113107    vlc_mutex_unlock( &p_rtcp->object_lock ); 
     
    139133} 
    140134 
     135/* Close communication with clients and release allocated objects */ 
     136int 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 
    141168/*  rtcp_find_client should be called with the object lock held. 
    142169 *  vlc_mutex_lock( &p_rtcp->obj_lock ); 
     
    163190 *-------------------------------------------------------------------------- 
    164191 */ 
    165 uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, 
     192uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, uint32_t u_ssrc, 
    166193                        vlc_bool_t b_sender, vlc_bool_t b_first ) 
    167194{ 
     
    175202    int n = p_rtcp->i_clients; 
    176203 
    177     int u_ssrc = 0; /* FIXME: how to know which client we look for?? */ 
    178      
    179204    if( b_first ) 
    180205        i_rtcp_min = (i_rtcp_min >> 1); 
     
    195220    /* calculate average time between reports */ 
    196221    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; 
    199224         
    200225    i_interval = p_client->p_stats->u_avg_pkt_size * ( n / i_bandwidth ); 
     
    211236 *-------------------------------------------------------------------------- 
    212237 */ 
    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; 
     238void 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; 
    218243    rtcp_stats_t *p_stats = NULL; 
    219244    mtime_t i_interval = 0; 
    220245    uint32_t i_pos = 0; 
    221246 
    222     int u_ssrc = 0; /* FIXME: how to know which client we look for?? */ 
    223  
    224247    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; 
    227250    p_stats = (rtcp_stats_t*) p_client->p_stats; 
    228251    i_interval = (mtime_t) rtcp_interval( p_this, u_bandwidth, 
    229                                           b_sender, *b_first ); 
     252                                          u_ssrc, b_sender, *b_first ); 
    230253    p_rtcp->i_next_date = p_rtcp->i_last_date + i_interval; 
    231254 
     
    255278                p_rtcp->i_last_date = p_rtcp->i_date; 
    256279                i_interval = rtcp_interval( p_this, u_bandwidth, 
    257                                             b_sender, *b_first ); 
     280                                            u_ssrc, b_sender, *b_first ); 
    258281                rtcp_schedule( p_this, p_rtcp->i_next_date + i_interval, rtcp_event ); 
    259282                *b_first = VLC_FALSE; 
     
    9901013    uint32_t i_count = strlen( psz_reason ); 
    9911014    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; 
    9931016 
    9941017    if( p_pkt->u_payload_type != RTCP_BYE ) 
     
    10131036    //FIXME: bs_write( s, 8, p_item->u_type ); 
    10141037    bs_write( s, 8, u_octet ); 
    1015  
     1038     
    10161039    for( i_pos = 0; i_pos < i_count; i_pos++ ) 
    10171040    { 
  • modules/mux/rtp/rtcp.h

    r4d243c1 ra5a265a  
    22 * rtcp.h: RTP/RTCP headerfile 
    33 ***************************************************************************** 
    4  * Copyright (C) 2005 M2X 
     4 * Copyright (C) 2005-2007 M2X 
    55 * 
    66 * $Id$ 
     
    145145typedef struct rtcp_client_t 
    146146{ 
     147    int fd;                        /*< socket descriptor of rtcp stream */ 
     148 
    147149    uint32_t    i_index; 
    148150    uint32_t    u_ssrc;            /*< channel name */ 
     
    166168    VLC_COMMON_MEMBERS 
    167169 
    168     int fd;                        /*< socket descriptor of rtcp stream */ 
    169  
    170170    uint32_t u_clients;            /*< number of clients connected */ 
    171171    uint32_t u_active;             /*< number of active senders */ 
     
    183183    bs_t    *bs;                   /*< bitstream decoding data pointer */ 
    184184 
     185    /* functions */ 
    185186    int (*pf_add_client)( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos ); 
    186187    int (*pf_del_client)( vlc_object_t *p_this, uint32_t u_ssrc ); 
    187188    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 ); 
    189191} rtcp_t; 
    190192 
     
    193195/* Should be called with vlc_mutex_lock( &p_this->objec_lock ) held */ 
    194196int rtcp_find_client( vlc_object_t *p_this, uint32_t u_ssrc, uint32_t *i_pos ); 
    195  
     197int rtcp_cleanup_clients( vlc_object_t *p_this ); 
     198int rtcp_destroy_clients( vlc_object_t *p_this ); 
    196199 
    197200/** 
     
    222225 * rtcp_pkt_new - Encode RTCP packet 
    223226 * Create a new RTCP packet of type 'type' 
    224  * Arguments 
     227 * Arguments: 
    225228 * \param type  type of RTCP packet @see 
    226229 */ 
     
    241244 * \param p_this        VLC_OBJECT of type rtcp_t 
    242245 * \param u_bandwith    bandwidth of RTP connection 
     246 * \param u_ssrc        client to sent or receive from 
    243247 * \param b_sender      are we the sender or the receiver 
    244248 * \param b_first       the first time this function is called use only half 
    245249 *                      of the initial waiting time 
    246250 */ 
    247 uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, 
     251uint64_t rtcp_interval( vlc_object_t *p_this, uint64_t u_bandwidth, uint32_t u_ssrc, 
    248252                        vlc_bool_t b_sender, vlc_bool_t b_first ); 
    249253 
     
    251255 * rtcp_expire 
    252256 * Decides to sent an RTCP report or a BYE record 
     257 * Arguments: 
    253258 * \param p_this        VLC_OBJECT of type rtcp_t 
    254259 * \param u_bandwith    bandwidth of RTP connection 
     260 * \param u_ssrc        client to sent or receive from 
    255261 * \param rtcp_event    type of event received 
    256262 * \param b_sender      are we the sender or the receiver 
     
    259265 *                      it will return *b_first = VLC_FALSE; 
    260266 */ 
    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 ); 
     267void 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 ); 
    263269 
    264270/** 
     
    266272 * Determine what to do on the received Sender Report, decode it 
    267273 * or leave the channel (BYE record). 
     274 * Arguments: 
    268275 * \param p_this        VLC_OBJECT of type rtcp_t 
    269276 * \param p_pkt         RTCP packet that was received