Changeset 24d0946f7a13ab7ee7f5c41fcf374f677bb6fd89

Show
Ignore:
Timestamp:
07/06/08 17:02:30 (6 months ago)
Author:
Rémi Denis-Courmont <rdenis@simphalempin.com>
git-committer:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1212850950 +0300
git-parent:

[be0a4188843b2cb1ab4b68a7bd08d78e178a5a21]

git-author:
Rémi Denis-Courmont <rdenis@simphalempin.com> 1212848629 +0300
Message:

RTP: support for DCCP

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/rtp.c

    rbe0a418 r24d0946  
    3232#include <vlc_aout.h> 
    3333#include <vlc_network.h> 
     34#ifdef HAVE_POLL 
     35# include <poll.h> 
     36#endif 
    3437#include <vlc_plugin.h> 
    3538 
     
    8992        change_integer_range (0, 32767); 
    9093 
     94    add_shortcut ("dccp"); 
    9195    add_shortcut ("rtp"); 
    9296    add_shortcut ("udplite"); 
     
    125129    int tp; /* transport protocol */ 
    126130 
     131    if (!strcmp (demux->psz_access, "dccp")) 
     132        tp = IPPROTO_DCCP; 
     133    else 
    127134    if (!strcmp (demux->psz_access, "rtp")) 
    128135        tp = IPPROTO_UDP; 
     
    151158 
    152159    /* Try to connect */ 
    153     int fd = net_OpenDgram (obj, dhost, dport, shost, sport, AF_UNSPEC, tp); 
     160    int fd = -1; 
     161 
     162    switch (tp) 
     163    { 
     164        case IPPROTO_UDP: 
     165        case IPPROTO_UDPLITE: 
     166            fd = net_OpenDgram (obj, dhost, dport, shost, sport, AF_UNSPEC, 
     167                                tp); 
     168            break; 
     169 
     170         case IPPROTO_DCCP: 
     171#ifndef SOCK_DCCP /* provisional API (FIXME) */ 
     172# ifdef __linux__ 
     173#  define SOCK_DCCP 6 
     174# endif 
     175#endif 
     176#ifdef SOCK_DCCP 
     177            var_Create (obj, "dccp-service", VLC_VAR_STRING); 
     178            var_SetString (obj, "dccp-service", "RTPV"); 
     179            fd = net_Connect (obj, shost, sport, SOCK_DCCP, tp); 
     180#else 
     181            msg_Err (obj, "DCCP support not included"); 
     182#endif 
     183            break; 
     184    } 
     185 
    154186    free (tmp); 
    155187    if (fd == -1) 
     
    266298 
    267299/** 
    268  * Gets a datagram from the network 
     300 * Checks if a file descriptor is hung up. 
     301 */ 
     302static bool fd_dead (int fd) 
     303
     304    struct pollfd ufd = { .fd = fd, }; 
     305 
     306    return (poll (&ufd, 1, 0) == 1) && (ufd.revents & POLLHUP); 
     307
     308 
     309 
     310/** 
     311 * Gets a datagram from the network, or NULL in case of fatal error. 
    269312 */ 
    270313static block_t *rtp_dgram_recv (demux_t *demux, int fd) 
    271314{ 
    272315    block_t *block = block_Alloc (0xffff); 
    273  
    274     ssize_t len = net_Read (VLC_OBJECT (demux), fd, NULL, 
    275                             block->p_buffer, block->i_buffer, false); 
    276     if (len == -1) 
    277     { 
    278         block_Release (block); 
    279         return NULL; 
    280     } 
     316    ssize_t len; 
     317 
     318    do 
     319    { 
     320        len = net_Read (VLC_OBJECT (demux), fd, NULL, 
     321                                block->p_buffer, block->i_buffer, false); 
     322        if (((len <= 0) && fd_dead (fd)) 
     323         || demux->b_die) 
     324        { 
     325            block_Release (block); 
     326            return NULL; 
     327        } 
     328    } 
     329    while (len == -1); 
     330 
    281331    return block_Realloc (block, 0, len); 
    282332} 
     
    471521    block = rtp_dgram_recv (demux, p_sys->fd); 
    472522    if (!block) 
    473         return 1
     523        return 0
    474524 
    475525    if (block->i_buffer < 2)