Changeset 0af8501b1a2406ed103fd8ecacd26c9c209225ca
- 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
| ra51ad8b |
r0af8501 |
|
| 444 | 444 | AC_CHECK_FUNCS(strncasecmp,,[AC_CHECK_FUNCS(strnicmp)]) |
|---|
| 445 | 445 | AC_CHECK_FUNCS(strcasestr,,[AC_CHECK_FUNCS(stristr)]) |
|---|
| | 446 | |
|---|
| | 447 | AS_IF([test "${SYS}" = "linux"], [ |
|---|
| | 448 | AC_CHECK_FUNCS(tee) |
|---|
| | 449 | ]) |
|---|
| 446 | 450 | |
|---|
| 447 | 451 | dnl Check for setlocal and langinfo |
|---|
| r4c48570 |
r0af8501 |
|
| 40 | 40 | |
|---|
| 41 | 41 | #ifdef HAVE_UNISTD_H |
|---|
| | 42 | # include <sys/types.h> |
|---|
| 42 | 43 | # include <unistd.h> |
|---|
| | 44 | # include <fcntl.h> |
|---|
| | 45 | # include <sys/stat.h> |
|---|
| 43 | 46 | #endif |
|---|
| 44 | 47 | |
|---|
| … | … | |
| 1305 | 1308 | sout_stream_id_t *id = (sout_stream_id_t *)p_this; |
|---|
| 1306 | 1309 | 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 |
|---|
| 1307 | 1321 | |
|---|
| 1308 | 1322 | while( !id->b_die ) |
|---|
| … | … | |
| 1310 | 1324 | block_t *out = block_FifoGet( id->p_fifo ); |
|---|
| 1311 | 1325 | 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 |
|---|
| 1313 | 1334 | mwait( i_date ); |
|---|
| 1314 | 1335 | |
|---|
| … | … | |
| 1316 | 1337 | for( int i = 0; i < id->sinkc; i++ ) |
|---|
| 1317 | 1338 | { |
|---|
| 1318 | | send( id->sinkv[i].rtp_fd, out->p_buffer, out->i_buffer, 0 ); |
|---|
| 1319 | 1339 | 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 ); |
|---|
| 1320 | 1351 | } |
|---|
| 1321 | 1352 | vlc_mutex_unlock( &id->lock_sink ); |
|---|
| 1322 | 1353 | |
|---|
| 1323 | 1354 | 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 |
|---|
| 1325 | 1364 | } |
|---|
| 1326 | 1365 | |
|---|