Changeset e30a3efa66e3663ad97e96f6499e1e0829020a6a
- 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
| r9f3bc42 |
re30a3ef |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * 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 $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Laurent Aimar <fenrir@via.ecp.fr> |
|---|
| … | … | |
| 33 | 33 | #include <vlc/sout.h> |
|---|
| 34 | 34 | |
|---|
| 35 | | #include "httpd.h" |
|---|
| | 35 | #include "vlc_httpd.h" |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | #define FREE( p ) if( p ) { free( p); (p) = NULL; } |
|---|
| … | … | |
| 61 | 61 | struct sout_access_out_sys_t |
|---|
| 62 | 62 | { |
|---|
| 63 | | httpd_t *p_httpd; |
|---|
| 64 | | |
|---|
| 65 | 63 | /* host */ |
|---|
| 66 | 64 | httpd_host_t *p_httpd_host; |
|---|
| … | … | |
| 76 | 74 | }; |
|---|
| 77 | 75 | |
|---|
| | 76 | #if 0 |
|---|
| 78 | 77 | static struct |
|---|
| 79 | 78 | { |
|---|
| … | … | |
| 123 | 122 | return( "application/octet-stream" ); |
|---|
| 124 | 123 | } |
|---|
| | 124 | #endif |
|---|
| | 125 | |
|---|
| 125 | 126 | /***************************************************************************** |
|---|
| 126 | 127 | * Open: open the file |
|---|
| … | … | |
| 137 | 138 | char *psz_file_name; |
|---|
| 138 | 139 | |
|---|
| 139 | | char *psz_mime; |
|---|
| | 140 | char *psz_mime = NULL; |
|---|
| 140 | 141 | |
|---|
| 141 | 142 | if( !( p_sys = p_access->p_sys = |
|---|
| … | … | |
| 197 | 198 | } |
|---|
| 198 | 199 | |
|---|
| 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 ); |
|---|
| 203 | 204 | |
|---|
| 204 | 205 | free( psz_name ); |
|---|
| 205 | 206 | free( psz_file_name ); |
|---|
| 206 | 207 | 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 ); |
|---|
| 218 | 224 | |
|---|
| 219 | 225 | free( psz_name ); |
|---|
| 220 | 226 | free( psz_file_name ); |
|---|
| 221 | 227 | 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; |
|---|
| 251 | 229 | } |
|---|
| 252 | 230 | |
|---|
| … | … | |
| 273 | 251 | sout_access_out_sys_t *p_sys = p_access->p_sys; |
|---|
| 274 | 252 | |
|---|
| 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 ); |
|---|
| 279 | 255 | |
|---|
| 280 | 256 | FREE( p_sys->p_header ); |
|---|
| 281 | 257 | |
|---|
| 282 | | msg_Info( p_access, "Close" ); |
|---|
| | 258 | msg_Dbg( p_access, "Close" ); |
|---|
| 283 | 259 | |
|---|
| 284 | 260 | free( p_sys ); |
|---|
| … | … | |
| 320 | 296 | p_sys->b_header_complete = VLC_TRUE; |
|---|
| 321 | 297 | |
|---|
| 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 ); |
|---|
| 329 | 303 | |
|---|
| 330 | 304 | p_next = p_buffer->p_next; |
|---|