/***************************************************************************** * Activate: initialize and create stuff *****************************************************************************/ static int Open(vlc_object_t *object) { intf_thread_t *intf = (intf_thread_t*)object; intf_sys_t *sys; int fd; if (!var_InheritBool(intf, "netsync-master")) { char *psz_master = var_InheritString(intf, "netsync-master-ip"); if (psz_master == NULL) { msg_Err(intf, "master address not specified"); return VLC_EGENERIC; } fd = net_ConnectUDP(VLC_OBJECT(intf), psz_master, NETSYNC_PORT, -1); free(psz_master); } else { fd = net_ListenUDP1(VLC_OBJECT(intf), NULL, NETSYNC_PORT); } if (fd == -1) { msg_Err(intf, "Netsync socket failure"); return VLC_EGENERIC; } intf->p_sys = sys = malloc(sizeof(*sys)); if (!sys) { net_Close(fd); return VLC_ENOMEM; } sys->fd = fd; sys->is_master = var_InheritBool(intf, "netsync-master"); sys->timeout = var_InheritInteger(intf, "netsync-timeout"); if (sys->timeout < 500) sys->timeout = 500; sys->playlist = pl_Get(intf); sys->input = NULL; var_AddCallback(sys->playlist, "input-current", PlaylistEvent, intf); return VLC_SUCCESS; }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; if( !notify_init( APPLICATION_NAME ) ) { free( p_sys ); msg_Err( p_intf, "can't find notification daemon" ); return VLC_EGENERIC; } p_intf->p_sys = p_sys; vlc_mutex_init( &p_sys->lock ); p_sys->notification = NULL; p_sys->b_has_actions = false; GList *p_caps = notify_get_server_caps (); if( p_caps ) { for( GList *c = p_caps; c != NULL; c = c->next ) { if( !strcmp( (char*)c->data, "actions" ) ) { p_sys->b_has_actions = true; break; } } g_list_foreach( p_caps, (GFunc)g_free, NULL ); g_list_free( p_caps ); } /* */ var_AddCallback( pl_Get( p_intf ), "item-current", ItemChange, p_intf ); return VLC_SUCCESS; }
int vlc_InitActions (libvlc_int_t *libvlc) { struct hotkey *keys; var_Create (libvlc, "key-pressed", VLC_VAR_INTEGER); var_Create (libvlc, "key-action", VLC_VAR_INTEGER); keys = malloc ((libvlc_actions_count + 1) * sizeof (*keys)); if (keys == NULL) { libvlc->p_hotkeys = NULL; return VLC_ENOMEM; } /* Initialize from configuration */ for (size_t i = 0; i < libvlc_actions_count; i++) { keys[i].psz_action = libvlc_actions[i].name; keys[i].i_key = var_InheritInteger (libvlc, libvlc_actions[i].name ); keys[i].i_action = libvlc_actions[i].value; #ifndef NDEBUG if (i > 0 && strcmp (libvlc_actions[i-1].name, libvlc_actions[i].name) >= 0) { msg_Err (libvlc, "%s and %s are not ordered properly", libvlc_actions[i-1].name, libvlc_actions[i].name); abort (); } #endif } qsort (keys, libvlc_actions_count, sizeof (*keys), keycmp); keys[libvlc_actions_count].psz_action = NULL; keys[libvlc_actions_count].i_key = 0; keys[libvlc_actions_count].i_action = 0; libvlc->p_hotkeys = keys; var_AddCallback (libvlc, "key-pressed", vlc_key_to_action, NULL); return VLC_SUCCESS; }
/***************************************************************************** * TrackChange: callback on playlist "item-current" *****************************************************************************/ static int TrackChange( intf_thread_t *p_intf ) { intf_sys_t *p_sys = p_intf->p_sys; playlist_t *p_playlist; input_thread_t *p_input = NULL; input_item_t *p_item = NULL; if( p_intf->p_sys->b_dead ) return VLC_SUCCESS; p_sys->b_meta_read = false; p_playlist = pl_Hold( p_intf ); p_input = playlist_CurrentInput( p_playlist ); if( !p_input ) { pl_Release( p_intf ); return VLC_SUCCESS; } pl_Release( p_intf ); p_item = input_GetItem( p_input ); if( !p_item ) { vlc_object_release( p_input ); return VLC_EGENERIC; } if( input_item_IsPreparsed( p_item ) ) { p_sys->b_meta_read = true; TrackChangeSignal( p_sys->p_conn, p_item ); } var_AddCallback( p_input, "state", AllCallback, p_intf ); vlc_object_release( p_input ); return VLC_SUCCESS; }
void InputManager::UpdateTeletext() { const bool b_enabled = var_CountChoices( p_input, "teletext-es" ) > 0; const int i_teletext_es = var_GetInteger( p_input, "teletext-es" ); /* Teletext is possible. Show the buttons */ emit teletextPossible( b_enabled ); /* If Teletext is selected */ if( b_enabled && i_teletext_es >= 0 ) { /* Then, find the current page */ int i_page = 100; bool b_transparent = false; if( p_input_vbi ) { var_DelCallback( p_input_vbi, "vbi-page", VbiEvent, this ); vlc_object_release( p_input_vbi ); } if( input_GetEsObjects( p_input, i_teletext_es, &p_input_vbi, NULL, NULL ) ) p_input_vbi = NULL; if( p_input_vbi ) { /* This callback is not remove explicitly, but interfaces * are guaranted to outlive input */ var_AddCallback( p_input_vbi, "vbi-page", VbiEvent, this ); i_page = var_GetInteger( p_input_vbi, "vbi-page" ); b_transparent = !var_GetBool( p_input_vbi, "vbi-opaque" ); } emit newTelexPageSet( i_page ); emit teletextTransparencyActivated( b_transparent ); } emit teletextActivated( b_enabled && i_teletext_es >= 0 ); }
static int OpenPitch( vlc_object_t *p_this ) { int err = Open( p_this ); if( err ) return err; filter_t *p_filter = (filter_t *)p_this; vlc_object_t *p_aout = p_filter->obj.parent; filter_sys_t *p_sys = p_filter->p_sys; float pitch_shift = var_CreateGetFloat( p_aout, "pitch-shift" ); var_AddCallback( p_aout, "pitch-shift", PitchCallback, p_sys ); PitchSetRateShift( p_sys, pitch_shift ); p_sys->resampler = ResamplerCreate(p_filter); if( !p_sys->resampler ) return VLC_EGENERIC; p_filter->pf_audio_filter = DoPitchWork; return VLC_SUCCESS; }
/***************************************************************************** * OpenIntf: initialize dummy interface *****************************************************************************/ int E_(OpenIntf) ( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; msg_Dbg( p_intf, "VCDOpenIntf" ); /* Allocate instance and initialize some members */ p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); if( p_intf->p_sys == NULL ) { return( 1 ); }; p_intf->pf_run = RunIntf; var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf ); p_intf->p_sys->m_still_time = 0; p_intf->p_sys->b_inf_still = 0; p_intf->p_sys->b_still = 0; return( 0 ); }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; playlist_t *p_playlist; intf_sys_t *p_sys = malloc( sizeof( intf_sys_t ) ); if( !p_sys ) { msg_Err( p_intf, "Out of memory" ); return VLC_ENOMEM; } p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( !p_playlist ) { msg_Err( p_intf, "could not find playlist object" ); return VLC_ENOOBJ; } var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); /* var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );*/ vlc_object_release( p_playlist ); if( !notify_init( APPLICATION_NAME ) ) { msg_Err( p_intf, "can't find notification daemon" ); return VLC_EGENERIC; } p_intf->p_sys = p_sys; vlc_mutex_init( p_this, &p_sys->lock ); p_intf->pf_run = Run; msg_Dbg( p_intf,"notify plugin started"); return VLC_SUCCESS; }
static int InputChange( vlc_object_t *p_playlist, const char *var, vlc_value_t prev, vlc_value_t value, void *data ) { intf_thread_t *p_intf = data; intf_sys_t *p_sys = p_intf->p_sys; if( p_sys->p_input ) { var_DelCallback( p_sys->p_input, "state", StateChange, p_intf ); vlc_object_release( p_sys->p_input ); } p_sys->p_input = VLC_OBJECT(playlist_CurrentInput( p_sys->p_playlist )); if( p_sys->p_input ) { Inhibit( p_intf, FREEDESKTOP ); Inhibit( p_intf, GNOME ); var_AddCallback( p_sys->p_input, "state", StateChange, p_intf ); } (void)var; (void)prev; (void)value; (void)p_playlist; return VLC_SUCCESS; }
/***************************************************************************** * CreateFilter: allocates time video filter *****************************************************************************/ static int CreateFilter( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; /* Allocate structure */ p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_sys == NULL ) { msg_Err( p_filter, "out of memory" ); return VLC_ENOMEM; } p_sys->p_style = malloc( sizeof( text_style_t ) ); memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) ); /* Hook used for callback variables */ p_sys->i_xoff = var_CreateGetInteger( p_filter->p_libvlc , "time-x" ); p_sys->i_yoff = var_CreateGetInteger( p_filter->p_libvlc , "time-y" ); p_sys->psz_format = var_CreateGetString( p_filter->p_libvlc, "time-format" ); p_sys->i_pos = var_CreateGetInteger( p_filter->p_libvlc , "time-position" ); p_sys->p_style->i_font_alpha = 255 - var_CreateGetInteger( p_filter->p_libvlc , "time-opacity" ); p_sys->p_style->i_font_color = var_CreateGetInteger( p_filter->p_libvlc , "time-color" ); p_sys->p_style->i_font_size = var_CreateGetInteger( p_filter->p_libvlc , "time-size" ); var_AddCallback( p_filter->p_libvlc, "time-x", TimeCallback, p_sys ); var_AddCallback( p_filter->p_libvlc, "time-y", TimeCallback, p_sys ); var_AddCallback( p_filter->p_libvlc, "time-format", TimeCallback, p_sys ); var_AddCallback( p_filter->p_libvlc, "time-position", TimeCallback, p_sys ); var_AddCallback( p_filter->p_libvlc, "time-color", TimeCallback, p_sys ); var_AddCallback( p_filter->p_libvlc, "time-opacity", TimeCallback, p_sys ); var_AddCallback( p_filter->p_libvlc, "time-size", TimeCallback, p_sys ); /* Misc init */ p_filter->pf_sub_filter = Filter; p_sys->last_time = ((time_t)-1); return VLC_SUCCESS; }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open(vlc_object_t *p_this) { intf_thread_t *p_intf = (intf_thread_t*) p_this; intf_sys_t *p_sys = calloc(1, sizeof(intf_sys_t)); msg_Dbg(p_intf, "Entering Open()"); if (!p_sys) return VLC_ENOMEM; p_intf->p_sys = p_sys; vlc_mutex_init(&p_sys->lock); vlc_cond_init(&p_sys->wait); var_AddCallback(pl_Get(p_intf), "item-current", ItemChange, p_intf); msg_Dbg(p_intf, "Added Item Change Callback"); p_intf->pf_run = Run; return VLC_SUCCESS; }
bool Dialogs::init() { // Allocate descriptor m_pProvider = (intf_thread_t *)vlc_object_create( getIntf(), sizeof( intf_thread_t ) ); if( m_pProvider == NULL ) return false; m_pModule = module_need( m_pProvider, "dialogs provider", NULL, false ); if( m_pModule == NULL ) { msg_Err( getIntf(), "no suitable dialogs provider found (hint: compile the qt4 plugin, and make sure it is loaded properly)" ); vlc_object_release( m_pProvider ); m_pProvider = NULL; return false; } /* Register callback for the intf-popupmenu variable */ var_AddCallback( getIntf()->p_libvlc, "intf-popupmenu", PopupMenuCB, this ); return true; }
/** * Creates a software amplifier. */ aout_volume_t *aout_volume_New(vlc_object_t *parent, const audio_replay_gain_t *gain) { aout_volume_t *vol = vlc_custom_create(parent, sizeof (aout_volume_t), "volume"); if (unlikely(vol == NULL)) return NULL; vol->module = NULL; vol->output_factor = 1.f; //audio_volume_t *obj = &vol->object; /* Gain */ if (gain != NULL) memcpy(&vol->replay_gain, gain, sizeof (vol->replay_gain)); else memset(&vol->replay_gain, 0, sizeof (vol->replay_gain)); var_AddCallback(parent, "audio-replay-gain-mode", ReplayGainCallback, vol); var_TriggerCallback(parent, "audio-replay-gain-mode"); return vol; }
/***************************************************************************** * Create *****************************************************************************/ static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; const vlc_chroma_description_t *p_chroma = vlc_fourcc_GetChromaDescription( p_filter->fmt_in.video.i_chroma ); if( p_chroma == NULL || p_chroma->plane_count == 0 ) return VLC_EGENERIC; /* Allocate structure */ filter_sys_t *p_sys = malloc( sizeof( filter_sys_t ) ); if( p_sys == NULL ) return VLC_ENOMEM; p_filter->p_sys = p_sys; p_sys->p_tmp = picture_NewFromFormat( &p_filter->fmt_in.video ); if( !p_sys->p_tmp ) { free( p_sys ); return VLC_ENOMEM; } p_sys->b_first = true; p_filter->pf_video_filter = Filter; config_ChainParse( p_filter, FILTER_PREFIX, ppsz_filter_options, p_filter->p_cfg ); atomic_init( &p_sys->i_factor, var_CreateGetIntegerCommand( p_filter, FILTER_PREFIX "factor" ) ); var_AddCallback( p_filter, FILTER_PREFIX "factor", MotionBlurCallback, p_sys ); return VLC_SUCCESS; }
int vout_OpenWrapper(vout_thread_t *vout, const char *splitter_name, const vout_display_state_t *state) { vout_thread_sys_t *sys = vout->p; msg_Dbg(vout, "Opening vout display wrapper"); /* */ sys->display.title = var_CreateGetNonEmptyString(vout, "video-title"); /* */ const mtime_t double_click_timeout = 300000; const mtime_t hide_timeout = var_CreateGetInteger(vout, "mouse-hide-timeout") * 1000; if (splitter_name) { sys->display.vd = vout_NewSplitter(vout, &vout->p->original, state, "$vout", splitter_name, double_click_timeout, hide_timeout); } else { sys->display.vd = vout_NewDisplay(vout, &vout->p->original, state, "$vout", double_click_timeout, hide_timeout); } if (!sys->display.vd) { free(sys->display.title); return VLC_EGENERIC; } /* */ #ifdef WIN32 var_Create(vout, "video-wallpaper", VLC_VAR_BOOL|VLC_VAR_DOINHERIT); var_AddCallback(vout, "video-wallpaper", Forward, NULL); #endif /* */ sys->decoder_pool = NULL; return VLC_SUCCESS; }
/* Add the callbacks on Input. Self explanatory */ inline void InputManager::addCallbacks() { var_AddCallback( p_input, "intf-event", InputEvent, this ); }
/** This function allocates and initialize the DirectX vout display. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; /* Load direct draw DLL */ sys->hddraw_dll = LoadLibrary(_T("DDRAW.DLL")); if (!sys->hddraw_dll) { msg_Warn(vd, "DirectXInitDDraw failed loading ddraw.dll"); free(sys); return VLC_EGENERIC; } /* */ sys->use_wallpaper = var_CreateGetBool(vd, "video-wallpaper"); /* FIXME */ sys->use_overlay = false;//var_CreateGetBool(vd, "overlay"); /* FIXME */ sys->restore_overlay = false; var_Create(vd, "directx-device", VLC_VAR_STRING | VLC_VAR_DOINHERIT); /* Initialisation */ if (CommonInit(vd)) goto error; /* */ video_format_t fmt = vd->fmt; if (DirectXOpen(vd, &fmt)) goto error; /* */ vout_display_info_t info = vd->info; info.is_slow = true; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = true; info.has_event_thread = true; /* Interaction TODO support starting with wallpaper mode */ vlc_mutex_init(&sys->lock); sys->ch_wallpaper = sys->use_wallpaper; sys->wallpaper_requested = sys->use_wallpaper; sys->use_wallpaper = false; vlc_value_t val; val.psz_string = _("Wallpaper"); var_Change(vd, "video-wallpaper", VLC_VAR_SETTEXT, &val, NULL); var_AddCallback(vd, "video-wallpaper", WallpaperCallback, NULL); /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = NULL; vd->display = Display; vd->control = Control; vd->manage = Manage; return VLC_SUCCESS; error: DirectXClose(vd); CommonClean(vd); if (sys->hddraw_dll) FreeLibrary(sys->hddraw_dll); free(sys); return VLC_EGENERIC; }
static int EqzInit( filter_t *p_filter, int i_rate ) { filter_sys_t *p_sys = p_filter->p_sys; eqz_config_t cfg; int i, ch; vlc_value_t val1, val2, val3; vlc_object_t *p_aout = p_filter->p_parent; int i_ret = VLC_ENOMEM; bool b_vlcFreqs = var_InheritBool( p_aout, "equalizer-vlcfreqs" ); EqzCoeffs( i_rate, 1.0f, b_vlcFreqs, &cfg ); /* Create the static filter config */ p_sys->i_band = cfg.i_band; p_sys->f_alpha = malloc( p_sys->i_band * sizeof(float) ); p_sys->f_beta = malloc( p_sys->i_band * sizeof(float) ); p_sys->f_gamma = malloc( p_sys->i_band * sizeof(float) ); if( !p_sys->f_alpha || !p_sys->f_beta || !p_sys->f_gamma ) goto error; for( i = 0; i < p_sys->i_band; i++ ) { p_sys->f_alpha[i] = cfg.band[i].f_alpha; p_sys->f_beta[i] = cfg.band[i].f_beta; p_sys->f_gamma[i] = cfg.band[i].f_gamma; } /* Filter dyn config */ p_sys->b_2eqz = false; p_sys->f_gamp = 1.0f; p_sys->f_amp = malloc( p_sys->i_band * sizeof(float) ); if( !p_sys->f_amp ) goto error; for( i = 0; i < p_sys->i_band; i++ ) { p_sys->f_amp[i] = 0.0f; } /* Filter state */ for( ch = 0; ch < 32; ch++ ) { p_sys->x[ch][0] = p_sys->x[ch][1] = p_sys->x2[ch][0] = p_sys->x2[ch][1] = 0.0f; for( i = 0; i < p_sys->i_band; i++ ) { p_sys->y[ch][i][0] = p_sys->y[ch][i][1] = p_sys->y2[ch][i][0] = p_sys->y2[ch][i][1] = 0.0f; } } p_sys->psz_newbands = NULL; var_Create( p_aout, "equalizer-bands", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); p_sys->b_2eqz = var_CreateGetBool( p_aout, "equalizer-2pass" ); var_Create( p_aout, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); /* Get initial values */ var_Get( p_aout, "equalizer-preset", &val1 ); var_Get( p_aout, "equalizer-bands", &val2 ); var_Get( p_aout, "equalizer-preamp", &val3 ); p_sys->b_first = true; PresetCallback( VLC_OBJECT( p_aout ), NULL, val1, val1, p_sys ); BandsCallback( VLC_OBJECT( p_aout ), NULL, val2, val2, p_sys ); PreampCallback( VLC_OBJECT( p_aout ), NULL, val3, val3, p_sys ); p_sys->b_first = false; free( val1.psz_string ); /* Exit if we have no preset and no bands value */ if (p_sys->psz_newbands == NULL && (!val2.psz_string || !*val2.psz_string)) { msg_Err(p_filter, "No preset selected"); free( val2.psz_string ); free( p_sys->f_amp ); i_ret = VLC_EGENERIC; goto error; } /* Register preset bands (for intf) if : */ /* We have no bands info --> the preset info must be given to the intf */ /* or The bands info matches the preset */ if( ( p_sys->psz_newbands && *(val2.psz_string) && strstr( p_sys->psz_newbands, val2.psz_string ) ) || !*val2.psz_string ) { var_SetString( p_aout, "equalizer-bands", p_sys->psz_newbands ); if( p_sys->f_newpreamp == p_sys->f_gamp ) var_SetFloat( p_aout, "equalizer-preamp", p_sys->f_newpreamp ); } free( val2.psz_string ); /* Add our own callbacks */ var_AddCallback( p_aout, "equalizer-preset", PresetCallback, p_sys ); var_AddCallback( p_aout, "equalizer-bands", BandsCallback, p_sys ); var_AddCallback( p_aout, "equalizer-preamp", PreampCallback, p_sys ); var_AddCallback( p_aout, "equalizer-2pass", TwoPassCallback, p_sys ); msg_Dbg( p_filter, "equalizer loaded for %d Hz with %d bands %d pass", i_rate, p_sys->i_band, p_sys->b_2eqz ? 2 : 1 ); for( i = 0; i < p_sys->i_band; i++ ) { msg_Dbg( p_filter, " %.2f Hz -> factor:%f alpha:%f beta:%f gamma:%f", cfg.band[i].f_frequency, p_sys->f_amp[i], p_sys->f_alpha[i], p_sys->f_beta[i], p_sys->f_gamma[i]); } return VLC_SUCCESS; error: free( p_sys->f_alpha ); free( p_sys->f_beta ); free( p_sys->f_gamma ); return i_ret; }
/***************************************************************************** * Run: rtci thread ***************************************************************************** * This part of the interface is in a separate thread so that we can call * exec() from within it without annoying the rest of the program. *****************************************************************************/ static void Run( intf_thread_t *p_intf ) { input_thread_t * p_input; playlist_t * p_playlist; char p_buffer[ MAX_LINE_LENGTH + 1 ]; vlc_bool_t b_showpos = config_GetInt( p_intf, "rtci-show-pos" ); int i_size = 0; int i_oldpos = 0; int i_newpos; p_buffer[0] = 0; p_input = NULL; p_playlist = NULL; p_intf->p_sys->b_extend = config_GetInt( p_intf, "rtci-extend" ); /* Register commands that will be cleaned up upon object destruction */ var_Create( p_intf, "quit", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "quit", Quit, NULL ); var_Create( p_intf, "intf", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "intf", Intf, NULL ); var_Create( p_intf, "add", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "add", Playlist, NULL ); var_Create( p_intf, "playlist", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "playlist", Playlist, NULL ); var_Create( p_intf, "play", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "play", Playlist, NULL ); var_Create( p_intf, "stop", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "stop", Playlist, NULL ); var_Create( p_intf, "prev", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "prev", Playlist, NULL ); var_Create( p_intf, "next", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "next", Playlist, NULL ); var_Create( p_intf, "marq-marquee", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "marq-marquee", Other, NULL ); var_Create( p_intf, "marq-x", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "marq-x", Other, NULL ); var_Create( p_intf, "marq-y", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "marq-y", Other, NULL ); var_Create( p_intf, "marq-timeout", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "marq-timeout", Other, NULL ); var_Create( p_intf, "pause", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "pause", Input, NULL ); var_Create( p_intf, "seek", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "seek", Input, NULL ); var_Create( p_intf, "title", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "title", Input, NULL ); var_Create( p_intf, "title_n", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "title_n", Input, NULL ); var_Create( p_intf, "title_p", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "title_p", Input, NULL ); var_Create( p_intf, "chapter", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "chapter", Input, NULL ); var_Create( p_intf, "chapter_n", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "chapter_n", Input, NULL ); var_Create( p_intf, "chapter_p", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "chapter_p", Input, NULL ); var_Create( p_intf, "volume", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "volume", Volume, NULL ); var_Create( p_intf, "volup", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "volup", VolumeMove, NULL ); var_Create( p_intf, "voldown", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "voldown", VolumeMove, NULL ); var_Create( p_intf, "adev", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "adev", AudioConfig, NULL ); var_Create( p_intf, "achan", VLC_VAR_STRING | VLC_VAR_ISCOMMAND ); var_AddCallback( p_intf, "achan", AudioConfig, NULL ); #ifdef WIN32 /* Get the file descriptor of the console input */ p_intf->p_sys->hConsoleIn = GetStdHandle(STD_INPUT_HANDLE); if( p_intf->p_sys->hConsoleIn == INVALID_HANDLE_VALUE ) { msg_Err( p_intf, "Couldn't open STD_INPUT_HANDLE" ); p_intf->b_die = VLC_TRUE; } #endif while( !p_intf->b_die ) { char *psz_cmd, *psz_arg; vlc_bool_t b_complete; if( p_intf->p_sys->i_socket_listen != - 1 && p_intf->p_sys->i_socket == -1 ) { p_intf->p_sys->i_socket = net_Accept( p_intf, p_intf->p_sys->i_socket_listen, 0 ); } b_complete = ReadCommand( p_intf, p_buffer, &i_size ); /* Manage the input part */ if( p_input == NULL ) { if( p_playlist ) { p_input = vlc_object_find( p_playlist, VLC_OBJECT_INPUT, FIND_CHILD ); } else { p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); if( p_input ) { p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT ); } } } else if( p_input->b_dead ) { vlc_object_release( p_input ); p_input = NULL; } if( p_input && b_showpos ) { i_newpos = 100 * var_GetFloat( p_input, "position" ); if( i_oldpos != i_newpos ) { i_oldpos = i_newpos; msg_rtci( "pos: %d%%\n", i_newpos ); } } /* Is there something to do? */ if( !b_complete ) continue; /* Skip heading spaces */ psz_cmd = p_buffer; while( *psz_cmd == ' ' ) { psz_cmd++; } /* Split psz_cmd at the first space and make sure that * psz_arg is valid */ psz_arg = strchr( psz_cmd, ' ' ); if( psz_arg ) { *psz_arg++ = 0; while( *psz_arg == ' ' ) { psz_arg++; } } else { psz_arg = ""; } /* If the user typed a registered local command, try it */ if( var_Type( p_intf, psz_cmd ) & VLC_VAR_ISCOMMAND ) { vlc_value_t val; int i_ret; val.psz_string = psz_arg; i_ret = var_Set( p_intf, psz_cmd, val ); msg_rtci( "%s: returned %i (%s)\n", psz_cmd, i_ret, vlc_error( i_ret ) ); } /* Or maybe it's a global command */ else if( var_Type( p_intf->p_libvlc, psz_cmd ) & VLC_VAR_ISCOMMAND ) { vlc_value_t val; int i_ret; val.psz_string = psz_arg; /* FIXME: it's a global command, but we should pass the * local object as an argument, not p_intf->p_libvlc. */ i_ret = var_Set( p_intf->p_libvlc, psz_cmd, val ); if( i_ret != 0 ) { msg_rtci( "%s: returned %i (%s)\n", psz_cmd, i_ret, vlc_error( i_ret ) ); } } else if( !strcmp( psz_cmd, "logout" ) ) { /* Close connection */ if( p_intf->p_sys->i_socket != -1 ) { net_Close( p_intf->p_sys->i_socket ); } p_intf->p_sys->i_socket = -1; } else if( !strcmp( psz_cmd, "info" ) ) { if( p_input ) { int i, j; vlc_mutex_lock( &p_input->input.p_item->lock ); for ( i = 0; i < p_input->input.p_item->i_categories; i++ ) { info_category_t *p_category = p_input->input.p_item->pp_categories[i]; msg_rtci( "+----[ %s ]\n", p_category->psz_name ); msg_rtci( "| \n" ); for ( j = 0; j < p_category->i_infos; j++ ) { info_t *p_info = p_category->pp_infos[j]; msg_rtci( "| %s: %s\n", p_info->psz_name, p_info->psz_value ); } msg_rtci( "| \n" ); } msg_rtci( "+----[ end of stream info ]\n" ); vlc_mutex_unlock( &p_input->input.p_item->lock ); } else { msg_rtci( "no input\n" ); } } else if( !strcmp( psz_cmd, "is_playing" ) ) { if( ! p_input ) { msg_rtci( "0\n" ); } else { msg_rtci( "1\n" ); } } else if( !strcmp( psz_cmd, "get_time" ) ) { if( ! p_input ) { msg_rtci("0\n"); } else { vlc_value_t time; var_Get( p_input, "time", &time ); msg_rtci( "%i\n", time.i_time / 1000000); } } else if( !strcmp( psz_cmd, "get_length" ) ) { if( ! p_input ) { msg_rtci("0\n"); } else { vlc_value_t time; var_Get( p_input, "length", &time ); msg_rtci( "%i\n", time.i_time / 1000000); } } else if( !strcmp( psz_cmd, "get_title" ) ) { if( ! p_input ) { msg_rtci("\n"); } else { msg_rtci( "%s\n", p_input->input.p_item->psz_name ); } } else switch( psz_cmd[0] ) { case 'f': case 'F': if( p_input ) { vout_thread_t *p_vout; p_vout = vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout ) { p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; vlc_object_release( p_vout ); } } break; case 's': case 'S': ; break; case '?': case 'h': case 'H': msg_rtci(_("+----[ Remote control commands ]\n")); msg_rtci("| \n"); msg_rtci(_("| add XYZ . . . . . . . . . . add XYZ to playlist\n")); msg_rtci(_("| playlist . . . show items currently in playlist\n")); msg_rtci(_("| play . . . . . . . . . . . . . . . . play stream\n")); msg_rtci(_("| stop . . . . . . . . . . . . . . . . stop stream\n")); msg_rtci(_("| next . . . . . . . . . . . . next playlist item\n")); msg_rtci(_("| prev . . . . . . . . . . previous playlist item\n")); msg_rtci(_("| title [X] . . . . set/get title in current item\n")); msg_rtci(_("| title_n . . . . . . next title in current item\n")); msg_rtci(_("| title_p . . . . previous title in current item\n")); msg_rtci(_("| chapter [X] . . set/get chapter in current item\n")); msg_rtci(_("| chapter_n . . . . next chapter in current item\n")); msg_rtci(_("| chapter_p . . previous chapter in current item\n")); msg_rtci("| \n"); msg_rtci(_("| seek X . seek in seconds, for instance `seek 12'\n")); msg_rtci(_("| pause . . . . . . . . . . . . . . toggle pause\n")); msg_rtci(_("| f . . . . . . . . . . . . . . toggle fullscreen\n")); msg_rtci(_("| info . . . information about the current stream\n")); msg_rtci("| \n"); msg_rtci(_("| volume [X] . . . . . . . . set/get audio volume\n")); msg_rtci(_("| volup [X] . . . . . raise audio volume X steps\n")); msg_rtci(_("| voldown [X] . . . . lower audio volume X steps\n")); msg_rtci(_("| adev [X] . . . . . . . . . set/get audio device\n")); msg_rtci(_("| achan [X]. . . . . . . . set/get audio channels\n")); msg_rtci("| \n"); if (p_intf->p_sys->b_extend) { msg_rtci(_("| marq-marquee STRING . . overlay STRING in video\n")); msg_rtci(_("| marq-x X . . . . . .offset of marquee, from left\n")); msg_rtci(_("| marq-y Y . . . . . . offset of marquee, from top\n")); msg_rtci(_("| marq-timeout T. . . . .timeout of marquee, in ms\n")); msg_rtci("| \n"); } msg_rtci(_("| help . . . . . . . . . . . . . this help message\n")); msg_rtci(_("| logout . . . . . .exit (if in socket connection)\n")); msg_rtci(_("| quit . . . . . . . . . . . . . . . . . quit vlc\n")); msg_rtci("| \n"); msg_rtci(_("+----[ end of help ]\n")); break; case '\0': /* Ignore empty lines */ break; default: msg_rtci(_("unknown command `%s', type `help' for help\n"), psz_cmd); break; } /* Command processed */ i_size = 0; p_buffer[0] = 0; } if( p_input ) { vlc_object_release( p_input ); p_input = NULL; } if( p_playlist ) { vlc_object_release( p_playlist ); p_playlist = NULL; } }
/** * Common open function */ static int OpenCommon( vlc_object_t *p_this, bool b_sub ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; char *psz_filename; /* */ if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) ) { msg_Err( p_filter, "Input and output format does not match" ); return VLC_EGENERIC; } /* */ p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; /* */ p_sys->p_blend = NULL; if( !b_sub ) { p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter), &p_filter->fmt_in.video ); if( !p_sys->p_blend ) { free( p_sys ); return VLC_EGENERIC; } } /* */ config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); /* */ logo_list_t *p_list = &p_sys->list; psz_filename = var_CreateGetStringCommand( p_filter, "logo-file" ); if( !psz_filename ) { if( p_sys->p_blend ) filter_DeleteBlend( p_sys->p_blend ); free( p_sys ); return VLC_ENOMEM; } if( *psz_filename == '\0' ) msg_Warn( p_this, "no logo file specified" ); p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity"); p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 ); p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" ); p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" ); p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" ); p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" ); p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "logo-y" ); /* Ignore aligment if a position is given for video filter */ if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 ) p_sys->i_pos = 0; vlc_mutex_init( &p_sys->lock ); LogoListLoad( p_this, p_list, psz_filename ); p_sys->b_spu_update = true; p_sys->b_mouse_grab = false; for( int i = 0; ppsz_filter_callbacks[i]; i++ ) var_AddCallback( p_filter, ppsz_filter_callbacks[i], LogoCallback, p_sys ); /* Misc init */ if( b_sub ) { p_filter->pf_sub_source = FilterSub; } else { p_filter->pf_video_filter = FilterVideo; p_filter->pf_video_mouse = Mouse; } free( psz_filename ); return VLC_SUCCESS; }
/***************************************************************************** * Open: open the audio device *****************************************************************************/ static int Open ( vlc_object_t *p_this ) { aout_instance_t *p_aout = (aout_instance_t *)p_this; SDL_AudioSpec desired, obtained; int i_nb_channels; vlc_value_t val, text; /* Check that no one uses the DSP. */ uint32_t i_flags = SDL_INIT_AUDIO; if( SDL_WasInit( i_flags ) ) { return VLC_EGENERIC; } i_flags |= SDL_INIT_EVENTTHREAD; #ifndef NDEBUG /* In debug mode you may want vlc to dump a core instead of staying * stuck */ i_flags |= SDL_INIT_NOPARACHUTE; #endif /* Initialize library */ if( SDL_Init( i_flags ) < 0 ) { msg_Err( p_aout, "cannot initialize SDL (%s)", SDL_GetError() ); return VLC_EGENERIC; } if( var_Get( p_aout, "audio-device", &val ) != VLC_ENOVAR ) { /* The user has selected an audio device. */ if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; } } i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); if ( i_nb_channels > 2 ) { /* SDL doesn't support more than two channels. */ i_nb_channels = 2; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } desired.freq = p_aout->output.output.i_rate; desired.format = AUDIO_S16SYS; desired.channels = i_nb_channels; desired.callback = SDLCallback; desired.userdata = p_aout; desired.samples = FRAME_SIZE; /* Open the sound device. */ if( SDL_OpenAudio( &desired, &obtained ) < 0 ) { return VLC_EGENERIC; } SDL_PauseAudio( 0 ); /* Now have a look at what we got. */ switch ( obtained.format ) { case AUDIO_S16LSB: p_aout->output.output.i_format = VLC_CODEC_S16L; break; case AUDIO_S16MSB: p_aout->output.output.i_format = VLC_CODEC_S16B; break; case AUDIO_U16LSB: p_aout->output.output.i_format = VLC_CODEC_U16L; break; case AUDIO_U16MSB: p_aout->output.output.i_format = VLC_CODEC_U16B; break; case AUDIO_S8: p_aout->output.output.i_format = VLC_CODEC_S8; break; case AUDIO_U8: p_aout->output.output.i_format = VLC_CODEC_U8; break; } /* Volume is entirely done in software. */ aout_VolumeSoftInit( p_aout ); if ( obtained.channels != i_nb_channels ) { p_aout->output.output.i_physical_channels = (obtained.channels == 2 ? AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT : AOUT_CHAN_CENTER); if ( var_Type( p_aout, "audio-device" ) == 0 ) { var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Device"); var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); val.i_int = (obtained.channels == 2) ? AOUT_VAR_STEREO : AOUT_VAR_MONO; text.psz_string = (obtained.channels == 2) ? _("Stereo") : _("Mono"); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } } else if ( var_Type( p_aout, "audio-device" ) == 0 ) { /* First launch. */ var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Device"); var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); val.i_int = AOUT_VAR_STEREO; text.psz_string = _("Stereo"); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_MONO; text.psz_string = _("Mono"); var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); if ( i_nb_channels == 2 ) { val.i_int = AOUT_VAR_STEREO; } else { val.i_int = AOUT_VAR_MONO; } var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } var_TriggerCallback( p_aout, "intf-change" ); p_aout->output.output.i_rate = obtained.freq; p_aout->output.i_nb_samples = obtained.samples; p_aout->output.pf_play = Play; return VLC_SUCCESS; }
/** * It creates a Direct3D vout display. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(vout_display_sys_t)); if (!sys) return VLC_ENOMEM; if (Direct3DCreate(vd)) { msg_Err(vd, "Direct3D could not be initialized"); Direct3DDestroy(vd); free(sys); return VLC_EGENERIC; } sys->use_desktop = var_CreateGetBool(vd, "direct3d-desktop"); sys->reset_device = false; sys->reset_device = false; sys->allow_hw_yuv = var_CreateGetBool(vd, "directx-hw-yuv"); sys->desktop_save.is_fullscreen = vd->cfg->is_fullscreen; sys->desktop_save.is_on_top = false; sys->desktop_save.win.left = var_InheritInteger(vd, "video-x"); sys->desktop_save.win.right = vd->cfg->display.width; sys->desktop_save.win.top = var_InheritInteger(vd, "video-y"); sys->desktop_save.win.bottom = vd->cfg->display.height; if (CommonInit(vd)) goto error; /* */ video_format_t fmt; if (Direct3DOpen(vd, &fmt)) { msg_Err(vd, "Direct3D could not be opened"); goto error; } /* */ vout_display_info_t info = vd->info; info.is_slow = true; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = true; info.has_event_thread = true; /* Interaction */ vlc_mutex_init(&sys->lock); sys->ch_desktop = false; sys->desktop_requested = sys->use_desktop; vlc_value_t val; val.psz_string = _("Desktop"); var_Change(vd, "direct3d-desktop", VLC_VAR_SETTEXT, &val, NULL); var_AddCallback(vd, "direct3d-desktop", DesktopCallback, NULL); /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = Prepare; vd->display = Display; vd->control = Control; vd->manage = Manage; /* Fix state in case of desktop mode */ if (sys->use_desktop && vd->cfg->is_fullscreen) vout_display_SendEventFullscreen(vd, false); return VLC_SUCCESS; error: Direct3DClose(vd); CommonClean(vd); Direct3DDestroy(vd); free(vd->sys); return VLC_EGENERIC; }
/***************************************************************************** * Open *****************************************************************************/ static int Open( vlc_object_t *p_this ) { sout_stream_t *p_stream = (sout_stream_t *)p_this; sout_stream_sys_t *p_sys; vlc_value_t val; config_ChainParse( p_stream, CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); p_sys = malloc( sizeof( sout_stream_sys_t ) ); if( !p_sys ) return VLC_ENOMEM; p_stream->p_sys = p_sys; p_sys->b_inited = false; p_sys->psz_id = var_CreateGetString( p_stream, CFG_PREFIX "id" ); p_sys->i_height = var_CreateGetIntegerCommand( p_stream, CFG_PREFIX "height" ); var_AddCallback( p_stream, CFG_PREFIX "height", HeightCallback, p_stream ); p_sys->i_width = var_CreateGetIntegerCommand( p_stream, CFG_PREFIX "width" ); var_AddCallback( p_stream, CFG_PREFIX "width", WidthCallback, p_stream ); var_Get( p_stream, CFG_PREFIX "sar", &val ); if( val.psz_string ) { char *psz_parser = strchr( val.psz_string, ':' ); if( psz_parser ) { *psz_parser++ = '\0'; p_sys->i_sar_num = atoi( val.psz_string ); p_sys->i_sar_den = atoi( psz_parser ); vlc_ureduce( &p_sys->i_sar_num, &p_sys->i_sar_den, p_sys->i_sar_num, p_sys->i_sar_den, 0 ); } else { msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string ); p_sys->i_sar_num = p_sys->i_sar_den = 1; } free( val.psz_string ); } else { p_sys->i_sar_num = p_sys->i_sar_den = 1; } p_sys->i_chroma = 0; val.psz_string = var_GetNonEmptyString( p_stream, CFG_PREFIX "chroma" ); if( val.psz_string && strlen( val.psz_string ) >= 4 ) { memcpy( &p_sys->i_chroma, val.psz_string, 4 ); msg_Dbg( p_stream, "Forcing image chroma to 0x%.8x (%4.4s)", p_sys->i_chroma, (char*)&p_sys->i_chroma ); } free( val.psz_string ); #define INT_COMMAND( a ) do { \ var_Create( p_stream, CFG_PREFIX #a, \ VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); \ var_AddCallback( p_stream, CFG_PREFIX #a, a ## Callback, \ p_stream ); } while(0) INT_COMMAND( alpha ); INT_COMMAND( x ); INT_COMMAND( y ); #undef INT_COMMAND p_stream->pf_add = Add; p_stream->pf_del = Del; p_stream->pf_send = Send; p_stream->pace_nocontrol = true; return VLC_SUCCESS; }
/** * Start the input for an item * * \param p_playlist the playlist object * \param p_item the item to play * \return nothing */ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item ) { playlist_private_t *p_sys = pl_priv(p_playlist); input_item_t *p_input = p_item->p_input; PL_ASSERT_LOCKED; msg_Dbg( p_playlist, "creating new input thread" ); p_input->i_nb_played++; set_current_status_item( p_playlist, p_item ); p_sys->status.i_status = PLAYLIST_RUNNING; UpdateActivity( p_playlist, DEFAULT_INPUT_ACTIVITY ); assert( p_sys->p_input == NULL ); if( !p_sys->p_input_resource ) p_sys->p_input_resource = input_resource_New( VLC_OBJECT( p_playlist ) ); input_thread_t *p_input_thread = input_Create( p_playlist, p_input, NULL, p_sys->p_input_resource ); if( p_input_thread ) { p_sys->p_input = p_input_thread; var_AddCallback( p_input_thread, "intf-event", InputEvent, p_playlist ); var_SetAddress( p_playlist, "input-current", p_input_thread ); if( input_Start( p_sys->p_input ) ) { vlc_object_release( p_input_thread ); p_sys->p_input = p_input_thread = NULL; } } char *psz_uri = input_item_GetURI( p_item->p_input ); if( psz_uri && ( !strncmp( psz_uri, "directory:", 10 ) || !strncmp( psz_uri, "vlc:", 4 ) ) ) { free( psz_uri ); return VLC_SUCCESS; } free( psz_uri ); /* TODO store art policy in playlist private data */ if( var_GetInteger( p_playlist, "album-art" ) == ALBUM_ART_WHEN_PLAYED ) { bool b_has_art; char *psz_arturl, *psz_name; psz_arturl = input_item_GetArtURL( p_input ); psz_name = input_item_GetName( p_input ); /* p_input->p_meta should not be null after a successfull CreateThread */ b_has_art = !EMPTY_STR( psz_arturl ); if( !b_has_art || strncmp( psz_arturl, "attachment://", 13 ) ) { PL_DEBUG( "requesting art for %s", psz_name ); playlist_AskForArtEnqueue( p_playlist, p_input ); } free( psz_arturl ); free( psz_name ); } /* FIXME: this is not safe !!*/ PL_UNLOCK; var_SetAddress( p_playlist, "item-current", p_input ); PL_LOCK; return VLC_SUCCESS; }
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 ); }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys; xosd *p_osd; char *psz_font, *psz_colour; if( getenv( "DISPLAY" ) == NULL ) { msg_Err( p_intf, "no display, please set the DISPLAY variable" ); return VLC_EGENERIC; } /* Allocate instance and initialize some members */ p_sys = p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); if( p_sys == NULL ) return VLC_ENOMEM; /* Initialize library */ psz_font = config_GetPsz( p_intf, "xosd-font" ); psz_colour = config_GetPsz( p_intf, "xosd-colour" ); p_osd = xosd_create( 1 ); if( p_osd == NULL ) { msg_Err( p_intf, "couldn't initialize libxosd" ); free( psz_colour ); free( psz_font ); free( p_sys ); return VLC_EGENERIC; } p_sys->p_osd = p_osd; /* Set user preferences */ xosd_set_outline_colour( p_osd, "black" ); xosd_set_font( p_osd, psz_font ); xosd_set_colour( p_osd, psz_colour ); xosd_set_timeout( p_osd, 3 ); xosd_set_pos( p_osd, config_GetInt( p_intf, "xosd-position" ) ? XOSD_bottom: XOSD_top ); xosd_set_horizontal_offset( p_osd, config_GetInt( p_intf, "xosd-text-offset" ) ); xosd_set_vertical_offset( p_osd, config_GetInt( p_intf, "xosd-text-offset" ) ); xosd_set_shadow_offset( p_osd, config_GetInt( p_intf, "xosd-shadow-offset" )); /* Initialize to NULL */ xosd_display( p_osd, 0, XOSD_string, "XOSD interface initialized" ); free( psz_colour ); free( psz_font ); // Initialize mutex and condition variable before adding the callbacks vlc_mutex_init( &p_sys->lock ); vlc_cond_init( &p_sys->cond ); // Add the callbacks playlist_t *p_playlist = pl_Hold( p_intf ); var_AddCallback( p_playlist, "item-current", PlaylistNext, p_this ); var_AddCallback( p_playlist, "item-change", PlaylistNext, p_this ); pl_Release( p_intf ); p_sys->b_need_update = true; p_intf->pf_run = Run; return VLC_SUCCESS; }
/***************************************************************************** * Open: probe the decoder and return score ***************************************************************************** * Tries to launch a decoder and return score so that the interface is able * to chose. *****************************************************************************/ static int Open( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t *) p_this; decoder_sys_t *p_sys = NULL; if( p_dec->fmt_in.i_codec != VLC_CODEC_TELETEXT ) return VLC_EGENERIC; p_dec->pf_decode_sub = Decode; p_sys = p_dec->p_sys = calloc( 1, sizeof(decoder_sys_t) ); if( p_sys == NULL ) return VLC_ENOMEM; p_sys->i_key[0] = p_sys->i_key[1] = p_sys->i_key[2] = '*' - '0'; p_sys->b_update = false; p_sys->p_vbi_dec = vbi_decoder_new(); p_sys->p_dvb_demux = vbi_dvb_pes_demux_new( NULL, NULL ); vlc_mutex_init( &p_sys->lock ); if( (p_sys->p_vbi_dec == NULL) || (p_sys->p_dvb_demux == NULL) ) { msg_Err( p_dec, "VBI decoder/demux could not be created." ); Close( p_this ); return VLC_ENOMEM; } /* Some broadcasters in countries with level 1 and level 1.5 still not send a G0 to do * matches against table 32 of ETSI 300 706. We try to do some best effort guessing * This is not perfect, but might handle some cases where we know the vbi language * is known. It would be better if people started sending G0 */ for( int i = 0; ppsz_default_triplet[i] != NULL; i++ ) { if( p_dec->fmt_in.psz_language && !strcasecmp( p_dec->fmt_in.psz_language, ppsz_default_triplet[i] ) ) { vbi_teletext_set_default_region( p_sys->p_vbi_dec, pi_default_triplet[i]); msg_Dbg( p_dec, "overwriting default zvbi region: %d", pi_default_triplet[i] ); } } vbi_event_handler_register( p_sys->p_vbi_dec, VBI_EVENT_TTX_PAGE | VBI_EVENT_NETWORK | #ifdef ZVBI_DEBUG VBI_EVENT_CAPTION | VBI_EVENT_TRIGGER | VBI_EVENT_ASPECT | VBI_EVENT_PROG_INFO | VBI_EVENT_NETWORK_ID | #endif 0 , EventHandler, p_dec ); /* Create the var on vlc_global. */ p_sys->i_wanted_page = var_CreateGetInteger( p_dec, "vbi-page" ); var_AddCallback( p_dec, "vbi-page", RequestPage, p_sys ); /* Check if the Teletext track has a known "initial page". */ if( p_sys->i_wanted_page == 100 && p_dec->fmt_in.subs.teletext.i_magazine != -1 ) { p_sys->i_wanted_page = 100 * p_dec->fmt_in.subs.teletext.i_magazine + vbi_bcd2dec( p_dec->fmt_in.subs.teletext.i_page ); var_SetInteger( p_dec, "vbi-page", p_sys->i_wanted_page ); } p_sys->i_wanted_subpage = VBI_ANY_SUBNO; p_sys->b_opaque = var_CreateGetBool( p_dec, "vbi-opaque" ); var_AddCallback( p_dec, "vbi-opaque", Opaque, p_sys ); p_sys->i_align = var_CreateGetInteger( p_dec, "vbi-position" ); var_AddCallback( p_dec, "vbi-position", Position, p_sys ); p_sys->b_text = var_CreateGetBool( p_dec, "vbi-text" ); // var_AddCallback( p_dec, "vbi-text", Text, p_sys ); /* Listen for keys */ var_AddCallback( p_dec->p_libvlc, "key-pressed", EventKey, p_dec ); es_format_Init( &p_dec->fmt_out, SPU_ES, VLC_CODEC_SPU ); if( p_sys->b_text ) p_dec->fmt_out.video.i_chroma = VLC_CODEC_TEXT; else p_dec->fmt_out.video.i_chroma = VLC_CODEC_RGBA; return VLC_SUCCESS; }
static int EqzInit( aout_filter_t *p_filter, int i_rate ) { aout_filter_sys_t *p_sys = p_filter->p_sys; const eqz_config_t *p_cfg; int i, ch; vlc_value_t val1, val2, val3; aout_instance_t *p_aout = (aout_instance_t *)p_filter->p_parent; /* Select the config */ if( i_rate == 48000 ) { p_cfg = &eqz_config_48000_10b; } else if( i_rate == 44100 ) { p_cfg = &eqz_config_44100_10b; } else { /* TODO compute the coeffs on the fly */ msg_Err( p_filter, "unsupported rate" ); return VLC_EGENERIC; } /* Create the static filter config */ p_sys->i_band = p_cfg->i_band; p_sys->f_alpha = malloc( p_sys->i_band * sizeof(float) ); p_sys->f_beta = malloc( p_sys->i_band * sizeof(float) ); p_sys->f_gamma = malloc( p_sys->i_band * sizeof(float) ); for( i = 0; i < p_sys->i_band; i++ ) { p_sys->f_alpha[i] = p_cfg->band[i].f_alpha; p_sys->f_beta[i] = p_cfg->band[i].f_beta; p_sys->f_gamma[i] = p_cfg->band[i].f_gamma; } /* Filter dyn config */ p_sys->b_2eqz = VLC_FALSE; p_sys->f_gamp = 1.0; p_sys->f_amp = malloc( p_sys->i_band * sizeof(float) ); for( i = 0; i < p_sys->i_band; i++ ) { p_sys->f_amp[i] = 0.0; } /* Filter state */ for( ch = 0; ch < 32; ch++ ) { p_sys->x[ch][0] = p_sys->x[ch][1] = p_sys->x2[ch][0] = p_sys->x2[ch][1] = 0.0; for( i = 0; i < p_sys->i_band; i++ ) { p_sys->y[ch][i][0] = p_sys->y[ch][i][1] = p_sys->y2[ch][i][0] = p_sys->y2[ch][i][1] = 0.0; } } var_CreateGetString( p_aout,"equalizer-bands" ); var_CreateGetString( p_aout, "equalizer-preset" ); p_sys->b_2eqz = var_CreateGetBool( p_aout, "equalizer-2pass" ); var_CreateGetFloat( p_aout, "equalizer-preamp" ); /* Get initial values */ var_Get( p_aout, "equalizer-preset", &val1 ); var_Get( p_aout, "equalizer-bands", &val2 ); var_Get( p_aout, "equalizer-preamp", &val3 ); p_sys->b_first = VLC_TRUE; PresetCallback( VLC_OBJECT( p_aout ), NULL, val1, val1, p_sys ); BandsCallback( VLC_OBJECT( p_aout ), NULL, val2, val2, p_sys ); PreampCallback( VLC_OBJECT( p_aout ), NULL, val3, val3, p_sys ); p_sys->b_first = VLC_FALSE; /* Register preset bands (for intf) if : */ /* We have no bands info --> the preset info must be given to the intf */ /* or The bands info matches the preset */ if (p_sys->psz_newbands == NULL) { msg_Err(p_filter, "No preset selected"); return (VLC_EGENERIC); } if( ( *(val2.psz_string) && strstr( p_sys->psz_newbands, val2.psz_string ) ) || !*val2.psz_string ) { var_SetString( p_aout, "equalizer-bands", p_sys->psz_newbands ); var_SetFloat( p_aout, "equalizer-preamp", p_sys->f_newpreamp ); } /* Add our own callbacks */ var_AddCallback( p_aout, "equalizer-preset", PresetCallback, p_sys ); var_AddCallback( p_aout, "equalizer-bands", BandsCallback, p_sys ); var_AddCallback( p_aout, "equalizer-preamp", PreampCallback, p_sys ); msg_Dbg( p_filter, "equalizer loaded for %d Hz with %d bands %d pass", i_rate, p_sys->i_band, p_sys->b_2eqz ? 2 : 1 ); for( i = 0; i < p_sys->i_band; i++ ) { msg_Dbg( p_filter, " %d Hz -> factor:%f alpha:%f beta:%f gamma:%f", (int)p_cfg->band[i].f_frequency, p_sys->f_amp[i], p_sys->f_alpha[i], p_sys->f_beta[i], p_sys->f_gamma[i]); } return VLC_SUCCESS; }
/***************************************************************************** * Init: initialize logo video thread output method *****************************************************************************/ static int Init( vout_thread_t *p_vout ) { vout_sys_t *p_sys = p_vout->p_sys; picture_t *p_pic; int i_index; 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; /* Load the video blending filter */ p_sys->p_blend = vlc_object_create( p_vout, sizeof(filter_t) ); vlc_object_attach( p_sys->p_blend, p_vout ); p_sys->p_blend->fmt_out.video.i_x_offset = p_sys->p_blend->fmt_out.video.i_y_offset = 0; p_sys->p_blend->fmt_in.video.i_x_offset = p_sys->p_blend->fmt_in.video.i_y_offset = 0; p_sys->p_blend->fmt_out.video.i_aspect = p_vout->render.i_aspect; p_sys->p_blend->fmt_out.video.i_chroma = p_vout->output.i_chroma; p_sys->p_blend->fmt_in.video.i_chroma = VLC_FOURCC('Y','U','V','A'); p_sys->p_blend->fmt_in.video.i_aspect = VOUT_ASPECT_FACTOR; p_sys->p_blend->fmt_in.video.i_width = p_sys->p_blend->fmt_in.video.i_visible_width = p_sys->p_pic->p[Y_PLANE].i_visible_pitch; p_sys->p_blend->fmt_in.video.i_height = p_sys->p_blend->fmt_in.video.i_visible_height = p_sys->p_pic->p[Y_PLANE].i_visible_lines; p_sys->p_blend->fmt_out.video.i_width = p_sys->p_blend->fmt_out.video.i_visible_width = p_vout->output.i_width; p_sys->p_blend->fmt_out.video.i_height = p_sys->p_blend->fmt_out.video.i_visible_height = p_vout->output.i_height; p_sys->p_blend->p_module = module_Need( p_sys->p_blend, "video blending", 0, 0 ); if( !p_sys->p_blend->p_module ) { msg_Err( p_vout, "can't open blending filter, aborting" ); vlc_object_detach( p_sys->p_blend ); vlc_object_destroy( p_sys->p_blend ); return VLC_EGENERIC; } if( p_sys->posx < 0 || p_sys->posy < 0 ) { p_sys->posx = 0; p_sys->posy = 0; if( p_sys->pos & SUBPICTURE_ALIGN_BOTTOM ) { p_sys->posy = p_vout->render.i_height - p_sys->i_height; } else if ( !(p_sys->pos & SUBPICTURE_ALIGN_TOP) ) { p_sys->posy = p_vout->render.i_height / 2 - p_sys->i_height / 2; } if( p_sys->pos & SUBPICTURE_ALIGN_RIGHT ) { p_sys->posx = p_vout->render.i_width - p_sys->i_width; } else if ( !(p_sys->pos & SUBPICTURE_ALIGN_LEFT) ) { p_sys->posx = p_vout->render.i_width / 2 - p_sys->i_width / 2; } } /* Try to open the real video output */ msg_Dbg( p_vout, "spawning the real video output" ); p_sys->p_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 ); /* Everything failed */ if( p_sys->p_vout == NULL ) { msg_Err( p_vout, "can't open vout, aborting" ); return VLC_EGENERIC; } var_AddCallback( p_sys->p_vout, "mouse-x", MouseEvent, p_vout); var_AddCallback( p_sys->p_vout, "mouse-y", MouseEvent, p_vout); ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES ); ADD_CALLBACKS( p_sys->p_vout, SendEvents ); ADD_PARENT_CALLBACKS( SendEventsToChild ); return VLC_SUCCESS; }
/** * ProjectM update thread which do the rendering * @param p_this: the p_thread object */ static void *Thread( void *p_data ) { filter_t *p_filter = (filter_t*)p_data; filter_sys_t *p_sys = p_filter->p_sys; video_format_t fmt; vlc_gl_t *gl; unsigned int i_last_width = 0; unsigned int i_last_height = 0; locale_t loc; locale_t oldloc; projectM *p_projectm; #ifndef HAVE_PROJECTM2 char *psz_config; #else char *psz_preset_path; char *psz_title_font; char *psz_menu_font; projectM::Settings settings; #endif vlc_savecancel(); /* Create the openGL provider */ p_sys->p_vout = (vout_thread_t *)vlc_object_create( p_filter, sizeof(vout_thread_t) ); if( !p_sys->p_vout ) goto error; /* */ video_format_Init( &fmt, 0 ); video_format_Setup( &fmt, VLC_CODEC_RGB32, p_sys->i_width, p_sys->i_height, 0, 1 ); fmt.i_sar_num = 1; fmt.i_sar_den = 1; vout_display_state_t state; memset( &state, 0, sizeof(state) ); state.cfg.display.sar.num = 1; state.cfg.display.sar.den = 1; state.cfg.is_display_filled = true; state.cfg.zoom.num = 1; state.cfg.zoom.den = 1; state.sar.num = 1; state.sar.den = 1; p_sys->p_vd = vout_NewDisplay( p_sys->p_vout, &fmt, &state, "opengl", 300000, 1000000 ); if( !p_sys->p_vd ) { vlc_object_release( p_sys->p_vout ); goto error; } var_Create( p_sys->p_vout, "fullscreen", VLC_VAR_BOOL ); var_AddCallback( p_sys->p_vout, "fullscreen", VoutCallback, p_sys->p_vd ); gl = vout_GetDisplayOpengl( p_sys->p_vd ); if( !gl ) { vout_DeleteDisplay( p_sys->p_vd, NULL ); vlc_object_release( p_sys->p_vout ); goto error; } /* Work-around the projectM locale bug */ loc = newlocale (LC_NUMERIC_MASK, "C", NULL); oldloc = uselocale (loc); /* Create the projectM object */ #ifndef HAVE_PROJECTM2 psz_config = var_InheritString( p_filter, "projectm-config" ); p_projectm = new projectM( psz_config ); free( psz_config ); #else psz_preset_path = var_InheritString( p_filter, "projectm-preset-path" ); #ifdef WIN32 if ( psz_preset_path == NULL ) { char *psz_data_path = config_GetDataDir( p_filter ); asprintf( &psz_preset_path, "%s" DIR_SEP "visualization", psz_data_path ); free( psz_data_path ); } #endif psz_title_font = var_InheritString( p_filter, "projectm-title-font" ); psz_menu_font = var_InheritString( p_filter, "projectm-menu-font" ); settings.meshX = var_InheritInteger( p_filter, "projectm-meshx" ); settings.meshY = var_InheritInteger( p_filter, "projectm-meshy" ); settings.fps = 35; settings.textureSize = var_InheritInteger( p_filter, "projectm-texture-size" ); settings.windowWidth = p_sys->i_width; settings.windowHeight = p_sys->i_height; settings.presetURL = psz_preset_path; settings.titleFontURL = psz_title_font; settings.menuFontURL = psz_menu_font; settings.smoothPresetDuration = 5; settings.presetDuration = 30; settings.beatSensitivity = 10; settings.aspectCorrection = 1; settings.easterEgg = 1; settings.shuffleEnabled = 1; p_projectm = new projectM( settings ); free( psz_menu_font ); free( psz_title_font ); free( psz_preset_path ); #endif /* HAVE_PROJECTM2 */ p_sys->i_buffer_size = p_projectm->pcm()->maxsamples; p_sys->p_buffer = (float*)calloc( p_sys->i_buffer_size, sizeof( float ) ); vlc_sem_post( &p_sys->ready ); /* Choose a preset randomly or projectM will always show the first one */ if ( p_projectm->getPlaylistSize() > 0 ) p_projectm->selectPreset( (unsigned)vlc_mrand48() % p_projectm->getPlaylistSize() ); /* */ for( ;; ) { const mtime_t i_deadline = mdate() + CLOCK_FREQ / 50; /* 50 fps max */ /* Manage the events */ vout_ManageDisplay( p_sys->p_vd, true ); if( p_sys->p_vd->cfg->display.width != i_last_width || p_sys->p_vd->cfg->display.height != i_last_height ) { /* FIXME it is not perfect as we will have black bands */ vout_display_place_t place; vout_display_PlacePicture( &place, &p_sys->p_vd->source, p_sys->p_vd->cfg, false ); p_projectm->projectM_resetGL( place.width, place.height ); i_last_width = p_sys->p_vd->cfg->display.width; i_last_height = p_sys->p_vd->cfg->display.height; } /* Render the image and swap the buffers */ vlc_mutex_lock( &p_sys->lock ); if( p_sys->i_nb_samples > 0 ) { p_projectm->pcm()->addPCMfloat( p_sys->p_buffer, p_sys->i_nb_samples ); p_sys->i_nb_samples = 0; } if( p_sys->b_quit ) { vlc_mutex_unlock( &p_sys->lock ); delete p_projectm; vout_DeleteDisplay( p_sys->p_vd, NULL ); vlc_object_release( p_sys->p_vout ); if (loc != (locale_t)0) { uselocale (oldloc); freelocale (loc); } return NULL; } vlc_mutex_unlock( &p_sys->lock ); p_projectm->renderFrame(); /* */ mwait( i_deadline ); if( !vlc_gl_Lock(gl) ) { vlc_gl_Swap( gl ); vlc_gl_Unlock( gl ); } } abort(); error: p_sys->b_error = true; vlc_sem_post( &p_sys->ready ); return NULL; }