Changeset 0af8501b1a2406ed103fd8ecacd26c9c209225ca

Show
Ignore:
Timestamp:
09/09/07 13:22:16 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1189336936 +0000
git-parent:

[af9789b6e9e2540a7666eb461754bc8e262bfa27]

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

stream_out_rtp: Linux splice() support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    ra51ad8b r0af8501  
    444444AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)]) 
    445445AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)]) 
     446 
     447AS_IF([test "${SYS}" = "linux"], [ 
     448  AC_CHECK_FUNCS(tee) 
     449]) 
    446450 
    447451dnl Check for setlocal and langinfo 
  • modules/stream_out/rtp.c

    r4c48570 r0af8501  
    4040 
    4141#ifdef HAVE_UNISTD_H 
     42#   include <sys/types.h> 
    4243#   include <unistd.h> 
     44#   include <fcntl.h> 
     45#   include <sys/stat.h> 
    4346#endif 
    4447 
     
    13051308    sout_stream_id_t *id = (sout_stream_id_t *)p_this; 
    13061309    unsigned i_caching = id->i_caching; 
     1310#ifdef HAVE_TEE 
     1311    int fd[5] = { -1, -1, -1, -1, -1 }; 
     1312 
     1313    if( pipe( fd ) ) 
     1314        fd[0] = fd[1] = -1; 
     1315    else 
     1316    if( pipe( fd ) ) 
     1317        fd[2] = fd[3] = -1; 
     1318    else 
     1319        fd[4] = open( "/dev/null", O_WRONLY ); 
     1320#endif 
    13071321 
    13081322    while( !id->b_die ) 
     
    13101324        block_t *out = block_FifoGet( id->p_fifo ); 
    13111325        mtime_t  i_date = out->i_dts + i_caching; 
    1312  
     1326        ssize_t  len = out->i_buffer; 
     1327 
     1328#ifdef HAVE_TEE 
     1329        if( fd[4] != -1 ) 
     1330            len = write( fd[1], out->p_buffer, len); 
     1331        if( len == -1 ) 
     1332            continue; /* Uho - should not happen */ 
     1333#endif 
    13131334        mwait( i_date ); 
    13141335 
     
    13161337        for( int i = 0; i < id->sinkc; i++ ) 
    13171338        { 
    1318             send( id->sinkv[i].rtp_fd, out->p_buffer, out->i_buffer, 0 ); 
    13191339            SendRTCP( id->sinkv[i].rtcp, out ); 
     1340 
     1341#ifdef HAVE_TEE 
     1342            tee( fd[0], fd[3], len, 0 ); 
     1343            if( splice( fd[2], NULL, id->sinkv[i].rtp_fd, NULL, len, 
     1344                        SPLICE_F_NONBLOCK ) >= 0 ) 
     1345                continue; 
     1346 
     1347            /* splice failed */ 
     1348            splice( fd[2], NULL, fd[4], NULL, len, 0 ); 
     1349#endif 
     1350            send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ); 
    13201351        } 
    13211352        vlc_mutex_unlock( &id->lock_sink ); 
    13221353 
    13231354        block_Release( out ); 
    1324     } 
     1355#ifdef HAVE_TEE 
     1356        splice( fd[0], NULL, fd[4], NULL, len, 0 ); 
     1357#endif 
     1358    } 
     1359 
     1360#ifdef HAVE_TEE 
     1361    for( unsigned i = 0; i < 5; i++ ) 
     1362        close( fd[i] ); 
     1363#endif 
    13251364} 
    13261365