/*** Replay gain ***/ static float aout_ReplayGainSelect(vlc_object_t *obj, const char *str, const audio_replay_gain_t *replay_gain) { unsigned mode = AUDIO_REPLAY_GAIN_MAX; if (likely(str != NULL)) { /* Find selectrf mode */ if (!strcmp (str, "track")) mode = AUDIO_REPLAY_GAIN_TRACK; else if (!strcmp (str, "album")) mode = AUDIO_REPLAY_GAIN_ALBUM; } /* */ float multiplier; if (mode == AUDIO_REPLAY_GAIN_MAX) { multiplier = 1.f; } else { float gain; /* If the selectrf mode is not available, prefer the other one */ if (!replay_gain->pb_gain[mode] && replay_gain->pb_gain[!mode]) mode = !mode; if (replay_gain->pb_gain[mode]) gain = replay_gain->pf_gain[mode] + var_InheritFloat (obj, "audio-replay-gain-preamp"); else gain = var_InheritFloat (obj, "audio-replay-gain-default"); multiplier = pow (10., gain / 20.); if (replay_gain->pb_peak[mode] && var_InheritBool (obj, "audio-replay-gain-peak-protection") && replay_gain->pf_peak[mode] * multiplier > 1.f) multiplier = 1.f / replay_gain->pf_peak[mode]; } /* Command line / configuration gain */ multiplier *= var_InheritFloat (obj, "gain"); return multiplier; }
/* * Obtain the window type from the window type variable. */ void window_get_param( vlc_object_t * p_aout, window_param * p_param ) { /* Fetch Kaiser parameter */ p_param->f_kaiser_alpha = var_InheritFloat( p_aout, "effect-kaiser-param" ); /* Fetch window type */ char * psz_preset = var_InheritString( p_aout, "effect-fft-window" ); if( !psz_preset ) { goto no_preset; } for( int i = 0; i < NB_WINDOWS; i++ ) { if( !strcasecmp( psz_preset, window_list[i] ) ) { p_param->wind_type = i; return; } } no_preset: msg_Warn( p_aout, "No matching window preset found; using rectangular " "window (i.e. no window)" ); p_param->wind_type = NONE; }
/** * Raises the volume. * \param value how much to increase (> 0) or decrease (< 0) the volume * \param volp if non-NULL, will contain contain the resulting volume */ int playlist_VolumeUp (playlist_t *pl, int value, float *volp) { int ret = -1; float delta = value * var_InheritFloat (pl, "volume-step"); audio_output_t *aout = playlist_GetAout (pl); if (aout != NULL) { float vol = aout_VolumeGet (aout); if (vol >= 0.) { vol += delta / (float)AOUT_VOLUME_DEFAULT; if (vol < 0.) vol = 0.; if (vol > 2.) vol = 2.; if (volp != NULL) *volp = vol; ret = aout_VolumeSet (aout, vol); } vlc_object_release (aout); } return ret; }
static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; if ( !AOUT_FMTS_IDENTICAL( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) ) { msg_Warn( p_filter, "bad input or output format" ); return VLC_EGENERIC; } p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; p_sys->p_mixer = aout_MixerNew( p_this, p_filter->fmt_in.audio.i_format ); if( !p_sys->p_mixer ) { msg_Warn( p_filter, "unsupported format" ); free( p_sys ); return VLC_EGENERIC; } p_sys->f_gain = var_InheritFloat( p_filter->p_parent, "gain-value" ); msg_Dbg( p_filter, "gain multiplier sets to %.2fx", p_sys->f_gain ); p_filter->pf_audio_filter = Process; return VLC_SUCCESS; }
/***************************************************************************** * OpenDecoder: probe the decoder and return score *****************************************************************************/ static int OpenDecoder( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; if( p_dec->fmt_in.i_codec != VLC_CODEC_SVG ) return VLC_EGENERIC; decoder_sys_t *p_sys = malloc( sizeof(decoder_sys_t) ); if (!p_sys) return VLC_ENOMEM; p_dec->p_sys = p_sys; p_sys->i_width = var_InheritInteger( p_this, "svg-width" ); p_sys->i_height = var_InheritInteger( p_this, "svg-height" ); p_sys->f_scale = var_InheritFloat( p_this, "svg-scale" ); /* Initialize library */ #if (GLIB_MAJOR_VERSION < 2 || GLIB_MINOR_VERSION < 36) g_type_init(); #endif /* Set output properties */ p_dec->fmt_out.i_codec = VLC_CODEC_BGRA; /* Set callbacks */ p_dec->pf_decode = DecodeBlock; return VLC_SUCCESS; }
/* Define the Input used. Add the callbacks on input p_input is held once here */ void InputManager::setInput( input_thread_t *_p_input ) { delInput(); p_input = _p_input; if( p_input && !( p_input->b_dead || !vlc_object_alive (p_input) ) ) { msg_Dbg( p_intf, "IM: Setting an input" ); vlc_object_hold( p_input ); addCallbacks(); UpdateStatus(); UpdateName(); UpdateArt(); UpdateTeletext(); UpdateNavigation(); UpdateVout(); p_item = input_GetItem( p_input ); emit rateChanged( var_GetFloat( p_input, "rate" ) ); } else { p_input = NULL; p_item = NULL; assert( !p_input_vbi ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); } }
/***************************************************************************** * OpenDecoder: probe the decoder and return score *****************************************************************************/ static int OpenDecoder( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; if( p_dec->fmt_in.i_codec != VLC_CODEC_SVG ) return VLC_EGENERIC; decoder_sys_t *p_sys = malloc( sizeof(decoder_sys_t) ); if (!p_sys) return VLC_ENOMEM; p_dec->p_sys = p_sys; p_sys->i_width = var_InheritInteger( p_this, "svg-width" ); p_sys->i_height = var_InheritInteger( p_this, "svg-height" ); p_sys->f_scale = var_InheritFloat( p_this, "svg-scale" ); /* Initialize library */ rsvg_init(); /* Set output properties */ p_dec->fmt_out.i_cat = VIDEO_ES; p_dec->fmt_out.i_codec = VLC_CODEC_BGRA; /* Set callbacks */ p_dec->pf_decode_video = DecodeBlock; return VLC_SUCCESS; }
/* delete Input if it ever existed. Delete the callbacls on input p_input is released once here */ void InputManager::delInput() { if( !p_input ) return; msg_Dbg( p_intf, "IM: Deleting the input" ); /* Save time / position */ float f_pos = var_GetFloat( p_input , "position" ); int64_t i_time = var_GetTime( p_input, "time"); int i_length = var_GetTime( p_input , "length" ) / CLOCK_FREQ; if( f_pos < 0.05 || f_pos > 0.95 || i_length < 60) { i_time = -1; } RecentsMRL::getInstance( p_intf )->setTime( p_item->psz_uri, i_time ); delCallbacks(); i_old_playing_status = END_S; p_item = NULL; oldName = ""; artUrl = ""; b_video = false; timeA = 0; timeB = 0; f_rate = 0. ; if( p_input_vbi ) { vlc_object_release( p_input_vbi ); p_input_vbi = NULL; } vlc_object_release( p_input ); p_input = NULL; emit positionUpdated( -1.0, 0 ,0 ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); emit nameChanged( "" ); emit chapterChanged( 0 ); emit titleChanged( 0 ); emit playingStatusChanged( END_S ); emit teletextPossible( false ); emit AtoBchanged( false, false ); emit voutChanged( false ); emit voutListChanged( NULL, 0 ); /* Reset all InfoPanels but stats */ emit artChanged( NULL ); emit artChanged( "" ); emit infoChanged( NULL ); emit currentMetaChanged( (input_item_t *)NULL ); emit encryptionChanged( false ); emit recordingStateChanged( false ); emit cachingChanged( 1 ); }
/* Define the Input used. Add the callbacks on input p_input is held once here */ void InputManager::setInput( input_thread_t *_p_input ) { delInput(); p_input = _p_input; if( p_input != NULL ) { msg_Dbg( p_intf, "IM: Setting an input" ); vlc_object_hold( p_input ); addCallbacks(); UpdateStatus(); UpdateName(); UpdateArt(); UpdateTeletext(); UpdateNavigation(); UpdateVout(); p_item = input_GetItem( p_input ); emit rateChanged( var_GetFloat( p_input, "rate" ) ); /* Get Saved Time */ if( p_item->i_type == ITEM_TYPE_FILE ) { char *uri = input_item_GetURI( p_item ); int i_time = RecentsMRL::getInstance( p_intf )->time( qfu(uri) ); if( i_time > 0 && qfu( uri ) != lastURI && !var_GetFloat( p_input, "run-time" ) && !var_GetFloat( p_input, "start-time" ) && !var_GetFloat( p_input, "stop-time" ) ) { emit resumePlayback( (int64_t)i_time * 1000 ); } playlist_Lock( THEPL ); // Add root items only playlist_item_t* p_node = playlist_CurrentPlayingItem( THEPL ); if ( p_node != NULL && p_node->p_parent != NULL && p_node->p_parent->i_id == THEPL->p_playing->i_id ) { // Save the latest URI to avoid asking to restore the // position on the same input file. lastURI = qfu( uri ); RecentsMRL::getInstance( p_intf )->addRecent( lastURI ); } playlist_Unlock( THEPL ); free( uri ); } } else { p_item = NULL; lastURI.clear(); assert( !p_input_vbi ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); } }
/***************************************************************************** * Open a directory *****************************************************************************/ static int Open( vlc_object_t *p_this ) { access_t *p_access = (access_t*)p_this; if( !p_access->psz_filepath ) return VLC_EGENERIC; /* Some tests can be skipped if this module was explicitly requested. * That way, the user can play "corrupt" recordings if necessary * and we can avoid false positives in the general case. */ bool b_strict = strcmp( p_access->psz_name, "vdr" ); /* Do a quick test based on the directory name to see if this * directory might contain a VDR recording. We can be reasonably * sure if ScanDirectory() actually finds files. */ if( b_strict ) { char psz_extension[4]; int i_length = 0; const char *psz_name = BaseName( p_access->psz_filepath ); if( sscanf( psz_name, "%*u-%*u-%*u.%*u.%*u.%*u%*[-.]%*u.%3s%n", psz_extension, &i_length ) != 1 || strcasecmp( psz_extension, "rec" ) || ( psz_name[i_length] != DIR_SEP_CHAR && psz_name[i_length] != '\0' ) ) return VLC_EGENERIC; } /* Only directories can be recordings */ struct stat st; if( vlc_stat( p_access->psz_filepath, &st ) || !S_ISDIR( st.st_mode ) ) return VLC_EGENERIC; access_sys_t *p_sys = vlc_calloc( p_this, 1, sizeof( *p_sys ) ); if( unlikely(p_sys == NULL) ) return VLC_ENOMEM; p_access->p_sys = p_sys; p_sys->fd = -1; p_sys->cur_seekpoint = 0; p_sys->fps = var_InheritFloat( p_access, "vdr-fps" ); ARRAY_INIT( p_sys->file_sizes ); /* Import all files and prepare playback. */ if( !ScanDirectory( p_access ) || !SwitchFile( p_access, 0 ) ) { Close( p_this ); return VLC_EGENERIC; } ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); return VLC_SUCCESS; }
/*** Replay gain ***/ float (aout_ReplayGainSelect)(vlc_object_t *obj, const char *str, const audio_replay_gain_t *replay_gain) { float gain = 0.; unsigned mode = AUDIO_REPLAY_GAIN_MAX; if (likely(str != NULL)) { /* Find selectrf mode */ if (!strcmp (str, "track")) mode = AUDIO_REPLAY_GAIN_TRACK; else if (!strcmp (str, "album")) mode = AUDIO_REPLAY_GAIN_ALBUM; /* If the selectrf mode is not available, prefer the other one */ if (mode != AUDIO_REPLAY_GAIN_MAX && !replay_gain->pb_gain[mode]) { if (replay_gain->pb_gain[!mode]) mode = !mode; } } /* */ if (mode == AUDIO_REPLAY_GAIN_MAX) return 1.; if (replay_gain->pb_gain[mode]) gain = replay_gain->pf_gain[mode] + var_InheritFloat (obj, "audio-replay-gain-preamp"); else gain = var_InheritFloat (obj, "audio-replay-gain-default"); float multiplier = pow (10., gain / 20.); if (replay_gain->pb_peak[mode] && var_InheritBool (obj, "audio-replay-gain-peak-protection") && replay_gain->pf_peak[mode] * multiplier > 1.0) multiplier = 1.0f / replay_gain->pf_peak[mode]; return multiplier; }
PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) { setWindowTitle( qtr( "Playlist" ) ); setWindowRole( "vlc-playlist" ); setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) ); playlistWidget = new PlaylistWidget( p_intf, this ); setCentralWidget( playlistWidget ); readSettings( "playlistdialog", QSize( 600,700 ) ); }
/***************************************************************************** * Open: initialize as "audio filter" *****************************************************************************/ static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; /* Allocate structure */ filter_sys_t *p_sys = p_filter->p_sys = malloc( sizeof(*p_sys) ); if( ! p_sys ) return VLC_ENOMEM; p_sys->scale = 1.0; p_sys->sample_rate = p_filter->fmt_in.audio.i_rate; p_sys->samples_per_frame = aout_FormatNbChannels( &p_filter->fmt_in.audio ); p_sys->bytes_per_sample = 4; p_sys->bytes_per_frame = p_sys->samples_per_frame * p_sys->bytes_per_sample; msg_Dbg( p_this, "format: %5i rate, %i nch, %i bps, %s", p_sys->sample_rate, p_sys->samples_per_frame, p_sys->bytes_per_sample, "fl32" ); p_sys->ms_stride = var_InheritInteger( p_this, "scaletempo-stride" ); p_sys->percent_overlap = var_InheritFloat( p_this, "scaletempo-overlap" ); p_sys->ms_search = var_InheritInteger( p_this, "scaletempo-search" ); msg_Dbg( p_this, "params: %i stride, %.3f overlap, %i search", p_sys->ms_stride, p_sys->percent_overlap, p_sys->ms_search ); p_sys->buf_queue = NULL; p_sys->buf_overlap = NULL; p_sys->table_blend = NULL; p_sys->buf_pre_corr = NULL; p_sys->table_window = NULL; p_sys->bytes_overlap = 0; p_sys->bytes_queued = 0; p_sys->bytes_to_slide = 0; p_sys->frames_stride_error = 0; if( reinit_buffers( p_filter ) != VLC_SUCCESS ) { Close( p_this ); return VLC_EGENERIC; } p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32; aout_FormatPrepare(&p_filter->fmt_in.audio); p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->pf_audio_filter = DoWork; return VLC_SUCCESS; }
void VlcProc::init_equalizer() { playlist_t* pPlaylist = getIntf()->p_sys->p_playlist; audio_output_t* pAout = playlist_GetAout( pPlaylist ); if( pAout ) { if( !var_Type( pAout, "equalizer-bands" ) ) var_Create( pAout, "equalizer-bands", VLC_VAR_STRING | VLC_VAR_DOINHERIT); if( !var_Type( pAout, "equalizer-preamp" ) ) var_Create( pAout, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT); // New Aout (addCallbacks) var_AddCallback( pAout, "audio-filter", onGenericCallback, this ); var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this ); var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this ); } // is equalizer enabled ? char *pFilters = pAout ? var_GetNonEmptyString( pAout, "audio-filter" ) : var_InheritString( getIntf(), "audio-filter" ); bool b_equalizer = pFilters && strstr( pFilters, "equalizer" ); free( pFilters ); SET_BOOL( m_cVarEqualizer, b_equalizer ); // retrieve initial bands char* bands = pAout ? var_GetString( pAout, "equalizer-bands" ) : var_InheritString( getIntf(), "equalizer-bands" ); if( bands ) { m_varEqBands.set( bands ); free( bands ); } // retrieve initial preamp float preamp = pAout ? var_GetFloat( pAout, "equalizer-preamp" ) : var_InheritFloat( getIntf(), "equalizer-preamp" ); EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)m_cVarEqPreamp.get(); pVarPreamp->set( (preamp + 20.0) / 40.0 ); if( pAout ) vlc_object_release( pAout); }
WindowManager::WindowManager( intf_thread_t *pIntf ): SkinObject( pIntf ), m_magnet( 0 ), m_alpha( 255 ), m_moveAlpha( 255 ), m_opacityEnabled( false ), m_opacity( 255 ), m_direction( kNone ), m_maximizeRect(0, 0, 50, 50), m_pTooltip( NULL ), m_pPopup( NULL ) { // Create and register a variable for the "on top" status VarManager *pVarManager = VarManager::instance( getIntf() ); m_cVarOnTop = VariablePtr( new VarBoolImpl( getIntf() ) ); pVarManager->registerVar( m_cVarOnTop, "vlc.isOnTop" ); // transparency switched on or off by user m_opacityEnabled = var_InheritBool( getIntf(), "skins2-transparency" ); // opacity overridden by user m_opacity = 255 * var_InheritFloat( getIntf(), "qt-opacity" ); }
/* delete Input if it ever existed. Delete the callbacls on input p_input is released once here */ void InputManager::delInput() { if( !p_input ) return; msg_Dbg( p_intf, "IM: Deleting the input" ); delCallbacks(); i_old_playing_status = END_S; p_item = NULL; oldName = ""; artUrl = ""; b_video = false; timeA = 0; timeB = 0; f_rate = 0. ; if( p_input_vbi ) { vlc_object_release( p_input_vbi ); p_input_vbi = NULL; } vlc_object_release( p_input ); p_input = NULL; emit positionUpdated( -1.0, 0 ,0 ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); emit nameChanged( "" ); emit chapterChanged( 0 ); emit titleChanged( 0 ); emit playingStatusChanged( END_S ); emit teletextPossible( false ); emit AtoBchanged( false, false ); emit voutChanged( false ); emit voutListChanged( NULL, 0 ); /* Reset all InfoPanels but stats */ emit artChanged( NULL ); emit artChanged( "" ); emit infoChanged( NULL ); emit currentMetaChanged( (input_item_t *)NULL ); emit encryptionChanged( false ); emit recordingStateChanged( false ); emit cachingChanged( 1 ); }
SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, QWidget *parent ) : QLabel( parent ), p_intf( _p_intf ) { tooltipStringPattern = qtr( "Current playback speed: %1\nClick to adjust" ); /* Create the Speed Control Widget */ speedControl = new SpeedControlWidget( p_intf, this ); speedControlMenu = new QMenu( this ); QWidgetAction *widgetAction = new QWidgetAction( speedControl ); widgetAction->setDefaultWidget( speedControl ); speedControlMenu->addAction( widgetAction ); /* Change the SpeedRate in the Status Bar */ CONNECT( THEMIM->getIM(), rateChanged( float ), this, setRate( float ) ); DCONNECT( THEMIM, inputChanged( input_thread_t * ), speedControl, activateOnState() ); setRate( var_InheritFloat( p_intf, "rate" ) ); }
/* Define the Input used. Add the callbacks on input p_input is held once here */ void InputManager::setInput( input_thread_t *_p_input ) { delInput(); p_input = _p_input; if( p_input != NULL ) { msg_Dbg( p_intf, "IM: Setting an input" ); vlc_object_hold( p_input ); addCallbacks(); UpdateStatus(); UpdateName(); UpdateArt(); UpdateTeletext(); UpdateNavigation(); UpdateVout(); p_item = input_GetItem( p_input ); emit rateChanged( var_GetFloat( p_input, "rate" ) ); /* Get Saved Time */ if( p_item->i_type == ITEM_TYPE_FILE ) { int i_time = RecentsMRL::getInstance( p_intf )->time( p_item->psz_uri ); if( i_time > 0 && !var_GetFloat( p_input, "run-time" ) && !var_GetFloat( p_input, "start-time" ) && !var_GetFloat( p_input, "stop-time" ) ) { emit resumePlayback( (int64_t)i_time * 1000 ); } } } else { p_item = NULL; assert( !p_input_vbi ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); } }
static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys = (filter_sys_t *)vlc_object_create( p_this, sizeof( *p_sys ) ); // sunqueen modify if( unlikely( p_sys == NULL ) ) return VLC_ENOMEM; p_filter->p_sys = p_sys; p_sys->volume.format = p_filter->fmt_in.audio.i_format; p_sys->module = module_need( &p_sys->volume, "audio volume", NULL, false ); if( p_sys->module == NULL ) { msg_Warn( p_filter, "unsupported format" ); vlc_object_release( &p_sys->volume ); return VLC_EGENERIC; } p_sys->f_gain = var_InheritFloat( p_filter->p_parent, "gain-value" ); msg_Dbg( p_filter, "gain multiplier sets to %.2fx", p_sys->f_gain ); p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->pf_audio_filter = Process; return VLC_SUCCESS; }
/***************************************************************************** * Open: *****************************************************************************/ static int Open( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; if (p_demux->out == NULL) return VLC_EGENERIC; p_sys = vlc_obj_calloc( p_this, 1, sizeof(demux_sys_t) ); if( !p_sys ) return VLC_ENOMEM; p_sys->f_fps = var_InheritFloat( p_demux, CFG_PREFIX "fps" ); if ( p_sys->f_fps <= 0 ) p_sys->f_fps = 1.0; p_sys->i_frame_interval = CLOCK_FREQ / p_sys->f_fps; #if FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR < 2 freerdp_channels_global_init(); #endif p_sys->p_instance = freerdp_new(); if ( !p_sys->p_instance ) { msg_Err( p_demux, "rdp instantiation error" ); return VLC_EGENERIC; } p_demux->p_sys = p_sys; p_sys->p_instance->PreConnect = preConnectHandler; p_sys->p_instance->PostConnect = postConnectHandler; p_sys->p_instance->Authenticate = authenticateHandler; /* Set up context handlers and let it be allocated */ p_sys->p_instance->ContextSize = sizeof( vlcrdp_context_t ); freerdp_context_new( p_sys->p_instance ); vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_sys->p_instance->context; p_vlccontext->p_demux = p_demux; /* Parse uri params for pre-connect */ vlc_url_t url; vlc_UrlParse( &url, p_demux->psz_location ); if ( !EMPTY_STR(url.psz_host) ) p_sys->psz_hostname = strdup( url.psz_host ); else p_sys->psz_hostname = strdup( "localhost" ); p_sys->i_port = ( url.i_port > 0 ) ? url.i_port : 3389; vlc_UrlClean( &url ); if ( ! freerdp_connect( p_sys->p_instance ) ) { msg_Err( p_demux, "can't connect to rdp server" ); goto error; } if ( vlc_clone( &p_sys->thread, DemuxThread, p_demux, VLC_THREAD_PRIORITY_INPUT ) != VLC_SUCCESS ) { msg_Err( p_demux, "can't spawn thread" ); freerdp_disconnect( p_sys->p_instance ); goto error; } p_demux->pf_demux = NULL; p_demux->pf_control = Control; return VLC_SUCCESS; error: freerdp_free( p_sys->p_instance ); free( p_sys->psz_hostname ); return VLC_EGENERIC; }
static int Open (vlc_object_t *p_this) { decoder_t *p_dec = (decoder_t *)p_this; if (p_dec->fmt_in.i_codec != VLC_CODEC_MIDI) return VLC_EGENERIC; decoder_sys_t *p_sys = (decoder_sys_t *)malloc (sizeof (*p_sys)); // sunqueen modify if (unlikely(p_sys == NULL)) return VLC_ENOMEM; p_sys->settings = new_fluid_settings (); p_sys->synth = new_fluid_synth (p_sys->settings); p_sys->soundfont = -1; char *font_path = var_InheritString (p_this, "soundfont"); if (font_path != NULL) { msg_Dbg (p_this, "loading sound fonts file %s", font_path); p_sys->soundfont = fluid_synth_sfload (p_sys->synth, font_path, 1); if (p_sys->soundfont == -1) msg_Err (p_this, "cannot load sound fonts file %s", font_path); free (font_path); } #ifdef _POSIX_VERSION else { glob_t gl; glob ("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, &gl); for (size_t i = 0; i < gl.gl_pathc; i++) { const char *path = gl.gl_pathv[i]; msg_Dbg (p_this, "loading sound fonts file %s", path); p_sys->soundfont = fluid_synth_sfload (p_sys->synth, path, 1); if (p_sys->soundfont != -1) break; /* it worked! */ msg_Err (p_this, "cannot load sound fonts file %s", path); } globfree (&gl); } #endif if (p_sys->soundfont == -1) { msg_Err (p_this, "sound font file required for synthesis"); dialog_Fatal (p_this, _("MIDI synthesis not set up"), _("A sound font file (.SF2) is required for MIDI synthesis.\n" "Please install a sound font and configure it " "from the VLC preferences " "(Input / Codecs > Audio codecs > FluidSynth).\n")); delete_fluid_synth (p_sys->synth); delete_fluid_settings (p_sys->settings); free (p_sys); return VLC_EGENERIC; } fluid_synth_set_chorus_on (p_sys->synth, var_InheritBool (p_this, "synth-chorus")); fluid_synth_set_gain (p_sys->synth, var_InheritFloat (p_this, "synth-gain")); fluid_synth_set_polyphony (p_sys->synth, var_InheritInteger (p_this, "synth-polyphony")); fluid_synth_set_reverb_on (p_sys->synth, var_InheritBool (p_this, "synth-reverb")); p_dec->fmt_out.i_cat = AUDIO_ES; p_dec->fmt_out.audio.i_rate = var_InheritInteger (p_this, "synth-sample-rate");; fluid_synth_set_sample_rate (p_sys->synth, p_dec->fmt_out.audio.i_rate); p_dec->fmt_out.audio.i_channels = 2; p_dec->fmt_out.audio.i_original_channels = p_dec->fmt_out.audio.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_dec->fmt_out.i_codec = VLC_CODEC_FL32; p_dec->fmt_out.audio.i_bitspersample = 32; date_Init (&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1); date_Set (&p_sys->end_date, 0); p_dec->p_sys = p_sys; p_dec->pf_decode_audio = DecodeBlock; return VLC_SUCCESS; }
/********************************************************************** * Fullscrenn control widget **********************************************************************/ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWidget *_parent ) : AbstractController( _p_i, _parent ) { RTL_UNAFFECTED_WIDGET i_mouse_last_x = -1; i_mouse_last_y = -1; b_mouse_over = false; i_mouse_last_move_x = -1; i_mouse_last_move_y = -1; #if HAVE_TRANSPARENCY b_slow_hide_begin = false; i_slow_hide_timeout = 1; #endif b_fullscreen = false; i_hide_timeout = 1; i_screennumber = -1; vout.clear(); setWindowFlags( Qt::ToolTip ); setMinimumWidth( FSC_WIDTH ); isWideFSC = false; setFrameShape( QFrame::StyledPanel ); setFrameStyle( QFrame::Sunken ); setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); QVBoxLayout *controlLayout2 = new QVBoxLayout( this ); controlLayout2->setContentsMargins( 4, 6, 4, 2 ); /* First line */ InputControlsWidget *inputC = new InputControlsWidget( p_intf, this ); controlLayout2->addWidget( inputC ); controlLayout = new QHBoxLayout; QString line = getSettings()->value( "MainWindow/FSCtoolbar", FSC_TB_DEFAULT ).toString(); parseAndCreate( line, controlLayout ); controlLayout2->addLayout( controlLayout ); /* hiding timer */ p_hideTimer = new QTimer( this ); p_hideTimer->setSingleShot( true ); CONNECT( p_hideTimer, timeout(), this, hideFSC() ); /* slow hiding timer */ #if HAVE_TRANSPARENCY p_slowHideTimer = new QTimer( this ); CONNECT( p_slowHideTimer, timeout(), this, slowHideFSC() ); f_opacity = var_InheritFloat( p_intf, "qt-fs-opacity" ); #endif i_sensitivity = var_InheritInteger( p_intf, "qt-fs-sensitivity" ); vlc_mutex_init_recursive( &lock ); DCONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, setVoutList( vout_thread_t **, int ) ); /* First Move */ previousPosition = getSettings()->value( "FullScreen/pos" ).toPoint(); screenRes = getSettings()->value( "FullScreen/screen" ).toRect(); isWideFSC = getSettings()->value( "FullScreen/wide" ).toBool(); i_screennumber = var_InheritInteger( p_intf, "qt-fullscreen-screennumber" ); CONNECT( this, fullscreenChanged( bool ), THEMIM, changeFullscreen( bool ) ); }
/***************************************************************************** * Open: allocates Wall video thread output method ***************************************************************************** * This function allocates and initializes a Wall vout method. *****************************************************************************/ static int Open( vlc_object_t *p_this ) { video_splitter_t *p_splitter = (video_splitter_t*)p_this; video_splitter_sys_t *p_sys; const panoramix_chroma_t *p_chroma; for( int i = 0; ; i++ ) { vlc_fourcc_t i_chroma = p_chroma_array[i].i_chroma; if( !i_chroma ) { msg_Err( p_splitter, "colorspace not supported by plug-in !" ); return VLC_EGENERIC; } if( i_chroma == p_splitter->fmt.i_chroma ) { p_chroma = &p_chroma_array[i]; break; } } /* Allocate structure */ p_splitter->p_sys = p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; /* */ p_sys->p_chroma = p_chroma; /* */ config_ChainParse( p_splitter, CFG_PREFIX, ppsz_filter_options, p_splitter->p_cfg ); /* */ p_sys->i_col = var_InheritInteger( p_splitter, CFG_PREFIX "cols" ); p_sys->i_row = var_InheritInteger( p_splitter, CFG_PREFIX "rows" ); /* Autodetect number of displays */ if( p_sys->i_col < 0 || p_sys->i_row < 0 ) { #ifdef WIN32 const int i_monitor_count = GetSystemMetrics(SM_CMONITORS); if( i_monitor_count > 1 ) { p_sys->i_col = GetSystemMetrics( SM_CXVIRTUALSCREEN ) / GetSystemMetrics( SM_CXSCREEN ); p_sys->i_row = GetSystemMetrics( SM_CYVIRTUALSCREEN ) / GetSystemMetrics( SM_CYSCREEN ); if( p_sys->i_col * p_sys->i_row != i_monitor_count ) { p_sys->i_col = i_monitor_count; p_sys->i_row = 1; } } #else const unsigned i_monitors = CountMonitors( p_this ); if( i_monitors > 1 ) /* Find closest to square */ for( unsigned w = 1; (i_monitors / w) >= w ; w++ ) { if( i_monitors % w ) continue; p_sys->i_row = w; p_sys->i_col = i_monitors / w; } #endif /* By default do 2x1 */ if( p_sys->i_row < 0 ) p_sys->i_row = 1; if( p_sys->i_col < 0 ) p_sys->i_col = 2; var_SetInteger( p_splitter, CFG_PREFIX "cols", p_sys->i_col); var_SetInteger( p_splitter, CFG_PREFIX "rows", p_sys->i_row); } /* */ p_sys->b_attenuate = var_InheritBool( p_splitter, CFG_PREFIX "attenuate"); p_sys->bz_length = var_InheritInteger( p_splitter, CFG_PREFIX "bz-length" ); p_sys->bz_height = var_InheritInteger( p_splitter, CFG_PREFIX "bz-height" ); p_sys->bz_begin = var_InheritInteger( p_splitter, CFG_PREFIX "bz-begin" ); p_sys->bz_middle = var_InheritInteger( p_splitter, CFG_PREFIX "bz-middle" ); p_sys->bz_end = var_InheritInteger( p_splitter, CFG_PREFIX "bz-end" ); p_sys->bz_middle_pos = var_InheritInteger( p_splitter, CFG_PREFIX "bz-middle-pos" ); double d_p = 100.0 / p_sys->bz_middle_pos; p_sys->a_2 = d_p * p_sys->bz_begin - (double)(d_p * d_p / (d_p - 1)) * p_sys->bz_middle + (double)(d_p / (d_p - 1)) * p_sys->bz_end; p_sys->a_1 = -(d_p + 1) * p_sys->bz_begin + (double)(d_p * d_p / (d_p - 1)) * p_sys->bz_middle - (double)(1 / (d_p - 1)) * p_sys->bz_end; p_sys->a_0 = p_sys->bz_begin; /* */ p_sys->i_col = VLC_CLIP( COL_MAX, 1, p_sys->i_col ); p_sys->i_row = VLC_CLIP( ROW_MAX, 1, p_sys->i_row ); msg_Dbg( p_splitter, "opening a %i x %i wall", p_sys->i_col, p_sys->i_row ); if( p_sys->bz_length > 0 && ( p_sys->i_row > 1 || p_sys->i_col > 1 ) ) { const int i_overlap_w2_max = p_splitter->fmt.i_width / p_sys->i_col / 2; const int i_overlap_h2_max = p_splitter->fmt.i_height / p_sys->i_row / 2; const int i_overlap2_max = __MIN( i_overlap_w2_max, i_overlap_h2_max ); if( p_sys->i_col > 1 ) p_sys->i_overlap_w2 = i_overlap2_max * p_sys->bz_length / 100; else p_sys->i_overlap_w2 = 0; if( p_sys->i_row > 1 ) p_sys->i_overlap_h2 = i_overlap2_max * p_sys->bz_height / 100; else p_sys->i_overlap_h2 = 0; /* */ int i_div_max_w = 1; int i_div_max_h = 1; for( int i = 0; i < VOUT_MAX_PLANES; i++ ) { i_div_max_w = __MAX( i_div_max_w, p_chroma->pi_div_w[i] ); i_div_max_h = __MAX( i_div_max_h, p_chroma->pi_div_h[i] ); } p_sys->i_overlap_w2 = i_div_max_w * (p_sys->i_overlap_w2 / i_div_max_w); p_sys->i_overlap_h2 = i_div_max_h * (p_sys->i_overlap_h2 / i_div_max_h); } else { p_sys->i_overlap_w2 = 0; p_sys->i_overlap_h2 = 0; } /* Compute attenuate parameters */ if( p_sys->b_attenuate ) { panoramix_gamma_t p_gamma[VOUT_MAX_PLANES]; p_gamma[0].f_gamma = var_InheritFloat( p_splitter, CFG_PREFIX "bz-gamma-red" ); p_gamma[1].f_gamma = var_InheritFloat( p_splitter, CFG_PREFIX "bz-gamma-green" ); p_gamma[2].f_gamma = var_InheritFloat( p_splitter, CFG_PREFIX "bz-gamma-blue" ); p_gamma[0].f_black_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blackcrush-red" ) / 255.0; p_gamma[1].f_black_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blackcrush-green" ) / 255.0; p_gamma[2].f_black_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blackcrush-blue" ) / 255.0; p_gamma[0].f_white_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitecrush-red" ) / 255.0; p_gamma[1].f_white_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitecrush-green" ) / 255.0; p_gamma[2].f_white_crush = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitecrush-blue" ) / 255.0; p_gamma[0].f_black_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blacklevel-red" ) / 255.0; p_gamma[1].f_black_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blacklevel-green" ) / 255.0; p_gamma[2].f_black_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-blacklevel-blue" ) / 255.0; p_gamma[0].f_white_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitelevel-red" ) / 255.0; p_gamma[1].f_white_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitelevel-green" ) / 255.0; p_gamma[2].f_white_level = var_InheritInteger( p_splitter, CFG_PREFIX "bz-whitelevel-blue" ) / 255.0; for( int i = 3; i < VOUT_MAX_PLANES; i++ ) { /* Initialize unsupported planes */ p_gamma[i].f_gamma = 1.0; p_gamma[i].f_black_crush = 140.0/255.0; p_gamma[i].f_white_crush = 200.0/255.0; p_gamma[i].f_black_level = 150.0/255.0; p_gamma[i].f_white_level = 0.0/255.0; } if( p_chroma->i_chroma == VLC_CODEC_YV12 ) { /* Exchange U and V */ panoramix_gamma_t t = p_gamma[1]; p_gamma[1] = p_gamma[2]; p_gamma[2] = t; } for( int i_index = 0; i_index < 256; i_index++ ) { for( int i_index2 = 0; i_index2 <= ACCURACY; i_index2++ ) { for( int i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++ ) { double f_factor = GammaFactor( &p_gamma[i_plane], (float)i_index / 255.0 ); float f_lut = clip_unit( 1.0 - ((ACCURACY - (float)i_index2) * f_factor / (ACCURACY - 1)) ); p_sys->p_lut[i_plane][i_index2][i_index] = f_lut * i_index + (int)( (1.0 - f_lut) * (float)p_chroma->pi_black[i_plane] ); } } } for( int i_plane = 0; i_plane < VOUT_MAX_PLANES; i_plane++ ) { if( !p_chroma->pi_div_w[i_plane] || !p_chroma->pi_div_h[i_plane] ) continue; const int i_length_w = (2 * p_sys->i_overlap_w2) / p_chroma->pi_div_w[i_plane]; const int i_length_h = (2 * p_sys->i_overlap_h2) / p_chroma->pi_div_h[i_plane]; for( int i_dir = 0; i_dir < 2; i_dir++ ) { const int i_length = i_dir == 0 ? i_length_w : i_length_h; const int i_den = i_length * i_length; const int a_2 = p_sys->a_2 * (ACCURACY / 100); const int a_1 = p_sys->a_1 * i_length * (ACCURACY / 100); const int a_0 = p_sys->a_0 * i_den * (ACCURACY / 100); for( int i_position = 0; i_position < 2; i_position++ ) { for( int i_index = 0; i_index < i_length; i_index++ ) { const int v = i_position == 1 ? i_index : (i_length - i_index); const int i_lambda = clip_accuracy( ACCURACY - (a_2 * v*v + a_1 * v + a_0) / i_den ); if( i_dir == 0 ) p_sys->lambdav[i_plane][i_position][i_index] = i_lambda; else p_sys->lambdah[i_plane][i_position][i_index] = i_lambda; } } } } } /* */ char *psz_state = var_InheritString( p_splitter, CFG_PREFIX "active" ); /* */ bool pb_active[COL_MAX*ROW_MAX]; for( int i = 0; i < COL_MAX*ROW_MAX; i++ ) pb_active[i] = psz_state == NULL; /* Parse active list if provided */ char *psz_tmp = psz_state; while( psz_tmp && *psz_tmp ) { char *psz_next = strchr( psz_tmp, ',' ); if( psz_next ) *psz_next++ = '\0'; const int i_index = atoi( psz_tmp ); if( i_index >= 0 && i_index < COL_MAX*ROW_MAX ) pb_active[i_index] = true; psz_tmp = psz_next; } free( psz_state ); /* */ p_splitter->i_output = Configuration( p_sys->pp_output, p_sys->i_col, p_sys->i_row, p_splitter->fmt.i_width, p_splitter->fmt.i_height, p_sys->i_overlap_w2, p_sys->i_overlap_h2, p_sys->b_attenuate, pb_active ); p_splitter->p_output = calloc( p_splitter->i_output, sizeof(*p_splitter->p_output) ); if( !p_splitter->p_output ) { free( p_sys ); return VLC_ENOMEM; } for( int y = 0; y < p_sys->i_row; y++ ) { for( int x = 0; x < p_sys->i_col; x++ ) { panoramix_output_t *p_output = &p_sys->pp_output[x][y]; if( !p_output->b_active ) continue; video_splitter_output_t *p_cfg = &p_splitter->p_output[p_output->i_output]; /* */ video_format_Copy( &p_cfg->fmt, &p_splitter->fmt ); p_cfg->fmt.i_visible_width = p_cfg->fmt.i_width = p_output->i_width; p_cfg->fmt.i_visible_height = p_cfg->fmt.i_height = p_output->i_height; p_cfg->window.i_x = p_output->i_x; p_cfg->window.i_y = p_output->i_y; p_cfg->window.i_align = p_output->i_align; p_cfg->psz_module = NULL; } } /* */ p_splitter->pf_filter = Filter; p_splitter->pf_mouse = Mouse; return VLC_SUCCESS; }
/***************************************************************************** * Create: allocates opencv_wrapper video thread output method ***************************************************************************** * This function allocates and initializes a opencv_wrapper vout method. *****************************************************************************/ static int Create( vlc_object_t *p_this ) { filter_t* p_filter = (filter_t*)p_this; char *psz_chroma, *psz_output; /* Allocate structure */ p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_filter->p_sys == NULL ) return VLC_ENOMEM; /* Load the internal OpenCV filter. * * This filter object is needed to call the internal OpenCV filter * for processing, the wrapper just converts into an IplImage* for * the other filter. * * We don't need to set up video formats for this filter as it not * actually using a picture_t. */ p_filter->p_sys->p_opencv = vlc_object_create( p_filter, sizeof(filter_t) ); if( !p_filter->p_sys->p_opencv ) { free( p_filter->p_sys ); return VLC_ENOMEM; } p_filter->p_sys->psz_inner_name = var_InheritString( p_filter, "opencv-filter-name" ); if( p_filter->p_sys->psz_inner_name ) p_filter->p_sys->p_opencv->p_module = module_need( p_filter->p_sys->p_opencv, "opencv internal filter", p_filter->p_sys->psz_inner_name, true ); if( !p_filter->p_sys->p_opencv->p_module ) { msg_Err( p_filter, "can't open internal opencv filter: %s", p_filter->p_sys->psz_inner_name ); free( p_filter->p_sys->psz_inner_name ); p_filter->p_sys->psz_inner_name = NULL; vlc_object_release( p_filter->p_sys->p_opencv ); free( p_filter->p_sys ); return VLC_ENOMOD; } /* Init structure */ p_filter->p_sys->p_image = image_HandlerCreate( p_filter ); for( int i = 0; i < VOUT_MAX_PLANES; i++ ) p_filter->p_sys->p_cv_image[i] = NULL; p_filter->p_sys->p_proc_image = NULL; p_filter->p_sys->p_to_be_freed = NULL; p_filter->p_sys->i_cv_image_size = 0; /* Retrieve and apply config */ psz_chroma = var_InheritString( p_filter, "opencv-chroma" ); if( psz_chroma == NULL ) { msg_Err( p_filter, "configuration variable %s empty, using 'grey'", "opencv-chroma" ); p_filter->p_sys->i_internal_chroma = GREY; } else if( !strcmp( psz_chroma, "input" ) ) p_filter->p_sys->i_internal_chroma = CINPUT; else if( !strcmp( psz_chroma, "I420" ) ) p_filter->p_sys->i_internal_chroma = GREY; else if( !strcmp( psz_chroma, "RGB32" ) ) p_filter->p_sys->i_internal_chroma = RGB; else { msg_Err( p_filter, "no valid opencv-chroma provided, using 'grey'" ); p_filter->p_sys->i_internal_chroma = GREY; } free( psz_chroma ); psz_output = var_InheritString( p_filter, "opencv-output" ); if( psz_output == NULL ) { msg_Err( p_filter, "configuration variable %s empty, using 'input'", "opencv-output" ); p_filter->p_sys->i_wrapper_output = VINPUT; } else if( !strcmp( psz_output, "none" ) ) p_filter->p_sys->i_wrapper_output = NONE; else if( !strcmp( psz_output, "input" ) ) p_filter->p_sys->i_wrapper_output = VINPUT; else if( !strcmp( psz_output, "processed" ) ) p_filter->p_sys->i_wrapper_output = PROCESSED; else { msg_Err( p_filter, "no valid opencv-output provided, using 'input'" ); p_filter->p_sys->i_wrapper_output = VINPUT; } free( psz_output ); p_filter->p_sys->f_scale = var_InheritFloat( p_filter, "opencv-scale" ); msg_Info(p_filter, "Configuration: opencv-scale: %f, opencv-chroma: %d, " "opencv-output: %d, opencv-filter %s", p_filter->p_sys->f_scale, p_filter->p_sys->i_internal_chroma, p_filter->p_sys->i_wrapper_output, p_filter->p_sys->psz_inner_name); #ifndef NDEBUG msg_Dbg( p_filter, "opencv_wrapper successfully started" ); #endif p_filter->pf_video_filter = Filter; return VLC_SUCCESS; }
/***************************************************************************** * Open: initialize as "audio filter" *****************************************************************************/ static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; bool b_fit = true; if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 || p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 ) { b_fit = false; p_filter->fmt_in.audio.i_format = p_filter->fmt_out.audio.i_format = VLC_CODEC_FL32; msg_Warn( p_filter, "bad input or output format" ); } if( ! AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) ) { b_fit = false; memcpy( &p_filter->fmt_out.audio, &p_filter->fmt_in.audio, sizeof(audio_sample_format_t) ); msg_Warn( p_filter, "input and output formats are not similar" ); } if( ! b_fit ) return VLC_EGENERIC; /* Allocate structure */ p_sys = p_filter->p_sys = malloc( sizeof(*p_sys) ); if( ! p_sys ) return VLC_ENOMEM; p_filter->pf_audio_filter = DoWork; p_sys->scale = 1.0; p_sys->sample_rate = p_filter->fmt_in.audio.i_rate; p_sys->samples_per_frame = aout_FormatNbChannels( &p_filter->fmt_in.audio ); p_sys->bytes_per_sample = 4; p_sys->bytes_per_frame = p_sys->samples_per_frame * p_sys->bytes_per_sample; msg_Dbg( p_this, "format: %5i rate, %i nch, %i bps, %s", p_sys->sample_rate, p_sys->samples_per_frame, p_sys->bytes_per_sample, "fl32" ); p_sys->ms_stride = var_InheritInteger( p_this, "scaletempo-stride" ); p_sys->percent_overlap = var_InheritFloat( p_this, "scaletempo-overlap" ); p_sys->ms_search = var_InheritInteger( p_this, "scaletempo-search" ); msg_Dbg( p_this, "params: %i stride, %.3f overlap, %i search", p_sys->ms_stride, p_sys->percent_overlap, p_sys->ms_search ); p_sys->buf_queue = NULL; p_sys->buf_overlap = NULL; p_sys->table_blend = NULL; p_sys->buf_pre_corr = NULL; p_sys->table_window = NULL; p_sys->bytes_overlap = 0; p_sys->bytes_queued = 0; p_sys->bytes_to_slide = 0; p_sys->frames_stride_error = 0; if( reinit_buffers( p_filter ) != VLC_SUCCESS ) { Close( p_this ); return VLC_EGENERIC; } return VLC_SUCCESS; }
/***************************************************************************** * Open: *****************************************************************************/ static int Open( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; if (p_demux->out == NULL) return VLC_EGENERIC; p_sys = vlc_obj_calloc( p_this, 1, sizeof(demux_sys_t) ); if( !p_sys ) return VLC_ENOMEM; p_sys->f_fps = var_InheritFloat( p_demux, CFG_PREFIX "fps" ); if ( p_sys->f_fps <= 0 ) p_sys->f_fps = 1.0; p_sys->i_frame_interval = vlc_tick_rate_duration( p_sys->f_fps ); char *psz_chroma = var_InheritString( p_demux, CFG_PREFIX "chroma" ); vlc_fourcc_t i_chroma = vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_chroma ); free( psz_chroma ); if ( !i_chroma || vlc_fourcc_IsYUV( i_chroma ) ) { msg_Err( p_demux, "Only RGB chroma are supported" ); return VLC_EGENERIC; } const vlc_chroma_description_t *p_chroma_desc = vlc_fourcc_GetChromaDescription( i_chroma ); if ( !p_chroma_desc ) { msg_Err( p_demux, "Unable to get RGB chroma description" ); return VLC_EGENERIC; } #ifdef NDEBUG rfbEnableClientLogging = FALSE; #endif p_sys->p_client = rfbGetClient( p_chroma_desc->pixel_bits / 3, // bitsPerSample 3, // samplesPerPixel p_chroma_desc->pixel_size ); // bytesPerPixel if ( ! p_sys->p_client ) { msg_Dbg( p_demux, "Unable to set up client for %s", vlc_fourcc_GetDescription( VIDEO_ES, i_chroma ) ); return VLC_EGENERIC; } msg_Dbg( p_demux, "set up client for %s %d %d %d", vlc_fourcc_GetDescription( VIDEO_ES, i_chroma ), p_chroma_desc->pixel_bits / 3, 3, p_chroma_desc->pixel_size ); p_sys->p_client->MallocFrameBuffer = mallocFrameBufferHandler; p_sys->p_client->canHandleNewFBSize = TRUE; p_sys->p_client->GetCredential = getCredentialHandler; p_sys->p_client->GetPassword = getPasswordHandler; /* VNC simple auth */ /* Set compression and quality levels */ p_sys->p_client->appData.compressLevel = var_InheritInteger( p_demux, CFG_PREFIX "compress-level" ); p_sys->p_client->appData.qualityLevel = var_InheritInteger( p_demux, CFG_PREFIX "quality-level" ); /* Parse uri params */ vlc_url_t url; vlc_UrlParse( &url, p_demux->psz_location ); if ( !EMPTY_STR(url.psz_host) ) p_sys->p_client->serverHost = strdup( url.psz_host ); else p_sys->p_client->serverHost = strdup( "localhost" ); p_sys->p_client->appData.viewOnly = TRUE; p_sys->p_client->serverPort = ( url.i_port > 0 ) ? url.i_port : 5900; msg_Dbg( p_demux, "VNC init %s host=%s port=%d", p_demux->psz_location, p_sys->p_client->serverHost, p_sys->p_client->serverPort ); vlc_UrlClean( &url ); /* make demux available for callback handlers */ rfbClientSetClientData( p_sys->p_client, DemuxThread, p_demux ); p_demux->p_sys = p_sys; if( !rfbInitClient( p_sys->p_client, NULL, NULL ) ) { msg_Err( p_demux, "can't connect to RFB server" ); return VLC_EGENERIC; } p_sys->i_starttime = vlc_tick_now(); if ( vlc_clone( &p_sys->thread, DemuxThread, p_demux, VLC_THREAD_PRIORITY_INPUT ) != VLC_SUCCESS ) { msg_Err( p_demux, "can't spawn thread" ); return VLC_EGENERIC; } p_demux->pf_demux = NULL; p_demux->pf_control = Control; return VLC_SUCCESS; }
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) { /* Variables initialisation */ bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL; stackCentralOldWidget= NULL; #ifndef HAVE_MAEMO sysTray = NULL; #endif fullscreenControls = NULL; cryptedLabel = NULL; controls = NULL; inputC = NULL; b_hideAfterCreation = false; // --qt-start-minimized playlistVisible = false; input_name = ""; /* Ask for Privacy */ FirstRun::CheckAndRun( this, p_intf ); /** * Configuration and settings * Pre-building of interface **/ /* Main settings */ setFocusPolicy( Qt::StrongFocus ); setAcceptDrops( true ); setWindowRole( "vlc-main" ); setWindowIcon( QApplication::windowIcon() ); setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) ); #ifdef Q_WS_MAC setAttribute( Qt::WA_MacBrushedMetal ); #endif /* Is video in embedded in the UI or not */ b_videoEmbedded = var_InheritBool( p_intf, "embedded-video" ); /* Does the interface resize to video size or the opposite */ b_autoresize = var_InheritBool( p_intf, "qt-video-autoresize" ); /* Are we in the enhanced always-video mode or not ? */ b_minimalView = var_InheritBool( p_intf, "qt-minimal-view" ); /* Do we want anoying popups or not */ b_notificationEnabled = var_InheritBool( p_intf, "qt-notification" ); /* Set the other interface settings */ settings = getSettings(); settings->beginGroup( "MainWindow" ); /* */ b_plDocked = getSettings()->value( "pl-dock-status", true ).toBool(); settings->endGroup( ); /************** * Status Bar * **************/ createStatusBar(); /************************** * UI and Widgets design **************************/ setVLCWindowsTitle(); /************ * Menu Bar * ************/ QVLCMenu::createMenuBar( this, p_intf ); CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, destroyPopupMenu() ); createMainWidget( settings ); /********************************* * Create the Systray Management * *********************************/ initSystray(); /******************** * Input Manager * ********************/ MainInputManager::getInstance( p_intf ); #ifdef WIN32 himl = NULL; p_taskbl = NULL; taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated"); #endif /************************************************************ * Connect the input manager to the GUI elements it manages * ************************************************************/ /** * Connects on nameChanged() * Those connects are different because options can impeach them to trigger. **/ /* Main Interface statusbar */ CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, setName( const QString& ) ); /* and systray */ #ifndef HAVE_MAEMO if( sysTray ) { CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, updateSystrayTooltipName( const QString& ) ); } #endif /* and title of the Main Interface*/ if( var_InheritBool( p_intf, "qt-name-in-title" ) ) { CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, setVLCWindowsTitle( const QString& ) ); }
static int Open(vlc_object_t *object) { demux_t *demux = (demux_t*)object; /* Detect the image type */ const image_format_t *img; const uint8_t *peek; int peek_size = 0; for (int i = 0; ; i++) { img = &formats[i]; if (!img->codec) return VLC_EGENERIC; if (img->detect) { if (img->detect(demux->s)) break; } else { if (peek_size < img->marker_size) peek_size = stream_Peek(demux->s, &peek, img->marker_size); if (peek_size >= img->marker_size && !memcmp(peek, img->marker, img->marker_size)) break; } } msg_Dbg(demux, "Detected image: %s", vlc_fourcc_GetDescription(VIDEO_ES, img->codec)); if( img->codec == VLC_CODEC_MXPEG ) { return VLC_EGENERIC; //let avformat demux this file } /* Load and if selected decode */ es_format_t fmt; es_format_Init(&fmt, VIDEO_ES, img->codec); fmt.video.i_chroma = fmt.i_codec; block_t *data = Load(demux); if (data && var_InheritBool(demux, "image-decode")) { char *string = var_InheritString(demux, "image-chroma"); vlc_fourcc_t chroma = vlc_fourcc_GetCodecFromString(VIDEO_ES, string); free(string); data = Decode(demux, &fmt.video, chroma, data); fmt.i_codec = fmt.video.i_chroma; } fmt.i_id = var_InheritInteger(demux, "image-id"); fmt.i_group = var_InheritInteger(demux, "image-group"); if (var_InheritURational(demux, &fmt.video.i_frame_rate, &fmt.video.i_frame_rate_base, "image-fps") || fmt.video.i_frame_rate <= 0 || fmt.video.i_frame_rate_base <= 0) { msg_Err(demux, "Invalid frame rate, using 10/1 instead"); fmt.video.i_frame_rate = 10; fmt.video.i_frame_rate_base = 1; } /* If loadind failed, we still continue to avoid mis-detection * by other demuxers. */ if (!data) msg_Err(demux, "Failed to load the image"); /* */ demux_sys_t *sys = malloc(sizeof(*sys)); if (!sys) { if (data) block_Release(data); es_format_Clean(&fmt); return VLC_ENOMEM; } sys->data = data; sys->es = es_out_Add(demux->out, &fmt); sys->duration = CLOCK_FREQ * var_InheritFloat(demux, "image-duration"); sys->is_realtime = var_InheritBool(demux, "image-realtime"); sys->pts_origin = sys->is_realtime ? mdate() : 0; sys->pts_next = VLC_TS_INVALID; date_Init(&sys->pts, fmt.video.i_frame_rate, fmt.video.i_frame_rate_base); date_Set(&sys->pts, 0); es_format_Clean(&fmt); demux->pf_demux = Demux; demux->pf_control = Control; demux->p_sys = sys; return VLC_SUCCESS; }
int screen_InitCapture(demux_t *p_demux) { demux_sys_t *p_sys = p_demux->p_sys; screen_data_t *p_data; CGLError returnedError; p_sys->p_data = p_data = calloc(1, sizeof(screen_data_t)); if (!p_data) return VLC_ENOMEM; /* fetch the screen we should capture */ p_data->display_id = kCGDirectMainDisplay; p_data->rate = var_InheritFloat (p_demux, "screen-fps"); unsigned int displayCount = 0; returnedError = CGGetOnlineDisplayList(0, NULL, &displayCount); if (!returnedError) { CGDirectDisplayID *ids; ids = (CGDirectDisplayID *)malloc(displayCount * sizeof(CGDirectDisplayID)); returnedError = CGGetOnlineDisplayList(displayCount, ids, &displayCount); if (!returnedError) { if (p_sys->i_display_id > 0) { for (unsigned int i = 0; i < displayCount; i++) { if (p_sys->i_display_id == ids[i]) { p_data->display_id = ids[i]; break; } } } else if (p_sys->i_screen_index > 0 && p_sys->i_screen_index <= displayCount) p_data->display_id = ids[p_sys->i_screen_index - 1]; } free(ids); } /* Get the device context for the whole screen */ CGRect rect = CGDisplayBounds(p_data->display_id); p_data->screen_left = rect.origin.x; p_data->screen_top = rect.origin.y; p_data->screen_width = rect.size.width; p_data->screen_height = rect.size.height; p_data->width = p_sys->i_width; p_data->height = p_sys->i_height; if (p_data->width <= 0 || p_data->height <= 0) { p_data->width = p_data->screen_width; p_data->height = p_data->screen_height; } /* setup format */ es_format_Init(&p_sys->fmt, VIDEO_ES, VLC_CODEC_RGB32); p_sys->fmt.video.i_visible_width = p_sys->fmt.video.i_width = rect.size.width; p_sys->fmt.video.i_visible_height = p_sys->fmt.video.i_height = rect.size.height; p_sys->fmt.video.i_bits_per_pixel = 32; p_sys->fmt.video.i_chroma = VLC_CODEC_RGB32; p_sys->fmt.video.i_rmask = 0x00ff0000; p_sys->fmt.video.i_gmask = 0x0000ff00; p_sys->fmt.video.i_bmask = 0x000000ff; p_sys->fmt.video.i_frame_rate = 1000 * p_data->rate; p_sys->fmt.video.i_frame_rate_base = 1000; p_sys->fmt.video.i_sar_num = p_sys->fmt.video.i_sar_den = 1; return VLC_SUCCESS; }
/***************************************************************************** * Open: check file and initializes structures *****************************************************************************/ static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; int i_size; bool b_matched = false; if( IsMxpeg( p_demux->s ) && !p_demux->b_force ) // let avformat handle this case return VLC_EGENERIC; demux_sys_t *p_sys = (demux_sys_t *)malloc( sizeof( demux_sys_t ) ); // sunqueen modify if( unlikely(p_sys == NULL) ) return VLC_ENOMEM; p_demux->pf_control = Control; p_demux->p_sys = p_sys; p_sys->p_es = NULL; p_sys->i_time = VLC_TS_0; p_sys->i_level = 0; p_sys->psz_separator = NULL; p_sys->i_frame_size_estimate = 15 * 1024; char *content_type = stream_ContentType( p_demux->s ); if ( content_type ) { //FIXME: this is not fully match to RFC char* boundary = strstr( content_type, "boundary=" ); if( boundary ) { boundary += strlen( "boundary=" ); size_t len = strlen( boundary ); if( len > 2 && boundary[0] == '"' && boundary[len-1] == '"' ) { boundary[len-1] = '\0'; boundary++; } p_sys->psz_separator = strdup( boundary ); if( !p_sys->psz_separator ) { free( content_type ); goto error; } } free( content_type ); } b_matched = CheckMimeHeader( p_demux, &i_size); if( b_matched ) { p_demux->pf_demux = MimeDemux; stream_Read( p_demux->s, NULL, i_size ); } else if( i_size == 0 ) { /* 0xffd8 identify a JPEG SOI */ if( p_sys->p_peek[0] == 0xFF && p_sys->p_peek[1] == 0xD8 ) { msg_Dbg( p_demux, "JPEG SOI marker detected" ); p_demux->pf_demux = MjpgDemux; p_sys->i_level++; } else { goto error; } } else { goto error; } /* Frame rate */ float f_fps = var_InheritFloat( p_demux, "mjpeg-fps" ); p_sys->i_still_end = 0; if( demux_IsPathExtension( p_demux, ".jpeg" ) || demux_IsPathExtension( p_demux, ".jpg" ) ) { /* Plain JPEG file = single still picture */ p_sys->b_still = true; if( f_fps == 0.f ) /* Defaults to 1fps */ f_fps = 1.f; } else p_sys->b_still = false; p_sys->i_frame_length = f_fps ? (CLOCK_FREQ / f_fps) : 0; es_format_Init( &p_sys->fmt, VIDEO_ES, 0 ); p_sys->fmt.i_codec = VLC_CODEC_MJPG; p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt ); return VLC_SUCCESS; error: free( p_sys->psz_separator ); free( p_sys ); return VLC_EGENERIC; }