Changeset 202

Show
Ignore:
Timestamp:
08/17/99 19:13:47 (15 years ago)
Author:
ucaccsp
Message:

Fixes for the RTP code from Markus Germeier <mager@…>
* time-out and delete sources

  • implements dv_diff
  • fixes tv_diff call in rtp_update

* fixes x-Bit in rtp_send_data
* rtp_send_bye now does send a BYE packet
* rtp_done shuts down the RTP stack and frees

memory and filedescriptors

Location:
common/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • common/trunk/MODS

    r198 r202  
    8585          pick? 
    8686        - Updates to the IPv6 code for the Detexis Musica IPv6 stack 
     87        - Updates to the RTP code from Markus Germeier: time-out and delete sources, 
     88          fix X but in RTP header, add support for sending BYE packets. 
    8789 
    8890Still to do... 
  • common/trunk/src/rtp.c

    r190 r202  
    11/* 
    2  * FILE:   rtp.c 
    3  * AUTHOR: Colin Perkins <c.perkins@cs.ucl.ac.uk> 
     2 * FILE:     rtp.c 
     3 * AUTHOR:   Colin Perkins <c.perkins@cs.ucl.ac.uk> 
     4 * MODIFIED: Orion Hodson <o.hodson@cs.ucl.ac.uk> 
     5 *           Markus Germeier <mager@tzi.de> 
    46 * 
    57 * The routines in this file implement the Real-time Transport Protocol, 
     
    611613static double tv_diff(struct timeval curr_time, struct timeval prev_time) 
    612614{ 
    613         /* Return curr_time - prev_time */ 
    614         UNUSED(curr_time); 
    615         UNUSED(prev_time); 
    616         return 0.0; 
     615    /* Return curr_time - prev_time */ 
     616    double sec; 
     617    double usec; 
     618 
     619    sec = curr_time.tv_sec - prev_time.tv_sec ; 
     620    usec = curr_time.tv_usec - prev_time.tv_usec ; 
     621 
     622    assert(sec >= 0); 
     623    if (usec < 0 ) { 
     624        assert(sec > 0); 
     625        sec--; 
     626        usec += 1000000; 
     627    } 
     628 
     629    return (sec+(usec/1000000)); 
    617630} 
    618631 
     
    12971310        packet->v    = 2; 
    12981311        packet->p    = 0; 
    1299         packet->x    = (extn == NULL); 
     1312        packet->x    = (extn != NULL); 
    13001313        packet->cc   = cc; 
    13011314        packet->m    = m; 
     
    16661679                        /* Expire sources which haven't been heard from for a long time.   */ 
    16671680                        /* Section 6.2.1 of the RTP specification details the timers used. */ 
    1668                         delay = tv_diff(s->last_active, curr_time); 
    1669  
     1681                        delay = tv_diff(curr_time, s->last_active); 
     1682                         
    16701683                        /* Check if we've received a BYE packet from this source.    */ 
    16711684                        /* If we have, and it was received more than 2 seconds ago   */ 
     
    16851698void rtp_send_bye(struct rtp *session) 
    16861699{ 
    1687         UNUSED(session); 
    1688 } 
    1689  
    1690 int rtp_sent_bye(struct rtp *session) 
    1691 { 
    1692         UNUSED(session); 
    1693         return TRUE; 
     1700        /* The function sends an RTCP BYE packet. It should implement BYE reconsideration, */ 
     1701        /* at present it either: a) sends a BYE packet immediately (if there are less than */ 
     1702        /* 50 members in the group), or b) returns without sending a BYE (if there are 50  */ 
     1703        /* or more members). See draft-ietf-avt-rtp-new-01.txt (section 6.3.7).            */ 
     1704        u_int8   buffer[RTP_MAX_PACKET_LEN]; 
     1705        u_int8  *ptr = buffer; 
     1706        rtcp_common     *common; 
     1707 
     1708        if (session->ssrc_count < 50) { 
     1709                ptr = format_rtcp_rr(ptr, RTP_MAX_PACKET_LEN - (ptr - buffer), session);     
     1710                common = (rtcp_common *) ptr; 
     1711                 
     1712                common->version = 2; 
     1713                common->p       = 0; 
     1714                common->count   = 1; 
     1715                common->pt      = RTCP_BYE; 
     1716                common->length  = ntohs(1); 
     1717                ptr += sizeof(common); 
     1718                 
     1719                *((u_int32 *) ptr) = htonl(session->my_ssrc);   
     1720                ptr += sizeof(session->my_ssrc);  
     1721                 
     1722                udp_send(session->rtcp_socket, buffer, ptr - buffer); 
     1723        } 
    16941724} 
    16951725 
    16961726void rtp_done(struct rtp *session) 
    16971727{ 
    1698         UNUSED(session); 
    1699 } 
    1700  
     1728        int i ; 
     1729 
     1730        for (i = 0; i < RTP_DB_SIZE; i++) { 
     1731        if (session->db[i] != NULL) { 
     1732            if (session->db[i]->ssrc != session->my_ssrc) { 
     1733                delete_source(session,session->db[i]->ssrc);         
     1734            } 
     1735        } 
     1736        } 
     1737        delete_source(session, session->my_ssrc); 
     1738 
     1739        udp_exit(session->rtp_socket); 
     1740        udp_exit(session->rtcp_socket); 
     1741        xfree(session); 
     1742} 
     1743 
  • common/trunk/src/rtp.h

    r84 r202  
    149149rtcp_rr         *rtp_get_rr(struct rtp *session, u_int32 reporter, u_int32 reportee); 
    150150void             rtp_send_bye(struct rtp *session); 
    151 int              rtp_sent_bye(struct rtp *session); 
    152151void             rtp_done(struct rtp *session); 
    153152