Changeset bd056290df9e85c7534862a31e2e62fa5b6c3c73

Show
Ignore:
Timestamp:
02/27/07 22:15:49 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1172610949 +0000
git-parent:

[c28624748ceb2bcc6d33d2a569a4f1b826ff2e8d]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1172610949 +0000
Message:

- Support for customizing the checksum coverage
- Make UDP-Lite an option rather than a distinct shortcut

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access_output/udp.c

    r4551908 rbd05629  
    106106#define AUTO_MCAST_LONGTEXT N_("Allocates an outbound multicast address " \ 
    107107                               "automatically.") 
     108#define UDPLITE_TEXT N_("UDP-Lite") 
     109#define UDPLITE_LONGTEXT N_("Use UDP-Lite/IP instead of normal UDP/IP") 
     110#define CSCOV_TEXT N_("Checksum coverage") 
     111#define CSCOV_LONGTEXT N_("Payload bytes covered by layer-4 checksum") 
    108112 
    109113vlc_module_begin(); 
     
    120124    add_bool( SOUT_CFG_PREFIX "auto-mcast", 0, NULL, AUTO_MCAST_TEXT, 
    121125              AUTO_MCAST_LONGTEXT, VLC_TRUE ); 
     126    add_bool( SOUT_CFG_PREFIX "udplite", 0, NULL, UDPLITE_TEXT, UDPLITE_LONGTEXT, VLC_TRUE ); 
     127    add_integer( SOUT_CFG_PREFIX "cscov", 12, NULL, CSCOV_TEXT, CSCOV_LONGTEXT, VLC_TRUE ); 
    122128 
    123129    set_capability( "sout access", 100 ); 
    124130    add_shortcut( "udp" ); 
    125131    add_shortcut( "rtp" ); // Will work only with ts muxer 
    126     add_shortcut( "udplite" ); 
    127132    set_callbacks( Open, Close ); 
    128133vlc_module_end(); 
     
    137142    "group", 
    138143    "raw", 
     144    "lite", 
     145    "cscov", 
    139146    NULL 
    140147}; 
     
    205212 * Open: open the file 
    206213 *****************************************************************************/ 
    207 /* FIXME: lots of leaks in error handling here! */ 
    208214static int Open( vlc_object_t *p_this ) 
    209215{ 
     
    212218 
    213219    char                *psz_dst_addr = NULL; 
    214     int                 i_dst_port, proto = IPPROTO_UDP, cscov = 8
     220    int                 i_dst_port, proto = IPPROTO_UDP
    215221    const char          *protoname = "UDP"; 
    216222 
     
    224230                       ppsz_core_options, p_access->p_cfg ); 
    225231 
    226     if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) ) 
    227     { 
    228         msg_Err( p_access, "not enough memory" ); 
    229         return VLC_EGENERIC; 
    230     } 
    231     p_access->p_sys = p_sys; 
    232  
    233     if( p_access->psz_access != NULL ) 
    234     { 
    235         if (strcmp (p_access->psz_access, "rtp") == 0) 
    236             p_sys->b_rtpts = VLC_TRUE; 
    237         if (strcmp (p_access->psz_access, "udplite") == 0) 
    238         { 
    239             protoname = "UDP-Lite"; 
    240             proto = IPPROTO_UDPLITE; 
    241             p_sys->b_rtpts = VLC_TRUE; 
    242         } 
    243     } 
    244     if (p_sys->b_rtpts) 
    245         cscov += RTP_HEADER_LENGTH; 
    246  
    247     i_dst_port = DEFAULT_PORT; 
    248     if (var_CreateGetBool (p_access, SOUT_CFG_PREFIX"auto-mcast")) 
    249     { 
    250         char buf[INET6_ADDRSTRLEN]; 
    251         if (MakeRandMulticast (AF_INET, buf, sizeof (buf)) != NULL) 
    252             psz_dst_addr = strdup (buf); 
    253     } 
    254     else 
    255     { 
    256         char *psz_parser = psz_dst_addr = strdup( p_access->psz_path ); 
    257  
    258         if (psz_parser[0] == '[') 
    259             psz_parser = strchr (psz_parser, ']'); 
    260  
    261         psz_parser = strchr (psz_parser, ':'); 
    262         if (psz_parser != NULL) 
    263         { 
    264             *psz_parser++ = '\0'; 
    265             i_dst_port = atoi (psz_parser); 
    266         } 
    267     } 
    268  
    269232    if (var_Create (p_access, "dst-port", VLC_VAR_INTEGER) 
    270233     || var_Create (p_access, "src-port", VLC_VAR_INTEGER) 
     
    272235     || var_Create (p_access, "src-addr", VLC_VAR_STRING)) 
    273236    { 
    274         free (p_sys); 
    275         free (psz_dst_addr); 
    276237        return VLC_ENOMEM; 
     238    } 
     239 
     240    if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) ) 
     241    { 
     242        msg_Err( p_access, "not enough memory" ); 
     243        return VLC_ENOMEM; 
     244    } 
     245    p_access->p_sys = p_sys; 
     246 
     247    if( p_access->psz_access != NULL ) 
     248    { 
     249        if (strcmp (p_access->psz_access, "rtp") == 0) 
     250            p_sys->b_rtpts = VLC_TRUE; 
     251    } 
     252 
     253    if (var_GetBool (p_access, SOUT_CFG_PREFIX"lite")) 
     254    { 
     255        protoname = "UDP-Lite"; 
     256        proto = IPPROTO_UDPLITE; 
     257    } 
     258 
     259    i_dst_port = DEFAULT_PORT; 
     260    if (var_GetBool (p_access, SOUT_CFG_PREFIX"auto-mcast")) 
     261    { 
     262        char buf[INET6_ADDRSTRLEN]; 
     263        if (MakeRandMulticast (AF_INET, buf, sizeof (buf)) != NULL) 
     264            psz_dst_addr = strdup (buf); 
     265    } 
     266    else 
     267    { 
     268        char *psz_parser = psz_dst_addr = strdup( p_access->psz_path ); 
     269 
     270        if (psz_parser[0] == '[') 
     271            psz_parser = strchr (psz_parser, ']'); 
     272 
     273        psz_parser = strchr (psz_parser, ':'); 
     274        if (psz_parser != NULL) 
     275        { 
     276            *psz_parser++ = '\0'; 
     277            i_dst_port = atoi (psz_parser); 
     278        } 
    277279    } 
    278280 
     
    326328    shutdown( i_handle, SHUT_RD ); 
    327329 
     330    int cscov = var_GetInteger (p_access, SOUT_CFG_PREFIX"cscov"); 
     331    if (cscov) 
     332    { 
     333        switch (proto) 
     334        { 
    328335#ifdef UDPLITE_SEND_CSCOV 
    329     if (proto == IPPROTO_UDPLITE) 
    330         setsockopt (i_handle, SOL_UDPLITE, UDPLITE_SEND_CSCOV, 
    331                     &cscov, sizeof (cscov)); 
    332 #endif 
     336            case IPPROTO_UDPLITE: 
     337                cscov += 8; 
     338                setsockopt (i_handle, SOL_UDPLITE, UDPLITE_SEND_CSCOV, 
     339                            &(int){ cscov }, sizeof (cscov)); 
     340                break; 
     341#endif 
     342#ifdef DCCP_SOCKOPT_RECV_CSCOV 
     343            /* FIXME: ^^is this the right name ? */ 
     344            /* FIXME: is this inherited by accept() ? */ 
     345            case IPPROTO_DCCP: 
     346                cscov = ((cscov + 3) >> 2) + 1; 
     347                if (cscov > 15) 
     348                    break; /* out of DCCP cscov range */ 
     349                setsockopt (i_handle, SOL_DCCP, DCCP_SOCKOPT_RECV_CSCOV, 
     350                            &(int){ cscov }, sizeof (cscov)); 
     351                break; 
     352#endif 
     353        } 
     354    } 
    333355 
    334356    var_Get( p_access, SOUT_CFG_PREFIX "caching", &val );