📄 vout_intf.c
字号:
else { if( psz_parser ) { memmove( psz_parser, psz_parser + strlen(psz_name) + (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ), strlen(psz_parser + strlen(psz_name)) + 1 ); /* Remove trailing : : */ if( *(psz_string+strlen(psz_string ) -1 ) == ':' ) { *(psz_string+strlen(psz_string ) -1 ) = '\0'; } } else { free( psz_string ); return; } } if( b_setconfig ) config_PutPsz( p_vout, "vout-filter", psz_string ); var_SetString( p_vout, "vout-filter", psz_string ); free( psz_string );}/***************************************************************************** * vout_ControlDefault: default methods for video output control. *****************************************************************************/int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args ){ (void)args; switch( i_query ) { case VOUT_REPARENT: case VOUT_CLOSE: vout_ReleaseWindow( p_vout, NULL ); return VLC_SUCCESS; case VOUT_SNAPSHOT: p_vout->b_snapshot = true; return VLC_SUCCESS; default: msg_Dbg( p_vout, "control query not supported" ); } return VLC_EGENERIC;}/***************************************************************************** * 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, "fucked 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}/***************************************************************************** * Object variables callbacks *****************************************************************************/static int ZoomCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; (void)psz_cmd; (void)oldval; (void)newval; (void)p_data; InitWindowSize( p_vout, &p_vout->i_window_width, &p_vout->i_window_height ); vout_Control( p_vout, VOUT_SET_SIZE, p_vout->i_window_width, p_vout->i_window_height ); return VLC_SUCCESS;}static int CropCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; int64_t i_aspect_num, i_aspect_den; unsigned int i_width, i_height; (void)oldval; (void)p_data; /* Restore defaults */ p_vout->fmt_in.i_x_offset = p_vout->fmt_render.i_x_offset; p_vout->fmt_in.i_visible_width = p_vout->fmt_render.i_visible_width; p_vout->fmt_in.i_y_offset = p_vout->fmt_render.i_y_offset; p_vout->fmt_in.i_visible_height = p_vout->fmt_render.i_visible_height; if( !strcmp( psz_cmd, "crop" ) ) { char *psz_end = NULL, *psz_parser = strchr( newval.psz_string, ':' ); if( psz_parser ) { /* We're using the 3:4 syntax */ i_aspect_num = strtol( newval.psz_string, &psz_end, 10 ); if( psz_end == newval.psz_string || !i_aspect_num ) goto crop_end; i_aspect_den = strtol( ++psz_parser, &psz_end, 10 ); if( psz_end == psz_parser || !i_aspect_den ) goto crop_end; i_width = p_vout->fmt_in.i_sar_den*p_vout->fmt_render.i_visible_height * i_aspect_num / i_aspect_den / p_vout->fmt_in.i_sar_num; i_height = p_vout->fmt_render.i_visible_width*p_vout->fmt_in.i_sar_num * i_aspect_den / i_aspect_num / p_vout->fmt_in.i_sar_den; if( i_width < p_vout->fmt_render.i_visible_width ) { p_vout->fmt_in.i_x_offset = p_vout->fmt_render.i_x_offset + (p_vout->fmt_render.i_visible_width - i_width) / 2; p_vout->fmt_in.i_visible_width = i_width; } else { p_vout->fmt_in.i_y_offset = p_vout->fmt_render.i_y_offset + (p_vout->fmt_render.i_visible_height - i_height) / 2; p_vout->fmt_in.i_visible_height = i_height; } } else { psz_parser = strchr( newval.psz_string, 'x' ); if( psz_parser ) { /* Maybe we're using the <width>x<height>+<left>+<top> syntax */ unsigned int i_crop_width, i_crop_height, i_crop_top, i_crop_left; i_crop_width = strtol( newval.psz_string, &psz_end, 10 ); if( psz_end != psz_parser ) goto crop_end; psz_parser = strchr( ++psz_end, '+' ); i_crop_height = strtol( psz_end, &psz_end, 10 ); if( psz_end != psz_parser ) goto crop_end; psz_parser = strchr( ++psz_end, '+' ); i_crop_left = strtol( psz_end, &psz_end, 10 ); if( psz_end != psz_parser ) goto crop_end; psz_end++; i_crop_top = strtol( psz_end, &psz_end, 10 ); if( *psz_end != '\0' ) goto crop_end; i_width = i_crop_width; p_vout->fmt_in.i_visible_width = i_width; i_height = i_crop_height; p_vout->fmt_in.i_visible_height = i_height; p_vout->fmt_in.i_x_offset = i_crop_left; p_vout->fmt_in.i_y_offset = i_crop_top; } else { /* Maybe we're using the <left>+<top>+<right>+<bottom> syntax */ unsigned int i_crop_top, i_crop_left, i_crop_bottom, i_crop_right; psz_parser = strchr( newval.psz_string, '+' ); i_crop_left = strtol( newval.psz_string, &psz_end, 10 ); if( psz_end != psz_parser ) goto crop_end; psz_parser = strchr( ++psz_end, '+' ); i_crop_top = strtol( psz_end, &psz_end, 10 ); if( psz_end != psz_parser ) goto crop_end; psz_parser = strchr( ++psz_end, '+' ); i_crop_right = strtol( psz_end, &psz_end, 10 ); if( psz_end != psz_parser ) goto crop_end; psz_end++; i_crop_bottom = strtol( psz_end, &psz_end, 10 ); if( *psz_end != '\0' ) goto crop_end; i_width = p_vout->fmt_render.i_visible_width - i_crop_left - i_crop_right; p_vout->fmt_in.i_visible_width = i_width; i_height = p_vout->fmt_render.i_visible_height - i_crop_top - i_crop_bottom; p_vout->fmt_in.i_visible_height = i_height; p_vout->fmt_in.i_x_offset = i_crop_left; p_vout->fmt_in.i_y_offset = i_crop_top; } } } else if( !strcmp( psz_cmd, "crop-top" ) || !strcmp( psz_cmd, "crop-left" ) || !strcmp( psz_cmd, "crop-bottom" ) || !strcmp( psz_cmd, "crop-right" ) ) { unsigned int i_crop_top, i_crop_left, i_crop_bottom, i_crop_right; i_crop_top = var_GetInteger( p_vout, "crop-top" ); i_crop_left = var_GetInteger( p_vout, "crop-left" ); i_crop_right = var_GetInteger( p_vout, "crop-right" ); i_crop_bottom = var_GetInteger( p_vout, "crop-bottom" ); i_width = p_vout->fmt_render.i_visible_width - i_crop_left - i_crop_right; p_vout->fmt_in.i_visible_width = i_width; i_height = p_vout->fmt_render.i_visible_height - i_crop_top - i_crop_bottom; p_vout->fmt_in.i_visible_height = i_height; p_vout->fmt_in.i_x_offset = i_crop_left; p_vout->fmt_in.i_y_offset = i_crop_top; } crop_end: InitWindowSize( p_vout, &p_vout->i_window_width, &p_vout->i_window_height ); p_vout->i_changes |= VOUT_CROP_CHANGE; msg_Dbg( p_vout, "cropping picture %ix%i to %i,%i,%ix%i", p_vout->fmt_in.i_width, p_vout->fmt_in.i_height, p_vout->fmt_in.i_x_offset, p_vout->fmt_in.i_y_offset, p_vout->fmt_in.i_visible_width, p_vout->fmt_in.i_visible_height ); var_SetVoid( p_vout, "crop-update" ); return VLC_SUCCESS;}static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; unsigned int i_aspect_num, i_aspect_den, i_sar_num, i_sar_den; vlc_value_t val; char *psz_end, *psz_parser = strchr( newval.psz_string, ':' ); (void)psz_cmd; (void)oldval; (void)p_data; /* Restore defaults */ p_vout->fmt_in.i_sar_num = p_vout->fmt_render.i_sar_num; p_vout->fmt_in.i_sar_den = p_vout->fmt_render.i_sar_den; p_vout->fmt_in.i_aspect = p_vout->fmt_render.i_aspect; p_vout->render.i_aspect = p_vout->fmt_render.i_aspect; if( !psz_parser ) goto aspect_end; i_aspect_num = strtol( newval.psz_string, &psz_end, 10 ); if( psz_end == newval.psz_string || !i_aspect_num ) goto aspect_end; i_aspect_den = strtol( ++psz_parser, &psz_end, 10 ); if( psz_end == psz_parser || !i_aspect_den ) goto aspect_end; i_sar_num = i_aspect_num * p_vout->fmt_render.i_visible_height; i_sar_den = i_aspect_den * p_vout->fmt_render.i_visible_width; vlc_ureduce( &i_sar_num, &i_sar_den, i_sar_num, i_sar_den, 0 ); p_vout->fmt_in.i_sar_num = i_sar_num; p_vout->fmt_in.i_sar_den = i_sar_den; p_vout->fmt_in.i_aspect = i_aspect_num * VOUT_ASPECT_FACTOR / i_aspect_den; p_vout->render.i_aspect = p_vout->fmt_in.i_aspect; aspect_end: if( p_vout->i_par_num && p_vout->i_par_den ) { p_vout->fmt_in.i_sar_num *= p_vout->i_par_den; p_vout->fmt_in.i_sar_den *= p_vout->i_par_num; p_vout->fmt_in.i_aspect = p_vout->fmt_in.i_aspect * p_vout->i_par_den / p_vout->i_par_num; p_vout->render.i_aspect = p_vout->fmt_in.i_aspect; } p_vout->i_changes |= VOUT_ASPECT_CHANGE; vlc_ureduce( &i_aspect_num, &i_aspect_den, p_vout->fmt_in.i_aspect, VOUT_ASPECT_FACTOR, 0 ); msg_Dbg( p_vout, "new aspect-ratio %i:%i, sample aspect-ratio %i:%i", i_aspect_num, i_aspect_den, p_vout->fmt_in.i_sar_num, p_vout->fmt_in.i_sar_den ); if( var_Get( p_vout, "crop", &val ) ) return VLC_EGENERIC; int i_ret = CropCallback( p_this, "crop", val, val, 0 ); free( val.psz_string ); return i_ret;}static int OnTopCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; vout_Control( p_vout, VOUT_SET_STAY_ON_TOP, newval.b_bool ); (void)psz_cmd; (void)oldval; (void)p_data; /* Modify libvlc as well because the vout might have to be restarted */ var_Create( p_vout->p_libvlc, "video-on-top", VLC_VAR_BOOL ); var_Set( p_vout->p_libvlc, "video-on-top", newval ); return VLC_SUCCESS;}static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ vout_thread_t *p_vout = (vout_thread_t *)p_this; vlc_value_t val; (void)psz_cmd; (void)oldval; (void)p_data; p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; /* Modify libvlc as well because the vout might have to be restarted */ var_Create( p_vout->p_libvlc, "fullscreen", VLC_VAR_BOOL ); var_Set( p_vout->p_libvlc, "fullscreen", newval ); val.b_bool = true; var_Set( p_vout, "intf-change", val ); return VLC_SUCCESS;}static int SnapshotCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(newval); VLC_UNUSED(p_data); vout_thread_t *p_vout = (vout_thread_t *)p_this; vout_Control( p_vout, VOUT_SNAPSHOT ); return VLC_SUCCESS;}static int TitleShowCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data); vout_thread_t *p_vout = (vout_thread_t *)p_this; p_vout->b_title_show = newval.b_bool; return VLC_SUCCESS;}static int TitleTimeoutCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data); vout_thread_t *p_vout = (vout_thread_t *)p_this; p_vout->i_title_timeout = (mtime_t) newval.i_int; return VLC_SUCCESS;}static int TitlePositionCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ){ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data); vout_thread_t *p_vout = (vout_thread_t *)p_this; p_vout->i_title_position = newval.i_int; return VLC_SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -