#include <vlc_common.h>
#include <vlc_httpd.h>
-#ifdef ENABLE_HTTPD
-
#include <assert.h>
#include <vlc_network.h>
{ ".mpe", "video/mpeg" },
{ ".mov", "video/quicktime" },
{ ".moov", "video/quicktime" },
+ { ".oga", "audio/ogg" },
{ ".ogg", "application/ogg" },
{ ".ogm", "application/ogg" },
+ { ".ogv", "video/ogg" },
+ { ".spx", "audio/ogg" },
{ ".wav", "audio/wav" },
{ ".wma", "audio/x-ms-wma" },
{ ".wmv", "video/x-ms-wmv" },
ptrval.p_address = httpd;
libvlc_priv (p_this->p_libvlc)->p_httpd = httpd;
- vlc_object_yield( httpd );
+ vlc_object_hold( httpd );
vlc_object_attach( httpd, p_this->p_libvlc );
}
free( psz_host );
if( httpd->i_host <= 0 )
{
+ libvlc_priv (httpd->p_libvlc)->p_httpd = NULL;
vlc_object_release( httpd );
vlc_object_detach( httpd );
vlc_object_release( httpd );
vlc_mutex_unlock( &host->lock );
}
-void httpd_MsgInit( httpd_message_t *msg )
+static void httpd_MsgInit( httpd_message_t *msg )
{
msg->cl = NULL;
msg->i_type = HTTPD_MSG_NONE;
msg->p_body = NULL;
}
-void httpd_MsgClean( httpd_message_t *msg )
+static void httpd_MsgClean( httpd_message_t *msg )
{
int i;
{
*p2++ = '\0';
}
- if( !strncasecmp( p, "rtsp:", 5 ) )
- {
- /* for rtsp url, you have rtsp://localhost:port/path */
- p += 5;
- while( *p == '/' ) p++;
- while( *p && *p != '/' ) p++;
+ if( !strncasecmp( p, ( cl->query.i_proto
+ == HTTPD_PROTO_HTTP ) ? "http" : "rtsp", 4 )
+ && p[4 + !!strchr( "sS", p[4] )] == ':' )
+ { /* Skip hier-part of URL (if present) */
+ p = strchr( p, ':' ) + 1; /* skip URI scheme */
+ if( !strncmp( p, "//", 2 ) ) /* skip authority */
+ { /* see RFC3986 ยง3.2 */
+ p += 2;
+ while( *p && !strchr( "/?#", *p ) ) p++;
+ }
}
cl->query.psz_url = strdup( p );
if( ( p3 = strchr( cl->query.psz_url, '?' ) ) )
counter_t *p_active_counter = stats_CounterCreate( host, VLC_VAR_INTEGER, STATS_COUNTER );
int evfd;
bool b_die;
+ int canc = vlc_savecancel ();
retry:
vlc_object_lock( host );
}
if( ( ( cl->query.i_proto == HTTPD_PROTO_HTTP ) &&
- ( ( cl->answer.i_version == 0 && b_keepalive ) ||
- ( cl->answer.i_version == 1 && !b_connection ) ) ) ||
+ ( ( cl->query.i_version == 0 && b_keepalive ) ||
+ ( cl->query.i_version == 1 && !b_connection ) ) ) ||
( ( cl->query.i_proto == HTTPD_PROTO_RTSP ) &&
!b_query && !b_connection ) )
{
/* Handle client sockets */
vlc_mutex_lock( &host->lock );
now = mdate();
+ nfd = host->nfd;
for( int i_client = 0; i_client < host->i_client; i_client++ )
{
httpd_client_t *cl = host->client[i_client];
- const struct pollfd *pufd = &ufd[host->nfd + i_client];
+ const struct pollfd *pufd = &ufd[nfd];
assert( pufd < &ufd[sizeof(ufd) / sizeof(ufd[0])] );
if( cl->fd != pufd->fd )
continue; // we were not waiting for this client
+ ++nfd;
if( pufd->revents == 0 )
continue; // no event received
stats_CounterClean( p_total_counter );
if( p_active_counter )
stats_CounterClean( p_active_counter );
+ vlc_restorecancel (canc);
return NULL;
}
-
-#else /* ENABLE_HTTPD */
-
-/* We just define an empty wrapper */
-httpd_host_t *httpd_TLSHostNew( vlc_object_t *a, const char *b,
- int c,
- const char *e, const char *f,
- const char *g, const char* h)
-{
- msg_Err( a, "HTTP daemon support is disabled" );
- return NULL;
-}
-
-httpd_host_t *httpd_HostNew( vlc_object_t *a, const char *b,
- int c )
-{
- msg_Err( a, "HTTP daemon support is disabled" );
- return NULL;
-}
-
-void httpd_HostDelete( httpd_host_t *a )
-{
-}
-
-httpd_url_t *httpd_UrlNew( httpd_host_t *host, const char *psz_url,
- const char *psz_user, const char *psz_password,
- const vlc_acl_t *p_acl )
-{
- return NULL;
-}
-
-httpd_url_t *httpd_UrlNewUnique( httpd_host_t *host, const char *psz_url,
- const char *psz_user, const char *psz_password,
- const vlc_acl_t *p_acl )
-{
- return NULL;
-}
-
-int httpd_UrlCatch( httpd_url_t *a, int b, httpd_callback_t c,
- httpd_callback_sys_t *d )
-{
- return 0;
-}
-
-void httpd_UrlDelete( httpd_url_t *a )
-{
-}
-
-char* httpd_ClientIP( const httpd_client_t *cl, char *psz_ip )
-{
- return NULL;
-}
-
-char* httpd_ServerIP( const httpd_client_t *cl, char *psz_ip )
-{
- return NULL;
-}
-
-void httpd_ClientModeStream( httpd_client_t *a )
-{
-}
-
-void httpd_ClientModeBidir( httpd_client_t *a )
-{
-}
-
-httpd_file_sys_t *httpd_FileDelete( httpd_file_t *file )
-{
- return NULL;
-}
-
-httpd_file_t *httpd_FileNew( httpd_host_t *host,
- const char *psz_url, const char *psz_mime,
- const char *psz_user, const char *psz_password,
- const vlc_acl_t *p_acl, httpd_file_callback_t pf_fill,
- httpd_file_sys_t *p_sys )
-{
- return NULL;
-}
-
-httpd_handler_t *httpd_HandlerNew( httpd_host_t *host, const char *psz_url,
- const char *psz_user,
- const char *psz_password,
- const vlc_acl_t *p_acl,
- httpd_handler_callback_t pf_fill,
- httpd_handler_sys_t *p_sys )
-{
- return NULL;
-}
-
-httpd_handler_sys_t *httpd_HandlerDelete( httpd_handler_t *handler )
-{
- return NULL;
-}
-
-void httpd_RedirectDelete( httpd_redirect_t *a )
-{
-}
-
-httpd_redirect_t *httpd_RedirectNew( httpd_host_t *host, const char *psz_url_dst,
- const char *psz_url_src )
-{
- return NULL;
-}
-
-void httpd_StreamDelete( httpd_stream_t *a )
-{
-}
-
-int httpd_StreamHeader( httpd_stream_t *a, uint8_t *b, int c )
-{
- return 0;
-}
-
-int httpd_StreamSend ( httpd_stream_t *a, uint8_t *b, int c )
-{
- return 0;
-}
-
-httpd_stream_t *httpd_StreamNew( httpd_host_t *host,
- const char *psz_url, const char *psz_mime,
- const char *psz_user, const char *psz_password,
- const vlc_acl_t *p_acl )
-{
- return NULL;
-}
-
-void httpd_MsgInit ( httpd_message_t *a )
-{
-}
-
-void httpd_MsgAdd ( httpd_message_t *a, const char *b, const char *c, ... )
-{
-}
-
-const char *httpd_MsgGet( const httpd_message_t *msg, const char *name )
-{
- return "";
-}
-
-void httpd_MsgClean( httpd_message_t *a )
-{
-}
-
-#endif /* ENABLE_HTTPD */