Commit 123a98f9 authored by Clément Stenac's avatar Clément Stenac

* modules/misc/httpd.c: added missing sanity checks

* modules/misc/sap.c: added sanity checks and more coding style fixes

* src/video_output/video_output.c:
  Video filters can now be enabled on the fly (vout is respawned)
  You need to var_Set( p_vout, "filters", psz_yourvalue)
      for this

* modules/gui/wxwindows/interface.cpp : Enable the adjust filter on the fly
parent ef41e224
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* interface.cpp : wxWindows plugin for vlc * interface.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: interface.cpp,v 1.62 2003/10/06 17:41:47 gbazin Exp $ * $Id: interface.cpp,v 1.63 2003/10/08 10:07:22 zorglub Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h> #include <vlc/aout.h>
#include <vlc/vout.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include "stream_control.h" #include "stream_control.h"
...@@ -498,9 +499,9 @@ void Interface::CreateOurExtraPanel() ...@@ -498,9 +499,9 @@ void Interface::CreateOurExtraPanel()
hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0, hue_slider = new wxSlider ( extra_frame, Hue_Event, 0, 0,
360, wxDefaultPosition, wxDefaultSize ); 360, wxDefaultPosition, wxDefaultSize );
hue_sizer->Add(hue_text,1, 0 ,0); hue_sizer->Add(hue_text,1, 0 ,0);
hue_sizer->Add(hue_slider,1, 0 ,0); hue_sizer->Add(hue_slider,1, 0 ,0);
hue_sizer->Layout(); hue_sizer->Layout();
wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *contrast_sizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *contrast_text = new wxStaticText( extra_frame, -1, wxStaticText *contrast_text = new wxStaticText( extra_frame, -1,
...@@ -598,6 +599,21 @@ void Interface::CreateOurExtraPanel() ...@@ -598,6 +599,21 @@ void Interface::CreateOurExtraPanel()
hue_slider->Disable(); hue_slider->Disable();
} }
int i_value = config_GetInt( p_intf, "hue" );
if( i_value > 0 && i_value < 360 )
hue_slider->SetValue( i_value );
float f_value;
f_value = config_GetFloat( p_intf, "saturation" );
if( f_value > 0 && f_value < 3 )
saturation_slider->SetValue( (int)(100 * f_value) );
f_value = config_GetFloat( p_intf, "contrast" );
if( f_value > 0 && f_value < 2 )
contrast_slider->SetValue( (int)(100 * f_value) );
f_value = config_GetFloat( p_intf, "brightness" );
if( f_value > 0 && f_value < 2 )
brightness_slider->SetValue( (int)(100 * f_value) );
extra_frame->Hide(); extra_frame->Hide();
free(psz_filters); free(psz_filters);
} }
...@@ -859,7 +875,17 @@ void Interface::OnEnableAdjust(wxCommandEvent& event) ...@@ -859,7 +875,17 @@ void Interface::OnEnableAdjust(wxCommandEvent& event)
sprintf( psz_new, "%s:adjust", psz_filters); sprintf( psz_new, "%s:adjust", psz_filters);
} }
config_PutPsz( p_intf, "filter", psz_new ); config_PutPsz( p_intf, "filter", psz_new );
vlc_value_t val;
vout_thread_t *p_vout =
(vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout != NULL )
{
val.psz_string = strdup( psz_new );
var_Set( p_vout, "filter", val);
vlc_object_release( p_vout );
}
if( val.psz_string ) free( val.psz_string );
brightness_slider->Enable(); brightness_slider->Enable();
saturation_slider->Enable(); saturation_slider->Enable();
contrast_slider->Enable(); contrast_slider->Enable();
...@@ -890,6 +916,17 @@ void Interface::OnEnableAdjust(wxCommandEvent& event) ...@@ -890,6 +916,17 @@ void Interface::OnEnableAdjust(wxCommandEvent& event)
} }
} }
config_PutPsz( p_intf, "filter", psz_filters); config_PutPsz( p_intf, "filter", psz_filters);
vlc_value_t val;
val.psz_string = strdup( psz_filters );
vout_thread_t *p_vout =
(vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout != NULL )
{
var_Set( p_vout, "filter", val);
vlc_object_release( p_vout );
}
if( val.psz_string ) free( val.psz_string );
} }
brightness_slider->Disable(); brightness_slider->Disable();
saturation_slider->Disable(); saturation_slider->Disable();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* httpd.c * httpd.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * Copyright (C) 2001-2003 VideoLAN
* $Id: httpd.c,v 1.27 2003/08/26 00:40:27 fenrir Exp $ * $Id: httpd.c,v 1.28 2003/10/08 10:07:22 zorglub Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -114,7 +114,9 @@ static httpd_file_t *RegisterFile ( httpd_t *, ...@@ -114,7 +114,9 @@ static httpd_file_t *RegisterFile ( httpd_t *,
httpd_file_callback_args_t *p_args ); httpd_file_callback_args_t *p_args );
static void UnregisterFile ( httpd_t *, httpd_file_t * ); static void UnregisterFile ( httpd_t *, httpd_file_t * );
//#define httpd_stream_t httpd_file_t #if 0
#define httpd_stream_t httpd_file_t
#endif
static httpd_stream_t *RegisterStream ( httpd_t *, static httpd_stream_t *RegisterStream ( httpd_t *,
char *psz_file, char *psz_mime, char *psz_file, char *psz_mime,
char *psz_user, char *psz_password ); char *psz_user, char *psz_password );
...@@ -143,7 +145,9 @@ enum httpd_authenticate_e ...@@ -143,7 +145,9 @@ enum httpd_authenticate_e
HTTPD_AUTHENTICATE_BASIC = 1 HTTPD_AUTHENTICATE_BASIC = 1
}; };
//typedef httpd_file_t httpd_stream_t; #if 0
typedef httpd_file_t httpd_stream_t;
#endif
struct httpd_file_t struct httpd_file_t
{ {
...@@ -207,12 +211,12 @@ typedef struct httpd_connection_s ...@@ -207,12 +211,12 @@ typedef struct httpd_connection_s
int i_state; int i_state;
int i_method; /* get/post */ int i_method; /* get/post */
char *psz_file; // file to be send char *psz_file; /* file to be send */
int i_http_error; // error to be send with the file int i_http_error; /* error to be send with the file */
char *psz_user; // if Authorization in the request header char *psz_user; /* if Authorization in the request header */
char *psz_password; char *psz_password;
uint8_t *p_request; // whith get: ?<*>, with post: main data uint8_t *p_request; /* whith get: ?<*>, with post: main data */
int i_request_size; int i_request_size;
httpd_file_t *p_file; httpd_file_t *p_file;
...@@ -288,19 +292,36 @@ static int Open( vlc_object_t *p_this ) ...@@ -288,19 +292,36 @@ static int Open( vlc_object_t *p_this )
p_httpt->b_error= 0; p_httpt->b_error= 0;
/* init httpt_t structure */ /* init httpt_t structure */
vlc_mutex_init( p_httpd, &p_httpt->host_lock ); if( vlc_mutex_init( p_httpd, &p_httpt->host_lock ) )
{
msg_Err( p_httpd, "Error in mutex creation");
return( VLC_EGENERIC );
}
p_httpt->i_host_count = 0; p_httpt->i_host_count = 0;
p_httpt->host = NULL; p_httpt->host = NULL;
vlc_mutex_init( p_httpd, &p_httpt->file_lock ); if( vlc_mutex_init( p_httpd, &p_httpt->file_lock ) )
{
msg_Err( p_httpd, "Error in mutex creation");
return( VLC_EGENERIC );
}
p_httpt->i_file_count = 0; p_httpt->i_file_count = 0;
p_httpt->file = NULL; p_httpt->file = NULL;
vlc_mutex_init( p_httpd, &p_httpt->connection_lock ); if( vlc_mutex_init( p_httpd, &p_httpt->connection_lock ) )
{
msg_Err( p_httpd, "Error in mutex creation");
return( VLC_EGENERIC );
}
p_httpt->i_connection_count = 0; p_httpt->i_connection_count = 0;
p_httpt->p_first_connection = NULL; p_httpt->p_first_connection = NULL;
vlc_mutex_init( p_httpd, &p_httpt->ban_lock ); if( vlc_mutex_init( p_httpd, &p_httpt->ban_lock ) )
{
msg_Err( p_httpd, "Error in mutex creation");
return( VLC_EGENERIC );
}
p_httpt->i_banned_ip_count = 0; p_httpt->i_banned_ip_count = 0;
p_httpt->p_first_banned_ip = NULL; p_httpt->p_first_banned_ip = NULL;
...@@ -559,9 +580,24 @@ static httpd_host_t *_RegisterHost( httpd_sys_t *p_httpt, char *psz_host_addr, i ...@@ -559,9 +580,24 @@ static httpd_host_t *_RegisterHost( httpd_sys_t *p_httpt, char *psz_host_addr, i
{ {
p_httpt->host = malloc( sizeof( httpd_host_t *) ); p_httpt->host = malloc( sizeof( httpd_host_t *) );
} }
if( !p_httpt->host )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
p_host = malloc( sizeof( httpd_host_t ) ); p_host = malloc( sizeof( httpd_host_t ) );
if( !p_host )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
p_host->i_ref = 1; p_host->i_ref = 1;
p_host->psz_host_addr = strdup( psz_host_addr ); p_host->psz_host_addr = strdup( psz_host_addr );
if( !p_host->psz_host_addr )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
p_host->i_port = i_port; p_host->i_port = i_port;
p_host->sock = sock; p_host->sock = sock;
p_host->fd = fd; p_host->fd = fd;
...@@ -642,6 +678,11 @@ static void _UnregisterHost( httpd_sys_t *p_httpt, httpd_host_t *p_ho ...@@ -642,6 +678,11 @@ static void _UnregisterHost( httpd_sys_t *p_httpt, httpd_host_t *p_ho
p_httpt->i_host_count--; p_httpt->i_host_count--;
p_httpt->host = realloc( p_httpt->host, p_httpt->host = realloc( p_httpt->host,
p_httpt->i_host_count * sizeof( httpd_host_t * ) ); p_httpt->i_host_count * sizeof( httpd_host_t * ) );
if( !p_httpt->p_host )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
} }
vlc_mutex_unlock( &p_httpt->host_lock ); vlc_mutex_unlock( &p_httpt->host_lock );
...@@ -663,7 +704,10 @@ static void __RegisterFile( httpd_sys_t *p_httpt, httpd_file_t *p_file ) ...@@ -663,7 +704,10 @@ static void __RegisterFile( httpd_sys_t *p_httpt, httpd_file_t *p_file )
{ {
p_httpt->file = malloc( sizeof( httpd_file_t *) ); p_httpt->file = malloc( sizeof( httpd_file_t *) );
} }
if( !p_httpt->file )
{
return;
}
p_httpt->file[p_httpt->i_file_count++] = p_file; p_httpt->file[p_httpt->i_file_count++] = p_file;
} }
...@@ -693,14 +737,29 @@ static httpd_file_t *_RegisterFile( httpd_sys_t *p_httpt, ...@@ -693,14 +737,29 @@ static httpd_file_t *_RegisterFile( httpd_sys_t *p_httpt,
} }
p_file = malloc( sizeof( httpd_file_t ) ); p_file = malloc( sizeof( httpd_file_t ) );
if( !p_file )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
p_file->i_ref = 0; p_file->i_ref = 0;
p_file->psz_file = strdup( psz_file ); p_file->psz_file = strdup( psz_file );
p_file->psz_mime = strdup( psz_mime ); p_file->psz_mime = strdup( psz_mime );
if( !p_file->psz_file || !p_file->psz_mime )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
if( psz_user && *psz_user ) if( psz_user && *psz_user )
{ {
p_file->i_authenticate_method = HTTPD_AUTHENTICATE_BASIC; p_file->i_authenticate_method = HTTPD_AUTHENTICATE_BASIC;
p_file->psz_user = strdup( psz_user ); p_file->psz_user = strdup( psz_user );
p_file->psz_password = strdup( psz_password ); p_file->psz_password = strdup( psz_password );
if( !p_file->psz_user || !p_file->psz_password )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
} }
else else
{ {
...@@ -763,14 +822,29 @@ static httpd_stream_t *_RegisterStream( httpd_sys_t *p_httpt, ...@@ -763,14 +822,29 @@ static httpd_stream_t *_RegisterStream( httpd_sys_t *p_httpt,
} }
p_stream = malloc( sizeof( httpd_stream_t ) ); p_stream = malloc( sizeof( httpd_stream_t ) );
if( !p_stream )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
p_stream->i_ref = 0; p_stream->i_ref = 0;
p_stream->psz_file = strdup( psz_file ); p_stream->psz_file = strdup( psz_file );
p_stream->psz_mime = strdup( psz_mime ); p_stream->psz_mime = strdup( psz_mime );
if( !p_file->psz_file || !p_file->psz_mime )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
if( psz_user && *psz_user ) if( psz_user && *psz_user )
{ {
p_stream->i_authenticate_method = HTTPD_AUTHENTICATE_BASIC; p_stream->i_authenticate_method = HTTPD_AUTHENTICATE_BASIC;
p_stream->psz_user = strdup( psz_user ); p_stream->psz_user = strdup( psz_user );
p_stream->psz_password = strdup( psz_password ); p_stream->psz_password = strdup( psz_password );
if( !p_file->psz_user || !p_file->psz_password )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
} }
else else
{ {
...@@ -788,6 +862,11 @@ static httpd_stream_t *_RegisterStream( httpd_sys_t *p_httpt, ...@@ -788,6 +862,11 @@ static httpd_stream_t *_RegisterStream( httpd_sys_t *p_httpt,
p_stream->i_buffer_pos = 0; p_stream->i_buffer_pos = 0;
p_stream->i_buffer_last_pos = 0; p_stream->i_buffer_last_pos = 0;
p_stream->p_buffer = malloc( p_stream->i_buffer_size ); p_stream->p_buffer = malloc( p_stream->i_buffer_size );
if( !p_stream->p_buffer )
{
msg_Err( p_httpt, "Out of memory" );
return NULL;
}
p_stream->i_header_size = 0; p_stream->i_header_size = 0;
p_stream->p_header = NULL; p_stream->p_header = NULL;
...@@ -900,8 +979,9 @@ static int _SendStream( httpd_sys_t *p_httpt, httpd_stream_t *p_stre ...@@ -900,8 +979,9 @@ static int _SendStream( httpd_sys_t *p_httpt, httpd_stream_t *p_stre
{ {
return( VLC_SUCCESS ); return( VLC_SUCCESS );
} }
//fprintf( stderr, "## i_data=%d pos=%lld\n", i_data, p_stream->i_buffer_pos ); #if 0
fprintf( stderr, "## i_data=%d pos=%lld\n", i_data, p_stream->i_buffer_pos );
#endif
vlc_mutex_lock( &p_httpt->file_lock ); vlc_mutex_lock( &p_httpt->file_lock );
/* save this pointer (to be used by new connection) */ /* save this pointer (to be used by new connection) */
...@@ -915,6 +995,7 @@ static int _SendStream( httpd_sys_t *p_httpt, httpd_stream_t *p_stre ...@@ -915,6 +995,7 @@ static int _SendStream( httpd_sys_t *p_httpt, httpd_stream_t *p_stre
i_copy = __MIN( i_count, p_stream->i_buffer_size - i_pos ); i_copy = __MIN( i_count, p_stream->i_buffer_size - i_pos );
/* Ok, we can't go past the end of our buffer */
memcpy( &p_stream->p_buffer[i_pos], memcpy( &p_stream->p_buffer[i_pos],
p_data, p_data,
i_copy ); i_copy );
...@@ -929,6 +1010,7 @@ static int _SendStream( httpd_sys_t *p_httpt, httpd_stream_t *p_stre ...@@ -929,6 +1010,7 @@ static int _SendStream( httpd_sys_t *p_httpt, httpd_stream_t *p_stre
return( VLC_SUCCESS ); return( VLC_SUCCESS );
} }
static int SendStream( httpd_t *p_httpd, httpd_stream_t *p_stream, uint8_t *p_data, int i_data ) static int SendStream( httpd_t *p_httpd, httpd_stream_t *p_stream, uint8_t *p_data, int i_data )
{ {
return( _SendStream( p_httpd->p_sys, p_stream, p_data, i_data ) ); return( _SendStream( p_httpd->p_sys, p_stream, p_data, i_data ) );
...@@ -949,6 +1031,11 @@ static int HeaderStream( httpd_t *p_httpd, httpd_stream_t *p_stream, ...@@ -949,6 +1031,11 @@ static int HeaderStream( httpd_t *p_httpd, httpd_stream_t *p_stream,
{ {
p_stream->i_header_size = i_data; p_stream->i_header_size = i_data;
p_stream->p_header = malloc( i_data ); p_stream->p_header = malloc( i_data );
if( !p_stream->p_header )
{
msg_Err( p_httpt, "Out of memory" );
return( VLC_ENOMEM );
}
memcpy( p_stream->p_header, memcpy( p_stream->p_header,
p_data, p_data,
i_data ); i_data );
...@@ -970,14 +1057,22 @@ static void httpd_info_add_ss( httpd_info_t *p_info, char *name, char *value ) ...@@ -970,14 +1057,22 @@ static void httpd_info_add_ss( httpd_info_t *p_info, char *name, char *value )
realloc( p_info->info, realloc( p_info->info,
sizeof( httpd_val_t ) * ( p_info->i_count + 1 ) ); sizeof( httpd_val_t ) * ( p_info->i_count + 1 ) );
} }
if( !p_info->info )
{
return;
}
p_info->info[p_info->i_count].psz_name = strdup( name ); p_info->info[p_info->i_count].psz_name = strdup( name );
if( ! p_info->info[p_info->i_count].psz_name )
{
return;
}
p_info->info[p_info->i_count].psz_value = strdup( value ? value : "(null)"); p_info->info[p_info->i_count].psz_value = strdup( value ? value : "(null)");
p_info->i_count++; p_info->i_count++;
} }
static void httpd_info_add_si( httpd_info_t *p_info, char *name, int i_value ) static void httpd_info_add_si( httpd_info_t *p_info, char *name, int i_value )
{ {
char v[40]; char v[40]; /* Ok, int is not so long */
sprintf( v, "%d", i_value ); sprintf( v, "%d", i_value );
httpd_info_add_ss( p_info, name, v ); httpd_info_add_ss( p_info, name, v );
...@@ -1101,7 +1196,10 @@ static int httpd_page_400_get( httpd_file_callback_args_t *p_args, ...@@ -1101,7 +1196,10 @@ static int httpd_page_400_get( httpd_file_callback_args_t *p_args,
char *p; char *p;
p = *pp_data = malloc( 1024 ); p = *pp_data = malloc( 1024 );
if( !p )
{
return VLC_ENOMEM ;
}
p += sprintf( p, "<html>\n" ); p += sprintf( p, "<html>\n" );
p += sprintf( p, "<head>\n" ); p += sprintf( p, "<head>\n" );
p += sprintf( p, "<title>Error 400</title>\n" ); p += sprintf( p, "<title>Error 400</title>\n" );
...@@ -1125,6 +1223,10 @@ static int httpd_page_401_get( httpd_file_callback_args_t *p_args, ...@@ -1125,6 +1223,10 @@ static int httpd_page_401_get( httpd_file_callback_args_t *p_args,
char *p; char *p;
p = *pp_data = malloc( 1024 ); p = *pp_data = malloc( 1024 );
if( !p )
{
return VLC_ENOMEM ;
}
p += sprintf( p, "<html>\n" ); p += sprintf( p, "<html>\n" );
p += sprintf( p, "<head>\n" ); p += sprintf( p, "<head>\n" );
...@@ -1148,6 +1250,10 @@ static int httpd_page_404_get( httpd_file_callback_args_t *p_args, ...@@ -1148,6 +1250,10 @@ static int httpd_page_404_get( httpd_file_callback_args_t *p_args,
char *p; char *p;
p = *pp_data = malloc( 1024 ); p = *pp_data = malloc( 1024 );
if( !p )
{
return VLC_ENOMEM ;
}
p += sprintf( p, "<html>\n" ); p += sprintf( p, "<html>\n" );
p += sprintf( p, "<head>\n" ); p += sprintf( p, "<head>\n" );
...@@ -1276,6 +1382,11 @@ static void httpd_ConnnectionNew( httpd_sys_t *p_httpt, int fd, struct sockaddr_ ...@@ -1276,6 +1382,11 @@ static void httpd_ConnnectionNew( httpd_sys_t *p_httpt, int fd, struct sockaddr_
/* create a new connection and link it */ /* create a new connection and link it */
p_con = malloc( sizeof( httpd_connection_t ) ); p_con = malloc( sizeof( httpd_connection_t ) );
if( !p_con )
{
msg_Err( p_httpt, "Out of memory" );
return;
}
p_con->i_state = HTTPD_CONNECTION_RECEIVING_REQUEST; p_con->i_state = HTTPD_CONNECTION_RECEIVING_REQUEST;
p_con->fd = fd; p_con->fd = fd;
p_con->i_last_activity_date = mdate(); p_con->i_last_activity_date = mdate();
...@@ -1293,8 +1404,13 @@ static void httpd_ConnnectionNew( httpd_sys_t *p_httpt, int fd, struct sockaddr_ ...@@ -1293,8 +1404,13 @@ static void httpd_ConnnectionNew( httpd_sys_t *p_httpt, int fd, struct sockaddr_
p_con->i_buffer = 0; p_con->i_buffer = 0;
p_con->i_buffer_size = 8096; p_con->i_buffer_size = 8096;
p_con->p_buffer = malloc( p_con->i_buffer_size ); p_con->p_buffer = malloc( p_con->i_buffer_size );
if( !p_con->p_buffer )
{
msg_Err( p_httpt, "Out of memory");
return ;
}
p_con->i_stream_pos = 0; // updated by httpd_thread */ p_con->i_stream_pos = 0; /* updated by httpd_thread */
p_con->p_next = NULL; p_con->p_next = NULL;
if( p_httpt->p_first_connection ) if( p_httpt->p_first_connection )
...@@ -1395,7 +1511,7 @@ static int httpd_RequestNextLine( char **pp_buffer, char *p_end ) ...@@ -1395,7 +1511,7 @@ static int httpd_RequestNextLine( char **pp_buffer, char *p_end )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
//char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /*char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";*/
static void b64_decode( char *dest, char *src ) static void b64_decode( char *dest, char *src )
{ {
int i_level; int i_level;
...@@ -1460,6 +1576,7 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection ...@@ -1460,6 +1576,7 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection
int i; int i;
int b_xplaystream = VLC_FALSE; int b_xplaystream = VLC_FALSE;
/* Size is checked for all of these */
char command[32]; char command[32];
char url[1024]; char url[1024];
char version[32]; char version[32];
...@@ -1475,8 +1592,9 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection ...@@ -1475,8 +1592,9 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection
httpd_RequestGetWord( command, 32, &p, p_end ); httpd_RequestGetWord( command, 32, &p, p_end );
httpd_RequestGetWord( url, 1024, &p, p_end ); httpd_RequestGetWord( url, 1024, &p, p_end );
httpd_RequestGetWord( version, 32, &p, p_end ); httpd_RequestGetWord( version, 32, &p, p_end );
//msg_Dbg( p_httpt, "ask =%s= =%s= =%s=", command, url, version ); #if 0
msg_Dbg( p_httpt, "ask =%s= =%s= =%s=", command, url, version );
#endif
p_con->p_request = NULL; p_con->p_request = NULL;
p_con->i_request_size = 0; p_con->i_request_size = 0;
if( !strcmp( command, "GET" ) ) if( !strcmp( command, "GET" ) )
...@@ -1515,11 +1633,14 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection ...@@ -1515,11 +1633,14 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection
if( httpd_RequestNextLine( &p, p_end ) ) if( httpd_RequestNextLine( &p, p_end ) )
{ {
//msg_Dbg( p_httpt, "failled new line" ); #if 0
msg_Dbg( p_httpt, "failled new line" );
#endif
break;; break;;
} }
//msg_Dbg( p_httpt, "new line=%s", p ); #if 0
msg_Dbg( p_httpt, "new line=%s", p );
#endif
httpd_RequestGetWord( header, 1024, &p, p_end ); httpd_RequestGetWord( header, 1024, &p, p_end );
if( !strcmp( header, "\r\n" ) || !strcmp( header, "\n" ) ) if( !strcmp( header, "\r\n" ) || !strcmp( header, "\n" ) )
{ {
...@@ -1537,9 +1658,13 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection ...@@ -1537,9 +1658,13 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection
char decoded[1024]; char decoded[1024];
httpd_RequestGetWord( basic, 1024, &p, p_end ); httpd_RequestGetWord( basic, 1024, &p, p_end );
// msg_Dbg( p_httpt, "Authorization: basic:%s", basic ); #if 0
msg_Dbg( p_httpt, "Authorization: basic:%s", basic );
#endif
b64_decode( decoded, basic ); b64_decode( decoded, basic );
// msg_Dbg( p_httpt, "Authorization: decoded:%s", decoded ); #if 0
msg_Dbg( p_httpt, "Authorization: decoded:%s", decoded );
#endif
if( strchr( decoded, ':' ) ) if( strchr( decoded, ':' ) )
{ {
char *p = strchr( decoded, ':' ); char *p = strchr( decoded, ':' );
...@@ -1595,7 +1720,11 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection ...@@ -1595,7 +1720,11 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection
{ {
p_con->i_request_size = p_end - p_request; p_con->i_request_size = p_end - p_request;
p_con->p_request = malloc( p_con->i_request_size + 1); p_con->p_request = malloc( p_con->i_request_size + 1);
if( !p_con->p_request)
{
msg_Err( p_httpt, "Out of memory" );
return;
}
memcpy( p_con->p_request, memcpy( p_con->p_request,
p_request, p_request,
p_con->i_request_size ); p_con->i_request_size );
...@@ -1606,17 +1735,23 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection ...@@ -1606,17 +1735,23 @@ static void httpd_ConnectionParseRequest( httpd_sys_t *p_httpt, httpd_connection
p_con->i_http_error = 200; p_con->i_http_error = 200;
create_header: create_header:
//msg_Dbg( p_httpt, "ask %s %s %d", command, p_con->psz_file, p_con->i_http_error ); #if 0
msg_Dbg( p_httpt, "ask %s %s %d", command, p_con->psz_file, p_con->i_http_error );
#endif
FREE( p_con->p_buffer ); FREE( p_con->p_buffer );
p_con->i_buffer = 0; p_con->i_buffer = 0;
p_con->i_buffer_size = 0; p_con->i_buffer_size = 0;
//vlc_mutex_lock( &p_httpt->file_lock ); #if 0
vlc_mutex_lock( &p_httpt->file_lock );
#endif
search_file: search_file:
/* search file */ /* search file */
p_con->p_file = NULL; p_con->p_file = NULL;
for( i = 0; i < p_httpt->i_file_count; i++ ) for( i = 0; i < p_httpt->i_file_count; i++ )
{ {
/* Our strdup call failed */
if( !p_con->psz_file ) return;
if( !strcmp( p_httpt->file[i]->psz_file, p_con->psz_file ) ) if( !strcmp( p_httpt->file[i]->psz_file, p_con->psz_file ) )
{ {
if( p_httpt->file[i]->b_stream || if( p_httpt->file[i]->b_stream ||
...@@ -1664,7 +1799,9 @@ search_file: ...@@ -1664,7 +1799,9 @@ search_file:
} }
p_con->p_file->i_ref++; p_con->p_file->i_ref++;
// vlc_mutex_unlock( &p_httpt->file_lock ); #if 0
vlc_mutex_unlock( &p_httpt->file_lock );
#endif
switch( p_con->i_http_error ) switch( p_con->i_http_error )
{ {
...@@ -1694,7 +1831,11 @@ search_file: ...@@ -1694,7 +1831,11 @@ search_file:
} }
p = p_con->p_buffer = malloc( p_con->i_buffer_size ); p = p_con->p_buffer = malloc( p_con->i_buffer_size );
if( !p)
{
msg_Err( p_httpt, "Out of memory" );
return;
}
p += sprintf( p, "HTTP/1.0 %d %s\r\n", p_con->i_http_error, psz_status ); p += sprintf( p, "HTTP/1.0 %d %s\r\n", p_con->i_http_error, psz_status );
/* Special mmsh case cludgy but ...*/ /* Special mmsh case cludgy but ...*/
...@@ -1752,7 +1893,9 @@ search_file: ...@@ -1752,7 +1893,9 @@ search_file:
{ {
p_con->i_method = HTTPD_CONNECTION_METHOD_HEAD; p_con->i_method = HTTPD_CONNECTION_METHOD_HEAD;
} }
//msg_Dbg( p_httpt, "answer=\n%s", p_con->p_buffer ); #if 0
msg_Dbg( p_httpt, "answer=\n%s", p_con->p_buffer );
#endif
} }
#define HTTPD_STREAM_PACKET 10000 #define HTTPD_STREAM_PACKET 10000
static void httpd_Thread( httpd_sys_t *p_httpt ) static void httpd_Thread( httpd_sys_t *p_httpt )
...@@ -1961,7 +2104,9 @@ static void httpd_Thread( httpd_sys_t *p_httpt ) ...@@ -1961,7 +2104,9 @@ static void httpd_Thread( httpd_sys_t *p_httpt )
{ {
i_len = 0; i_len = 0;
} }
// msg_Warn( p_httpt, "on %d send %d bytes %s", p_con->i_buffer_size, i_len, p_con->p_buffer + p_con->i_buffer ); #if 0
msg_Warn( p_httpt, "on %d send %d bytes %s", p_con->i_buffer_size, i_len, p_con->p_buffer + p_con->i_buffer );
#endif
#if defined( WIN32 ) || defined( UNDER_CE ) #if defined( WIN32 ) || defined( UNDER_CE )
if( ( i_len < 0 && WSAGetLastError() != WSAEWOULDBLOCK ) || ( i_len == 0 ) ) if( ( i_len < 0 && WSAGetLastError() != WSAEWOULDBLOCK ) || ( i_len == 0 ) )
...@@ -1989,7 +2134,7 @@ static void httpd_Thread( httpd_sys_t *p_httpt ) ...@@ -1989,7 +2134,7 @@ static void httpd_Thread( httpd_sys_t *p_httpt )
if( !p_con->p_file->b_stream || p_con->i_method == HTTPD_CONNECTION_METHOD_HEAD ) if( !p_con->p_file->b_stream || p_con->i_method == HTTPD_CONNECTION_METHOD_HEAD )
{ {
p_con->i_state = HTTPD_CONNECTION_SENDING_FILE; // be sure to out from HTTPD_CONNECTION_SENDING_HEADER p_con->i_state = HTTPD_CONNECTION_SENDING_FILE; /* be sure to out from HTTPD_CONNECTION_SENDING_HEADER */
if( p_con->i_method == HTTPD_CONNECTION_METHOD_GET ) if( p_con->i_method == HTTPD_CONNECTION_METHOD_GET )
{ {
p_con->p_file->pf_get( p_con->p_file->p_sys, p_con->p_file->pf_get( p_con->p_file->p_sys,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sap.c : SAP interface module * sap.c : SAP interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: sap.c,v 1.24 2003/10/06 16:23:30 zorglub Exp $ * $Id: sap.c,v 1.25 2003/10/08 10:07:22 zorglub Exp $
* *
* Authors: Arnaud Schauly <gitan@via.ecp.fr> * Authors: Arnaud Schauly <gitan@via.ecp.fr>
* Clment Stenac <zorglub@via.ecp.fr> * Clment Stenac <zorglub@via.ecp.fr>
...@@ -116,7 +116,7 @@ static void free_sd( sess_descr_t * ); ...@@ -116,7 +116,7 @@ static void free_sd( sess_descr_t * );
static int ismult( char * ); static int ismult( char * );
/* The struct that contains sdp informations */ /* The struct that contains sdp informations */
struct sess_descr_t struct sess_descr_t
{ {
char *psz_version; char *psz_version;
char *psz_origin; char *psz_origin;
...@@ -136,13 +136,13 @@ struct sess_descr_t ...@@ -136,13 +136,13 @@ struct sess_descr_t
}; };
/* All this informations are not useful yet. */ /* All this informations are not useful yet. */
struct media_descr_t struct media_descr_t
{ {
char *psz_medianame; char *psz_medianame;
char *psz_mediaconnection; char *psz_mediaconnection;
}; };
struct attr_descr_t struct attr_descr_t
{ {
char *psz_field; char *psz_field;
char *psz_value; char *psz_value;
...@@ -212,11 +212,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -212,11 +212,11 @@ static void Run( intf_thread_t *p_intf )
char *psz_network = NULL; char *psz_network = NULL;
int fd = - 1; int fd = - 1;
int fdv6 = -1; int fdv6 = -1;
int no_sap_ipv4 = config_GetInt( p_intf, "no-sap-ipv4" ); int no_sap_ipv4 = config_GetInt( p_intf, "no-sap-ipv4" );
int sap_ipv6 = config_GetInt( p_intf, "sap-ipv6" ); int sap_ipv6 = config_GetInt( p_intf, "sap-ipv6" );
char *sap_ipv6_scope = config_GetPsz( p_intf, "sap-ipv6-scope" ); char *sap_ipv6_scope = config_GetPsz( p_intf, "sap-ipv6-scope" );
char buffer[MAX_SAP_BUFFER + 1]; char buffer[MAX_SAP_BUFFER + 1];
module_t *p_network; module_t *p_network;
...@@ -227,15 +227,15 @@ static void Run( intf_thread_t *p_intf ) ...@@ -227,15 +227,15 @@ static void Run( intf_thread_t *p_intf )
msg_Warn( p_intf, "Unable to parse module configuration" ); msg_Warn( p_intf, "Unable to parse module configuration" );
return; return;
} }
/* Prepare IPv4 Networking */ /* Prepare IPv4 Networking */
if ( no_sap_ipv4 == 0) if ( no_sap_ipv4 == 0)
{ {
if( !(psz_addr = config_GetPsz( p_intf, "sap-addr" ) ) ) if( !(psz_addr = config_GetPsz( p_intf, "sap-addr" ) ) )
{ {
psz_addr = strdup( HELLO_GROUP ); psz_addr = strdup( HELLO_GROUP );
} }
/* Prepare the network_socket_t structure */ /* Prepare the network_socket_t structure */
socket_desc.i_type = NETWORK_UDP; socket_desc.i_type = NETWORK_UDP;
socket_desc.psz_bind_addr = psz_addr; socket_desc.psz_bind_addr = psz_addr;
...@@ -245,10 +245,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -245,10 +245,10 @@ static void Run( intf_thread_t *p_intf )
socket_desc.i_ttl = 0; socket_desc.i_ttl = 0;
p_intf->p_private = (void*) &socket_desc; p_intf->p_private = (void*) &socket_desc;
psz_network = "ipv4"; psz_network = "ipv4";
/* Create, Bind the socket, ... with the appropriate module */ /* Create, Bind the socket, ... with the appropriate module */
if( !( p_network = module_Need( p_intf, "network", psz_network ) ) ) if( !( p_network = module_Need( p_intf, "network", psz_network ) ) )
{ {
msg_Warn( p_intf, "failed to open a connection (udp)" ); msg_Warn( p_intf, "failed to open a connection (udp)" );
...@@ -264,12 +264,17 @@ static void Run( intf_thread_t *p_intf ) ...@@ -264,12 +264,17 @@ static void Run( intf_thread_t *p_intf )
{ {
/* Prepare the network_socket_t structure */ /* Prepare the network_socket_t structure */
psz_addrv6=(char *)malloc(sizeof(char)*38); psz_addrv6=(char *)malloc(sizeof(char)*38);
if( !psz_addrv6)
{
msg_Warn( p_intf, "Out of memory !" );
}
/* Max size of an IPv6 address */ /* Max size of an IPv6 address */
sprintf(psz_addrv6,"[%s%c%s]",IPV6_ADDR_1, sprintf(psz_addrv6,"[%s%c%s]",IPV6_ADDR_1,
sap_ipv6_scope[0],IPV6_ADDR_2); sap_ipv6_scope[0],IPV6_ADDR_2);
socket_desc.i_type = NETWORK_UDP; socket_desc.i_type = NETWORK_UDP;
socket_desc.psz_bind_addr = psz_addrv6; socket_desc.psz_bind_addr = psz_addrv6;
socket_desc.i_bind_port = HELLO_PORT; socket_desc.i_bind_port = HELLO_PORT;
...@@ -278,10 +283,10 @@ static void Run( intf_thread_t *p_intf ) ...@@ -278,10 +283,10 @@ static void Run( intf_thread_t *p_intf )
socket_desc.i_ttl = 0; socket_desc.i_ttl = 0;
p_intf->p_private = (void*) &socket_desc; p_intf->p_private = (void*) &socket_desc;
psz_network = "ipv6"; psz_network = "ipv6";
/* Create, Bind the socket, ... with the appropriate module */ /* Create, Bind the socket, ... with the appropriate module */
if( !( p_network = module_Need( p_intf, "network", psz_network ) ) ) if( !( p_network = module_Need( p_intf, "network", psz_network ) ) )
{ {
msg_Warn( p_intf, "failed to open a connection (udp)" ); msg_Warn( p_intf, "failed to open a connection (udp)" );
...@@ -292,7 +297,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -292,7 +297,7 @@ static void Run( intf_thread_t *p_intf )
fdv6 = socket_desc.i_handle; fdv6 = socket_desc.i_handle;
} }
/* read SAP packets */ /* read SAP packets */
while( !p_intf->b_die ) while( !p_intf->b_die )
{ {
...@@ -317,7 +322,20 @@ static void Run( intf_thread_t *p_intf ) ...@@ -317,7 +322,20 @@ static void Run( intf_thread_t *p_intf )
} }
/* Closing socket */ /* Closing socket */
close( socket_desc.i_handle ); if( fd )
{
if( close( fd ) )
{
msg_Warn( p_intf, "Ohoh, unable to close the socket") ;
}
}
if( fdv6 )
{
if( close( fdv6 ) )
{
msg_Warn( p_intf, "Ohoh, unable to close the socket") ;
}
}
} }
/******************************************************************** /********************************************************************
...@@ -415,7 +433,7 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -415,7 +433,7 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
if(!strcasecmp( p_sd->pp_attributes[i]->psz_field , "http-path")) if(!strcasecmp( p_sd->pp_attributes[i]->psz_field , "http-path"))
{ {
psz_http_path = strdup( p_sd->pp_attributes[i]->psz_value ); psz_http_path = strdup( p_sd->pp_attributes[i]->psz_value );
} }
} }
...@@ -606,7 +624,7 @@ static int parse_sap( char *p_packet ) ...@@ -606,7 +624,7 @@ static int parse_sap( char *p_packet )
for(;p_packet[i_hlen] != 'v' && p_packet[i_hlen+1] != '=' ; i_hlen++); for(;p_packet[i_hlen] != 'v' && p_packet[i_hlen+1] != '=' ; i_hlen++);
return i_hlen-1; return i_hlen-1;
} }
return(i_hlen); return(i_hlen);
} }
...@@ -649,8 +667,8 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet ) ...@@ -649,8 +667,8 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet )
{ {
sess_descr_t * sd; sess_descr_t * sd;
char *psz_eof; char *psz_eof;
unsigned int i; unsigned int i;
// According to RFC 2327, the first bytes should be exactly "v=" // According to RFC 2327, the first bytes should be exactly "v="
if((p_packet[0] != 'v') || (p_packet[1] != '=')) if((p_packet[0] != 'v') || (p_packet[1] != '='))
{ {
...@@ -676,11 +694,11 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet ) ...@@ -676,11 +694,11 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet )
sd->psz_repeat = NULL; sd->psz_repeat = NULL;
sd->psz_attribute = NULL; sd->psz_attribute = NULL;
sd->psz_connection = NULL; sd->psz_connection = NULL;
sd->i_media = 0; sd->i_media = 0;
sd->i_attributes = 0; sd->i_attributes = 0;
while( *p_packet != '\0' ) while( *p_packet != '\0' )
{ {
#define FIELD_COPY( p ) \ #define FIELD_COPY( p ) \
...@@ -740,30 +758,41 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet ) ...@@ -740,30 +758,41 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet )
{ {
sd->pp_attributes = sd->pp_attributes =
realloc( sd->pp_attributes, realloc( sd->pp_attributes,
sizeof( attr_descr_t ) * sizeof( attr_descr_t ) *
( sd->i_attributes +1 ) ); ( sd->i_attributes +1 ) );
} }
else else
{ {
sd->pp_attributes = malloc( sizeof( void * ) ); sd->pp_attributes = malloc( sizeof( void * ) );
} }
if( !sd->pp_attributes )
{
msg_Warn( p_intf, "Out of memory !" );
return NULL;
}
sd->pp_attributes[sd->i_attributes] = sd->pp_attributes[sd->i_attributes] =
malloc( sizeof( attr_descr_t ) ); malloc( sizeof( attr_descr_t ) );
if( ! sd->pp_attributes[sd->i_attributes])
{
msg_Warn( p_intf, "Out of memory !" );
return NULL;
}
p_packet += 2; p_packet += 2;
psz_eof = strchr( p_packet, ':'); psz_eof = strchr( p_packet, ':');
if(psz_eof) if(psz_eof)
*psz_eof = '\0'; *psz_eof = '\0';
sd->pp_attributes[sd->i_attributes]->psz_field = sd->pp_attributes[sd->i_attributes]->psz_field =
strdup( p_packet ); strdup( p_packet );
sd->pp_attributes[sd->i_attributes]->psz_value = sd->pp_attributes[sd->i_attributes]->psz_value =
strdup( ++psz_eof ); strdup( ++psz_eof );
for( i=0 ; i< for( i=0 ; i<
strlen(sd->pp_attributes[sd->i_attributes]->psz_value) ; strlen(sd->pp_attributes[sd->i_attributes]->psz_value) ;
i++ ) i++ )
{ {
if(sd->pp_attributes[sd->i_attributes]->psz_value[i] if(sd->pp_attributes[sd->i_attributes]->psz_value[i]
=='\n' ) =='\n' )
sd->pp_attributes[sd->i_attributes]->psz_value[i] =0; sd->pp_attributes[sd->i_attributes]->psz_value[i] =0;
} }
sd->i_attributes++; sd->i_attributes++;
break; break;
...@@ -779,13 +808,17 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet ) ...@@ -779,13 +808,17 @@ static sess_descr_t * parse_sdp( intf_thread_t * p_intf, char *p_packet )
{ {
sd->pp_media = malloc( sizeof( void * ) ); sd->pp_media = malloc( sizeof( void * ) );
} }
if( !sd->pp_media )
{
msg_Warn( p_intf, "Out of memory !" );
return NULL;
}
sd->pp_media[sd->i_media] = sd->pp_media[sd->i_media] =
malloc( sizeof( media_descr_t ) ); malloc( sizeof( media_descr_t ) );
sd->pp_media[sd->i_media]->psz_medianame = NULL; sd->pp_media[sd->i_media]->psz_medianame = NULL;
sd->pp_media[sd->i_media]->psz_mediaconnection = NULL; sd->pp_media[sd->i_media]->psz_mediaconnection = NULL;
sd->pp_media[sd->i_media]->psz_medianame = strndup( &p_packet[2], i_field_len ); sd->pp_media[sd->i_media]->psz_medianame =
strndup( &p_packet[2], i_field_len );
sd->i_media++; sd->i_media++;
break; break;
...@@ -863,14 +896,14 @@ static int ismult( char *psz_uri ) ...@@ -863,14 +896,14 @@ static int ismult( char *psz_uri )
i_value = strtol( psz_uri, &psz_end, 0 ); i_value = strtol( psz_uri, &psz_end, 0 );
/* IPv6 */ /* IPv6 */
if( psz_uri[0] == '[') if( psz_uri[0] == '[')
{ {
if( strncasecmp( &psz_uri[1], "FF0" , 3) || if( strncasecmp( &psz_uri[1], "FF0" , 3) ||
strncasecmp( &psz_uri[2], "FF0" , 3)) strncasecmp( &psz_uri[2], "FF0" , 3))
return( VLC_TRUE ); return( VLC_TRUE );
else else
return( VLC_FALSE ); return( VLC_FALSE );
} }
if( *psz_end != '.' ) { return( VLC_FALSE ); } if( *psz_end != '.' ) { return( VLC_FALSE ); }
...@@ -885,7 +918,7 @@ static int ismult( char *psz_uri ) ...@@ -885,7 +918,7 @@ static int ismult( char *psz_uri )
* Taken from udp.c * Taken from udp.c
******************************************************************************/ ******************************************************************************/
static ssize_t NetRead( intf_thread_t *p_intf, static ssize_t NetRead( intf_thread_t *p_intf,
int i_handle, int i_handle_v6, int i_handle, int i_handle_v6,
byte_t *p_buffer, size_t i_len) byte_t *p_buffer, size_t i_len)
{ {
#ifdef UNDER_CE #ifdef UNDER_CE
...@@ -898,14 +931,14 @@ static ssize_t NetRead( intf_thread_t *p_intf, ...@@ -898,14 +931,14 @@ static ssize_t NetRead( intf_thread_t *p_intf,
int i_max_handle; int i_max_handle;
ssize_t i_recv=-1; ssize_t i_recv=-1;
/* Get the max handle for select */ /* Get the max handle for select */
if( i_handle_v6 > i_handle ) if( i_handle_v6 > i_handle )
i_max_handle = i_handle_v6; i_max_handle = i_handle_v6;
else else
i_max_handle = i_handle; i_max_handle = i_handle;
/* Initialize file descriptor set */ /* Initialize file descriptor set */
FD_ZERO( &fds ); FD_ZERO( &fds );
if( i_handle > 0 ) FD_SET( i_handle, &fds ); if( i_handle > 0 ) FD_SET( i_handle, &fds );
...@@ -926,7 +959,7 @@ static ssize_t NetRead( intf_thread_t *p_intf, ...@@ -926,7 +959,7 @@ static ssize_t NetRead( intf_thread_t *p_intf,
} }
else if( i_ret > 0 ) else if( i_ret > 0 )
{ {
/* Get the data */ /* Get the data */
if(i_handle >0) if(i_handle >0)
{ {
if(FD_ISSET( i_handle, &fds )) if(FD_ISSET( i_handle, &fds ))
...@@ -941,7 +974,7 @@ static ssize_t NetRead( intf_thread_t *p_intf, ...@@ -941,7 +974,7 @@ static ssize_t NetRead( intf_thread_t *p_intf,
i_recv = recv( i_handle_v6, p_buffer, i_len, 0 ); i_recv = recv( i_handle_v6, p_buffer, i_len, 0 );
} }
} }
if( i_recv < 0 ) if( i_recv < 0 )
{ {
msg_Err( p_intf, "recv failed (%s)", strerror(errno) ); msg_Err( p_intf, "recv failed (%s)", strerror(errno) );
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread. * thread, and destroy a previously oppened video output thread.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: video_output.c,v 1.237 2003/10/05 23:03:35 gbazin Exp $ * $Id: video_output.c,v 1.238 2003/10/08 10:07:22 zorglub Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -62,6 +62,8 @@ static int FullscreenCallback( vlc_object_t *, char const *, ...@@ -62,6 +62,8 @@ static int FullscreenCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int DeinterlaceCallback( vlc_object_t *, char const *, static int DeinterlaceCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int FilterCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/***************************************************************************** /*****************************************************************************
* vout_Request: find a video output thread, create one, or destroy one. * vout_Request: find a video output thread, create one, or destroy one.
...@@ -399,12 +401,12 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, ...@@ -399,12 +401,12 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
return NULL; return NULL;
} }
p_vout->p_text_renderer_module = module_Need( p_vout, "text renderer", p_vout->p_text_renderer_module = module_Need( p_vout, "text renderer",
NULL ); NULL );
if( p_vout->p_text_renderer_module == NULL ) if( p_vout->p_text_renderer_module == NULL )
{ {
msg_Warn( p_vout, "no suitable text renderer module" ); msg_Warn( p_vout, "no suitable text renderer module" );
p_vout->pf_add_string = NULL; p_vout->pf_add_string = NULL;
} }
/* Create a few object variables for interface interaction */ /* Create a few object variables for interface interaction */
...@@ -440,6 +442,17 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, ...@@ -440,6 +442,17 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
} }
var_AddCallback( p_vout, "deinterlace", DeinterlaceCallback, NULL ); var_AddCallback( p_vout, "deinterlace", DeinterlaceCallback, NULL );
var_Create( p_vout, "filter", VLC_VAR_STRING );
text.psz_string = _("Filters");
var_Change( p_vout, "filter", VLC_VAR_SETTEXT, &text, NULL );
var_Change( p_vout, "filter", VLC_VAR_INHERITVALUE, &val, NULL );
if( var_Get( p_vout, "filter", &val ) == VLC_SUCCESS )
{
var_Set( p_vout, "filter", val );
}
var_AddCallback( p_vout, "filter", FilterCallback, NULL );
/* Calculate delay created by internal caching */ /* Calculate delay created by internal caching */
p_input_thread = (input_thread_t *)vlc_object_find( p_vout, p_input_thread = (input_thread_t *)vlc_object_find( p_vout,
VLC_OBJECT_INPUT, FIND_ANYWHERE ); VLC_OBJECT_INPUT, FIND_ANYWHERE );
...@@ -1363,3 +1376,45 @@ static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -1363,3 +1376,45 @@ static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd,
var_Set( p_vout, "intf-change", val ); var_Set( p_vout, "intf-change", val );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
input_thread_t *p_input;
vlc_value_t val;
unsigned int i;
p_input = (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT,
FIND_PARENT );
if (!p_input)
{
msg_Err( p_vout, "Input not found" );
return( VLC_EGENERIC );
}
/* Restart the video stream */
vlc_mutex_lock( &p_input->stream.stream_lock );
p_vout->b_filter_change = VLC_TRUE;
#define ES p_input->stream.pp_es[i]
for( i = 0 ; i < p_input->stream.i_es_number ; i++ )
{
if( ( ES->i_cat == VIDEO_ES ) && ES->p_decoder_fifo != NULL )
{
input_UnselectES( p_input, ES );
input_SelectES( p_input, ES );
}
#undef ES
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
vlc_object_release( p_input );
val.b_bool = VLC_TRUE;
var_Set( p_vout, "intf-change", val );
return VLC_SUCCESS;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment