Changeset cbc66ff62b56b1dea3ba99b9b0f1a28659773427
- Timestamp:
- 24/03/07 01:24:22 (2 years ago)
- git-parent:
- Files:
-
- modules/access/mms/mms.c (modified) (2 diffs)
- modules/access/mms/mmsh.c (modified) (9 diffs)
- modules/access/mms/mmsh.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/access/mms/mms.c
rd3fe7f2 rcbc66ff 58 58 "Select the stream with the maximum bitrate under that limit." ) 59 59 60 #define PROXY_TEXT N_("HTTP proxy") 61 #define PROXY_LONGTEXT N_( \ 62 "HTTP proxy to be used It must be of the form " \ 63 "http://[user[:pass]@]myproxy.mydomain:myport/ ; " \ 64 "if empty, the http_proxy environment variable will be tried." ) 65 60 66 vlc_module_begin(); 61 67 set_shortname( "MMS" ); … … 71 77 add_integer( "mms-maxbitrate", 0, NULL, BITRATE_TEXT, BITRATE_LONGTEXT , 72 78 VLC_FALSE ); 79 add_string( "mmsh-proxy", NULL, NULL, PROXY_TEXT, PROXY_LONGTEXT, 80 VLC_FALSE ); 73 81 74 82 add_shortcut( "mms" ); modules/access/mms/mmsh.c
r830641e rcbc66ff 25 25 * Preamble 26 26 *****************************************************************************/ 27 #define _GNU_SOURCE 27 28 #include <stdlib.h> 28 29 … … 30 31 #include <vlc_access.h> 31 32 #include "vlc_playlist.h" 33 #include "vlc_strings.h" 32 34 33 35 #include <vlc_network.h> … … 75 77 access_sys_t *p_sys; 76 78 char *psz_location = NULL; 79 char *psz_proxy; 77 80 78 81 /* init p_sys */ … … 94 97 p_sys->fd = -1; 95 98 p_sys->i_start= 0; 99 100 /* Handle proxy */ 101 p_sys->b_proxy = VLC_FALSE; 102 memset( &p_sys->proxy, 0, sizeof(p_sys->proxy) ); 103 104 /* Check proxy */ 105 /* TODO reuse instead http-proxy from http access ? */ 106 psz_proxy = var_CreateGetString( p_access, "mmsh-proxy" ); 107 if( *psz_proxy ) 108 { 109 p_sys->b_proxy = VLC_TRUE; 110 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 ); 111 } 112 #ifdef HAVE_GETENV 113 else 114 { 115 char *psz_proxy = getenv( "http_proxy" ); 116 if( psz_proxy && *psz_proxy ) 117 { 118 p_sys->b_proxy = VLC_TRUE; 119 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 ); 120 } 121 } 122 #endif 123 free( psz_proxy ); 124 125 if( p_sys->b_proxy ) 126 { 127 if( p_sys->proxy.psz_host == NULL || *p_sys->proxy.psz_host == '\0' ) 128 { 129 msg_Warn( p_access, "invalid proxy host" ); 130 vlc_UrlClean( &p_sys->proxy ); 131 free( p_sys ); 132 return VLC_EGENERIC; 133 } 134 if( p_sys->proxy.i_port <= 0 ) 135 p_sys->proxy.i_port = 80; 136 msg_Dbg( p_access, "Using http proxy %s:%d", 137 p_sys->proxy.psz_host, p_sys->proxy.i_port ); 138 } 96 139 97 140 /* open a tcp connection */ … … 434 477 return 0; 435 478 } 479 480 static int OpenConnection( access_t *p_access ) 481 { 482 access_sys_t *p_sys = p_access->p_sys; 483 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url; 484 485 if( ( p_sys->fd = net_ConnectTCP( p_access, 486 srv.psz_host, srv.i_port ) ) < 0 ) 487 { 488 msg_Err( p_access, "cannot connect to %s:%d", 489 srv.psz_host, srv.i_port ); 490 return VLC_EGENERIC; 491 } 492 493 if( p_sys->b_proxy ) 494 { 495 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, 496 "GET http://%s:%d%s HTTP/1.0\r\n", 497 p_sys->url.psz_host, p_sys->url.i_port, 498 ( p_sys->url.psz_path == NULL || *p_sys->url.psz_path == '\0' ) ? "/" : p_sys->url.psz_path ); 499 500 /* Proxy Authentication */ 501 if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username ) 502 { 503 char *buf; 504 char *b64; 505 506 asprintf( &buf, "%s:%s", p_sys->proxy.psz_username, 507 p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" ); 508 509 b64 = vlc_b64_encode( buf ); 510 free( buf ); 511 512 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, 513 "Proxy-Authorization: Basic %s\r\n", b64 ); 514 free( b64 ); 515 } 516 } 517 else 518 { 519 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, 520 "GET %s HTTP/1.0\r\n" 521 "Host: %s:%d\r\n", 522 ( p_sys->url.psz_path == NULL || *p_sys->url.psz_path == '\0' ) ? "/" : p_sys->url.psz_path, 523 p_sys->url.psz_host, p_sys->url.i_port ); 524 } 525 return VLC_SUCCESS; 526 } 527 436 528 /***************************************************************************** 437 529 * Describe: … … 453 545 E_( GenerateGuid )( &p_sys->guid ); 454 546 455 if( ( p_sys->fd = net_ConnectTCP( p_access, p_sys->url.psz_host, 456 p_sys->url.i_port ) ) < 0 ) 457 { 458 msg_Err( p_access, "cannot connect to %s:%d", p_sys->url.psz_host, 459 p_sys->url.i_port ); 460 goto error; 461 } 462 463 /* send first request */ 547 OpenConnection( p_access ); 548 464 549 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, 465 "GET %s HTTP/1.0\r\n"466 550 "Accept: */*\r\n" 467 551 "User-Agent: "MMSH_USER_AGENT"\r\n" 468 "Host: %s:%d\r\n"469 552 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%d,max-duration=0\r\n" 470 553 "Pragma: xClientGUID={"GUID_FMT"}\r\n" 471 554 "Connection: Close\r\n", 472 ( p_sys->url.psz_path == NULL || *p_sys->url.psz_path == '\0' ) ? "/" : p_sys->url.psz_path,473 p_sys->url.psz_host, p_sys->url.i_port,474 555 p_sys->i_request_context++, 475 556 GUID_PRINT( p_sys->guid ) ); … … 647 728 msg_Dbg( p_access, "starting stream" ); 648 729 649 if( ( p_sys->fd = net_ConnectTCP( p_access, p_sys->url.psz_host,650 p_sys->url.i_port ) ) < 0 )651 {652 /* should not occur */653 msg_Err( p_access, "cannot connect to the server" );654 return VLC_EGENERIC;655 }656 657 730 for( i = 1; i < 128; i++ ) 658 731 { … … 663 736 i_streams_selected++; 664 737 } 665 666 738 if( i_streams_selected <= 0 ) 667 739 { … … 669 741 return VLC_EGENERIC; 670 742 } 743 744 OpenConnection( p_access ); 745 671 746 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, 672 "GET %s HTTP/1.0\r\n"673 747 "Accept: */*\r\n" 674 "User-Agent: "MMSH_USER_AGENT"\r\n" 675 "Host: %s:%d\r\n", 676 ( p_sys->url.psz_path == NULL || *p_sys->url.psz_path == '\0' ) ? "/" : p_sys->url.psz_path, 677 p_sys->url.psz_host, p_sys->url.i_port ); 748 "User-Agent: "MMSH_USER_AGENT"\r\n" ); 678 749 if( p_sys->b_broadcast ) 679 750 { modules/access/mms/mmsh.h
r2cb472d rcbc66ff 45 45 vlc_url_t url; 46 46 47 vlc_bool_t b_proxy; 48 vlc_url_t proxy; 49 47 50 int i_request_context; 48 51
