/***************************************************************************** * aout_OutputNew : allocate a new output and rework the filter pipeline ***************************************************************************** * This function is entered with the mixer lock. *****************************************************************************/ int aout_OutputNew( aout_instance_t * p_aout, audio_sample_format_t * p_format ) { /* Retrieve user defaults. */ int i_rate = var_InheritInteger( p_aout, "aout-rate" ); vlc_value_t val, text; /* kludge to avoid a fpu error when rate is 0... */ if( i_rate == 0 ) i_rate = -1; memcpy( &p_aout->output.output, p_format, sizeof(audio_sample_format_t) ); if ( i_rate != -1 ) p_aout->output.output.i_rate = i_rate; aout_FormatPrepare( &p_aout->output.output ); /* Find the best output plug-in. */ p_aout->output.p_module = module_need( p_aout, "audio output", "$aout", false ); if ( p_aout->output.p_module == NULL ) { msg_Err( p_aout, "no suitable audio output module" ); return -1; } if ( var_Type( p_aout, "audio-channels" ) == (VLC_VAR_INTEGER | VLC_VAR_HASCHOICE) ) { /* The user may have selected a different channels configuration. */ var_Get( p_aout, "audio-channels", &val ); if ( val.i_int == AOUT_VAR_CHAN_RSTEREO ) { p_aout->output.output.i_original_channels |= AOUT_CHAN_REVERSESTEREO; } else if ( val.i_int == AOUT_VAR_CHAN_STEREO ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_CHAN_LEFT ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; } else if ( val.i_int == AOUT_VAR_CHAN_RIGHT ) { p_aout->output.output.i_original_channels = AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_CHAN_DOLBYS ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_DOLBYSTEREO; } } else if ( p_aout->output.output.i_physical_channels == AOUT_CHAN_CENTER && (p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) ) { /* Mono - create the audio-channels variable. */ var_Create( p_aout, "audio-channels", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Channels"); var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); val.i_int = AOUT_VAR_CHAN_STEREO; text.psz_string = _("Stereo"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) { /* Go directly to the left channel. */ p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT ); } var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, NULL ); } else if ( p_aout->output.output.i_physical_channels == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) && (p_aout->output.output.i_original_channels & (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) ) { /* Stereo - create the audio-channels variable. */ var_Create( p_aout, "audio-channels", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Channels"); var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DOLBYSTEREO ) { val.i_int = AOUT_VAR_CHAN_DOLBYS; text.psz_string = _("Dolby Surround"); } else { val.i_int = AOUT_VAR_CHAN_STEREO; text.psz_string = _("Stereo"); } var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_RSTEREO; text.psz_string=_("Reverse stereo"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) { /* Go directly to the left channel. */ p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT ); } var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, NULL ); } var_SetBool( p_aout, "intf-change", true ); aout_FormatPrepare( &p_aout->output.output ); aout_lock_output_fifo( p_aout ); /* Prepare FIFO. */ aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate ); aout_unlock_output_fifo( p_aout ); aout_FormatPrint( p_aout, "output", &p_aout->output.output ); /* Calculate the resulting mixer output format. */ p_aout->mixer_format = p_aout->output.output; if ( !AOUT_FMT_NON_LINEAR(&p_aout->output.output) ) { /* Non-S/PDIF mixer only deals with float32 or fixed32. */ p_aout->mixer_format.i_format = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_FI32; aout_FormatPrepare( &p_aout->mixer_format ); } else { p_aout->mixer_format.i_format = p_format->i_format; } aout_FormatPrint( p_aout, "mixer", &p_aout->mixer_format ); /* Create filters. */ p_aout->output.i_nb_filters = 0; if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters, &p_aout->output.i_nb_filters, &p_aout->mixer_format, &p_aout->output.output ) < 0 ) { msg_Err( p_aout, "couldn't create audio output pipeline" ); module_unneed( p_aout, p_aout->output.p_module ); return -1; } /* Prepare hints for the buffer allocator. */ p_aout->mixer_allocation.b_alloc = true; p_aout->mixer_allocation.i_bytes_per_sec = p_aout->mixer_format.i_bytes_per_frame * p_aout->mixer_format.i_rate / p_aout->mixer_format.i_frame_length; aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters, p_aout->output.i_nb_filters, &p_aout->mixer_allocation ); p_aout->output.b_error = 0; return 0; }
/***************************************************************************** * InitWindowSize: find the initial dimensions the video window should have. ***************************************************************************** * This function will check the "width", "height" and "zoom" config options and * will calculate the size that the video window should have. *****************************************************************************/ static void InitWindowSize( vout_thread_t *p_vout, unsigned *pi_width, unsigned *pi_height ) { vlc_value_t val; int i_width, i_height; uint64_t ll_zoom; #define FP_FACTOR 1000 /* our fixed point factor */ var_Get( p_vout, "width", &val ); i_width = val.i_int; var_Get( p_vout, "height", &val ); i_height = val.i_int; var_Get( p_vout, "zoom", &val ); ll_zoom = (uint64_t)( FP_FACTOR * val.f_float ); if( i_width > 0 && i_height > 0) { *pi_width = (int)( i_width * ll_zoom / FP_FACTOR ); *pi_height = (int)( i_height * ll_zoom / FP_FACTOR ); goto initwsize_end; } else if( i_width > 0 ) { *pi_width = (int)( i_width * ll_zoom / FP_FACTOR ); *pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom * p_vout->fmt_in.i_sar_den * i_width / p_vout->fmt_in.i_sar_num / FP_FACTOR / p_vout->fmt_in.i_visible_width ); goto initwsize_end; } else if( i_height > 0 ) { *pi_height = (int)( i_height * ll_zoom / FP_FACTOR ); *pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom * p_vout->fmt_in.i_sar_num * i_height / p_vout->fmt_in.i_sar_den / FP_FACTOR / p_vout->fmt_in.i_visible_height ); goto initwsize_end; } if( p_vout->fmt_in.i_sar_num == 0 || p_vout->fmt_in.i_sar_den == 0 ) { msg_Warn( p_vout, "f****d up aspect" ); *pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom / FP_FACTOR ); *pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom /FP_FACTOR); } else if( p_vout->fmt_in.i_sar_num >= p_vout->fmt_in.i_sar_den ) { *pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom * p_vout->fmt_in.i_sar_num / p_vout->fmt_in.i_sar_den / FP_FACTOR ); *pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom / FP_FACTOR ); } else { *pi_width = (int)( p_vout->fmt_in.i_visible_width * ll_zoom / FP_FACTOR ); *pi_height = (int)( p_vout->fmt_in.i_visible_height * ll_zoom * p_vout->fmt_in.i_sar_den / p_vout->fmt_in.i_sar_num / FP_FACTOR ); } initwsize_end: msg_Dbg( p_vout, "window size: %dx%d", p_vout->i_window_width, p_vout->i_window_height ); #undef FP_FACTOR }
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 = (float *)malloc( p_sys->i_band * sizeof(float) ); // sunqueen modify p_sys->f_beta = (float *)malloc( p_sys->i_band * sizeof(float) ); // sunqueen modify p_sys->f_gamma = (float *)malloc( p_sys->i_band * sizeof(float) ); // sunqueen modify 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 = (float *)malloc( p_sys->i_band * sizeof(float) ); // sunqueen modify 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; }
/***************************************************************************** * InterfaceWindow::UpdateInterface *****************************************************************************/ void InterfaceWindow::UpdateInterface() { if( !p_input ) { p_input = (input_thread_t *) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); } else if( p_input->b_dead ) { vlc_object_release( p_input ); p_input = NULL; } /* Get ready to update the interface */ if( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) != B_OK ) { return; } if( b_playlist_update ) { #if 0 if( fPlaylistWindow->Lock() ) { fPlaylistWindow->UpdatePlaylist( true ); fPlaylistWindow->Unlock(); b_playlist_update = false; } #endif p_mediaControl->SetEnabled( !playlist_IsEmpty( p_playlist ) ); } if( p_input ) { vlc_value_t val; p_mediaControl->SetEnabled( true ); bool hasTitles = !var_Get( p_input, "title", &val ); bool hasChapters = !var_Get( p_input, "chapter", &val ); p_mediaControl->SetStatus( var_GetInteger( p_input, "state" ), var_GetInteger( p_input, "rate" ) ); var_Get( p_input, "position", &val ); p_mediaControl->SetProgress( val.f_float ); _SetMenusEnabled( true, hasChapters, hasTitles ); _UpdateSpeedMenu( var_GetInteger( p_input, "rate" ) ); // enable/disable skip buttons #if 0 bool canSkipPrev; bool canSkipNext; p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext ); p_mediaControl->SetSkippable( canSkipPrev, canSkipNext ); #endif audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); p_mediaControl->SetAudioEnabled( true ); p_mediaControl->SetMuted( i_volume ); } else { p_mediaControl->SetAudioEnabled( false ); _SetMenusEnabled( false ); if( !playlist_IsEmpty( p_playlist ) ) { p_mediaControl->SetProgress( 0 ); #if 0 // enable/disable skip buttons bool canSkipPrev; bool canSkipNext; p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext ); p_mediaControl->SetSkippable( canSkipPrev, canSkipNext ); #endif } else { p_mediaControl->SetEnabled( false ); } } Unlock(); fLastUpdateTime = system_time(); }
/***************************************************************************** * OpenEncoder: probe the encoder and return score *****************************************************************************/ static int OpenEncoder( vlc_object_t *p_this ) { encoder_t *p_enc = (encoder_t *)p_this; encoder_sys_t *p_sys; vlc_value_t val; if( p_enc->fmt_out.i_codec != VLC_FOURCC('m','p','g','a') && p_enc->fmt_out.i_codec != VLC_FOURCC('m','p','2','a') && p_enc->fmt_out.i_codec != VLC_FOURCC('m','p','2',' ') && !p_enc->b_force ) { return VLC_EGENERIC; } if( p_enc->fmt_in.audio.i_channels > 2 ) { msg_Err( p_enc, "doesn't support > 2 channels" ); return VLC_EGENERIC; } /* Allocate the memory needed to store the decoder's structure */ if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL ) { msg_Err( p_enc, "out of memory" ); return VLC_EGENERIC; } p_enc->p_sys = p_sys; p_enc->pf_encode_audio = Encode; p_enc->fmt_in.i_codec = AOUT_FMT_S16_NE; p_enc->fmt_out.i_codec = VLC_FOURCC('m','p','g','a'); sout_CfgParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg ); p_sys->p_toolame = toolame_init(); /* Set options */ toolame_setSampleFreq( p_sys->p_toolame, p_enc->fmt_out.audio.i_rate ); var_Get( p_enc, ENC_CFG_PREFIX "vbr", &val ); if ( val.b_bool ) { FLOAT i_quality; var_Get( p_enc, ENC_CFG_PREFIX "quality", &val ); i_quality = val.i_int; if ( i_quality > 50.0 ) i_quality = 50.0; if ( i_quality < 0.0 ) i_quality = 0.0; toolame_setVBR( p_sys->p_toolame, 1 ); toolame_setVBRLevel( p_sys->p_toolame, i_quality ); } else { toolame_setBitrate( p_sys->p_toolame, p_enc->fmt_out.i_bitrate / 1000 ); } if ( p_enc->fmt_in.audio.i_channels == 1 ) { toolame_setMode( p_sys->p_toolame, MPG_MD_MONO ); } else { var_Get( p_enc, ENC_CFG_PREFIX "mode", &val ); switch ( val.i_int ) { case 1: toolame_setMode( p_sys->p_toolame, MPG_MD_DUAL_CHANNEL ); break; case 2: toolame_setMode( p_sys->p_toolame, MPG_MD_JOINT_STEREO ); break; case 0: default: toolame_setMode( p_sys->p_toolame, MPG_MD_STEREO ); break; } } if ( toolame_init_params( p_sys->p_toolame ) ) { msg_Err( p_enc, "toolame initialization failed" ); return -VLC_EGENERIC; } p_sys->i_nb_samples = 0; aout_DateInit( &p_sys->pts, p_enc->fmt_out.audio.i_rate ); return VLC_SUCCESS; }
/***************************************************************************** * DecodeAudio: *****************************************************************************/ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; vlc_value_t lockval; block_t *p_block; int i_error; #ifdef LOADER /* We must do open and close in the same thread (unless we do * Setup_LDT_Keeper in the main thread before all others */ if( p_sys == NULL ) { if( OpenAudio( p_dec ) ) { /* Fatal */ p_dec->b_error = VLC_TRUE; return NULL; } p_sys = p_dec->p_sys; } #endif if( pp_block == NULL || *pp_block == NULL ) { return NULL; } p_block = *pp_block; if( p_sys->i_out_frames > 0 && p_sys->i_out >= p_sys->i_out_frames ) { /* Ask new data */ p_sys->i_out = 0; p_sys->i_out_frames = 0; *pp_block = NULL; return NULL; } if( p_sys->i_out_frames <= 0 ) { if( ( p_sys->pts = p_block->i_pts ) < mdate() ) { block_Release( p_block ); *pp_block = NULL; return NULL; } /* Append data */ if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer ) { p_sys->i_buffer_size = p_sys->i_buffer + p_block->i_buffer + 1024; p_sys->p_buffer = realloc( p_sys->p_buffer, p_sys->i_buffer_size ); } memcpy( &p_sys->p_buffer[p_sys->i_buffer], p_block->p_buffer, p_block->i_buffer ); p_sys->i_buffer += p_block->i_buffer; if( p_sys->i_buffer > p_sys->InFrameSize ) { int i_frames = p_sys->i_buffer / p_sys->InFrameSize; unsigned long i_out_frames, i_out_bytes; var_Get( p_dec->p_libvlc, "qt_mutex", &lockval ); vlc_mutex_lock( lockval.p_address ); i_error = p_sys->SoundConverterConvertBuffer( p_sys->myConverter, p_sys->p_buffer, i_frames, p_sys->out_buffer, &i_out_frames, &i_out_bytes ); vlc_mutex_unlock( lockval.p_address ); /* msg_Dbg( p_dec, "decoded %d frames -> %ld frames (error=%d)", i_frames, i_out_frames, i_error ); msg_Dbg( p_dec, "decoded %ld frames = %ld bytes", i_out_frames, i_out_bytes ); */ p_sys->i_buffer -= i_frames * p_sys->InFrameSize; if( p_sys->i_buffer > 0 ) { memmove( &p_sys->p_buffer[0], &p_sys->p_buffer[i_frames * p_sys->InFrameSize], p_sys->i_buffer ); } if( p_sys->pts != 0 && p_sys->pts != aout_DateGet( &p_sys->date ) ) { aout_DateSet( &p_sys->date, p_sys->pts ); } else if( !aout_DateGet( &p_sys->date ) ) { return NULL; } if( !i_error && i_out_frames > 0 ) { /* we have others samples */ p_sys->i_out_frames = i_out_frames; p_sys->i_out = 0; } } } if( p_sys->i_out < p_sys->i_out_frames ) { aout_buffer_t *p_out; int i_frames = __MIN( p_sys->i_out_frames - p_sys->i_out, 1000 ); p_out = p_dec->pf_aout_buffer_new( p_dec, i_frames ); if( p_out ) { p_out->start_date = aout_DateGet( &p_sys->date ); p_out->end_date = aout_DateIncrement( &p_sys->date, i_frames ); memcpy( p_out->p_buffer, &p_sys->out_buffer[2 * p_sys->i_out * p_dec->fmt_out.audio.i_channels], p_out->i_nb_bytes ); p_sys->i_out += i_frames; } return p_out; } return NULL; }
/***************************************************************************** * DecodeVideo: *****************************************************************************/ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; vlc_value_t lockval; block_t *p_block; picture_t *p_pic; mtime_t i_pts; ComponentResult cres; #ifdef LOADER /* We must do open and close in the same thread (unless we do * Setup_LDT_Keeper in the main thread before all others */ if( p_sys == NULL ) { if( OpenVideo( p_dec ) ) { /* Fatal */ p_dec->b_error = VLC_TRUE; return NULL; } p_sys = p_dec->p_sys; } #endif if( pp_block == NULL || *pp_block == NULL ) { return NULL; } p_block = *pp_block; *pp_block = NULL; i_pts = p_block->i_pts ? p_block->i_pts : p_block->i_dts; if( i_pts < mdate() ) { p_sys->i_late++; } else { p_sys->i_late = 0; } msg_Dbg( p_dec, "bufsize: %d", p_block->i_buffer); if( p_sys->i_late > 10 ) { msg_Dbg( p_dec, "too late buffer -> dropped" ); block_Release( p_block ); return NULL; } var_Get( p_dec->p_libvlc, "qt_mutex", &lockval ); vlc_mutex_lock( lockval.p_address ); if( ( p_pic = p_dec->pf_vout_buffer_new( p_dec ) ) ) { p_sys->decpar.data = (Ptr)p_block->p_buffer; p_sys->decpar.bufferSize = p_block->i_buffer; (**p_sys->framedescHandle).dataSize = p_block->i_buffer; cres = p_sys->ImageCodecBandDecompress( p_sys->ci, &p_sys->decpar ); ++p_sys->decpar.frameNumber; if( cres &0xFFFF ) { msg_Dbg( p_dec, "quicktime_video: ImageCodecBandDecompress" " cres=0x%X (-0x%X) %d :(\n", (int)cres,(int)-cres, (int)cres ); } memcpy( p_pic->p[0].p_pixels, p_sys->plane, p_dec->fmt_in.video.i_width * p_dec->fmt_in.video.i_height * 2 ); p_pic->date = i_pts; } vlc_mutex_unlock( lockval.p_address ); block_Release( p_block ); return p_pic; }
mvar_t *mvar_InputVarSetNew( intf_thread_t *p_intf, char *name, input_thread_t *p_input, const char *psz_variable ) { intf_sys_t *p_sys = p_intf->p_sys; mvar_t *s = mvar_New( name, "set" ); vlc_value_t val, val_list, text_list; int i_type, i; if( p_input == NULL ) { return s; } /* Check the type of the object variable */ i_type = var_Type( p_sys->p_input, psz_variable ); /* Make sure we want to display the variable */ if( i_type & VLC_VAR_HASCHOICE ) { var_Change( p_sys->p_input, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL ); if( val.i_int == 0 ) return s; if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 ) return s; } else { return s; } switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_VOID: case VLC_VAR_BOOL: case VLC_VAR_VARIABLE: case VLC_VAR_STRING: case VLC_VAR_INTEGER: break; default: /* Variable doesn't exist or isn't handled */ return s; } if( var_Get( p_sys->p_input, psz_variable, &val ) < 0 ) { return s; } if( var_Change( p_sys->p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list ) < 0 ) { if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); return s; } for( i = 0; i < val_list.p_list->i_count; i++ ) { char psz_int[16]; mvar_t *itm; switch( i_type & VLC_VAR_TYPE ) { case VLC_VAR_STRING: itm = mvar_New( name, "set" ); mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string ); mvar_AppendNewVar( itm, "id", val_list.p_list->p_values[i].psz_string ); snprintf( psz_int, sizeof(psz_int), "%d", ( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) ) ); mvar_AppendNewVar( itm, "selected", psz_int ); mvar_AppendVar( s, itm ); break; case VLC_VAR_INTEGER: itm = mvar_New( name, "set" ); mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string ); snprintf( psz_int, sizeof(psz_int), "%d", val_list.p_list->p_values[i].i_int ); mvar_AppendNewVar( itm, "id", psz_int ); snprintf( psz_int, sizeof(psz_int), "%d", ( val.i_int == val_list.p_list->p_values[i].i_int ) && !( i_type & VLC_VAR_ISCOMMAND ) ); mvar_AppendNewVar( itm, "selected", psz_int ); mvar_AppendVar( s, itm ); break; default: break; } } /* clean up everything */ if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); var_FreeList( &val_list, &text_list ); return s; }
/***************************************************************************** * 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; char *psz_files, *psz_sizes; int i_height = 0, i_width = 0; p_sys = calloc( 1, sizeof(sout_stream_sys_t) ); if( !p_sys ) return VLC_ENOMEM; p_sys->p_out = sout_StreamNew( p_stream->p_sout, p_stream->psz_next ); if( !p_sys->p_out ) { msg_Err( p_stream, "cannot create chain" ); free( p_sys ); return VLC_EGENERIC; } config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); var_Get( p_stream, SOUT_CFG_PREFIX "files", &val ); psz_files = val.psz_string; var_Get( p_stream, SOUT_CFG_PREFIX "sizes", &val ); psz_sizes = val.psz_string; p_sys->i_nb_pictures = 0; while ( psz_files && *psz_files ) { char * psz_file = psz_files; char * psz_size = psz_sizes; while ( *psz_files && *psz_files != ':' ) psz_files++; if ( *psz_files == ':' ) *psz_files++ = '\0'; if ( *psz_sizes ) { while ( *psz_sizes && *psz_sizes != ':' ) psz_sizes++; if ( *psz_sizes == ':' ) *psz_sizes++ = '\0'; if ( sscanf( psz_size, "%dx%d", &i_width, &i_height ) != 2 ) { msg_Err( p_stream, "bad size %s for file %s", psz_size, psz_file ); free( p_sys ); return VLC_EGENERIC; } } if ( UnpackFromFile( p_stream, psz_file, i_width, i_height, &p_sys->p_pictures[p_sys->i_nb_pictures] ) < 0 ) { free( p_sys ); return VLC_EGENERIC; } p_sys->i_nb_pictures++; } var_Get( p_stream, SOUT_CFG_PREFIX "aspect-ratio", &val ); if ( val.psz_string ) { char *psz_parser = strchr( val.psz_string, ':' ); if( psz_parser ) { *psz_parser++ = '\0'; p_sys->i_aspect = atoi( val.psz_string ) * VOUT_ASPECT_FACTOR / atoi( psz_parser ); } else { msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string ); p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3; } free( val.psz_string ); } else { p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3; } var_Get( p_stream, SOUT_CFG_PREFIX "port", &val ); p_sys->i_fd = net_ListenUDP1( VLC_OBJECT(p_stream), NULL, val.i_int ); if ( p_sys->i_fd < 0 ) { free( p_sys ); return VLC_EGENERIC; } var_Get( p_stream, SOUT_CFG_PREFIX "command", &val ); p_sys->i_cmd = val.i_int; p_sys->i_old_cmd = 0; var_Get( p_stream, SOUT_CFG_PREFIX "gop", &val ); p_sys->i_gop = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "qscale", &val ); p_sys->i_qscale = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "mute-audio", &val ); p_sys->b_audio = val.b_bool; p_stream->pf_add = Add; p_stream->pf_del = Del; p_stream->pf_send = Send; p_stream->p_sys = p_sys; avcodec_init(); avcodec_register_all(); return VLC_SUCCESS; }
/***************************************************************************** * Run: main loop *****************************************************************************/ static void Run( intf_thread_t *p_intf ) { char *code, *c; playlist_t *p_playlist; input_thread_t *p_input; vout_thread_t *p_vout = NULL; while( !p_intf->b_die ) { /* Sleep a bit */ msleep( INTF_IDLE_SLEEP ); /* Update the input */ if( p_intf->p_sys->p_input == NULL ) { p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE ); } else if( p_intf->p_sys->p_input->b_dead ) { vlc_object_release( p_intf->p_sys->p_input ); p_intf->p_sys->p_input = NULL; } p_input = p_intf->p_sys->p_input; /* Update the vout */ if( p_vout == NULL ) { p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); p_intf->p_sys->p_vout = p_vout; } else if( p_vout->b_die ) { vlc_object_release( p_vout ); p_vout = NULL; p_intf->p_sys->p_vout = NULL; } /* We poll the lircsocket */ if( lirc_nextcode(&code) != 0 ) { break; } if( code == NULL ) { continue; } while( !p_intf->b_die && lirc_code2char( p_intf->p_sys->config, code, &c ) == 0 && c != NULL ) { if( !strcmp( c, "QUIT" ) ) { p_intf->p_vlc->b_die = VLC_TRUE; vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Quit" ) ); continue; } else if( !strcmp( c, "VOL_UP" ) ) { audio_volume_t i_newvol; aout_VolumeUp( p_intf, 1, &i_newvol ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"), i_newvol * 100 / AOUT_VOLUME_MAX ); } else if( !strcmp( c, "VOL_DOWN" ) ) { audio_volume_t i_newvol; aout_VolumeDown( p_intf, 1, &i_newvol ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"), i_newvol * 100 / AOUT_VOLUME_MAX ); } else if( !strcmp( c, "MUTE" ) ) { audio_volume_t i_newvol = -1; aout_VolumeMute( p_intf, &i_newvol ); if( i_newvol == 0 ) { vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Mute" ) ); } else { vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %d%%"), i_newvol * 100 / AOUT_VOLUME_MAX ); } } if( p_vout ) { if( !strcmp( c, "FULLSCREEN" ) ) { p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; continue; } if( !strcmp( c, "ACTIVATE" ) ) { vlc_value_t val; val.psz_string = "ENTER"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "LEFT" ) ) { vlc_value_t val; val.psz_string = "LEFT"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "RIGHT" ) ) { vlc_value_t val; val.psz_string = "RIGHT"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "UP" ) ) { vlc_value_t val; val.psz_string = "UP"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } if( !strcmp( c, "DOWN" ) ) { vlc_value_t val; val.psz_string = "DOWN"; if (var_Set( p_vout, "key-pressed", val ) != VLC_SUCCESS) { msg_Warn( p_intf, "key-press failed" ); } continue; } } if( !strcmp( c, "PLAY" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } continue; } if( !strcmp( c, "PLAYPAUSE" ) ) { vlc_value_t val; val.i_int = PLAYING_S; if( p_input ) { var_Get( p_input, "state", &val ); } if( p_input && val.i_int != PAUSE_S ) { vout_OSDMessage( VLC_OBJECT(p_intf), DEFAULT_CHAN, _( "Pause" ) ); val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { vlc_mutex_lock( &p_playlist->object_lock ); if( p_playlist->i_size ) { vlc_mutex_unlock( &p_playlist->object_lock ); vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Play" ) ); playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } } } continue; } else if( p_input ) { if( !strcmp( c, "AUDIO_TRACK" ) ) { vlc_value_t val, list, list2; int i_count, i; var_Get( p_input, "audio-es", &val ); var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, &list, &list2 ); i_count = list.p_list->i_count; for( i = 0; i < i_count; i++ ) { if( val.i_int == list.p_list->p_values[i].i_int ) { break; } } /* value of audio-es was not in choices list */ if( i == i_count ) { msg_Warn( p_input, "invalid current audio track, selecting 0" ); var_Set( p_input, "audio-es", list.p_list->p_values[0] ); i = 0; } else if( i == i_count - 1 ) { var_Set( p_input, "audio-es", list.p_list->p_values[0] ); i = 0; } else { var_Set( p_input, "audio-es", list.p_list->p_values[i+1] ); i++; } vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Audio track: %s"), list2.p_list->p_values[i].psz_string ); } else if( !strcmp( c, "SUBTITLE_TRACK" ) ) { vlc_value_t val, list, list2; int i_count, i; var_Get( p_input, "spu-es", &val ); var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, &list, &list2 ); i_count = list.p_list->i_count; for( i = 0; i < i_count; i++ ) { if( val.i_int == list.p_list->p_values[i].i_int ) { break; } } /* value of audio-es was not in choices list */ if( i == i_count ) { msg_Warn( p_input, "invalid current subtitle track, selecting 0" ); var_Set( p_input, "spu-es", list.p_list->p_values[0] ); i = 0; } else if( i == i_count - 1 ) { var_Set( p_input, "spu-es", list.p_list->p_values[0] ); i = 0; } else { var_Set( p_input, "spu-es", list.p_list->p_values[i+1] ); i = i + 1; } vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Subtitle track: %s"), list2.p_list->p_values[i].psz_string ); } else if( !strcmp( c, "PAUSE" ) ) { vlc_value_t val; vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Pause" ) ); val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else if( !strcmp( c, "NEXT" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Next( p_playlist ); vlc_object_release( p_playlist ); } } else if( !strcmp( c, "PREV" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Prev( p_playlist ); vlc_object_release( p_playlist ); } } else if( !strcmp( c, "STOP" ) ) { p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); } } else if( !strcmp( c, "FAST" ) ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-faster", val ); } else if( !strcmp( c, "SLOW" ) ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_input, "rate-slower", val ); } /* beginning of modifications by stephane Thu Jun 19 15:29:49 CEST 2003 */ else if ( !strcmp(c, "CHAPTER_N" ) || !strcmp( c, "CHAPTER_P" ) ) { unsigned int i_chapter = 0; if( !strcmp( c, "CHAPTER_N" ) ) { var_SetVoid( p_input, "next-chapter" ); } else if( !strcmp( c, "CHAPTER_P" ) ) { var_SetVoid( p_input, "prev-chapter" ); } } /* end of modification by stephane Thu Jun 19 15:29:49 CEST 2003 */ } } free( code ); } }
/***************************************************************************** * 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; p_sys = vlc_object_create( p_this, sizeof( sout_stream_sys_t ) ); if( !p_stream->p_next ) { msg_Err( p_stream, "cannot create chain" ); vlc_object_release( p_sys ); return VLC_EGENERIC; } p_sys->i_master_drift = 0; config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg ); /* Audio transcoding parameters */ var_Get( p_stream, SOUT_CFG_PREFIX "aenc", &val ); p_sys->psz_aenc = NULL; p_sys->p_audio_cfg = NULL; if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = config_ChainCreate( &p_sys->psz_aenc, &p_sys->p_audio_cfg, val.psz_string ); free( psz_next ); } free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "acodec", &val ); p_sys->i_acodec = 0; if( val.psz_string && *val.psz_string ) { char fcc[4] = " "; memcpy( fcc, val.psz_string, __MIN( strlen( val.psz_string ), 4 ) ); p_sys->i_acodec = VLC_FOURCC( fcc[0], fcc[1], fcc[2], fcc[3] ); } free( val.psz_string ); p_sys->psz_alang = var_GetNonEmptyString( p_stream, SOUT_CFG_PREFIX "alang" ); var_Get( p_stream, SOUT_CFG_PREFIX "ab", &val ); p_sys->i_abitrate = val.i_int; if( p_sys->i_abitrate < 4000 ) p_sys->i_abitrate *= 1000; var_Get( p_stream, SOUT_CFG_PREFIX "samplerate", &val ); p_sys->i_sample_rate = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "channels", &val ); p_sys->i_channels = val.i_int; if( p_sys->i_acodec ) { if( ( p_sys->i_acodec == VLC_CODEC_MP3 || p_sys->i_acodec == VLC_CODEC_MPGA ) && p_sys->i_channels > 2 ) { msg_Warn( p_stream, "%d channels invalid for mp3, forcing to 2", p_sys->i_channels ); p_sys->i_channels = 2; } msg_Dbg( p_stream, "codec audio=%4.4s %dHz %d channels %dKb/s", (char *)&p_sys->i_acodec, p_sys->i_sample_rate, p_sys->i_channels, p_sys->i_abitrate / 1000 ); } var_Get( p_stream, SOUT_CFG_PREFIX "afilter", &val ); if( val.psz_string && *val.psz_string ) p_sys->psz_af = val.psz_string; else { free( val.psz_string ); p_sys->psz_af = NULL; } /* Video transcoding parameters */ var_Get( p_stream, SOUT_CFG_PREFIX "venc", &val ); p_sys->psz_venc = NULL; p_sys->p_video_cfg = NULL; if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = config_ChainCreate( &p_sys->psz_venc, &p_sys->p_video_cfg, val.psz_string ); free( psz_next ); } free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "vcodec", &val ); p_sys->i_vcodec = 0; if( val.psz_string && *val.psz_string ) { char fcc[4] = " "; memcpy( fcc, val.psz_string, __MIN( strlen( val.psz_string ), 4 ) ); p_sys->i_vcodec = VLC_FOURCC( fcc[0], fcc[1], fcc[2], fcc[3] ); } free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "vb", &val ); p_sys->i_vbitrate = val.i_int; if( p_sys->i_vbitrate < 16000 ) p_sys->i_vbitrate *= 1000; var_Get( p_stream, SOUT_CFG_PREFIX "scale", &val ); p_sys->f_scale = val.f_float; var_Get( p_stream, SOUT_CFG_PREFIX "fps", &val ); p_sys->f_fps = val.f_float; var_Get( p_stream, SOUT_CFG_PREFIX "hurry-up", &val ); p_sys->b_hurry_up = val.b_bool; var_Get( p_stream, SOUT_CFG_PREFIX "width", &val ); p_sys->i_width = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "height", &val ); p_sys->i_height = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "maxwidth", &val ); p_sys->i_maxwidth = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "maxheight", &val ); p_sys->i_maxheight = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "vfilter", &val ); if( val.psz_string && *val.psz_string ) p_sys->psz_vf2 = val.psz_string; else { free( val.psz_string ); p_sys->psz_vf2 = NULL; } var_Get( p_stream, SOUT_CFG_PREFIX "deinterlace", &val ); p_sys->b_deinterlace = val.b_bool; var_Get( p_stream, SOUT_CFG_PREFIX "deinterlace-module", &val ); p_sys->psz_deinterlace = NULL; p_sys->p_deinterlace_cfg = NULL; if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = config_ChainCreate( &p_sys->psz_deinterlace, &p_sys->p_deinterlace_cfg, val.psz_string ); free( psz_next ); } free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "threads", &val ); p_sys->i_threads = val.i_int; var_Get( p_stream, SOUT_CFG_PREFIX "high-priority", &val ); p_sys->b_high_priority = val.b_bool; if( p_sys->i_vcodec ) { msg_Dbg( p_stream, "codec video=%4.4s %dx%d scaling: %f %dkb/s", (char *)&p_sys->i_vcodec, p_sys->i_width, p_sys->i_height, p_sys->f_scale, p_sys->i_vbitrate / 1000 ); } /* Subpictures transcoding parameters */ p_sys->p_spu = NULL; p_sys->psz_senc = NULL; p_sys->p_spu_cfg = NULL; p_sys->i_scodec = 0; var_Get( p_stream, SOUT_CFG_PREFIX "senc", &val ); if( val.psz_string && *val.psz_string ) { char *psz_next; psz_next = config_ChainCreate( &p_sys->psz_senc, &p_sys->p_spu_cfg, val.psz_string ); free( psz_next ); } free( val.psz_string ); var_Get( p_stream, SOUT_CFG_PREFIX "scodec", &val ); if( val.psz_string && *val.psz_string ) { char fcc[4] = " "; memcpy( fcc, val.psz_string, __MIN( strlen( val.psz_string ), 4 ) ); p_sys->i_scodec = VLC_FOURCC( fcc[0], fcc[1], fcc[2], fcc[3] ); } free( val.psz_string ); if( p_sys->i_scodec ) { msg_Dbg( p_stream, "codec spu=%4.4s", (char *)&p_sys->i_scodec ); } var_Get( p_stream, SOUT_CFG_PREFIX "soverlay", &val ); p_sys->b_soverlay = val.b_bool; var_Get( p_stream, SOUT_CFG_PREFIX "sfilter", &val ); if( val.psz_string && *val.psz_string ) { p_sys->p_spu = spu_Create( p_stream ); if( p_sys->p_spu ) spu_ChangeFilters( p_sys->p_spu, val.psz_string ); } free( val.psz_string ); /* OSD menu transcoding parameters */ p_sys->psz_osdenc = NULL; p_sys->p_osd_cfg = NULL; p_sys->i_osdcodec = 0; p_sys->b_osd = false; var_Get( p_stream, SOUT_CFG_PREFIX "osd", &val ); if( val.b_bool ) { char *psz_next; psz_next = config_ChainCreate( &p_sys->psz_osdenc, &p_sys->p_osd_cfg, strdup( "dvbsub") ); free( psz_next ); p_sys->i_osdcodec = VLC_CODEC_YUVP; msg_Dbg( p_stream, "codec osd=%4.4s", (char *)&p_sys->i_osdcodec ); if( !p_sys->p_spu ) { p_sys->p_spu = spu_Create( p_stream ); if( p_sys->p_spu ) spu_ChangeFilters( p_sys->p_spu, "osdmenu" ); } else { spu_ChangeFilters( p_sys->p_spu, "osdmenu" ); } } /* Audio settings */ var_Get( p_stream, SOUT_CFG_PREFIX "audio-sync", &val ); p_sys->b_master_sync = val.b_bool; if( p_sys->f_fps > 0 ) p_sys->b_master_sync = true; p_stream->pf_add = Add; p_stream->pf_del = Del; p_stream->pf_send = Send; p_stream->p_sys = p_sys; return VLC_SUCCESS; }
static int EqzInit( filter_t *p_filter, int i_rate ) { filter_sys_t *p_sys = p_filter->p_sys; const eqz_config_t *p_cfg; int i, ch; vlc_value_t val1, val2, val3; vlc_object_t *p_aout = p_filter->p_parent; int i_ret = VLC_ENOMEM; /* 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, "rate not supported" ); 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) ); 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] = 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 = false; p_sys->f_gamp = 1.0; 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.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_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 ); /* 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"); free( val2.psz_string ); free( p_sys->f_amp ); i_ret = VLC_EGENERIC; goto error; } 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 ); 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, " %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; error: free( p_sys->f_alpha ); free( p_sys->f_beta ); free( p_sys->f_gamma ); return i_ret; }
/***************************************************************************** * 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; }
/***************************************************************************** * OpenFilter: probe the filter and return score *****************************************************************************/ static int OpenFilter(vlc_object_t *p_this) { filter_t *p_filter = (filter_t*) p_this; filter_sys_t *p_sys; /* Allocate the memory needed to store the decoder's structure */ if ((p_filter->p_sys = p_sys = (filter_sys_t *) malloc(sizeof (filter_sys_t))) == NULL) { return VLC_ENOMEM; } vlc_value_t val1; var_Get(p_filter->p_parent->p_parent, "video-object", &val1); analytic_input_params *parameters = (analytic_input_params*) val1.p_address; p_sys->input_parameters = parameters; p_sys->event_info.i_region_size = 0; p_sys->event_info.p_region = NULL; p_sys->i_id = 0; p_sys->counter = 0; p_filter->p_sys->x_old = 0; p_filter->p_sys->x_new = 0; p_filter->p_sys->y_old = 0; p_filter->p_sys->y_new = 0; p_filter->p_sys->mov = 0; p_filter->p_sys->click = 0; p_filter->p_sys->save_preset = 0; p_filter->p_sys->scroll_value = 0; p_filter->p_sys->Var_on_click_zoom = 0; p_filter->p_sys->angle_rotate = 0; p_filter->p_sys->start = 1; ///////////////////////////////////////////////////////text file assignment///////////////////// //////////////// creating folder "fisheye_config" //////////////////////// char idnum[20]; sprintf(idnum, "%d", p_filter->p_sys->input_parameters->cameraid); char name[] = "fisheye_config/camera_num_"; strcpy(p_filter->p_sys->camera_id, name); char txt[] = ".txt"; strcat(p_filter->p_sys->camera_id, idnum); strcat(p_filter->p_sys->camera_id, txt); //Open the input file ifstream input; input.open(p_filter->p_sys->camera_id); if (!input) { cout << "camera1.txt could not be accessed!" << endl; ofstream outf(p_filter->p_sys->camera_id); // If we couldn't open the output file stream for writing if (!outf) { // Print an error and exit cerr << "Uh oh, Sample.dat could not be opened for writing!" << endl; return 0; } // We'll write two lines into this file outf << "radius = 400.00" << endl; outf << "theta = 1.57" << endl; outf << "centre_x = 200.00" << endl; outf << "centre_y = 200.00" << endl; outf.close(); p_filter->p_sys->start = 0; input.open(p_filter->p_sys->camera_id); } else { //Variables string temp; if (!input.eof()) { getline(input, temp); //Get 1 line from the file and place into temp p_filter->p_sys->radius_video = HOME_MADE_ATOI(temp); } if (!input.eof()) { getline(input, temp); //Get 1 line from the file and place into temp p_filter->p_sys->theta = HOME_MADE_ATOI(temp); } if (!input.eof()) { getline(input, temp); //Get 1 line from the file and place into temp p_filter->p_sys->centre_x = HOME_MADE_ATOI(temp); } if (!input.eof()) { getline(input, temp); //Get 1 line from the file and place into temp p_filter->p_sys->centre_y = HOME_MADE_ATOI(temp); } } input.close(); //////////////////////////////////////////////////////////////////////////////////////////////////////// p_filter->p_sys->para = p_filter->p_sys->input_parameters->debugParam.thresh4; p_filter->pf_video_filter = Filter; p_filter->pf_video_mouse = Mouse; /////////////////////////////////////////////////////// var_CreateGetIntegerCommand(p_filter, "mouse-wheel"); var_AddCallback(p_filter, "mouse-wheel", MouseWheelCallback, p_sys); p_filter->p_sys->f_scale = p_filter->p_sys->input_parameters->debugParam.minObjHeight; p_filter->p_sys->output_max_height = p_filter->p_sys->input_parameters->debugParam.maxObjHeight; p_filter->p_sys->output_max_width = p_filter->p_sys->input_parameters->debugParam.maxObjWidth; /////////////////////////////////////////////////////////////// return VLC_SUCCESS; }
/***************************************************************************** * OSD menu Funtions *****************************************************************************/ osd_menu_t *osd_MenuCreate( vlc_object_t *p_this, const char *psz_file ) { osd_menu_t *p_osd = NULL; vlc_value_t val; vlc_mutex_t *p_lock; int i_volume = 0; int i_steps = 0; /* to be sure to avoid multiple creation */ p_lock = osd_GetMutex( p_this ); vlc_mutex_lock( p_lock ); var_Create( p_this->p_libvlc, "osd", VLC_VAR_ADDRESS ); var_Get( p_this->p_libvlc, "osd", &val ); if( val.p_address == NULL ) { static const char osdmenu_name[] = "osd menu"; p_osd = vlc_custom_create( p_this, sizeof( *p_osd ), VLC_OBJECT_GENERIC, osdmenu_name ); if( !p_osd ) return NULL; p_osd->p_parser = NULL; vlc_object_attach( p_osd, p_this->p_libvlc ); /* Parse configuration file */ if ( !osd_ParserLoad( p_osd, psz_file ) ) goto error; if( !p_osd->p_state ) goto error; /* Setup default button (first button) */ p_osd->p_state->p_visible = p_osd->p_button; p_osd->p_state->p_visible->p_current_state = osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT ); p_osd->i_width = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch; p_osd->i_height = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines; if( p_osd->p_state->p_volume ) { /* Update the volume state images to match the current volume */ i_volume = config_GetInt( p_this, "volume" ); i_steps = osd_VolumeStep( p_this, i_volume, p_osd->p_state->p_volume->i_ranges ); p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps ); } /* Initialize OSD state */ osd_UpdateState( p_osd->p_state, p_osd->i_x, p_osd->i_y, p_osd->i_width, p_osd->i_height, NULL ); /* Signal when an update of OSD menu is needed */ var_Create( p_osd, "osd-menu-update", VLC_VAR_BOOL ); var_Create( p_osd, "osd-menu-visible", VLC_VAR_BOOL ); var_SetBool( p_osd, "osd-menu-update", false ); var_SetBool( p_osd, "osd-menu-visible", false ); val.p_address = p_osd; var_Set( p_this->p_libvlc, "osd", val ); } else p_osd = val.p_address; vlc_object_hold( p_osd ); vlc_mutex_unlock( p_lock ); return p_osd; error: vlc_mutex_unlock( p_lock ); osd_MenuDelete( p_this, p_osd ); return NULL; }
/**************************************************************************** * Seek command parsing handling ****************************************************************************/ void HandleSeek( intf_thread_t *p_intf, char *p_value ) { intf_sys_t *p_sys = p_intf->p_sys; vlc_value_t val; int i_stock = 0; uint64_t i_length; int i_value = 0; int i_relative = 0; #define POSITION_ABSOLUTE 12 #define POSITION_REL_FOR 13 #define POSITION_REL_BACK 11 #define VL_TIME_ABSOLUTE 0 #define VL_TIME_REL_FOR 1 #define VL_TIME_REL_BACK -1 if( p_sys->p_input ) { var_Get( p_sys->p_input, "length", &val ); i_length = val.i_time; while( p_value[0] != '\0' ) { switch(p_value[0]) { case '+': { i_relative = VL_TIME_REL_FOR; p_value++; break; } case '-': { i_relative = VL_TIME_REL_BACK; p_value++; break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { i_stock = strtol( p_value , &p_value , 10 ); break; } case '%': /* for percentage ie position */ { i_relative += POSITION_ABSOLUTE; i_value = i_stock; i_stock = 0; p_value[0] = '\0'; break; } case ':': { i_value = 60 * (i_value + i_stock) ; i_stock = 0; p_value++; break; } case 'h': case 'H': /* hours */ { i_value += 3600 * i_stock; i_stock = 0; /* other characters which are not numbers are not * important */ while( ((p_value[0] < '0') || (p_value[0] > '9')) && (p_value[0] != '\0') ) { p_value++; } break; } case 'm': case 'M': case '\'': /* minutes */ { i_value += 60 * i_stock; i_stock = 0; p_value++; while( ((p_value[0] < '0') || (p_value[0] > '9')) && (p_value[0] != '\0') ) { p_value++; } break; } case 's': case 'S': case '"': /* seconds */ { i_value += i_stock; i_stock = 0; while( ((p_value[0] < '0') || (p_value[0] > '9')) && (p_value[0] != '\0') ) { p_value++; } break; } default: { p_value++; break; } } } /* if there is no known symbol, I consider it as seconds. * Otherwise, i_stock = 0 */ i_value += i_stock; switch(i_relative) { case VL_TIME_ABSOLUTE: { if( (uint64_t)( i_value ) * 1000000 <= i_length ) val.i_time = (uint64_t)( i_value ) * 1000000; else val.i_time = i_length; var_Set( p_sys->p_input, "time", val ); msg_Dbg( p_intf, "requested seek position: %dsec", i_value ); break; } case VL_TIME_REL_FOR: { var_Get( p_sys->p_input, "time", &val ); if( (uint64_t)( i_value ) * 1000000 + val.i_time <= i_length ) { val.i_time = ((uint64_t)( i_value ) * 1000000) + val.i_time; } else { val.i_time = i_length; } var_Set( p_sys->p_input, "time", val ); msg_Dbg( p_intf, "requested seek position forward: %dsec", i_value ); break; } case VL_TIME_REL_BACK: { var_Get( p_sys->p_input, "time", &val ); if( (int64_t)( i_value ) * 1000000 > val.i_time ) { val.i_time = 0; } else { val.i_time = val.i_time - ((uint64_t)( i_value ) * 1000000); } var_Set( p_sys->p_input, "time", val ); msg_Dbg( p_intf, "requested seek position backward: %dsec", i_value ); break; } case POSITION_ABSOLUTE: { val.f_float = __MIN( __MAX( ((float) i_value ) / 100.0 , 0.0 ), 100.0 ); var_Set( p_sys->p_input, "position", val ); msg_Dbg( p_intf, "requested seek percent: %d%%", i_value ); break; } case POSITION_REL_FOR: { var_Get( p_sys->p_input, "position", &val ); val.f_float += __MIN( __MAX( ((float) i_value ) / 100.0, 0.0 ) , 100.0 ); var_Set( p_sys->p_input, "position", val ); msg_Dbg( p_intf, "requested seek percent forward: %d%%", i_value ); break; } case POSITION_REL_BACK: { var_Get( p_sys->p_input, "position", &val ); val.f_float -= __MIN( __MAX( ((float) i_value ) / 100.0, 0.0 ) , 100.0 ); var_Set( p_sys->p_input, "position", val ); msg_Dbg( p_intf, "requested seek percent backward: %d%%", i_value ); break; } default: { msg_Dbg( p_intf, "invalid seek request" ); break; } } } #undef POSITION_ABSOLUTE #undef POSITION_REL_FOR #undef POSITION_REL_BACK #undef VL_TIME_ABSOLUTE #undef VL_TIME_REL_FOR #undef VL_TIME_REL_BACK }
/***************************************************************************** * OpenAudio: *****************************************************************************/ static int OpenAudio( decoder_t *p_dec ) { decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) ); vlc_value_t lockval; int i_error; char fcc[4]; unsigned long WantedBufferSize; unsigned long InputBufferSize = 0; unsigned long OutputBufferSize = 0; memset( p_sys, 0, sizeof( decoder_sys_t ) ); p_dec->p_sys = p_sys; p_dec->pf_decode_audio = DecodeAudio; memcpy( fcc, &p_dec->fmt_in.i_codec, 4 ); /* get lock, avoid segfault */ var_Get( p_dec->p_libvlc, "qt_mutex", &lockval ); vlc_mutex_lock( lockval.p_address ); #ifdef __APPLE__ EnterMovies(); #endif if( QTAudioInit( p_dec ) ) { msg_Err( p_dec, "cannot initialize QT"); goto exit_error; } #ifndef __APPLE__ if( ( i_error = p_sys->InitializeQTML( 6 + 16 ) ) ) { msg_Dbg( p_dec, "error on InitializeQTML = %d", i_error ); goto exit_error; } #endif /* input format settings */ p_sys->InputFormatInfo.flags = 0; p_sys->InputFormatInfo.sampleCount = 0; p_sys->InputFormatInfo.buffer = NULL; p_sys->InputFormatInfo.reserved = 0; p_sys->InputFormatInfo.numChannels = p_dec->fmt_in.audio.i_channels; p_sys->InputFormatInfo.sampleSize = p_dec->fmt_in.audio.i_bitspersample; p_sys->InputFormatInfo.sampleRate = p_dec->fmt_in.audio.i_rate; p_sys->InputFormatInfo.format = FCC( fcc[0], fcc[1], fcc[2], fcc[3] ); /* output format settings */ p_sys->OutputFormatInfo.flags = 0; p_sys->OutputFormatInfo.sampleCount = 0; p_sys->OutputFormatInfo.buffer = NULL; p_sys->OutputFormatInfo.reserved = 0; p_sys->OutputFormatInfo.numChannels = p_dec->fmt_in.audio.i_channels; p_sys->OutputFormatInfo.sampleSize = 16; p_sys->OutputFormatInfo.sampleRate = p_dec->fmt_in.audio.i_rate; p_sys->OutputFormatInfo.format = FCC( 'N', 'O', 'N', 'E' ); i_error = p_sys->SoundConverterOpen( &p_sys->InputFormatInfo, &p_sys->OutputFormatInfo, &p_sys->myConverter ); if( i_error ) { msg_Err( p_dec, "error on SoundConverterOpen = %d", i_error ); goto exit_error; } #if 0 /* tell the sound converter we accept VBR formats */ i_error = SoundConverterSetInfo( p_dec->myConverter, siClientAcceptsVBR, (void *)true ); #endif if( p_dec->fmt_in.i_extra > 36 + 8 ) { i_error = p_sys->SoundConverterSetInfo( p_sys->myConverter, FCC( 'w', 'a', 'v', 'e' ), ((uint8_t*)p_dec->fmt_in.p_extra) + 36 + 8 ); msg_Dbg( p_dec, "error on SoundConverterSetInfo = %d", i_error ); } WantedBufferSize = p_sys->OutputFormatInfo.numChannels * p_sys->OutputFormatInfo.sampleRate * 2; p_sys->FramesToGet = 0; i_error = p_sys->SoundConverterGetBufferSizes( p_sys->myConverter, WantedBufferSize, &p_sys->FramesToGet, &InputBufferSize, &OutputBufferSize ); msg_Dbg( p_dec, "WantedBufferSize=%li InputBufferSize=%li " "OutputBufferSize=%li FramesToGet=%li", WantedBufferSize, InputBufferSize, OutputBufferSize, p_sys->FramesToGet ); p_sys->InFrameSize = (InputBufferSize + p_sys->FramesToGet - 1 ) / p_sys->FramesToGet; p_sys->OutFrameSize = OutputBufferSize / p_sys->FramesToGet; msg_Dbg( p_dec, "frame size %d -> %d", p_sys->InFrameSize, p_sys->OutFrameSize ); if( (i_error = p_sys->SoundConverterBeginConversion(p_sys->myConverter)) ) { msg_Err( p_dec, "error on SoundConverterBeginConversion = %d", i_error ); goto exit_error; } es_format_Init( &p_dec->fmt_out, AUDIO_ES, AOUT_FMT_S16_NE ); p_dec->fmt_out.audio.i_rate = p_sys->OutputFormatInfo.sampleRate; p_dec->fmt_out.audio.i_channels = p_sys->OutputFormatInfo.numChannels; p_dec->fmt_out.audio.i_physical_channels = p_dec->fmt_out.audio.i_original_channels = pi_channels_maps[p_sys->OutputFormatInfo.numChannels]; aout_DateInit( &p_sys->date, p_dec->fmt_out.audio.i_rate ); p_sys->i_buffer = 0; p_sys->i_buffer_size = 100*1000; p_sys->p_buffer = malloc( p_sys->i_buffer_size ); p_sys->i_out = 0; p_sys->i_out_frames = 0; vlc_mutex_unlock( lockval.p_address ); return VLC_SUCCESS; exit_error: #ifdef LOADER Restore_LDT_Keeper( p_sys->ldt_fs ); #endif vlc_mutex_unlock( lockval.p_address ); free( p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * RunIntf: main loop *****************************************************************************/ static void RunIntf( intf_thread_t *p_intf ) { vout_thread_t * p_vout = NULL; if( InitThread( p_intf ) < 0 ) { msg_Err( p_intf, "can't initialize CMML interface" ); return; } #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "CMML intf initialized" ); #endif /* if video output is dying, disassociate ourselves from it */ if( p_vout && p_vout->b_die ) { var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf ); vlc_object_release( p_vout ); p_vout = NULL; } /* Main loop */ while( !p_intf->b_die ) { /* find a video output if we currently don't have one */ if( p_vout == NULL ) { p_vout = vlc_object_find( p_intf->p_sys->p_input, VLC_OBJECT_VOUT, FIND_CHILD ); if( p_vout ) { #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "found vout thread" ); #endif var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf ); } } vlc_mutex_lock( &p_intf->change_lock ); /* * keyboard event */ if( p_intf->p_sys->b_key_pressed ) { vlc_value_t val; int i, i_action = -1; struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys; /* Find action triggered by hotkey (if any) */ var_Get( p_intf->p_vlc, "key-pressed", &val ); /* Acknowledge that we've handled the b_key_pressed event */ p_intf->p_sys->b_key_pressed = VLC_FALSE; #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "Got a keypress: %d", val.i_int ); #endif for( i = 0; p_hotkeys[i].psz_action != NULL; i++ ) { if( p_hotkeys[i].i_key == val.i_int ) i_action = p_hotkeys[i].i_action; } /* What did the user do? */ if( i_action != -1 ) { switch( i_action ) { case ACTIONID_NAV_ACTIVATE: FollowAnchor( p_intf ); break; case ACTIONID_HISTORY_BACK: GoBack( p_intf ); break; case ACTIONID_HISTORY_FORWARD: GoForward( p_intf ); break; default: break; } } } vlc_mutex_unlock( &p_intf->change_lock ); (void) DisplayPendingAnchor( p_intf, p_vout ); /* Wait a bit */ msleep( INTF_IDLE_SLEEP ); } /* if we're here, the video output is dying: release the vout object */ if( p_vout ) { var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf ); vlc_object_release( p_vout ); } vlc_object_release( p_intf->p_sys->p_input ); }
/***************************************************************************** * OpenVideo: *****************************************************************************/ static int OpenVideo( decoder_t *p_dec ) { decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) ); #ifndef WIN32 vlc_value_t lockval; long i_result; ComponentDescription desc; Component prev; ComponentResult cres; ImageSubCodecDecompressCapabilities icap; /* for ImageCodecInitialize() */ CodecInfo cinfo; /* for ImageCodecGetCodecInfo() */ ImageDescription *id; char fcc[4]; int i_vide = p_dec->fmt_in.i_extra; uint8_t *p_vide = p_dec->fmt_in.p_extra; p_dec->p_sys = p_sys; p_dec->pf_decode_video = DecodeVideo; p_sys->i_late = 0; if( i_vide <= 0 ) { msg_Err( p_dec, "missing extra info" ); free( p_sys ); return VLC_EGENERIC; } memcpy( fcc, &p_dec->fmt_in.i_codec, 4 ); msg_Dbg( p_dec, "quicktime_video %4.4s %dx%d", fcc, p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height ); /* get lock, avoid segfault */ var_Get( p_dec->p_libvlc, "qt_mutex", &lockval ); vlc_mutex_lock( lockval.p_address ); #ifdef __APPLE__ EnterMovies(); #endif if( QTVideoInit( p_dec ) ) { msg_Err( p_dec, "cannot initialize QT"); goto exit_error; } #ifndef __APPLE__ if( ( i_result = p_sys->InitializeQTML( 6 + 16 ) ) ) { msg_Dbg( p_dec, "error on InitializeQTML = %d", (int)i_result ); goto exit_error; } #endif /* init ComponentDescription */ memset( &desc, 0, sizeof( ComponentDescription ) ); desc.componentType = FCC( 'i', 'm', 'd', 'c' ); desc.componentSubType = FCC( fcc[0], fcc[1], fcc[2], fcc[3] ); desc.componentManufacturer = 0; desc.componentFlags = 0; desc.componentFlagsMask = 0; if( !( prev = p_sys->FindNextComponent( NULL, &desc ) ) ) { msg_Err( p_dec, "cannot find requested component" ); goto exit_error; } msg_Dbg( p_dec, "component id=0x%p", prev ); p_sys->ci = p_sys->OpenComponent( prev ); msg_Dbg( p_dec, "component instance p=0x%p", p_sys->ci ); memset( &icap, 0, sizeof( ImageSubCodecDecompressCapabilities ) ); cres = p_sys->ImageCodecInitialize( p_sys->ci, &icap ); msg_Dbg( p_dec, "ImageCodecInitialize->0x%X size=%d (%d)\n", (int)cres, (int)icap.recordSize, (int)icap.decompressRecordSize); memset( &cinfo, 0, sizeof( CodecInfo ) ); cres = p_sys->ImageCodecGetCodecInfo( p_sys->ci, &cinfo ); msg_Dbg( p_dec, "Flags: compr: 0x%x decomp: 0x%x format: 0x%x\n", (unsigned int)cinfo.compressFlags, (unsigned int)cinfo.decompressFlags, (unsigned int)cinfo.formatFlags ); msg_Dbg( p_dec, "quicktime_video: Codec name: %.*s\n", ((unsigned char*)&cinfo.typeName)[0], ((unsigned char*)&cinfo.typeName)+1 ); /* make a yuy2 gworld */ p_sys->OutBufferRect.top = 0; p_sys->OutBufferRect.left = 0; p_sys->OutBufferRect.right = p_dec->fmt_in.video.i_width; p_sys->OutBufferRect.bottom = p_dec->fmt_in.video.i_height; /* codec data FIXME use codec not SVQ3 */ msg_Dbg( p_dec, "vide = %d", i_vide ); id = malloc( sizeof( ImageDescription ) + ( i_vide - 70 ) ); id->idSize = sizeof( ImageDescription ) + ( i_vide - 70 ); id->cType = FCC( fcc[0], fcc[1], fcc[2], fcc[3] ); id->version = GetWBE ( p_vide + 0 ); id->revisionLevel = GetWBE ( p_vide + 2 ); id->vendor = GetDWBE( p_vide + 4 ); id->temporalQuality = GetDWBE( p_vide + 8 ); id->spatialQuality = GetDWBE( p_vide + 12 ); id->width = GetWBE ( p_vide + 16 ); id->height = GetWBE ( p_vide + 18 ); id->hRes = GetDWBE( p_vide + 20 ); id->vRes = GetDWBE( p_vide + 24 ); id->dataSize = GetDWBE( p_vide + 28 ); id->frameCount = GetWBE ( p_vide + 32 ); memcpy( &id->name, p_vide + 34, 32 ); id->depth = GetWBE ( p_vide + 66 ); id->clutID = GetWBE ( p_vide + 68 ); if( i_vide > 70 ) { memcpy( ((char*)&id->clutID) + 2, p_vide + 70, i_vide - 70 ); } msg_Dbg( p_dec, "idSize=%d ver=%d rev=%d vendor=%d tempQ=%d " "spaQ=%d w=%d h=%d dpi=%d%d dataSize=%d depth=%d frameCount=%d clutID=%d", (int)id->idSize, id->version, id->revisionLevel, (int)id->vendor, (int)id->temporalQuality, (int)id->spatialQuality, (int)id->width, (int)id->height, (int)id->hRes, (int)id->vRes, (int)id->dataSize, id->depth, id->frameCount, id->clutID ); p_sys->framedescHandle = (ImageDescriptionHandle) NewHandleClear( id->idSize ); memcpy( *p_sys->framedescHandle, id, id->idSize ); p_sys->plane = malloc( p_dec->fmt_in.video.i_width * p_dec->fmt_in.video.i_height * 3 ); i_result = p_sys->QTNewGWorldFromPtr( &p_sys->OutBufferGWorld, /*pixel format of new GWorld==YUY2 */ kYUVSPixelFormat, /* we should benchmark if yvu9 is * faster for svq3, too */ &p_sys->OutBufferRect, 0, 0, 0, p_sys->plane, p_dec->fmt_in.video.i_width * 2 ); msg_Dbg( p_dec, "NewGWorldFromPtr returned:%ld\n", 65536 - ( i_result&0xffff ) ); memset( &p_sys->decpar, 0, sizeof( CodecDecompressParams ) ); p_sys->decpar.imageDescription = p_sys->framedescHandle; p_sys->decpar.startLine = 0; p_sys->decpar.stopLine = ( **p_sys->framedescHandle ).height; p_sys->decpar.frameNumber = 1; p_sys->decpar.matrixFlags = 0; p_sys->decpar.matrixType = 0; p_sys->decpar.matrix = 0; p_sys->decpar.capabilities = &p_sys->codeccap; p_sys->decpar.accuracy = codecNormalQuality; p_sys->decpar.srcRect = p_sys->OutBufferRect; p_sys->decpar.transferMode = srcCopy; p_sys->decpar.dstPixMap = **p_sys->GetGWorldPixMap( p_sys->OutBufferGWorld );/*destPixmap; */ cres = p_sys->ImageCodecPreDecompress( p_sys->ci, &p_sys->decpar ); msg_Dbg( p_dec, "quicktime_video: ImageCodecPreDecompress cres=0x%X\n", (int)cres ); es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_FOURCC( 'Y', 'U', 'Y', '2' )); p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width; p_dec->fmt_out.video.i_height= p_dec->fmt_in.video.i_height; p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height; vlc_mutex_unlock( lockval.p_address ); return VLC_SUCCESS; exit_error: #ifdef LOADER Restore_LDT_Keeper( p_sys->ldt_fs ); #endif vlc_mutex_unlock( lockval.p_address ); #endif /* !WIN32 */ return VLC_EGENERIC; }
/***************************************************************************** * DisplayPendingAnchor: get a pending anchor description/URL from the CMML * decoder and display it on screen *****************************************************************************/ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout ) { decoder_t *p_cmml_decoder; char *psz_description = NULL; char *psz_url = NULL; intf_thread_t *p_primary_intf; vlc_value_t val; p_cmml_decoder = p_intf->p_sys->p_cmml_decoder; if( var_Get( p_cmml_decoder, "psz-current-anchor-description", &val ) != VLC_SUCCESS ) { return VLC_TRUE; } if( !val.p_address ) return VLC_TRUE; psz_description = val.p_address; if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val ) == VLC_SUCCESS ) { psz_url = val.p_address; } if( p_vout != NULL ) { /* don't display anchor if main interface can display it */ p_primary_intf = vlc_object_find( p_intf->p_vlc, VLC_OBJECT_INTF, FIND_CHILD ); if( p_primary_intf ) { if( var_Get( p_primary_intf, "intf-displays-cmml-description", &val ) == VLC_SUCCESS ) { if( val.b_bool == VLC_TRUE ) return VLC_TRUE; } } /* display anchor as subtitle on-screen */ if( DisplayAnchor( p_intf, p_vout, psz_description, psz_url ) != VLC_SUCCESS ) { /* text render unsuccessful: do nothing */ return VLC_FALSE; } /* text render successful: clear description */ val.p_address = NULL; if( var_Set( p_cmml_decoder, "psz-current-anchor-description", val ) != VLC_SUCCESS ) { msg_Dbg( p_intf, "reset of psz-current-anchor-description failed" ); } free( psz_description ); psz_url = NULL; } return VLC_TRUE; }
/***************************************************************************** * InterfaceWindow::MessageReceived *****************************************************************************/ void InterfaceWindow::MessageReceived( BMessage * p_message ) { switch( p_message->what ) { case B_ABOUT_REQUESTED: { BAlert * alert; alert = new BAlert( "VLC media player" VERSION, "VLC media player" VERSION " (BeOS interface)\n\n" "The VideoLAN team <*****@*****.**>\n" "http://www.videolan.org/", _("OK") ); alert->Go(); break; } case TOGGLE_ON_TOP: break; case OPEN_FILE: _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") ); break; case LOAD_SUBFILE: _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") ); break; #if 0 case OPEN_PLAYLIST: if (fPlaylistWindow->Lock()) { if (fPlaylistWindow->IsHidden()) fPlaylistWindow->Show(); else fPlaylistWindow->Activate(); fPlaylistWindow->Unlock(); } break; #endif case OPEN_DVD: { const char * psz_device; if( p_playlist && p_message->FindString( "device", &psz_device ) == B_OK ) { char psz_uri[1024]; memset( psz_uri, 0, 1024 ); snprintf( psz_uri, 1024, "dvdnav:%s", psz_device ); playlist_Add( p_playlist, psz_uri, psz_device, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true ); } UpdatePlaylist(); } break; case SUBFILE_RECEIVED: { entry_ref ref; if( p_message->FindRef( "refs", 0, &ref ) == B_OK ) { BPath path( &ref ); if ( path.InitCheck() == B_OK ) config_PutPsz( p_intf, "sub-file", path.Path() ); } break; } case STOP_PLAYBACK: if( p_playlist ) { playlist_Stop( p_playlist ); } p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT); break; case START_PLAYBACK: case PAUSE_PLAYBACK: { vlc_value_t val; val.i_int = PLAYING_S; if( p_input ) { var_Get( p_input, "state", &val ); } if( p_input && val.i_int != PAUSE_S ) { val.i_int = PAUSE_S; var_Set( p_input, "state", val ); } else { playlist_Play( p_playlist ); } break; } case HEIGHTH_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 ); } break; case QUARTER_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 ); } break; case HALF_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 ); } break; case NORMAL_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT ); } break; case TWICE_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 ); } break; case FOUR_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 ); } break; case HEIGHT_PLAY: if( p_input ) { var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 ); } break; case SEEK_PLAYBACK: /* handled by semaphores */ break; case VOLUME_CHG: aout_VolumeSet( p_intf, p_mediaControl->GetVolume() ); break; case VOLUME_MUTE: aout_ToggleMute( p_intf, NULL ); break; case SELECT_CHANNEL: { int32 channel; if( p_input ) { if( p_message->FindInt32( "audio-es", &channel ) == B_OK ) { var_SetInteger( p_input, "audio-es", channel ); } else if( p_message->FindInt32( "spu-es", &channel ) == B_OK ) { var_SetInteger( p_input, "spu-es", channel ); } } break; } case PREV_TITLE: if( p_input ) { var_TriggerCallback( p_input, "prev-title" ); } break; case NEXT_TITLE: if( p_input ) { var_TriggerCallback( p_input, "next-title" ); } break; case TOGGLE_TITLE: { int32 index; if( p_input && p_message->FindInt32( "index", &index ) == B_OK ) { var_SetInteger( p_input, "title", index ); } break; } case PREV_CHAPTER: if( p_input ) { var_TriggerCallback( p_input, "prev-chapter" ); } break; case NEXT_CHAPTER: if( p_input ) { var_TriggerCallback( p_input, "next-chapter" ); } break; case TOGGLE_CHAPTER: { int32 index; if( p_input && p_message->FindInt32( "index", &index ) == B_OK ) { var_SetInteger( p_input, "chapter", index ); } break; } case PREV_FILE: if( p_playlist ) { playlist_Prev( p_playlist ); } break; case NEXT_FILE: if( p_playlist ) { playlist_Next( p_playlist ); } break; case NAVIGATE_PREV: if( p_input ) { vlc_value_t val; /* First try to go to previous chapter */ if( !var_Get( p_input, "chapter", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( p_input, "prev-chapter" ); break; } } /* Try to go to previous title */ if( !var_Get( p_input, "title", &val ) ) { if( val.i_int > 1 ) { var_TriggerCallback( p_input, "prev-title" ); break; } } /* Try to go to previous file */ if( p_playlist ) { playlist_Prev( p_playlist ); } } break; case NAVIGATE_NEXT: if( p_input ) { /* First try to go to next chapter */ if( !var_Get( p_input, "chapter", &val ) ) { int i_chapter_count = var_CountChoices( p_input, "chapter" ); if( i_chapter_count > val.i_int ) { var_TriggerCallback( p_input, "next-chapter" ); break; } } /* Try to go to next title */ if( !var_Get( p_input, "title", &val ) ) { int i_title_count = var_CountChoices( p_input, "title" ); if( i_title_count > val.i_int ) { var_TriggerCallback( p_input, "next-title" ); break; } } /* Try to go to next file */ if( p_playlist ) { playlist_Next( p_playlist ); } } break; // drag'n'drop and system messages case MSG_SOUNDPLAY: // convert soundplay drag'n'drop message (containing paths) // to normal message (containing refs) { const char* path; for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ ) { entry_ref ref; if ( get_ref_for_path( path, &ref ) == B_OK ) p_message->AddRef( "refs", &ref ); } } // fall through case B_REFS_RECEIVED: case B_SIMPLE_DATA: { /* file(s) opened by the File menu -> append to the playlist; file(s) opened by drag & drop -> replace playlist; file(s) opened by 'shift' + drag & drop -> append */ int32 count; type_code dummy; if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK || count < 1 ) { break; } bool b_remove = ( p_message->WasDropped() && !( modifiers() & B_SHIFT_KEY ) ); if( b_remove && p_playlist ) { playlist_Clear( p_playlist, true ); } entry_ref ref; for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ ) { BPath path( &ref ); /* TODO: find out if this is a DVD icon */ if( p_playlist ) { playlist_Add( p_playlist, path.Path(), NULL, PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true ); } } UpdatePlaylist(); break; } case OPEN_PREFERENCES: { if( fPreferencesWindow->Lock() ) { if (fPreferencesWindow->IsHidden()) fPreferencesWindow->Show(); else fPreferencesWindow->Activate(); fPreferencesWindow->Unlock(); } break; } case OPEN_MESSAGES: { if( fMessagesWindow->Lock() ) { if (fMessagesWindow->IsHidden()) fMessagesWindow->Show(); else fMessagesWindow->Activate(); fMessagesWindow->Unlock(); } break; } case MSG_UPDATE: UpdateInterface(); break; default: BWindow::MessageReceived( p_message ); break; } }
/***************************************************************************** * FollowAnchor: follow the current anchor being displayed to the user *****************************************************************************/ static void FollowAnchor ( intf_thread_t *p_intf ) { intf_sys_t *p_sys; decoder_t *p_cmml_decoder; char *psz_url = NULL; vlc_value_t val; msg_Dbg( p_intf, "User followed anchor" ); p_sys = p_intf->p_sys; p_cmml_decoder = p_sys->p_cmml_decoder; if( var_Get( p_cmml_decoder, "psz-current-anchor-url", &val ) == VLC_SUCCESS ) { if( val.p_address ) psz_url = val.p_address; } #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "Current URL is \"%s\"", psz_url ); #endif if( psz_url ) { playlist_t *p_playlist; playlist_item_t *p_current_item; char *psz_uri_to_load; mtime_t i_seconds; vlc_value_t time; p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if ( !p_playlist ) { msg_Warn( p_intf, "can't find playlist" ); return; } /* Get new URL */ p_current_item = p_playlist->pp_items[p_playlist->i_index]; #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", p_current_item->input.psz_uri ); #endif psz_uri_to_load = XURL_Concat( p_current_item->input.psz_uri, psz_url ); #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "URL to load is \"%s\"", psz_uri_to_load ); #endif if( var_Get( p_intf->p_sys->p_input, "time", &time ) ) { msg_Dbg( p_intf, "couldn't get time from current clip" ); time.i_time = 0; } i_seconds = time.i_time / 1000000; #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "Current time is \"%lld\"", i_seconds ); #endif /* TODO: we need a (much) more robust way of detecting whether * the file's a media file ... */ if( strstr( psz_uri_to_load, ".anx" ) != NULL ) { history_t *p_history = NULL; history_item_t *p_history_item = NULL; char *psz_timed_url; p_history = GetHistory( p_playlist ); /* create history item */ psz_timed_url = GetTimedURLFromPlaylistItem( p_intf, p_current_item ); p_history_item = historyItem_New( psz_timed_url, psz_timed_url ); free( psz_timed_url ); if( !p_history_item ) { msg_Warn( p_intf, "could not initialise history item" ); } else { #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "history pre-index %d", p_history->i_index ); #endif history_PruneAndInsert( p_history, p_history_item ); #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "new history item at %p, uri is \"%s\"", p_history_item, p_history_item->psz_uri ); msg_Dbg( p_intf, "history index now %d", p_history->i_index ); #endif } /* free current-anchor-url */ free( psz_url ); val.p_address = NULL; if( var_Set( p_cmml_decoder, "psz-current-anchor-url", val ) != VLC_SUCCESS ) { msg_Dbg( p_intf, "couldn't reset psz-current-anchor-url" ); } ReplacePlaylistItem( p_playlist, psz_uri_to_load ); } else { #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url ); #endif (void) browser_Open( psz_url ); playlist_Command( p_playlist, PLAYLIST_PAUSE, 0 ); } free( psz_uri_to_load ); vlc_object_release( p_playlist ); } }
/***************************************************************************** * OpenPostproc: probe and open the postproc *****************************************************************************/ static int OpenPostproc( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; vlc_value_t val, val_orig, text; unsigned i_cpu = vlc_CPU(); int i_flags = 0; if( p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height || p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width ) { msg_Err( p_filter, "Filter input and output formats must be identical" ); return VLC_EGENERIC; } /* Set CPU capabilities */ if( i_cpu & CPU_CAPABILITY_MMX ) i_flags |= PP_CPU_CAPS_MMX; if( i_cpu & CPU_CAPABILITY_MMXEXT ) i_flags |= PP_CPU_CAPS_MMX2; if( i_cpu & CPU_CAPABILITY_3DNOW ) i_flags |= PP_CPU_CAPS_3DNOW; if( i_cpu & CPU_CAPABILITY_ALTIVEC ) i_flags |= PP_CPU_CAPS_ALTIVEC; switch( p_filter->fmt_in.video.i_chroma ) { case VLC_CODEC_I444: case VLC_CODEC_J444: /* case VLC_CODEC_YUVA: FIXME: Should work but alpha plane needs to be copied manually and I'm kind of feeling too lazy to write the code to do that ATM (i_pitch vs i_visible_pitch...). */ i_flags |= PP_FORMAT_444; break; case VLC_CODEC_I422: case VLC_CODEC_J422: i_flags |= PP_FORMAT_422; break; case VLC_CODEC_I411: i_flags |= PP_FORMAT_411; break; case VLC_CODEC_I420: case VLC_CODEC_J420: case VLC_CODEC_YV12: i_flags |= PP_FORMAT_420; break; default: msg_Err( p_filter, "Unsupported input chroma (%4.4s)", (char*)&p_filter->fmt_in.video.i_chroma ); return VLC_EGENERIC; } p_sys = malloc( sizeof( filter_sys_t ) ); if( !p_sys ) return VLC_ENOMEM; p_filter->p_sys = p_sys; p_sys->pp_context = pp_get_context( p_filter->fmt_in.video.i_width, p_filter->fmt_in.video.i_height, i_flags ); if( !p_sys->pp_context ) { msg_Err( p_filter, "Error while creating post processing context." ); free( p_sys ); return VLC_EGENERIC; } config_ChainParse( p_filter, FILTER_PREFIX, ppsz_filter_options, p_filter->p_cfg ); var_Create( p_filter, FILTER_PREFIX "q", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); text.psz_string = _("Post processing"); var_Change( p_filter, FILTER_PREFIX "q", VLC_VAR_SETTEXT, &text, NULL ); var_Get( p_filter, FILTER_PREFIX "q", &val_orig ); var_Change( p_filter, FILTER_PREFIX "q", VLC_VAR_DELCHOICE, &val_orig, NULL ); val.psz_string = var_GetNonEmptyString( p_filter, FILTER_PREFIX "name" ); if( val_orig.i_int ) { p_sys->pp_mode = pp_get_mode_by_name_and_quality( val.psz_string ? val.psz_string : "default", val_orig.i_int ); if( !p_sys->pp_mode ) { msg_Err( p_filter, "Error while creating post processing mode." ); free( val.psz_string ); pp_free_context( p_sys->pp_context ); free( p_sys ); return VLC_EGENERIC; } } else { p_sys->pp_mode = NULL; } free( val.psz_string ); for( val.i_int = 0; val.i_int <= PP_QUALITY_MAX; val.i_int++ ) { switch( val.i_int ) { case 0: text.psz_string = _("Disable"); break; case 1: text.psz_string = _("Lowest"); break; case PP_QUALITY_MAX: text.psz_string = _("Highest"); break; default: text.psz_string = NULL; break; } var_Change( p_filter, FILTER_PREFIX "q", VLC_VAR_ADDCHOICE, &val, text.psz_string?&text:NULL ); } vlc_mutex_init( &p_sys->lock ); /* Add the callback at the end to prevent crashes */ var_AddCallback( p_filter, FILTER_PREFIX "q", PPQCallback, NULL ); var_AddCallback( p_filter, FILTER_PREFIX "name", PPNameCallback, NULL ); p_filter->pf_video_filter = PostprocPict; p_sys->b_had_matrix = true; return VLC_SUCCESS; }
static void GoForward( intf_thread_t *p_intf ) { vlc_value_t history; history_t *p_history = NULL; history_item_t *p_history_item = NULL; history_item_t *p_new_history_item = NULL; playlist_t *p_playlist = NULL; playlist_item_t *p_current_item; #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "Going forward in navigation history" ); #endif /* Find the playlist */ p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if ( !p_playlist ) { msg_Warn( p_intf, "can't find playlist" ); return; } /* Retrieve navigation history from playlist */ if( var_Get( p_playlist, "navigation-history", &history ) != VLC_SUCCESS || !history.p_address ) { /* History doesn't exist yet: ignore user's request */ msg_Warn( p_intf, "can't go back: no history exists yet" ); vlc_object_release( p_playlist ); return; } p_history = history.p_address; #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "forward: nav history retrieved from %p", p_history ); msg_Dbg( p_intf, "nav history index:%d, p_xarray:%p", p_history->i_index, p_history->p_xarray ); #endif /* Check whether we can go forward in the history */ if( history_CanGoForward( p_history ) == VLC_FALSE ) { msg_Warn( p_intf, "can't go forward: already at end of history" ); vlc_object_release( p_playlist ); return; } /* Save the currently-playing media in a new history item */ p_new_history_item = malloc( sizeof(history_item_t) ); if( !p_new_history_item ) { #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "forward: could not initialise new history item" ); #endif vlc_object_release( p_playlist ); return; } p_current_item = p_playlist->pp_items[p_playlist->i_index]; p_new_history_item->psz_uri = GetTimedURLFromPlaylistItem( p_intf, p_current_item ); p_new_history_item->psz_name = p_new_history_item->psz_uri; /* Go forward in the history, saving the currently-playing item */ (void) history_GoForwardSavingCurrentItem( p_history, p_new_history_item ); p_history_item = history_Item( p_history ); #ifdef CMML_INTF_DEBUG msg_Dbg( p_intf, "retrieving item from h index %d", p_history->i_index ); msg_Dbg( p_intf, "got next history item: %p", p_history_item ); msg_Dbg( p_intf, "next history item URL: \"%s\"", p_history_item->psz_uri ); #endif ReplacePlaylistItem( p_playlist, p_history_item->psz_uri ); vlc_object_release( p_playlist ); }
void vout_IntfInit( vout_thread_t *p_vout ) { vlc_value_t val, text, old_val; bool b_force_par = false; char *psz_buf; int i; /* Create a few object variables we'll need later on */ var_Create( p_vout, "snapshot-path", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-prefix", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-format", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-preview", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-sequential", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-num", VLC_VAR_INTEGER ); var_SetInteger( p_vout, "snapshot-num", 1 ); var_Create( p_vout, "snapshot-width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "snapshot-height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); p_vout->i_alignment = var_CreateGetInteger( p_vout, "align" ); var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "mouse-hide-timeout", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); p_vout->b_title_show = var_CreateGetBool( p_vout, "video-title-show" ); p_vout->i_title_timeout = (mtime_t)var_CreateGetInteger( p_vout, "video-title-timeout" ); p_vout->i_title_position = var_CreateGetInteger( p_vout, "video-title-position" ); var_AddCallback( p_vout, "video-title-show", TitleShowCallback, NULL ); var_AddCallback( p_vout, "video-title-timeout", TitleTimeoutCallback, NULL ); var_AddCallback( p_vout, "video-title-position", TitlePositionCallback, NULL ); /* Zoom object var */ var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT ); text.psz_string = _("Zoom"); var_Change( p_vout, "zoom", VLC_VAR_SETTEXT, &text, NULL ); var_Get( p_vout, "zoom", &old_val ); for( i = 0; p_zoom_values[i].f_value; i++ ) { if( old_val.f_float == p_zoom_values[i].f_value ) var_Change( p_vout, "zoom", VLC_VAR_DELCHOICE, &old_val, NULL ); val.f_float = p_zoom_values[i].f_value; text.psz_string = _( p_zoom_values[i].psz_label ); var_Change( p_vout, "zoom", VLC_VAR_ADDCHOICE, &val, &text ); } var_Set( p_vout, "zoom", old_val ); /* Is this really needed? */ var_AddCallback( p_vout, "zoom", ZoomCallback, NULL ); /* Crop offset vars */ var_Create( p_vout, "crop-left", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_Create( p_vout, "crop-top", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_Create( p_vout, "crop-right", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_Create( p_vout, "crop-bottom", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); var_AddCallback( p_vout, "crop-left", CropCallback, NULL ); var_AddCallback( p_vout, "crop-top", CropCallback, NULL ); var_AddCallback( p_vout, "crop-right", CropCallback, NULL ); var_AddCallback( p_vout, "crop-bottom", CropCallback, NULL ); /* Crop object var */ var_Create( p_vout, "crop", VLC_VAR_STRING | VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT ); text.psz_string = _("Crop"); var_Change( p_vout, "crop", VLC_VAR_SETTEXT, &text, NULL ); val.psz_string = (char*)""; var_Change( p_vout, "crop", VLC_VAR_DELCHOICE, &val, 0 ); for( i = 0; p_crop_values[i].psz_value; i++ ) { val.psz_string = (char*)p_crop_values[i].psz_value; text.psz_string = _( p_crop_values[i].psz_label ); var_Change( p_vout, "crop", VLC_VAR_ADDCHOICE, &val, &text ); } /* update triggered every time the vout's crop parameters are changed */ var_Create( p_vout, "crop-update", VLC_VAR_VOID ); /* Add custom crop ratios */ psz_buf = config_GetPsz( p_vout, "custom-crop-ratios" ); AddCustomRatios( p_vout, "crop", psz_buf ); free( psz_buf ); var_AddCallback( p_vout, "crop", CropCallback, NULL ); var_Get( p_vout, "crop", &old_val ); if( old_val.psz_string && *old_val.psz_string ) var_Change( p_vout, "crop", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 ); free( old_val.psz_string ); /* Monitor pixel aspect-ratio */ var_Create( p_vout, "monitor-par", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Get( p_vout, "monitor-par", &val ); if( val.psz_string && *val.psz_string ) { char *psz_parser = strchr( val.psz_string, ':' ); unsigned int i_aspect_num = 0, i_aspect_den = 0; float i_aspect = 0; if( psz_parser ) { i_aspect_num = strtol( val.psz_string, 0, 10 ); i_aspect_den = strtol( ++psz_parser, 0, 10 ); } else { i_aspect = atof( val.psz_string ); vlc_ureduce( &i_aspect_num, &i_aspect_den, i_aspect *VOUT_ASPECT_FACTOR, VOUT_ASPECT_FACTOR, 0 ); } if( !i_aspect_num || !i_aspect_den ) i_aspect_num = i_aspect_den = 1; p_vout->i_par_num = i_aspect_num; p_vout->i_par_den = i_aspect_den; vlc_ureduce( &p_vout->i_par_num, &p_vout->i_par_den, p_vout->i_par_num, p_vout->i_par_den, 0 ); msg_Dbg( p_vout, "overriding monitor pixel aspect-ratio: %i:%i", p_vout->i_par_num, p_vout->i_par_den ); b_force_par = true; } free( val.psz_string ); /* Aspect-ratio object var */ var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT ); text.psz_string = _("Aspect-ratio"); var_Change( p_vout, "aspect-ratio", VLC_VAR_SETTEXT, &text, NULL ); val.psz_string = (char*)""; var_Change( p_vout, "aspect-ratio", VLC_VAR_DELCHOICE, &val, 0 ); for( i = 0; p_aspect_ratio_values[i].psz_value; i++ ) { val.psz_string = (char*)p_aspect_ratio_values[i].psz_value; text.psz_string = _( p_aspect_ratio_values[i].psz_label ); var_Change( p_vout, "aspect-ratio", VLC_VAR_ADDCHOICE, &val, &text ); } /* Add custom aspect ratios */ psz_buf = config_GetPsz( p_vout, "custom-aspect-ratios" ); AddCustomRatios( p_vout, "aspect-ratio", psz_buf ); free( psz_buf ); var_AddCallback( p_vout, "aspect-ratio", AspectCallback, NULL ); var_Get( p_vout, "aspect-ratio", &old_val ); if( (old_val.psz_string && *old_val.psz_string) || b_force_par ) var_Change( p_vout, "aspect-ratio", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 ); free( old_val.psz_string ); /* Initialize the dimensions of the video window */ InitWindowSize( p_vout, &p_vout->i_window_width, &p_vout->i_window_height ); /* Add a variable to indicate if the window should be on top of others */ var_Create( p_vout, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); text.psz_string = _("Always on top"); var_Change( p_vout, "video-on-top", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_vout, "video-on-top", OnTopCallback, NULL ); /* Add a variable to indicate whether we want window decoration or not */ var_Create( p_vout, "video-deco", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); /* Add a fullscreen variable */ if( var_CreateGetBoolCommand( p_vout, "fullscreen" ) ) { /* user requested fullscreen */ p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; } text.psz_string = _("Fullscreen"); var_Change( p_vout, "fullscreen", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_vout, "fullscreen", FullscreenCallback, NULL ); /* Add a snapshot variable */ var_Create( p_vout, "video-snapshot", VLC_VAR_VOID | VLC_VAR_ISCOMMAND ); text.psz_string = _("Snapshot"); var_Change( p_vout, "video-snapshot", VLC_VAR_SETTEXT, &text, NULL ); var_AddCallback( p_vout, "video-snapshot", SnapshotCallback, NULL ); /* Mouse coordinates */ var_Create( p_vout, "mouse-x", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-y", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-button-down", VLC_VAR_INTEGER ); var_Create( p_vout, "mouse-moved", VLC_VAR_BOOL ); var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER ); var_Create( p_vout, "intf-change", VLC_VAR_BOOL ); var_SetBool( p_vout, "intf-change", true ); }
/***************************************************************************** * Open: *****************************************************************************/ static int Open( vlc_object_t *p_this ) { ts_table_t *p_table = (ts_table_t *)p_this; ts_stream_t *p_ts_stream = p_table->p_ts_stream; ts_packetizer_sys_t *p_sys; vlc_value_t val; char *psz_network_name; mtime_t i_max_period; unsigned short subi[3]; vlc_rand_bytes( subi, sizeof(subi) ); p_sys = p_table->p_sys = malloc( sizeof(ts_packetizer_sys_t) ); memset( p_sys, 0, sizeof(ts_packetizer_sys_t) ); config_ChainParse( p_table, SOUT_CFG_PREFIX, ppsz_sout_options, p_table->p_cfg ); tstable_CommonOptions( p_table ); if ( p_table->i_rap_advance == -1 ) i_max_period = p_table->i_max_period; else i_max_period = p_table->i_period; switch ( p_ts_stream->params.i_conformance ) { default: case CONFORMANCE_NONE: case CONFORMANCE_ISO: case CONFORMANCE_HDMV: break; case CONFORMANCE_ATSC: msg_Warn( p_table, "NIT is not compatible with ATSC conformance" ); break; case CONFORMANCE_DVB: if ( i_max_period > INT64_C(10000000) ) msg_Warn( p_table, "NIT period shouldn't exceed 10 s in DVB systems" ); break; } var_Get( p_table, SOUT_CFG_PREFIX "version", &val ); if ( val.i_int != -1 ) p_sys->i_version = val.i_int % 32; else p_sys->i_version = nrand48(subi) % 32; var_Get( p_table, SOUT_CFG_PREFIX "network-name", &val ); psz_network_name = val.psz_string; p_sys->p_network_name = p_ts_stream->params.pf_charset( p_ts_stream->params.p_charset, psz_network_name, &p_sys->i_network_name_size ); if ( p_sys->i_network_name_size > 255 ) { msg_Warn( p_table, "network name is too large: %s", psz_network_name ); p_sys->i_network_name_size = 255; } UpdateTable( p_table ); p_table->b_defines_program = true; p_table->i_program = 0; p_table->i_peak_bitrate = T_STD_PEAK_RATE; p_table->i_priority = TSPACK_PRIORITY_SI; p_table->pf_send = Send; tstable_Force( p_table ); msg_Dbg( p_table, "setting up NIT network ID %u name \"%s\"", p_ts_stream->i_nid, psz_network_name ); free( psz_network_name ); return VLC_SUCCESS; }
static void test_creation_and_type( libvlc_int_t *p_libvlc ) { vlc_value_t val; val.i_int = 4212; var_Create( p_libvlc, "bla", VLC_VAR_INTEGER ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER) ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER) ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND) ); var_Change( p_libvlc, "bla", VLC_VAR_SETMIN, &val, NULL ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMIN) ); var_Change( p_libvlc, "bla", VLC_VAR_SETMAX, &val, NULL ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMIN | VLC_VAR_HASMAX) ); var_Change( p_libvlc, "bla", VLC_VAR_SETSTEP, &val, NULL ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMIN | VLC_VAR_HASMAX | VLC_VAR_HASSTEP) ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR ); var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER) ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND) ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE) ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR ); var_Create( p_libvlc, "bla", VLC_VAR_INTEGER ); var_Change( p_libvlc, "bla", VLC_VAR_SETMIN, &val, NULL ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMIN) ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMIN | VLC_VAR_HASCHOICE) ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR ); var_Create( p_libvlc, "bla", VLC_VAR_INTEGER ); var_Change( p_libvlc, "bla", VLC_VAR_SETMAX, &val, NULL ); var_Change( p_libvlc, "bla", VLC_VAR_SETSTEP, &val, NULL ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMAX | VLC_VAR_HASSTEP) ); assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ) == VLC_SUCCESS ); assert( var_Type( p_libvlc, "bla" ) == (VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND | VLC_VAR_HASMAX | VLC_VAR_HASSTEP | VLC_VAR_HASCHOICE) ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); var_Destroy( p_libvlc, "bla" ); assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR ); }
/***************************************************************************** * OpenDecoder: probe the decoder and return score ***************************************************************************** * Tries to launch a decoder and return score so that the interface is able * to chose. *****************************************************************************/ static int OpenDecoder( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; decoder_sys_t *p_sys; vlc_value_t val; if( p_dec->fmt_in.i_codec != VLC_FOURCC('s','u','b','t') && p_dec->fmt_in.i_codec != VLC_FOURCC('s','s','a',' ') ) { return VLC_EGENERIC; } p_dec->pf_decode_sub = DecodeBlock; /* Allocate the memory needed to store the decoder's structure */ if( ( p_dec->p_sys = p_sys = (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) { msg_Err( p_dec, "out of memory" ); return VLC_ENOMEM; } /* init of p_sys */ p_sys->i_align = 0; p_sys->iconv_handle = (vlc_iconv_t)-1; p_sys->b_autodetect_utf8 = VLC_FALSE; p_sys->b_ass = VLC_FALSE; p_sys->i_original_height = -1; p_sys->i_original_width = -1; p_sys->pp_ssa_styles = NULL; p_sys->i_ssa_styles = 0; if( p_dec->fmt_in.subs.psz_encoding && *p_dec->fmt_in.subs.psz_encoding ) { msg_Dbg( p_dec, "using demux suggested character encoding: %s", p_dec->fmt_in.subs.psz_encoding ); if( strcmp( p_dec->fmt_in.subs.psz_encoding, "UTF-8" ) ) p_sys->iconv_handle = vlc_iconv_open( "UTF-8", p_dec->fmt_in.subs.psz_encoding ); } else { var_Create( p_dec, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Get( p_dec, "subsdec-encoding", &val ); if( !strcmp( val.psz_string, DEFAULT_NAME ) ) { const char *psz_charset = GetFallbackEncoding(); p_sys->b_autodetect_utf8 = var_CreateGetBool( p_dec, "subsdec-autodetect-utf8" ); p_sys->iconv_handle = vlc_iconv_open( "UTF-8", psz_charset ); msg_Dbg( p_dec, "using fallback character encoding: %s", psz_charset ); } else if( !strcmp( val.psz_string, "UTF-8" ) ) { msg_Dbg( p_dec, "using enforced character encoding: UTF-8" ); } else if( val.psz_string ) { msg_Dbg( p_dec, "using enforced character encoding: %s", val.psz_string ); p_sys->iconv_handle = vlc_iconv_open( "UTF-8", val.psz_string ); if( p_sys->iconv_handle == (vlc_iconv_t)-1 ) { msg_Warn( p_dec, "unable to do requested conversion" ); } } if( val.psz_string ) free( val.psz_string ); } var_Create( p_dec, "subsdec-align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Get( p_dec, "subsdec-align", &val ); p_sys->i_align = val.i_int; if( p_dec->fmt_in.i_codec == VLC_FOURCC('s','s','a',' ') && var_CreateGetBool( p_dec, "subsdec-formatted" ) ) { if( p_dec->fmt_in.i_extra > 0 ) ParseSSAHeader( p_dec ); } return VLC_SUCCESS; }
/***************************************************************************** * Create: allocates osd-text video thread output method ***************************************************************************** * This function allocates and initializes a Clone vout method. *****************************************************************************/ static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; char *psz_fontfile = NULL; int i, i_error; int i_fontsize = 0; vlc_value_t val; /* Allocate structure */ p_sys = malloc( sizeof( filter_sys_t ) ); if( !p_sys ) { msg_Err( p_filter, "out of memory" ); return VLC_ENOMEM; } p_sys->p_face = 0; p_sys->p_library = 0; for( i = 0; i < 256; i++ ) { p_sys->pi_gamma[i] = (uint8_t)( pow( (double)i * 255.0f, 0.5f ) ); } var_Create( p_filter, "freetype-font", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_filter, "freetype-fontsize", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_filter, "freetype-rel-fontsize", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); /* Look what method was requested */ var_Get( p_filter, "freetype-font", &val ); psz_fontfile = val.psz_string; if( !psz_fontfile || !*psz_fontfile ) { if( psz_fontfile ) free( psz_fontfile ); psz_fontfile = (char *)malloc( PATH_MAX + 1 ); #ifdef WIN32 GetWindowsDirectory( psz_fontfile, PATH_MAX + 1 ); strcat( psz_fontfile, "\\fonts\\arial.ttf" ); #elif SYS_DARWIN strcpy( psz_fontfile, DEFAULT_FONT ); #else msg_Err( p_filter, "user didn't specify a font" ); goto error; #endif } i_error = FT_Init_FreeType( &p_sys->p_library ); if( i_error ) { msg_Err( p_filter, "couldn't initialize freetype" ); goto error; } i_error = FT_New_Face( p_sys->p_library, psz_fontfile ? psz_fontfile : "", 0, &p_sys->p_face ); if( i_error == FT_Err_Unknown_File_Format ) { msg_Err( p_filter, "file %s have unknown format", psz_fontfile ); goto error; } else if( i_error ) { msg_Err( p_filter, "failed to load font file %s", psz_fontfile ); goto error; } i_error = FT_Select_Charmap( p_sys->p_face, ft_encoding_unicode ); if( i_error ) { msg_Err( p_filter, "Font has no unicode translation table" ); goto error; } p_sys->i_use_kerning = FT_HAS_KERNING( p_sys->p_face ); var_Get( p_filter, "freetype-fontsize", &val ); if( val.i_int ) { i_fontsize = val.i_int; } else { var_Get( p_filter, "freetype-rel-fontsize", &val ); i_fontsize = (int)p_filter->fmt_out.video.i_height / val.i_int; } if( i_fontsize <= 0 ) { msg_Warn( p_filter, "Invalid fontsize, using 12" ); i_fontsize = 12; } msg_Dbg( p_filter, "Using fontsize: %i", i_fontsize); i_error = FT_Set_Pixel_Sizes( p_sys->p_face, 0, i_fontsize ); if( i_error ) { msg_Err( p_filter, "couldn't set font size to %d", i_fontsize ); goto error; } if( psz_fontfile ) free( psz_fontfile ); p_filter->pf_render_string = RenderText; p_filter->p_sys = p_sys; return VLC_SUCCESS; error: if( p_sys->p_face ) FT_Done_Face( p_sys->p_face ); if( p_sys->p_library ) FT_Done_FreeType( p_sys->p_library ); if( psz_fontfile ) free( psz_fontfile ); free( p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * InitVideo: initialize the video decoder ***************************************************************************** * the ffmpeg codec will be opened, some memory allocated. The vout is not yet * opened (done after the first decoded frame). *****************************************************************************/ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) { decoder_sys_t *p_sys; vlc_value_t lockval; vlc_value_t val; var_Get( p_dec->p_libvlc, "avcodec", &lockval ); /* Allocate the memory needed to store the decoder's structure */ if( ( p_dec->p_sys = p_sys = (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) { msg_Err( p_dec, "out of memory" ); return VLC_EGENERIC; } p_dec->p_sys->p_context = p_context; p_dec->p_sys->p_codec = p_codec; p_dec->p_sys->i_codec_id = i_codec_id; p_dec->p_sys->psz_namecodec = psz_namecodec; p_sys->p_ff_pic = avcodec_alloc_frame(); /* ***** Fill p_context with init values ***** */ /* FIXME: remove when ffmpeg deals properly with avc1 */ if( p_dec->fmt_in.i_codec != VLC_FOURCC('a','v','c','1') ) /* End FIXME */ p_sys->p_context->codec_tag = ffmpeg_CodecTag( p_dec->fmt_in.i_codec ); p_sys->p_context->width = p_dec->fmt_in.video.i_width; p_sys->p_context->height = p_dec->fmt_in.video.i_height; p_sys->p_context->bits_per_sample = p_dec->fmt_in.video.i_bits_per_pixel; /* ***** Get configuration of ffmpeg plugin ***** */ p_sys->p_context->workaround_bugs = config_GetInt( p_dec, "ffmpeg-workaround-bugs" ); p_sys->p_context->error_resilience = config_GetInt( p_dec, "ffmpeg-error-resilience" ); var_Create( p_dec, "grayscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Get( p_dec, "grayscale", &val ); if( val.b_bool ) p_sys->p_context->flags |= CODEC_FLAG_GRAY; var_Create( p_dec, "ffmpeg-vismv", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Get( p_dec, "ffmpeg-vismv", &val ); #if LIBAVCODEC_BUILD >= 4698 if( val.i_int ) p_sys->p_context->debug_mv = val.i_int; #endif var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Get( p_dec, "ffmpeg-lowres", &val ); #if LIBAVCODEC_BUILD >= 4723 if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int; #endif /* ***** ffmpeg frame skipping ***** */ var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Get( p_dec, "ffmpeg-hurry-up", &val ); p_sys->b_hurry_up = val.b_bool; /* ***** ffmpeg direct rendering ***** */ p_sys->b_direct_rendering = 0; var_Create( p_dec, "ffmpeg-dr", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Get( p_dec, "ffmpeg-dr", &val ); if( val.b_bool && (p_sys->p_codec->capabilities & CODEC_CAP_DR1) && ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) && /* Apparently direct rendering doesn't work with YUV422P */ p_sys->p_context->pix_fmt != PIX_FMT_YUV422P && /* H264 uses too many reference frames */ p_sys->i_codec_id != CODEC_ID_H264 && !(p_sys->p_context->width % 16) && !(p_sys->p_context->height % 16) && #if LIBAVCODEC_BUILD >= 4698 !p_sys->p_context->debug_mv ) #else 1 ) #endif { /* Some codecs set pix_fmt only after the 1st frame has been decoded, * so we need to do another check in ffmpeg_GetFrameBuf() */ p_sys->b_direct_rendering = 1; } #ifdef LIBAVCODEC_PP p_sys->p_pp = NULL; p_sys->b_pp = p_sys->b_pp_async = p_sys->b_pp_init = VLC_FALSE; p_sys->p_pp = E_(OpenPostproc)( p_dec, &p_sys->b_pp_async ); #endif /* ffmpeg doesn't properly release old pictures when frames are skipped */ //if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = 0; if( p_sys->b_direct_rendering ) { msg_Dbg( p_dec, "using direct rendering" ); p_sys->p_context->flags |= CODEC_FLAG_EMU_EDGE; } /* Always use our get_buffer wrapper so we can calculate the * PTS correctly */ p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf; p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf; p_sys->p_context->opaque = p_dec; /* ***** init this codec with special data ***** */ if( p_dec->fmt_in.i_extra ) { int i_size = p_dec->fmt_in.i_extra; if( p_sys->i_codec_id == CODEC_ID_SVQ3 ) { uint8_t *p; p_sys->p_context->extradata_size = i_size + 12; p = p_sys->p_context->extradata = malloc( p_sys->p_context->extradata_size ); memcpy( &p[0], "SVQ3", 4 ); memset( &p[4], 0, 8 ); memcpy( &p[12], p_dec->fmt_in.p_extra, i_size ); /* Now remove all atoms before the SMI one */ if( p_sys->p_context->extradata_size > 0x5a && strncmp( &p[0x56], "SMI ", 4 ) ) { uint8_t *psz = &p[0x52]; while( psz < &p[p_sys->p_context->extradata_size - 8] ) { int i_size = GetDWBE( psz ); if( i_size <= 1 ) { /* FIXME handle 1 as long size */ break; } if( !strncmp( &psz[4], "SMI ", 4 ) ) { memmove( &p[0x52], psz, &p[p_sys->p_context->extradata_size] - psz ); break; } psz += i_size; } } } else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '0' ) || p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '3' ) || p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '2', '0' ) ) { if( p_dec->fmt_in.i_extra == 8 ) { p_sys->p_context->extradata_size = 8; p_sys->p_context->extradata = malloc( 8 ); memcpy( p_sys->p_context->extradata, p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra ); p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1]; msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", p_sys->p_context->sub_id ); } } /* FIXME: remove when ffmpeg deals properly with avc1 */ else if( p_dec->fmt_in.i_codec == VLC_FOURCC('a','v','c','1') ) { ; } /* End FIXME */ else { p_sys->p_context->extradata_size = i_size; p_sys->p_context->extradata = malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); memcpy( p_sys->p_context->extradata, p_dec->fmt_in.p_extra, i_size ); memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], 0, FF_INPUT_BUFFER_PADDING_SIZE ); } } /* ***** misc init ***** */ p_sys->input_pts = p_sys->input_dts = 0; p_sys->i_pts = 0; p_sys->b_has_b_frames = VLC_FALSE; p_sys->b_first_frame = VLC_TRUE; p_sys->i_late_frames = 0; p_sys->i_buffer = 0; p_sys->i_buffer_orig = 1; p_sys->p_buffer_orig = p_sys->p_buffer = malloc( p_sys->i_buffer_orig ); /* Set output properties */ p_dec->fmt_out.i_cat = VIDEO_ES; p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); /* Setup palette */ #if LIBAVCODEC_BUILD >= 4688 if( p_dec->fmt_in.video.p_palette ) p_sys->p_context->palctrl = (AVPaletteControl *)p_dec->fmt_in.video.p_palette; else p_sys->p_context->palctrl = &palette_control; #endif /* ***** Open the codec ***** */ vlc_mutex_lock( lockval.p_address ); if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 ) { vlc_mutex_unlock( lockval.p_address ); msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); free( p_sys ); return VLC_EGENERIC; } vlc_mutex_unlock( lockval.p_address ); msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); return VLC_SUCCESS; }