Changeset 0a342122be23ccbb7d856c18f19323eb94a71e75
- Timestamp:
- 06/12/07 20:08:04
(1 year ago)
- Author:
- Jean-Paul Saman <jpsaman@videolan.org>
- git-committer:
- Jean-Paul Saman <jpsaman@videolan.org> 1196968084 +0000
- git-parent:
[fde8b7fc53e178f59adc59e88df6eb623fa9797d]
- git-author:
- Jean-Paul Saman <jpsaman@videolan.org> 1196968084 +0000
- Message:
Cleanup.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rcfd1271 |
r0a34212 |
|
| 220 | 220 | MediaSubsession *sub = NULL; |
|---|
| 221 | 221 | int i, i_return; |
|---|
| | 222 | int i_error = VLC_EGENERIC; |
|---|
| 222 | 223 | |
|---|
| 223 | 224 | if( p_demux->s ) |
|---|
| … | … | |
| 293 | 294 | uint8_t *p_sdp = (uint8_t*) malloc( i_sdp_max ); |
|---|
| 294 | 295 | |
|---|
| | 296 | if( !p_sdp ) |
|---|
| | 297 | { |
|---|
| | 298 | i_error = VLC_ENOMEM; |
|---|
| | 299 | goto error; |
|---|
| | 300 | } |
|---|
| | 301 | |
|---|
| 295 | 302 | for( ;; ) |
|---|
| 296 | 303 | { |
|---|
| … | … | |
| 333 | 340 | { |
|---|
| 334 | 341 | msg_Err( p_demux, "Failed to retrieve the RTSP Session Description" ); |
|---|
| | 342 | i_error = VLC_ENOMEM; |
|---|
| 335 | 343 | goto error; |
|---|
| 336 | 344 | } |
|---|
| … | … | |
| 389 | 397 | |
|---|
| 390 | 398 | free( p_sys ); |
|---|
| 391 | | return VLC_EGENERIC; |
|---|
| | 399 | return i_error; |
|---|
| 392 | 400 | } |
|---|
| 393 | 401 | |
|---|
| … | … | |
| 448 | 456 | int i_ret = VLC_SUCCESS; |
|---|
| 449 | 457 | |
|---|
| | 458 | psz_url = (char*)malloc( strlen( p_sys->psz_path ) + 8 ); |
|---|
| | 459 | if( !psz_url ) return VLC_ENOMEM; |
|---|
| | 460 | |
|---|
| | 461 | if( p_sys->url.psz_username || p_sys->url.psz_password ) |
|---|
| | 462 | { |
|---|
| | 463 | sprintf( psz_url, "rtsp://%s%s", p_sys->url.psz_host, |
|---|
| | 464 | p_sys->url.psz_path ); |
|---|
| | 465 | |
|---|
| | 466 | psz_user = strdup( p_sys->url.psz_username ); |
|---|
| | 467 | psz_pwd = strdup( p_sys->url.psz_password ); |
|---|
| | 468 | } |
|---|
| | 469 | else |
|---|
| | 470 | { |
|---|
| | 471 | sprintf( psz_url, "rtsp://%s", p_sys->psz_path ); |
|---|
| | 472 | |
|---|
| | 473 | psz_user = var_CreateGetString( p_demux, "rtsp-user" ); |
|---|
| | 474 | psz_pwd = var_CreateGetString( p_demux, "rtsp-pwd" ); |
|---|
| | 475 | } |
|---|
| | 476 | |
|---|
| 450 | 477 | createnew: |
|---|
| 451 | 478 | if( var_CreateGetBool( p_demux, "rtsp-http" ) ) |
|---|
| … | … | |
| 475 | 502 | } |
|---|
| 476 | 503 | |
|---|
| 477 | | |
|---|
| 478 | | psz_url = (char*)malloc( strlen( p_sys->psz_path ) + 8 ); |
|---|
| 479 | | if( !psz_url ) return VLC_ENOMEM; |
|---|
| 480 | | |
|---|
| 481 | | if( p_sys->url.psz_username || p_sys->url.psz_password ) |
|---|
| 482 | | { |
|---|
| 483 | | sprintf( psz_url, "rtsp://%s%s", p_sys->url.psz_host, |
|---|
| 484 | | p_sys->url.psz_path ); |
|---|
| 485 | | |
|---|
| 486 | | psz_user = strdup( p_sys->url.psz_username ); |
|---|
| 487 | | psz_pwd = strdup( p_sys->url.psz_password ); |
|---|
| 488 | | } |
|---|
| 489 | | else |
|---|
| 490 | | { |
|---|
| 491 | | sprintf( psz_url, "rtsp://%s", p_sys->psz_path ); |
|---|
| 492 | | |
|---|
| 493 | | psz_user = var_CreateGetString( p_demux, "rtsp-user" ); |
|---|
| 494 | | psz_pwd = var_CreateGetString( p_demux, "rtsp-pwd" ); |
|---|
| 495 | | } |
|---|
| 496 | | |
|---|
| 497 | 504 | describe: |
|---|
| 498 | | msg_Info( p_demux, "[%s] user=%s pwd=%s", psz_url, psz_user, psz_pwd ); |
|---|
| 499 | 505 | authenticator.setUsernameAndPassword( (const char*)psz_user, |
|---|
| 500 | 506 | (const char*)psz_pwd ); |
|---|
| … | … | |
| 504 | 510 | if( psz_options ) delete [] psz_options; |
|---|
| 505 | 511 | |
|---|
| 506 | | p_sdp = p_sys->rtsp->describeURL( psz_url, |
|---|
| 507 | | &authenticator, var_CreateGetBool( p_demux, "rtsp-kasenna" ) ); |
|---|
| 508 | | |
|---|
| 509 | | if( psz_user ) free( psz_user ); |
|---|
| 510 | | if( psz_pwd ) free( psz_pwd ); |
|---|
| 511 | | |
|---|
| | 512 | p_sdp = p_sys->rtsp->describeURL( psz_url, &authenticator, |
|---|
| | 513 | var_CreateGetBool( p_demux, "rtsp-kasenna" ) ); |
|---|
| 512 | 514 | if( p_sdp == NULL ) |
|---|
| 513 | 515 | { |
|---|
| … | … | |
| 518 | 520 | msg_Dbg( p_demux, "DESCRIBE failed with %d: %s", i_code, psz_error ); |
|---|
| 519 | 521 | if( var_CreateGetBool( p_demux, "rtsp-http" ) ) |
|---|
| 520 | | sscanf( psz_error, "%*s %*s HTTP GET %*s HTTP/%*u.%*u %3u %*s", &i_code ); |
|---|
| | 522 | sscanf( psz_error, "%*s %*s HTTP GET %*s HTTP/%*u.%*u %3u %*s", |
|---|
| | 523 | &i_code ); |
|---|
| 521 | 524 | else sscanf( psz_error, "%*sRTSP/%*s%3u", &i_code ); |
|---|
| 522 | 525 | |
|---|
| 523 | 526 | if( i_code == 401 ) |
|---|
| 524 | 527 | { |
|---|
| 525 | | char *psz_login = NULL; char *psz_password = NULL; |
|---|
| | 528 | int i_result; |
|---|
| 526 | 529 | msg_Dbg( p_demux, "authentication failed" ); |
|---|
| 527 | 530 | |
|---|
| 528 | | i_ret = intf_UserLoginPassword( p_demux, _("RTSP authentication"), |
|---|
| | 531 | if( psz_user ) free( psz_user ); |
|---|
| | 532 | if( psz_pwd ) free( psz_pwd ); |
|---|
| | 533 | psz_user = psz_pwd = NULL; |
|---|
| | 534 | |
|---|
| | 535 | i_result = intf_UserLoginPassword( p_demux, _("RTSP authentication"), |
|---|
| 529 | 536 | _("Please enter a valid login name and a password."), |
|---|
| 530 | | &psz_login, &psz_password ); |
|---|
| 531 | | if( i_ret == DIALOG_OK_YES ) |
|---|
| | 537 | &psz_user, &psz_pwd ); |
|---|
| | 538 | if( i_result == DIALOG_OK_YES ) |
|---|
| 532 | 539 | { |
|---|
| 533 | 540 | msg_Dbg( p_demux, "retrying with user=%s, pwd=%s", |
|---|
| 534 | | psz_login, psz_password ); |
|---|
| 535 | | if( psz_login ) psz_user = psz_login; |
|---|
| 536 | | if( psz_password ) psz_pwd = psz_password; |
|---|
| 537 | | i_ret = VLC_SUCCESS; |
|---|
| | 541 | psz_user, psz_pwd ); |
|---|
| 538 | 542 | goto describe; |
|---|
| 539 | 543 | } |
|---|
| 540 | | if( psz_login ) free( psz_login ); |
|---|
| 541 | | if( psz_password ) free( psz_password ); |
|---|
| 542 | 544 | } |
|---|
| 543 | 545 | else if( !var_GetBool( p_demux, "rtsp-http" ) ) |
|---|
| … | … | |
| 548 | 550 | msg_Dbg( p_demux, "we will now try HTTP tunneling mode" ); |
|---|
| 549 | 551 | var_Set( p_demux, "rtsp-http", val ); |
|---|
| 550 | | if( psz_url ) free( psz_url ); |
|---|
| 551 | 552 | if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp ); |
|---|
| 552 | 553 | goto createnew; |
|---|
| … | … | |
| 557 | 558 | |
|---|
| 558 | 559 | /* malloc-ated copy */ |
|---|
| | 560 | if( psz_user ) free( psz_user ); |
|---|
| | 561 | if( psz_pwd ) free( psz_pwd ); |
|---|
| | 562 | |
|---|
| 559 | 563 | if( p_sys->p_sdp ) free( p_sys->p_sdp ); |
|---|
| 560 | 564 | p_sys->p_sdp = NULL; |
|---|