Changeset 21f7e7ea477453871b494758c2dec31e0c23287c
- Timestamp:
- 03/28/08 10:54:55
(5 months ago)
- Author:
- Jean-Paul Saman <jpsaman@videolan.org>
- git-committer:
- Jean-Paul Saman <jpsaman@videolan.org> 1206698095 +0100
- git-parent:
[d0641277d87a51ed1602dc36f5585c9b4705dccb]
- git-author:
- Rafaël Carré <funman@videolan.org> 1206697525 +0100
- Message:
MMS: close access on network timeout
defaults to timeout on 5s (configurable) without data (there will be 10 tries before returning EOF)
fix some EOF return paths
check malloc()
Signed-off-by: Jean-Paul Saman <jpsaman@videolan.org>
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r99fab90 |
r21f7e7e |
|
| 66 | 66 | "if empty, the http_proxy environment variable will be tried." ) |
|---|
| 67 | 67 | |
|---|
| | 68 | #define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)") |
|---|
| | 69 | #define TIMEOUT_LONGTEXT N_("Amount of time (in ms) to wait before aborting network reception of data. Note that there will be 10 retries before completely giving up.") |
|---|
| | 70 | |
|---|
| 68 | 71 | vlc_module_begin(); |
|---|
| 69 | 72 | set_shortname( "MMS" ); |
|---|
| … | … | |
| 75 | 78 | add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL, |
|---|
| 76 | 79 | CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); |
|---|
| | 80 | |
|---|
| | 81 | add_integer( "mms-timeout", 5000, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT, |
|---|
| | 82 | VLC_TRUE ); |
|---|
| 77 | 83 | |
|---|
| 78 | 84 | add_bool( "mms-all", 0, NULL, ALL_TEXT, ALL_LONGTEXT, VLC_TRUE ); |
|---|
| r5cb4066 |
r21f7e7e |
|
| 112 | 112 | p_access->info.i_seekpoint = 0; |
|---|
| 113 | 113 | p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); |
|---|
| | 114 | if( !p_sys ) return VLC_ENOMEM; |
|---|
| 114 | 115 | memset( p_sys, 0, sizeof( access_sys_t ) ); |
|---|
| | 116 | |
|---|
| | 117 | p_sys->i_timeout = var_CreateGetInteger( p_access, "mms-timeout" ); |
|---|
| 115 | 118 | |
|---|
| 116 | 119 | /* *** Parse URL and get server addr/port and path *** */ |
|---|
| … | … | |
| 346 | 349 | while( !p_access->b_die ) |
|---|
| 347 | 350 | { |
|---|
| 348 | | mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ); |
|---|
| | 351 | if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 ) |
|---|
| | 352 | { |
|---|
| | 353 | p_access->info.b_eof = VLC_TRUE; |
|---|
| | 354 | return VLC_EGENERIC; |
|---|
| | 355 | } |
|---|
| | 356 | |
|---|
| 349 | 357 | if( p_sys->i_command == 0x1e ) |
|---|
| 350 | 358 | { |
|---|
| … | … | |
| 356 | 364 | while( !p_access->b_die ) |
|---|
| 357 | 365 | { |
|---|
| 358 | | mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ); |
|---|
| | 366 | if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 ) |
|---|
| | 367 | { |
|---|
| | 368 | p_access->info.b_eof = VLC_TRUE; |
|---|
| | 369 | return VLC_EGENERIC; |
|---|
| | 370 | } |
|---|
| 359 | 371 | if( p_sys->i_command == 0x05 ) |
|---|
| 360 | 372 | { |
|---|
| … | … | |
| 365 | 377 | |
|---|
| 366 | 378 | /* get a packet */ |
|---|
| 367 | | mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ); |
|---|
| | 379 | if( mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ) < 0 ) |
|---|
| | 380 | { |
|---|
| | 381 | p_access->info.b_eof = VLC_TRUE; |
|---|
| | 382 | return VLC_EGENERIC; |
|---|
| | 383 | } |
|---|
| | 384 | |
|---|
| 368 | 385 | msg_Dbg( p_access, "Streaming restarted" ); |
|---|
| 369 | 386 | |
|---|
| … | … | |
| 387 | 404 | |
|---|
| 388 | 405 | /* *** now send data if needed *** */ |
|---|
| 389 | | while( i_data < (size_t)i_len ) |
|---|
| | 406 | while( i_data < i_len ) |
|---|
| 390 | 407 | { |
|---|
| 391 | 408 | if( p_access->info.i_pos < p_sys->i_header ) |
|---|
| … | … | |
| 504 | 521 | p_sys->p_cmd = NULL; |
|---|
| 505 | 522 | p_sys->i_cmd = 0; |
|---|
| 506 | | p_access->info.b_eof = 0; |
|---|
| | 523 | p_access->info.b_eof = VLC_FALSE; |
|---|
| 507 | 524 | |
|---|
| 508 | 525 | /* *** send command 1 : connection request *** */ |
|---|
| … | … | |
| 853 | 870 | "unknown answer (0x%x instead of 0x05)", |
|---|
| 854 | 871 | p_sys->i_command ); |
|---|
| 855 | | return( -1 ); |
|---|
| | 872 | return -1; |
|---|
| 856 | 873 | } |
|---|
| 857 | 874 | else |
|---|
| 858 | 875 | { |
|---|
| 859 | 876 | /* get a packet */ |
|---|
| 860 | | mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ); |
|---|
| | 877 | if( mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ) < 0 ) |
|---|
| | 878 | return -1; |
|---|
| 861 | 879 | msg_Dbg( p_access, "streaming started" ); |
|---|
| 862 | | return( 0 ); |
|---|
| | 880 | return 0; |
|---|
| 863 | 881 | } |
|---|
| 864 | 882 | } |
|---|
| … | … | |
| 1029 | 1047 | /* We'll wait 0.5 second if nothing happens */ |
|---|
| 1030 | 1048 | timeout = 500; |
|---|
| | 1049 | |
|---|
| | 1050 | if( i_try * timeout > p_sys->i_timeout ) |
|---|
| | 1051 | { |
|---|
| | 1052 | msg_Err(p_access, "no data received"); |
|---|
| | 1053 | return -1; |
|---|
| | 1054 | } |
|---|
| 1031 | 1055 | |
|---|
| 1032 | 1056 | if( i_try > 3 && (p_sys->i_buffer_tcp > 0 || p_sys->i_buffer_udp > 0) ) |
|---|
| … | … | |
| 1444 | 1468 | case 0x03: |
|---|
| 1445 | 1469 | msg_Warn( p_access, "socket closed by server" ); |
|---|
| 1446 | | p_access->info.b_eof = 1; |
|---|
| | 1470 | p_access->info.b_eof = VLC_TRUE; |
|---|
| 1447 | 1471 | return VLC_EGENERIC; |
|---|
| 1448 | 1472 | case 0x1e: |
|---|
| 1449 | 1473 | msg_Warn( p_access, "end of media stream" ); |
|---|
| 1450 | | p_access->info.b_eof = 1; |
|---|
| | 1474 | p_access->info.b_eof = VLC_TRUE; |
|---|
| 1451 | 1475 | return VLC_EGENERIC; |
|---|
| 1452 | 1476 | default: |
|---|
| … | … | |
| 1455 | 1479 | } |
|---|
| 1456 | 1480 | } |
|---|
| | 1481 | p_access->info.b_eof = VLC_TRUE; |
|---|
| 1457 | 1482 | msg_Warn( p_access, "failed to receive command (aborting)" ); |
|---|
| 1458 | 1483 | |
|---|
| … | … | |
| 1491 | 1516 | case 0x03: |
|---|
| 1492 | 1517 | msg_Warn( p_access, "socket closed by server" ); |
|---|
| 1493 | | p_access->info.b_eof = 1; |
|---|
| | 1518 | p_access->info.b_eof = VLC_TRUE; |
|---|
| 1494 | 1519 | return -1; |
|---|
| 1495 | 1520 | case 0x1e: |
|---|
| 1496 | 1521 | msg_Warn( p_access, "end of media stream" ); |
|---|
| 1497 | | p_access->info.b_eof = 1; |
|---|
| | 1522 | p_access->info.b_eof = VLC_TRUE; |
|---|
| 1498 | 1523 | return -1; |
|---|
| 1499 | 1524 | case 0x20: |
|---|
| … | … | |
| 1513 | 1538 | msg_Err( p_access, "cannot receive %s (aborting)", |
|---|
| 1514 | 1539 | ( i_type == MMS_PACKET_HEADER ) ? "header" : "media data" ); |
|---|
| | 1540 | p_access->info.b_eof = VLC_TRUE; |
|---|
| 1515 | 1541 | return -1; |
|---|
| 1516 | 1542 | } |
|---|
| r29ec304 |
r21f7e7e |
|
| 45 | 45 | |
|---|
| 46 | 46 | asf_header_t asfh; |
|---|
| | 47 | |
|---|
| | 48 | unsigned i_timeout; |
|---|
| 47 | 49 | |
|---|
| 48 | 50 | /* */ |
|---|