void ExtraPanel::OnEqRestore( wxCommandEvent &event ) { aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); if( p_aout == NULL ) { vlc_value_t val; vlc_bool_t b_previous = eq_chkbox->IsChecked(); val.f_float = 12.0; IntfPreampCallback( NULL, NULL, val,val, this ); config_PutFloat( p_intf, "equalizer-preamp", 12.0 ); val.psz_string = strdup( "0 0 0 0 0 0 0 0 0 0" ); IntfBandsCallback( NULL, NULL, val,val, this ); config_PutPsz( p_intf, "equalizer-bands", "0 0 0 0 0 0 0 0 0 0"); config_PutPsz( p_intf, "equalizer-preset","flat" ); eq_chkbox->SetValue( b_previous ); } else { var_SetFloat( p_aout, "equalizer-preamp", 12.0 ); config_PutFloat( p_intf, "equalizer-preamp", 12.0 ); var_SetString( p_aout, "equalizer-bands", "0 0 0 0 0 0 0 0 0 0"); config_PutPsz( p_intf, "equalizer-bands", "0 0 0 0 0 0 0 0 0 0"); var_SetString( p_aout , "equalizer-preset" , "flat" ); config_PutPsz( p_intf, "equalizer-preset","flat" ); vlc_object_release( p_aout ); } }
void ExtraPanel::OnChangeEqualizer( wxScrollEvent &event ) { aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf, VLC_OBJECT_AOUT, FIND_ANYWHERE); char psz_values[102]; memset( psz_values, 0, 102 ); /* Smoothing */ int i_diff = event.GetPosition() - i_values[ event.GetId() - Band0_Event ]; i_values[ event.GetId() - Band0_Event] = event.GetPosition(); for( int i = event.GetId() + 1 ; i <= Band9_Event ; i++ ) { int i_new = band_sliders[ i-Band0_Event ]->GetValue() + (int)( i_diff * pow( (float)i_smooth / 100 , i- event.GetId() ) ) ; if( i_new < 0 ) i_new = 0; if( i_new > 400 ) i_new = 400; band_sliders[ i-Band0_Event ]->SetValue( i_new ); } for( int i = Band0_Event ; i < event.GetId() ; i++ ) { int i_new = band_sliders[ i-Band0_Event ]->GetValue() + (int)( i_diff * pow( (float)i_smooth / 100 , event.GetId() - i ) ); if( i_new < 0 ) i_new = 0; if( i_new > 400 ) i_new = 400; band_sliders[ i-Band0_Event ]->SetValue( i_new ); } /* Write the new bands values */ for( int i = 0 ; i < 10 ; i++ ) { char psz_val[5]; float f_val = (float)( 400 - band_sliders[i]->GetValue() ) / 10- 20 ; sprintf( psz_values, "%s %f", psz_values, f_val ); sprintf( psz_val, "%.1f", f_val ); band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") + wxU( psz_val ) + wxT("dB" ) ); } if( p_aout == NULL ) { config_PutPsz( p_intf, "equalizer-bands", psz_values ); } else { var_SetString( p_aout, "equalizer-bands", psz_values ); config_PutPsz( p_intf, "equalizer-bands", psz_values ); b_my_update = VLC_TRUE; vlc_object_release( p_aout ); } }
/* Removes an extra interface from the configuration */ void config_RemoveIntf( vlc_object_t *p_this, const char *psz_intf ) { vlc_object_t *libvlc = VLC_OBJECT(p_this->obj.libvlc); assert( psz_intf ); char *psz_config, *psz_parser; size_t i_len = strlen( psz_intf ); psz_config = psz_parser = config_GetPsz( libvlc, "extraintf" ); while( psz_parser ) { if( !strncmp( psz_intf, psz_parser, i_len ) ) { char *psz_newconfig; char *psz_end = psz_parser + i_len; if( *psz_end == ':' ) psz_end++; *psz_parser = '\0'; if( asprintf( &psz_newconfig, "%s%s", psz_config, psz_end ) != -1 ) { config_PutPsz( libvlc, "extraintf", psz_newconfig ); free( psz_newconfig ); } break; } psz_parser = strchr( psz_parser, ':' ); if( psz_parser ) psz_parser++; /* skip the ':' */ } free( psz_config ); psz_config = psz_parser = config_GetPsz( libvlc, "control" ); while( psz_parser ) { if( !strncmp( psz_intf, psz_parser, i_len ) ) { char *psz_newconfig; char *psz_end = psz_parser + i_len; if( *psz_end == ':' ) psz_end++; *psz_parser = '\0'; if( asprintf( &psz_newconfig, "%s%s", psz_config, psz_end ) != -1 ) { config_PutPsz( libvlc, "control", psz_newconfig ); free( psz_newconfig ); } break; } psz_parser = strchr( psz_parser, ':' ); if( psz_parser ) psz_parser++; /* skip the ':' */ } free( psz_config ); }
/* Adds an extra interface to the configuration */ void config_AddIntf( vlc_object_t *p_this, const char *psz_intf ) { vlc_object_t *libvlc = VLC_OBJECT(p_this->obj.libvlc); assert( psz_intf ); char *psz_config, *psz_parser; size_t i_len = strlen( psz_intf ); psz_config = psz_parser = config_GetPsz( libvlc, "control" ); while( psz_parser ) { if( !strncmp( psz_intf, psz_parser, i_len ) ) { free( psz_config ); return; } psz_parser = strchr( psz_parser, ':' ); if( psz_parser ) psz_parser++; /* skip the ':' */ } free( psz_config ); psz_config = psz_parser = config_GetPsz( libvlc, "extraintf" ); while( psz_parser ) { if( !strncmp( psz_intf, psz_parser, i_len ) ) { free( psz_config ); return; } psz_parser = strchr( psz_parser, ':' ); if( psz_parser ) psz_parser++; /* skip the ':' */ } /* interface not found in the config, let's add it */ if( psz_config && strlen( psz_config ) > 0 ) { char *psz_newconfig; if( asprintf( &psz_newconfig, "%s:%s", psz_config, psz_intf ) != -1 ) { config_PutPsz( libvlc, "extraintf", psz_newconfig ); free( psz_newconfig ); } } else config_PutPsz( libvlc, "extraintf", psz_intf ); free( psz_config ); }
void ExtendedDialog::saveConfig() { assert( currentTab() == AUDIO_TAB || currentTab() == VIDEO_TAB ); QHash<QString, QVariant> *hashConfig = &m_hashConfigs[currentTab()]; for( QHash<QString, QVariant>::iterator i = hashConfig->begin(); i != hashConfig->end(); ++i ) { QVariant &value = i.value(); switch( static_cast<QMetaType::Type>(value.type()) ) { case QMetaType::QString: config_PutPsz( p_intf, qtu(i.key()), qtu(value.toString()) ); break; case QMetaType::Int: config_PutInt( p_intf, qtu(i.key()), value.toInt() ) ; break; case QMetaType::Double: case QMetaType::Float: config_PutFloat( p_intf, qtu(i.key()), value.toFloat() ) ; break; default: vlc_assert_unreachable(); } } config_SaveConfigFile( p_intf ); hashConfig->clear(); m_applyButton->setEnabled( false ); }
void PrefsPanel::ApplyChanges() { vlc_value_t val; for( size_t i = 0; i < config_array.size(); i++ ) { ConfigControl *control = config_array[i]; switch( control->GetType() ) { case CONFIG_ITEM_STRING: case CONFIG_ITEM_FILE: case CONFIG_ITEM_DIRECTORY: case CONFIG_ITEM_MODULE: config_PutPsz( p_intf, control->GetName(), control->GetPszValue() ); break; case CONFIG_ITEM_KEY: /* So you don't need to restart to have the changes take effect */ val.i_int = control->GetIntValue(); var_Set( p_intf->p_vlc, control->GetName(), val ); case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_BOOL: config_PutInt( p_intf, control->GetName(), control->GetIntValue() ); break; case CONFIG_ITEM_FLOAT: config_PutFloat( p_intf, control->GetName(), control->GetFloatValue() ); break; } } }
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg ) { // Make sure we are not called from set() if (!m_isUpdating) { float val; stringstream ss; // Write one digit after the floating point ss << setprecision( 1 ) << setiosflags( ios::fixed ); // Convert the band values to a string val = 40 * ((VarPercent*)m_cBands[0].get())->get() - 20; ss << val; for( int i = 1; i < kNbBands; i++ ) { val = 40 * ((VarPercent*)m_cBands[i].get())->get() - 20; ss << " " << val; } string bands = ss.str(); aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(), VLC_OBJECT_AOUT, FIND_ANYWHERE ); config_PutPsz( getIntf(), "equalizer-bands", bands.c_str() ); if( pAout ) { // Update the audio output var_SetString( pAout, "equalizer-bands", (char*)bands.c_str() ); vlc_object_release( pAout ); } } }
void Theme::saveConfig() { msg_Dbg( getIntf(), "saving theme configuration"); map<string, TopWindowPtr>::const_iterator itWin; map<string, GenericLayoutPtr>::const_iterator itLay; ostringstream outStream; for( itWin = m_windows.begin(); itWin != m_windows.end(); itWin++ ) { TopWindow *pWin = itWin->second.get(); // Find the layout id for this window string layoutId; const GenericLayout *pLayout = &pWin->getActiveLayout(); for( itLay = m_layouts.begin(); itLay != m_layouts.end(); itLay++ ) { if( itLay->second.get() == pLayout ) { layoutId = itLay->first; } } outStream << '[' << itWin->first << ' ' << layoutId << ' ' << pWin->getLeft() << ' ' << pWin->getTop() << ' ' << pLayout->getWidth() << ' ' << pLayout->getHeight() << ' ' << (pWin->getVisibleVar().get() ? 1 : 0) << ']'; } // Save config to file config_PutPsz( getIntf(), "skins2-config", outStream.str().c_str() ); }
bool ThemeLoader::load( const string &fileName ) { string path = getFilePath( fileName ); //Before all, let's see if the file is present struct stat p_stat; if( vlc_stat( fileName.c_str(), &p_stat ) ) return false; // First, we try to un-targz the file, and if it fails we hope it's a XML // file... #if defined( HAVE_ZLIB_H ) if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) ) return false; #else if( ! parse( path, fileName ) ) return false; #endif Theme *pNewTheme = getIntf()->p_sys->p_theme; if( !pNewTheme ) return false; // Restore the theme configuration getIntf()->p_sys->p_theme->loadConfig(); // Retain new loaded skins in config config_PutPsz( getIntf(), "skins2-last", fileName.c_str() ); return true; }
static int vlclua_config_set( lua_State *L ) { vlc_object_t *p_this = vlclua_get_this( L ); const char *psz_name = luaL_checkstring( L, 1 ); switch( config_GetType( p_this, psz_name ) ) { case VLC_VAR_STRING: config_PutPsz( p_this, psz_name, luaL_checkstring( L, 2 ) ); break; case VLC_VAR_INTEGER: config_PutInt( p_this, psz_name, luaL_checkinteger( L, 2 ) ); break; case VLC_VAR_BOOL: config_PutInt( p_this, psz_name, luaL_checkboolean( L, 2 ) ); break; case VLC_VAR_FLOAT: config_PutFloat( p_this, psz_name, luaL_checknumber( L, 2 ) ); break; default: return vlclua_error( L ); } return 0; }
static void ChangeVFiltersString( intf_thread_t *p_intf, char *psz_name, vlc_bool_t b_add ) { vout_thread_t *p_vout; char *psz_parser, *psz_string; psz_string = config_GetPsz( p_intf, "filter" ); if( !psz_string ) psz_string = strdup(""); psz_parser = strstr( psz_string, psz_name ); if( b_add ) { if( !psz_parser ) { psz_parser = psz_string; asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s", psz_string, psz_name ); free( psz_parser ); } else { return; } } else { if( psz_parser ) { memmove( psz_parser, psz_parser + strlen(psz_name) + (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ), strlen(psz_parser + strlen(psz_name)) + 1 ); /* Remove trailing : : */ if( *(psz_string+strlen(psz_string ) -1 ) == ':' ) { *(psz_string+strlen(psz_string ) -1 ) = '\0'; } } else { free( psz_string ); return; } } /* Vout is not kept, so put that in the config */ config_PutPsz( p_intf, "filter", psz_string ); /* Try to set on the fly */ p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); if( p_vout ) { var_SetString( p_vout, "filter", psz_string ); vlc_object_release( p_vout ); } free( psz_string ); }
/*********************** * Set the audio output. ***********************/ int libvlc_audio_output_set( libvlc_instance_t *p_instance, const char *psz_name ) { if( module_exists( psz_name ) ) { config_PutPsz( p_instance->p_libvlc_int, "aout", psz_name ); return true; } else return false; }
/***************************** * Set device for using *****************************/ void libvlc_audio_output_device_set( libvlc_instance_t *p_instance, const char *psz_audio_output, const char *psz_device_id ) { char *psz_config_name = NULL; if( !psz_audio_output || !psz_device_id ) return; if( asprintf( &psz_config_name, "%s-audio-device", psz_audio_output ) == -1 ) return; config_PutPsz( p_instance->p_libvlc_int, psz_config_name, psz_device_id ); free( psz_config_name ); }
void vout_EnableFilter( vout_thread_t *p_vout, char *psz_name, bool b_add, bool b_setconfig ) { char *psz_parser; char *psz_string = config_GetPsz( p_vout, "vout-filter" ); /* Todo : Use some generic chain manipulation functions */ if( !psz_string ) psz_string = strdup(""); psz_parser = strstr( psz_string, psz_name ); if( b_add ) { if( !psz_parser ) { psz_parser = psz_string; if( asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s", psz_string, psz_name ) == -1 ) { free( psz_parser ); return; } free( psz_parser ); } else return; } else { if( psz_parser ) { memmove( psz_parser, psz_parser + strlen(psz_name) + (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ), strlen(psz_parser + strlen(psz_name)) + 1 ); /* Remove trailing : : */ if( *(psz_string+strlen(psz_string ) -1 ) == ':' ) { *(psz_string+strlen(psz_string ) -1 ) = '\0'; } } else { free( psz_string ); return; } } if( b_setconfig ) config_PutPsz( p_vout, "vout-filter", psz_string ); var_SetString( p_vout, "vout-filter", psz_string ); free( psz_string ); }
bool ThemeLoader::load( const string &fileName ) { string path = getFilePath( fileName ); //Before all, let's see if the file is present struct stat p_stat; if( vlc_stat( path.c_str(), &p_stat ) ) return false; // First, we try to un-targz the file, and if it fails we hope it's a XML // file... #if defined( HAVE_ZLIB_H ) if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) ) return false; #else if( ! parse( path, fileName ) ) return false; #endif Theme *pNewTheme = getIntf()->p_sys->p_theme; if( !pNewTheme ) { return false; } // Check if the skin to load is in the config file, to load its config char *skin_last = config_GetPsz( getIntf(), "skins2-last" ); if( skin_last != NULL && fileName == (string)skin_last ) { // Restore the theme configuration getIntf()->p_sys->p_theme->loadConfig(); // Used to anchor the windows at the beginning pNewTheme->getWindowManager().stopMove(); } else { config_PutPsz( getIntf(), "skins2-last", fileName.c_str() ); // Show the windows pNewTheme->getWindowManager().showAll( true ); } free( skin_last ); return true; }
bool ThemeLoader::load( const string &fileName ) { // First, we try to un-targz the file, and if it fails we hope it's a XML // file... string path = getFilePath( fileName ); #if defined( HAVE_ZLIB_H ) if( ! extract( sToLocale( fileName ) ) && ! parse( path, fileName ) ) return false; #else if( ! parse( path, fileName ) ) return false; #endif Theme *pNewTheme = getIntf()->p_sys->p_theme; if( !pNewTheme ) { return false; } // Check if the skin to load is in the config file, to load its config char *skin_last = config_GetPsz( getIntf(), "skins2-last" ); if( skin_last != NULL && fileName == (string)skin_last ) { // Restore the theme configuration getIntf()->p_sys->p_theme->loadConfig(); // Used to anchor the windows at the beginning pNewTheme->getWindowManager().stopMove(); } else { config_PutPsz( getIntf(), "skins2-last", fileName.c_str() ); // Show the windows pNewTheme->getWindowManager().showAll( true ); } if( skin_last ) free( skin_last ); // The new theme cannot embed a video output yet VlcProc::instance( getIntf() )->dropVout(); return true; }
static void SaveUrls( services_discovery_t *p_sd ) { services_discovery_sys_t *p_sys = p_sd->p_sys; int i; char *psz_urls; int len = 0; for( i=0; i < p_sys->i_urls; i++ ) len += strlen( p_sys->ppsz_urls[i] ) + 1; psz_urls = (char*) calloc( len, sizeof(char) ); for( i=0; i < p_sys->i_urls; i++ ) { strcat( psz_urls, p_sys->ppsz_urls[i] ); if( i < p_sys->i_urls - 1 ) strcat( psz_urls, "|" ); } config_PutPsz( p_sd, "podcast-urls", psz_urls ); free( psz_urls ); }
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg ) { (void)rBand; (void)arg; playlist_t *pPlaylist = getIntf()->p_sys->p_playlist; audio_output_t *pAout = playlist_GetAout( pPlaylist ); // Make sure we are not called from set() if (!m_isUpdating) { float val; stringstream ss; // Write one digit after the floating point ss << setprecision( 1 ) << setiosflags( ios::fixed ); // Convert the band values to a string val = 40 * ((VarPercent*)m_cBands[0].get())->get() - 20; ss << val; for( int i = 1; i < kNbBands; i++ ) { val = 40 * ((VarPercent*)m_cBands[i].get())->get() - 20; ss << " " << val; } string bands = ss.str(); config_PutPsz( getIntf(), "equalizer-bands", bands.c_str() ); if( pAout ) { // Update the audio output var_SetString( pAout, "equalizer-bands", (char*)bands.c_str() ); } } if( pAout ) vlc_object_release( pAout ); }
void ConfigControl::doApply( intf_thread_t *p_intf ) { switch( getType() ) { case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_BOOL: { VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(this); assert( vicc ); config_PutInt( p_intf, vicc->getName(), vicc->getValue() ); break; } case CONFIG_ITEM_FLOAT: { VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(this); assert( vfcc ); config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() ); break; } case CONFIG_ITEM_STRING: { VStringConfigControl *vscc = qobject_cast<VStringConfigControl *>(this); assert( vscc ); config_PutPsz( p_intf, vscc->getName(), qtu( vscc->getValue() ) ); break; } case CONFIG_ITEM_KEY: { KeySelectorControl *ksc = qobject_cast<KeySelectorControl *>(this); assert( ksc ); ksc->doApply(); } } }
/***************************************************************************** * Init: initialize Clone video thread output method *****************************************************************************/ static int Init( vout_thread_t *p_vout ) { int i_index, i_vout; picture_t *p_pic; char *psz_default_vout; I_OUTPUTPICTURES = 0; /* Initialize the output structure */ p_vout->output.i_chroma = p_vout->render.i_chroma; p_vout->output.i_width = p_vout->render.i_width; p_vout->output.i_height = p_vout->render.i_height; p_vout->output.i_aspect = p_vout->render.i_aspect; /* Try to open the real video output */ msg_Dbg( p_vout, "spawning the real video outputs" ); /* Save the default vout */ psz_default_vout = config_GetPsz( p_vout, "vout" ); for( i_vout = 0; i_vout < p_vout->p_sys->i_clones; i_vout++ ) { if( p_vout->p_sys->ppsz_vout_list == NULL || ( !strncmp( p_vout->p_sys->ppsz_vout_list[i_vout], "default", 8 ) ) ) { p_vout->p_sys->pp_vout[i_vout] = vout_Create( p_vout, p_vout->render.i_width, p_vout->render.i_height, p_vout->render.i_chroma, p_vout->render.i_aspect ); } else { /* create the appropriate vout instead of the default one */ config_PutPsz( p_vout, "vout", p_vout->p_sys->ppsz_vout_list[i_vout] ); p_vout->p_sys->pp_vout[i_vout] = vout_Create( p_vout, p_vout->render.i_width, p_vout->render.i_height, p_vout->render.i_chroma, p_vout->render.i_aspect ); /* Reset the default value */ config_PutPsz( p_vout, "vout", psz_default_vout ); } if( p_vout->p_sys->pp_vout[ i_vout ] == NULL ) { msg_Err( p_vout, "failed to clone %i vout threads", p_vout->p_sys->i_clones ); p_vout->p_sys->i_clones = i_vout; if( psz_default_vout ) free( psz_default_vout ); RemoveAllVout( p_vout ); return VLC_EGENERIC; } ADD_CALLBACKS( p_vout->p_sys->pp_vout[ i_vout ], SendEvents ); } if( psz_default_vout ) free( psz_default_vout ); ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES ); ADD_PARENT_CALLBACKS( SendEventsToChild ); return VLC_SUCCESS; }
/***************************************************************************** * HTTPOpen: Start the internal HTTP server *****************************************************************************/ int E_(HTTPOpen)( access_t *p_access ) { #define FREE( x ) \ if ( (x) != NULL ) \ free( x ); access_sys_t *p_sys = p_access->p_sys; char *psz_address, *psz_cert = NULL, *psz_key = NULL, *psz_ca = NULL, *psz_crl = NULL, *psz_user = NULL, *psz_password = NULL, *psz_acl = NULL; int i_port = 0; char psz_tmp[10]; vlc_acl_t *p_acl = NULL; httpd_file_sys_t *f; vlc_mutex_init( p_access, &p_sys->httpd_mutex ); vlc_cond_init( p_access, &p_sys->httpd_cond ); p_sys->b_request_frontend_info = p_sys->b_request_mmi_info = VLC_FALSE; p_sys->i_httpd_timeout = 0; psz_address = var_GetString( p_access, "dvb-http-host" ); if( psz_address != NULL && *psz_address ) { char *psz_parser = strchr( psz_address, ':' ); if( psz_parser ) { *psz_parser++ = '\0'; i_port = atoi( psz_parser ); } } else { if ( psz_address != NULL ) free( psz_address ); return VLC_SUCCESS; } /* determine SSL configuration */ psz_cert = var_GetString( p_access, "dvb-http-intf-cert" ); if ( psz_cert != NULL && *psz_cert ) { msg_Dbg( p_access, "enabling TLS for HTTP interface (cert file: %s)", psz_cert ); psz_key = config_GetPsz( p_access, "dvb-http-intf-key" ); psz_ca = config_GetPsz( p_access, "dvb-http-intf-ca" ); psz_crl = config_GetPsz( p_access, "dvb-http-intf-crl" ); if ( i_port <= 0 ) i_port = 8443; } else { if ( !*psz_cert ) { free( psz_cert ); psz_cert = NULL; } if ( i_port <= 0 ) i_port= 8082; } /* Ugly hack to allow to run several HTTP servers on different ports. */ sprintf( psz_tmp, ":%d", i_port + 1 ); config_PutPsz( p_access, "dvb-http-host", psz_tmp ); msg_Dbg( p_access, "base %s:%d", psz_address, i_port ); p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_access), psz_address, i_port, psz_cert, psz_key, psz_ca, psz_crl ); FREE( psz_cert ); FREE( psz_key ); FREE( psz_ca ); FREE( psz_crl ); if ( p_sys->p_httpd_host == NULL ) { msg_Err( p_access, "cannot listen on %s:%d", psz_address, i_port ); free( psz_address ); return VLC_EGENERIC; } free( psz_address ); psz_user = var_GetString( p_access, "dvb-http-user" ); psz_password = var_GetString( p_access, "dvb-http-password" ); psz_acl = var_GetString( p_access, "dvb-http-acl" ); if ( psz_acl != NULL ) { p_acl = ACL_Create( p_access, VLC_FALSE ); if( ACL_LoadFile( p_acl, psz_acl ) ) { ACL_Destroy( p_acl ); p_acl = NULL; } } /* Declare an index.html file. */ f = malloc( sizeof(httpd_file_sys_t) ); f->p_access = p_access; f->p_file = httpd_FileNew( p_sys->p_httpd_host, "/index.html", "text/html; charset=UTF-8", psz_user, psz_password, p_acl, HttpCallback, f ); FREE( psz_user ); FREE( psz_password ); FREE( psz_acl ); if ( p_acl != NULL ) ACL_Destroy( p_acl ); if ( f->p_file == NULL ) { free( f ); p_sys->p_httpd_file = NULL; return VLC_EGENERIC; } p_sys->p_httpd_file = f; p_sys->p_httpd_redir = httpd_RedirectNew( p_sys->p_httpd_host, "/index.html", "/" ); #undef FREE return VLC_SUCCESS; }
static void RunIntf( intf_thread_t *p_intf ) { int i_x, i_oldx = 0, i_sum = 0, i = 0; int p_oldx[FILTER_LENGTH]; memset( p_oldx, 0, FILTER_LENGTH * sizeof( int ) ); for( ;; ) { const char *psz_filter, *psz_type; bool b_change = false; /* Wait a bit, get orientation, change filter if necessary */ #warning FIXME: check once (or less) per picture, not once per interval msleep( INTF_IDLE_SLEEP ); int canc = vlc_savecancel(); i_x = GetOrientation( p_intf ); i_sum += i_x - p_oldx[i]; p_oldx[i++] = i_x; if( i == FILTER_LENGTH ) i = 0; i_x = i_sum / FILTER_LENGTH; if( p_intf->p_sys->b_use_rotate ) { if( i_oldx != i_x ) { /* TODO: cache object pointer */ vlc_object_t *p_obj = vlc_object_find_name( p_intf->p_libvlc, "rotate" ); if( p_obj ) { var_SetInteger( p_obj, "rotate-deciangle", ((3600+i_x/2)%3600) ); i_oldx = i_x; vlc_object_release( p_obj ); } } goto loop; } if( i_x < -HIGH_THRESHOLD && i_oldx > -LOW_THRESHOLD ) { b_change = true; psz_filter = "transform"; psz_type = "270"; } else if( ( i_x > -LOW_THRESHOLD && i_oldx < -HIGH_THRESHOLD ) || ( i_x < LOW_THRESHOLD && i_oldx > HIGH_THRESHOLD ) ) { b_change = true; psz_filter = ""; psz_type = ""; } else if( i_x > HIGH_THRESHOLD && i_oldx < LOW_THRESHOLD ) { b_change = true; psz_filter = "transform"; psz_type = "90"; } if( b_change ) { #warning FIXME: refactor this plugin as a video filter! input_thread_t *p_input; p_input = playlist_CurrentInput( pl_Get( p_intf ) ); if( p_input ) { vout_thread_t *p_vout; p_vout = input_GetVout( p_input ); if( p_vout ) { #warning FIXME: do not override the permanent configuration! #warning FIXME: transform-type does not exist anymore config_PutPsz( p_vout, "transform-type", psz_type ); var_SetString( p_vout, "video-filter", psz_filter ); vlc_object_release( p_vout ); } vlc_object_release( p_input ); i_oldx = i_x; } } loop: vlc_restorecancel( canc ); } }
ThemeRepository::ThemeRepository( intf_thread_t *pIntf ): SkinObject( pIntf ) { vlc_value_t val, text; // Create a variable to add items in wxwindows popup menu var_Create( pIntf, "intf-skins", VLC_VAR_STRING | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); text.psz_string = _("Select skin"); var_Change( pIntf, "intf-skins", VLC_VAR_SETTEXT, &text, NULL ); // Scan vlt files in the resource path OSFactory *pOsFactory = OSFactory::instance( pIntf ); list<string> resPath = pOsFactory->getResourcePath(); list<string>::const_iterator it; for( it = resPath.begin(); it != resPath.end(); ++it ) { parseDirectory( *it ); } // retrieve skins from skins directories and locate default skins map<string,string>::const_iterator itmap, itdefault; for( itmap = m_skinsMap.begin(); itmap != m_skinsMap.end(); ++itmap ) { string name = itmap->first; string path = itmap->second; val.psz_string = (char*) path.c_str(); text.psz_string = (char*) name.c_str(); var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val, &text ); if( name == "Default" ) itdefault = itmap; } // retrieve last skins stored or skins requested by user char* psz_current = var_InheritString( getIntf(), "skins2-last" ); string current = string( psz_current ? psz_current : "" ); free( psz_current ); // check if skins exists and is readable bool b_readable = !ifstream( current.c_str() ).fail(); msg_Dbg( getIntf(), "requested skins %s is %s accessible", current.c_str(), b_readable ? "" : "NOT" ); // set the default skins if given skins not accessible if( !b_readable ) current = itdefault->second; // save this valid skins for reuse config_PutPsz( getIntf(), "skins2-last", current.c_str() ); // Update repository updateRepository(); // Set the callback var_AddCallback( pIntf, "intf-skins", changeSkin, this ); // variable for opening a dialog box to change skins var_Create( pIntf, "intf-skins-interactive", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); text.psz_string = _("Open skin ..."); var_Change( pIntf, "intf-skins-interactive", VLC_VAR_SETTEXT, &text, NULL ); // Set the callback var_AddCallback( pIntf, "intf-skins-interactive", changeSkin, this ); }
/* This function will add or remove a a module from a string list (colon * separated). It will return true if there is a modification * In case p_aout is NULL, we will use configuration instead of variable */ bool aout_ChangeFilterString( vlc_object_t *p_obj, aout_instance_t *p_aout, const char *psz_variable, const char *psz_name, bool b_add ) { if( *psz_name == '\0' ) return false; char *psz_list; if( p_aout ) { psz_list = var_GetString( p_aout, psz_variable ); } else { psz_list = var_CreateGetString( p_obj->p_libvlc, psz_variable ); var_Destroy( p_obj->p_libvlc, psz_variable ); } /* Split the string into an array of filters */ int i_count = 1; for( char *p = psz_list; p && *p; p++ ) i_count += *p == ':'; i_count += b_add; const char **ppsz_filter = calloc( i_count, sizeof(*ppsz_filter) ); if( !ppsz_filter ) { free( psz_list ); return false; } bool b_present = false; i_count = 0; for( char *p = psz_list; p && *p; ) { char *psz_end = strchr(p, ':'); if( psz_end ) *psz_end++ = '\0'; else psz_end = p + strlen(p); if( *p ) { b_present |= !strcmp( p, psz_name ); ppsz_filter[i_count++] = p; } p = psz_end; } if( b_present == b_add ) { free( ppsz_filter ); free( psz_list ); return false; } if( b_add ) { int i_order = FilterOrder( psz_name ); int i; for( i = 0; i < i_count; i++ ) { if( FilterOrder( ppsz_filter[i] ) > i_order ) break; } if( i < i_count ) memmove( &ppsz_filter[i+1], &ppsz_filter[i], (i_count - i) * sizeof(*ppsz_filter) ); ppsz_filter[i] = psz_name; i_count++; } else { for( int i = 0; i < i_count; i++ ) { if( !strcmp( ppsz_filter[i], psz_name ) ) ppsz_filter[i] = ""; } } size_t i_length = 0; for( int i = 0; i < i_count; i++ ) i_length += 1 + strlen( ppsz_filter[i] ); char *psz_new = malloc( i_length + 1 ); *psz_new = '\0'; for( int i = 0; i < i_count; i++ ) { if( *ppsz_filter[i] == '\0' ) continue; if( *psz_new ) strcat( psz_new, ":" ); strcat( psz_new, ppsz_filter[i] ); } free( ppsz_filter ); free( psz_list ); if( p_aout ) var_SetString( p_aout, psz_variable, psz_new ); else config_PutPsz( p_obj, psz_variable, psz_new ); free( psz_new ); return true; }
void vout_EnableFilter( vout_thread_t *p_vout, const char *psz_name, bool b_add, bool b_setconfig ) { char *psz_parser; char *psz_string; const char *psz_filter_type; module_t *p_obj = module_find( psz_name ); if( !p_obj ) { msg_Err( p_vout, "Unable to find filter module \"%s\".", psz_name ); return; } if( module_provides( p_obj, "video filter2" ) ) { psz_filter_type = "video-filter"; } else if( module_provides( p_obj, "sub source" ) ) { psz_filter_type = "sub-source"; } else if( module_provides( p_obj, "sub filter" ) ) { psz_filter_type = "sub-filter"; } else { msg_Err( p_vout, "Unknown video filter type." ); return; } psz_string = var_GetString( p_vout, psz_filter_type ); /* Todo : Use some generic chain manipulation functions */ if( !psz_string ) psz_string = strdup(""); psz_parser = strstr( psz_string, psz_name ); if( b_add ) { if( !psz_parser ) { psz_parser = psz_string; if( asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s", psz_string, psz_name ) == -1 ) { free( psz_parser ); return; } free( psz_parser ); } else return; } else { if( psz_parser ) { memmove( psz_parser, psz_parser + strlen(psz_name) + (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ), strlen(psz_parser + strlen(psz_name)) + 1 ); /* Remove trailing : : */ if( *(psz_string+strlen(psz_string ) -1 ) == ':' ) { *(psz_string+strlen(psz_string ) -1 ) = '\0'; } } else { free( psz_string ); return; } } if( b_setconfig ) { config_PutPsz( p_vout, psz_filter_type, psz_string ); } var_SetString( p_vout, psz_filter_type, psz_string ); free( psz_string ); }
static void ChangeFiltersString( intf_thread_t *p_intf, aout_instance_t * p_aout, char *psz_name, vlc_bool_t b_add ) { char *psz_parser, *psz_string; if( p_aout ) { psz_string = var_GetString( p_aout, "audio-filter" ); } else { psz_string = config_GetPsz( p_intf, "audio-filter" ); } if( !psz_string ) psz_string = strdup(""); psz_parser = strstr( psz_string, psz_name ); if( b_add ) { if( !psz_parser ) { psz_parser = psz_string; asprintf( &psz_string, (*psz_string) ? "%s,%s" : "%s%s", psz_string, psz_name ); free( psz_parser ); } else { return; } } else { if( psz_parser ) { memmove( psz_parser, psz_parser + strlen(psz_name) + (*(psz_parser + strlen(psz_name)) == ',' ? 1 : 0 ), strlen(psz_parser + strlen(psz_name)) + 1 ); if( *(psz_string+strlen(psz_string ) -1 ) == ',' ) { *(psz_string+strlen(psz_string ) -1 ) = '\0'; } } else { free( psz_string ); return; } } if( p_aout == NULL ) { config_PutPsz( p_intf, "audio-filter", psz_string ); } else { var_SetString( p_aout, "audio-filter", psz_string ); for( int i = 0; i < p_aout->i_nb_inputs; i++ ) { p_aout->pp_inputs[i]->b_restart = VLC_TRUE; } } free( psz_string ); }
void VStringConfigControl::doApply() { config_PutPsz( p_this, getName(), qtu( getValue() ) ); }
/* FIXME */ void ExtraPanel::OnRatio( wxCommandEvent& event ) { config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() ); }
bool MediaLibrary::Start() { if ( m_ml != nullptr ) return true; std::unique_ptr<medialibrary::IMediaLibrary> ml( NewMediaLibrary() ); m_logger.reset( new Logger( VLC_OBJECT( m_vlc_ml ) ) ); ml->setVerbosity( medialibrary::LogLevel::Info ); ml->setLogger( m_logger.get() ); auto userDir = vlc::wrap_cptr( config_GetUserDir( VLC_USERDATA_DIR ) ); std::string mlDir = std::string{ userDir.get() } + "/ml/"; auto thumbnailsDir = mlDir + "thumbnails/"; auto initStatus = ml->initialize( mlDir + "ml.db", thumbnailsDir, this ); switch ( initStatus ) { case medialibrary::InitializeResult::AlreadyInitialized: msg_Info( m_vlc_ml, "MediaLibrary was already initialized" ); return true; case medialibrary::InitializeResult::Failed: msg_Err( m_vlc_ml, "Medialibrary failed to initialize" ); return false; case medialibrary::InitializeResult::DbReset: msg_Info( m_vlc_ml, "Database was reset" ); break; case medialibrary::InitializeResult::Success: msg_Dbg( m_vlc_ml, "MediaLibrary successfully initialized" ); break; } ml->addParserService( std::make_shared<MetadataExtractor>( VLC_OBJECT( m_vlc_ml ) ) ); try { ml->addThumbnailer( std::make_shared<Thumbnailer>( m_vlc_ml, std::move( thumbnailsDir ) ) ); } catch ( const std::runtime_error& ex ) { msg_Err( m_vlc_ml, "Failed to provide a thumbnailer module to the " "medialib: %s", ex.what() ); return false; } if ( ml->start() == false ) { msg_Err( m_vlc_ml, "Failed to start the MediaLibrary" ); return false; } // Reload entry points we already know about, and then add potential new ones. // Doing it the other way around would cause the initial scan to be performed // twice, as we start discovering the new folders, then reload them. ml->reload(); auto folders = vlc::wrap_cptr( var_InheritString( m_vlc_ml, "ml-folders" ) ); if ( folders != nullptr && strlen( folders.get() ) > 0 ) { std::istringstream ss( folders.get() ); std::string folder; while ( std::getline( ss, folder, ';' ) ) ml->discover( folder ); } else { std::string varValue; for( auto&& target : { VLC_VIDEOS_DIR, VLC_MUSIC_DIR } ) { auto folder = vlc::wrap_cptr( config_GetUserDir( target ) ); if( folder == nullptr ) continue; auto folderMrl = vlc::wrap_cptr( vlc_path2uri( folder.get(), nullptr ) ); ml->discover( folderMrl.get() ); varValue += std::string{ ";" } + folderMrl.get(); } if ( varValue.empty() == false ) config_PutPsz( "ml-folders", varValue.c_str()+1 ); /* skip initial ';' */ } m_ml = std::move( ml ); return true; }
/***************************************************************************** * InterfaceWindow::MessageReceived *****************************************************************************/ void InterfaceWindow::MessageReceived( BMessage * p_message ) { switch( p_message->what ) { case B_ABOUT_REQUESTED: { BAlert * alert; alert = new BAlert( "VLC media player" VERSION, "VLC media player" VERSION " (BeOS interface)\n\n" "The VideoLAN team <*****@*****.**>\n" "http://www.videolan.org/", _("OK") ); alert->Go(); break; } case TOGGLE_ON_TOP: break; case OPEN_FILE: _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") ); break; case LOAD_SUBFILE: _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") ); break; #if 0 case OPEN_PLAYLIST: if (fPlaylistWindow->Lock()) { if (fPlaylistWindow->IsHidden()) fPlaylistWindow->Show(); else fPlaylistWindow->Activate(); fPlaylistWindow->Unlock(); } break; #endif case OPEN_DVD: { const char * psz_device; if( p_playlist && p_message->FindString( "device", &psz_device ) == B_OK ) { char psz_uri[1024]; memset( psz_uri, 0, 1024 ); snprintf( psz_uri, 1024, "dvdnav:%s", psz_device ); playlist_Add( p_playlist, psz_uri, psz_device, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true ); } UpdatePlaylist(); } break; case SUBFILE_RECEIVED: { entry_ref ref; if( p_message->FindRef( "refs", 0, &ref ) == B_OK ) { BPath path( &ref ); if ( path.InitCheck() == B_OK ) config_PutPsz( p_intf, "sub-file", path.Path() ); } break; } case STOP_PLAYBACK: if( p_playlist ) { playlist_Stop( p_playlist ); } p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT); break; case START_PLAYBACK: case PAUSE_PLAYBACK: { vlc_value_t val; val.i_int = PLAYING_S; if( p_input ) { var_Get( p_input, "state", &val ); } if( p_input && val.i_int != PAUSE_S ) { val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else { playlist_Play( p_playlist ); } break; } case HEIGHTH_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 ); } break; case QUARTER_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 ); } break; case HALF_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 ); } break; case NORMAL_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT ); } break; case TWICE_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 ); } break; case FOUR_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 ); } break; case HEIGHT_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 ); } break; case SEEK_PLAYBACK: /* handled by semaphores */ break; case VOLUME_CHG: aout_VolumeSet( p_intf, p_mediaControl->GetVolume() ); break; case VOLUME_MUTE: aout_ToggleMute( p_intf, NULL ); break; case SELECT_CHANNEL: { int32 channel; if( p_input ) { if( p_message->FindInt32( "audio-es", &channel ) == B_OK ) { var_SetInteger( p_input, "audio-es", channel ); } else if( p_message->FindInt32( "spu-es", &channel ) == B_OK ) { var_SetInteger( p_input, "spu-es", channel ); } } break; } case PREV_TITLE: if( p_input ) { var_TriggerCallback( p_input, "prev-title" ); } break; case NEXT_TITLE: if( p_input ) { var_TriggerCallback( p_input, "next-title" ); } break; case TOGGLE_TITLE: { int32 index; if( p_input && p_message->FindInt32( "index", &index ) == B_OK ) { var_SetInteger( p_input, "title", index ); } break; } case PREV_CHAPTER: if( p_input ) { var_TriggerCallback( p_input, "prev-chapter" ); } break; case NEXT_CHAPTER: if( p_input ) { var_TriggerCallback( p_input, "next-chapter" ); } break; case TOGGLE_CHAPTER: { int32 index; if( p_input && p_message->FindInt32( "index", &index ) == B_OK ) { var_SetInteger( p_input, "chapter", index ); } break; } case PREV_FILE: if( p_playlist ) { playlist_Prev( p_playlist ); } break; case NEXT_FILE: if( p_playlist ) { playlist_Next( p_playlist ); } break; case NAVIGATE_PREV: if( p_input ) { vlc_value_t val; /* First try to go to previous chapter */ if( !var_Get( p_input, "chapter", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( p_input, "prev-chapter" ); break; } } /* Try to go to previous title */ if( !var_Get( p_input, "title", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( p_input, "prev-title" ); break; } } /* Try to go to previous file */ if( p_playlist ) { playlist_Prev( p_playlist ); } } break; case NAVIGATE_NEXT: if( p_input ) { /* First try to go to next chapter */ if( !var_Get( p_input, "chapter", &val ) ) { int i_chapter_count = var_CountChoices( p_input, "chapter" ); if( i_chapter_count > val.i_int ) { var_TriggerCallback( p_input, "next-chapter" ); break; } } /* Try to go to next title */ if( !var_Get( p_input, "title", &val ) ) { int i_title_count = var_CountChoices( p_input, "title" ); if( i_title_count > val.i_int ) { var_TriggerCallback( p_input, "next-title" ); break; } } /* Try to go to next file */ if( p_playlist ) { playlist_Next( p_playlist ); } } break; // drag'n'drop and system messages case MSG_SOUNDPLAY: // convert soundplay drag'n'drop message (containing paths) // to normal message (containing refs) { const char* path; for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ ) { entry_ref ref; if ( get_ref_for_path( path, &ref ) == B_OK ) p_message->AddRef( "refs", &ref ); } } // fall through case B_REFS_RECEIVED: case B_SIMPLE_DATA: { /* file(s) opened by the File menu -> append to the playlist; file(s) opened by drag & drop -> replace playlist; file(s) opened by 'shift' + drag & drop -> append */ int32 count; type_code dummy; if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK || count < 1 ) { break; } bool b_remove = ( p_message->WasDropped() && !( modifiers() & B_SHIFT_KEY ) ); if( b_remove && p_playlist ) { playlist_Clear( p_playlist, true ); } entry_ref ref; for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ ) { BPath path( &ref ); /* TODO: find out if this is a DVD icon */ if( p_playlist ) { playlist_Add( p_playlist, path.Path(), NULL, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true ); } } UpdatePlaylist(); break; } case OPEN_PREFERENCES: { if( fPreferencesWindow->Lock() ) { if (fPreferencesWindow->IsHidden()) fPreferencesWindow->Show(); else fPreferencesWindow->Activate(); fPreferencesWindow->Unlock(); } break; } case OPEN_MESSAGES: { if( fMessagesWindow->Lock() ) { if (fMessagesWindow->IsHidden()) fMessagesWindow->Show(); else fMessagesWindow->Activate(); fMessagesWindow->Unlock(); } break; } case MSG_UPDATE: UpdateInterface(); break; default: BWindow::MessageReceived( p_message ); break; } }