Changeset e30a3efa66e3663ad97e96f6499e1e0829020a6a

Show
Ignore:
Timestamp:
03/03/04 14:25:53 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1078320353 +0000
git-parent:

[a6e1d27ae43fbe5ac37a83d6bd7ea121b48c07f9]

git-author:
Laurent Aimar <fenrir@videolan.org> 1078320353 +0000
Message:
  • http: ported to new httpd.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access_output/http.c

    r9f3bc42 re30a3ef  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: http.c,v 1.11 2004/02/03 20:12:53 fenrir Exp $ 
     5 * $Id: http.c,v 1.12 2004/03/03 13:25:53 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    3333#include <vlc/sout.h> 
    3434 
    35 #include "httpd.h" 
     35#include "vlc_httpd.h" 
    3636 
    3737#define FREE( p ) if( p ) { free( p); (p) = NULL; } 
     
    6161struct sout_access_out_sys_t 
    6262{ 
    63     httpd_t             *p_httpd; 
    64  
    6563    /* host */ 
    6664    httpd_host_t        *p_httpd_host; 
     
    7674}; 
    7775 
     76#if 0 
    7877static struct 
    7978{ 
     
    123122    return( "application/octet-stream" ); 
    124123} 
     124#endif 
     125 
    125126/***************************************************************************** 
    126127 * Open: open the file 
     
    137138    char                *psz_file_name; 
    138139 
    139     char                *psz_mime
     140    char                *psz_mime = NULL
    140141 
    141142    if( !( p_sys = p_access->p_sys = 
     
    197198    } 
    198199 
    199     p_sys->p_httpd = httpd_Find( VLC_OBJECT(p_access), VLC_TRUE ); 
    200     if( !p_sys->p_httpd
    201     { 
    202         msg_Err( p_access, "cannot start httpd daemon" ); 
     200    p_sys->p_httpd_host = httpd_HostNew( VLC_OBJECT(p_access), psz_bind_addr, i_bind_port ); 
     201    if( p_sys->p_httpd_host == NULL
     202    { 
     203        msg_Err( p_access, "cannot listen on %s:%d", psz_bind_addr, i_bind_port ); 
    203204 
    204205        free( psz_name ); 
    205206        free( psz_file_name ); 
    206207        free( p_sys ); 
    207         return( VLC_EGENERIC ); 
    208     } 
    209  
    210     p_sys->p_httpd_host = 
    211         p_sys->p_httpd->pf_register_host( p_sys->p_httpd, 
    212                                           psz_bind_addr, i_bind_port ); 
    213  
    214     if( !p_sys->p_httpd_host ) 
    215     { 
    216         msg_Err( p_access, "cannot listen on %s:%d", psz_bind_addr, i_bind_port ); 
    217         httpd_Release( p_sys->p_httpd ); 
     208        return VLC_EGENERIC; 
     209    } 
     210 
     211    if( p_access->psz_access && !strcmp( p_access->psz_access, "mmsh" ) ) 
     212    { 
     213        psz_mime = "video/x-ms-asf-stream"; 
     214    } 
     215 
     216    p_sys->p_httpd_stream = httpd_StreamNew( p_sys->p_httpd_host, 
     217                                             psz_file_name, psz_mime, 
     218                                             sout_cfg_find_value( p_access->p_cfg, "user" ), 
     219                                             sout_cfg_find_value( p_access->p_cfg, "pwd" ) ); 
     220    if( p_sys->p_httpd_stream == NULL ) 
     221    { 
     222        msg_Err( p_access, "cannot add stream %s", psz_file_name ); 
     223        httpd_HostDelete( p_sys->p_httpd_host ); 
    218224 
    219225        free( psz_name ); 
    220226        free( psz_file_name ); 
    221227        free( p_sys ); 
    222         return( VLC_EGENERIC ); 
    223     } 
    224  
    225     if( p_access->psz_access && !strcmp( p_access->psz_access, "mmsh" ) ) 
    226     { 
    227         psz_mime = "video/x-ms-asf-stream"; 
    228     } 
    229     else 
    230     { 
    231         psz_mime = GetMime( psz_file_name ); 
    232     } 
    233     p_sys->p_httpd_stream = 
    234         p_sys->p_httpd->pf_register_stream( p_sys->p_httpd, 
    235                                             psz_file_name, 
    236                                             psz_mime, 
    237                                             sout_cfg_find_value( p_access->p_cfg, "user" ), 
    238                                             sout_cfg_find_value( p_access->p_cfg, "pwd" ) ); 
    239  
    240     if( !p_sys->p_httpd_stream ) 
    241     { 
    242         msg_Err( p_access, "cannot add stream %s", psz_file_name ); 
    243         p_sys->p_httpd->pf_unregister_host( p_sys->p_httpd, p_sys->p_httpd_host ); 
    244         httpd_Release( p_sys->p_httpd ); 
    245  
    246         free( psz_name ); 
    247         free( psz_file_name ); 
    248         free( p_sys ); 
    249  
    250         return( VLC_EGENERIC ); 
     228        return VLC_EGENERIC; 
    251229    } 
    252230 
     
    273251    sout_access_out_sys_t   *p_sys = p_access->p_sys; 
    274252 
    275     p_sys->p_httpd->pf_unregister_stream( p_sys->p_httpd, p_sys->p_httpd_stream ); 
    276     p_sys->p_httpd->pf_unregister_host( p_sys->p_httpd, p_sys->p_httpd_host ); 
    277  
    278     httpd_Release( p_sys->p_httpd ); 
     253    httpd_StreamDelete( p_sys->p_httpd_stream ); 
     254    httpd_HostDelete( p_sys->p_httpd_host ); 
    279255 
    280256    FREE( p_sys->p_header ); 
    281257 
    282     msg_Info( p_access, "Close" ); 
     258    msg_Dbg( p_access, "Close" ); 
    283259 
    284260    free( p_sys ); 
     
    320296            p_sys->b_header_complete = VLC_TRUE; 
    321297 
    322             p_sys->p_httpd->pf_header_stream( p_sys->p_httpd, 
    323                                               p_sys->p_httpd_stream, 
    324                                               p_sys->p_header, p_sys->i_header_size ); 
    325         } 
    326             /* send data */ 
    327         i_err = p_sys->p_httpd->pf_send_stream( p_sys->p_httpd, p_sys->p_httpd_stream, 
    328                                                 p_buffer->p_buffer, p_buffer->i_size ); 
     298            httpd_StreamHeader( p_sys->p_httpd_stream, p_sys->p_header, p_sys->i_header_size ); 
     299        } 
     300 
     301        /* send data */ 
     302        i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer, p_buffer->i_size ); 
    329303 
    330304        p_next = p_buffer->p_next;