Changeset e2a501e94652979c9a078b1996aa15adf1a66174
- Timestamp:
- 24/09/07 17:44:15
(1 year ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1190648655 +0000
- git-parent:
[839d6e8b7b9f29dbcc85ea0dba79737b88af353b]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1190648655 +0000
- Message:
Factor out RTSP control URL writing so it can be re-used
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rdd1dd6a |
re2a501e |
|
| 340 | 340 | char psz_sesbuf[17]; |
|---|
| 341 | 341 | const char *psz_session = NULL, *psz; |
|---|
| | 342 | char control[sizeof("rtsp://[]:12345") + NI_MAXNUMERICHOST |
|---|
| | 343 | + strlen( rtsp->psz_path )]; |
|---|
| 342 | 344 | |
|---|
| 343 | 345 | if( answer == NULL || query == NULL || cl == NULL ) |
|---|
| 344 | 346 | return VLC_SUCCESS; |
|---|
| | 347 | else |
|---|
| | 348 | { |
|---|
| | 349 | /* Build self-referential control URL */ |
|---|
| | 350 | char ip[NI_MAXNUMERICHOST], *ptr; |
|---|
| | 351 | |
|---|
| | 352 | httpd_ServerIP( cl, ip ); |
|---|
| | 353 | ptr = strchr( ip, '%' ); |
|---|
| | 354 | if( ptr != NULL ) |
|---|
| | 355 | *ptr = '\0'; |
|---|
| | 356 | |
|---|
| | 357 | if( strchr( ip, ':' ) != NULL ) |
|---|
| | 358 | sprintf( control, "rtsp://[%s]:%u%s", ip, rtsp->port, |
|---|
| | 359 | rtsp->psz_path ); |
|---|
| | 360 | else |
|---|
| | 361 | sprintf( control, "rtsp://%s:%u%s", ip, rtsp->port, |
|---|
| | 362 | rtsp->psz_path ); |
|---|
| | 363 | } |
|---|
| 345 | 364 | |
|---|
| 346 | 365 | /* */ |
|---|
| … | … | |
| 368 | 387 | } |
|---|
| 369 | 388 | |
|---|
| 370 | | char ip[NI_MAXNUMERICHOST], *ptr; |
|---|
| 371 | | char control[sizeof("rtsp://[]:12345") + sizeof( ip ) |
|---|
| 372 | | + strlen( rtsp->psz_path )]; |
|---|
| 373 | | |
|---|
| 374 | | /* Build self-referential URL */ |
|---|
| 375 | | httpd_ServerIP( cl, ip ); |
|---|
| 376 | | ptr = strchr( ip, '%' ); |
|---|
| 377 | | if( ptr != NULL ) |
|---|
| 378 | | *ptr = '\0'; |
|---|
| 379 | | |
|---|
| 380 | | if( strchr( ip, ':' ) != NULL ) |
|---|
| 381 | | sprintf( control, "rtsp://[%s]:%u%s", ip, rtsp->port, |
|---|
| 382 | | rtsp->psz_path ); |
|---|
| 383 | | else |
|---|
| 384 | | sprintf( control, "rtsp://%s:%u%s", ip, rtsp->port, |
|---|
| 385 | | rtsp->psz_path ); |
|---|
| 386 | | |
|---|
| 387 | | ptr = SDPGenerate( rtsp->owner, control ); |
|---|
| 388 | | |
|---|
| 389 | 389 | answer->i_status = 200; |
|---|
| 390 | 390 | httpd_MsgAdd( answer, "Content-Type", "%s", "application/sdp" ); |
|---|
| 391 | 391 | httpd_MsgAdd( answer, "Content-Base", "%s", control ); |
|---|
| 392 | | answer->p_body = (uint8_t *)ptr; |
|---|
| 393 | | answer->i_body = strlen( ptr ); |
|---|
| | 392 | answer->p_body = (uint8_t *)SDPGenerate( rtsp->owner, control ); |
|---|
| | 393 | if( answer->p_body != NULL ) |
|---|
| | 394 | answer->i_body = strlen( (char *)answer->p_body ); |
|---|
| | 395 | else |
|---|
| | 396 | answer->i_status = 500; |
|---|
| 394 | 397 | break; |
|---|
| 395 | 398 | } |
|---|