Changeset e2a501e94652979c9a078b1996aa15adf1a66174

Show
Ignore:
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
  • modules/stream_out/rtsp.c

    rdd1dd6a re2a501e  
    340340    char psz_sesbuf[17]; 
    341341    const char *psz_session = NULL, *psz; 
     342    char control[sizeof("rtsp://[]:12345") + NI_MAXNUMERICHOST 
     343                  + strlen( rtsp->psz_path )]; 
    342344 
    343345    if( answer == NULL || query == NULL || cl == NULL ) 
    344346        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    } 
    345364 
    346365    /* */ 
     
    368387            } 
    369388 
    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  
    389389            answer->i_status = 200; 
    390390            httpd_MsgAdd( answer, "Content-Type",  "%s", "application/sdp" ); 
    391391            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; 
    394397            break; 
    395398        }