int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { panscan_init(); aspect_save_orig(width,height); aspect_save_prescale(d_width,d_height); if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) { aspect(&d_width,&d_height,A_NOZOOM); vo_dx = (int)(vo_screenwidth - d_width) / 2; vo_dy = (int)(vo_screenheight - d_height) / 2; geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight); geometry_xy_changed |= xinerama_screen >= 0; vo_dx += xinerama_x; vo_dy += xinerama_y; vo_dwidth = d_width; vo_dheight = d_height; #ifdef CONFIG_GUI if (use_gui) { // GUI creates and manages window for us gui(GUI_SETUP_VIDEO_WINDOW, 0); } #endif } return vo->config(width, height, d_width, d_height, flags, title, format); }
int config_video_out(vo_functions_t *vo, uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { panscan_init(); aspect_save_orig(width,height); aspect_save_prescale(d_width,d_height); if (vo->control(VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) { aspect(&d_width,&d_height,A_NOZOOM); vo_dx = (int)(vo_screenwidth - d_width) / 2; vo_dy = (int)(vo_screenheight - d_height) / 2; geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight); vo_dx += xinerama_x; vo_dy += xinerama_y; vo_dwidth = d_width; vo_dheight = d_height; } return vo->config(width, height, d_width, d_height, flags, title, format); }
static int config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_height, uint32_t flags, char *title, uint32_t format){ title = "MPlayer VIDIX WIN32 Overlay"; panscan_init(); image_height = height; image_width = width; image_format = format; vo_screenwidth = GetSystemMetrics(SM_CXSCREEN); vo_screenheight = GetSystemMetrics(SM_CYSCREEN); vo_depthonscreen = GetDeviceCaps(GetDC(GetDesktopWindow()),BITSPIXEL); aspect_save_orig(width, height); aspect_save_prescale(d_width, d_height); aspect_save_screenres(vo_screenwidth, vo_screenheight); vo_dx = 0; vo_dy = 0; vo_dx=( vo_screenwidth - d_width ) / 2; vo_dy=( vo_screenheight - d_height ) / 2; geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, vo_screenheight); vo_fs = flags&VOFLAG_FULLSCREEN; aspect(&d_width, &d_height, A_NOZOOM); vo_dwidth=d_width; vo_dheight=d_height; window_aspect = (float)d_width / (float)d_height; if(!vo_config_count){ HINSTANCE hInstance = GetModuleHandle(NULL); WNDCLASS wc; RECT rd; rd.left = vo_dx; rd.top = vo_dy; rd.right = rd.left + vo_dwidth; rd.bottom = rd.top + vo_dheight; AdjustWindowRect(&rd,WS_OVERLAPPEDWINDOW| WS_SIZEBOX,0); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon =ExtractIcon(hInstance,"mplayer.exe",0); //LoadIcon(NULL,IDI_APPLICATION); wc.hbrBackground = CreateSolidBrush(RGB(255,0,255)); wc.lpszClassName = "MPlayer - The Movie Player"; wc.lpszMenuName = NULL; RegisterClass(&wc); hWnd = CreateWindow("MPlayer - The Movie Player", title, WS_OVERLAPPEDWINDOW| WS_SIZEBOX, rd.left, rd.top, rd.right - rd.left, rd.bottom - rd.top, NULL, NULL, hInstance, NULL); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszClassName = "MPlayer - Fullscreen"; RegisterClass(&wc); hWndFS = CreateWindow("MPlayer - Fullscreen","MPlayer VIDIX Fullscreen",WS_POPUP,0,0,vo_screenwidth,vo_screenheight,hWnd,NULL,hInstance,NULL); } ShowWindow(hWnd,SW_SHOW); if(vo_fs)ShowWindow(hWndFS,SW_SHOW); return 0; }
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11, struct mp_fifo *key_fifo, struct input_ctx *input_ctx) { char **vo_list = opts->video_driver_list; int i; struct vo *vo = talloc_ptrtype(NULL, vo); struct vo initial_values = { .opts = opts, .x11 = x11, .key_fifo = key_fifo, .input_ctx = input_ctx, .event_fd = -1, .registered_fd = -1, }; // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0]) while (vo_list[0][0]) { char *name = strdup(vo_list[0]); vo_subdevice = strchr(name,':'); if (!strcmp(name, "pgm")) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n"); if (!strcmp(name, "md5")) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The md5 video output driver has been replaced by -vo md5sum.\n"); if (vo_subdevice) { vo_subdevice[0] = 0; ++vo_subdevice; } for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; const vo_info_t *info = video_driver->info; if (!strcmp(info->short_name, name)) { // name matches, try it *vo = initial_values; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) { free(name); return vo; // success! } talloc_free_children(vo); } } // continue... free(name); ++vo_list; if (!(vo_list[0])) return NULL; // do NOT fallback to others } // now try the rest... vo_subdevice = NULL; for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; *vo = initial_values; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) return vo; // success! talloc_free_children(vo); } free(vo); return NULL; } static int event_fd_callback(void *ctx, int fd) { struct vo *vo = ctx; vo_check_events(vo); return MP_INPUT_NOTHING; } int vo_config(struct vo *vo, uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { struct MPOpts *opts = vo->opts; panscan_init(vo); aspect_save_orig(vo, width, height); aspect_save_prescale(vo, d_width, d_height); if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) { aspect(vo, &d_width, &d_height, A_NOZOOM); vo->dx = (int)(opts->vo_screenwidth - d_width) / 2; vo->dy = (int)(opts->vo_screenheight - d_height) / 2; geometry(&vo->dx, &vo->dy, &d_width, &d_height, opts->vo_screenwidth, opts->vo_screenheight); geometry_xy_changed |= xinerama_screen >= 0; vo->dx += xinerama_x; vo->dy += xinerama_y; vo->dwidth = d_width; vo->dheight = d_height; } int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, title, format); vo->config_ok = (ret == 0); vo->config_count += vo->config_ok; if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) { mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback, NULL, vo); vo->registered_fd = vo->event_fd; } return ret; } /** * \brief lookup an integer in a table, table must have 0 as the last key * \param key key to search for * \result translation corresponding to key or "to" value of last mapping * if not found. */ int lookup_keymap_table(const struct mp_keymap *map, int key) { while (map->from && map->from != key) map++; return map->to; } /** * \brief helper function for the kind of panscan-scaling that needs a source * and destination rectangle like Direct3D and VDPAU */ static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size, int *src_start, int *src_end, int *dst_start, int *dst_end) { if (scaled_src_size > dst_size) { int border = src_size * (scaled_src_size - dst_size) / scaled_src_size; // round to a multiple of 2, this is at least needed for vo_direct3d and ATI cards border = (border / 2 + 1) & ~1; *src_start = border; *src_end = src_size - border; *dst_start = 0; *dst_end = dst_size; } else { *src_start = 0; *src_end = src_size; *dst_start = (dst_size - scaled_src_size) / 2; *dst_end = *dst_start + scaled_src_size; } } /** * Calculate the appropriate source and destination rectangle to * get a correctly scaled picture, including pan-scan. * Can be extended to take future cropping support into account. * * \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL * \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires, * may be NULL and only left and top are currently valid. */ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *borders, const struct vo_rect *crop) { static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0}; int scaled_width = 0; int scaled_height = 0; if (!crop) crop = &no_crop; src_width -= crop->left + crop->right; src_height -= crop->top + crop->bottom; if (src_width < 2) src_width = 2; if (src_height < 2) src_height = 2; dst->left = 0; dst->right = vo->dwidth; dst->top = 0; dst->bottom = vo->dheight; src->left = 0; src->right = src_width; src->top = 0; src->bottom = src_height; if (borders) { borders->left = 0; borders->top = 0; } if (aspect_scaling()) { aspect(vo, &scaled_width, &scaled_height, A_WINZOOM); panscan_calc_windowed(vo); scaled_width += vo->panscan_x; scaled_height += vo->panscan_y; if (borders) { borders->left = (vo->dwidth - scaled_width ) / 2; borders->top = (vo->dheight - scaled_height) / 2; } src_dst_split_scaling(src_width, vo->dwidth, scaled_width, &src->left, &src->right, &dst->left, &dst->right); src_dst_split_scaling(src_height, vo->dheight, scaled_height, &src->top, &src->bottom, &dst->top, &dst->bottom); } src->left += crop->left; src->right += crop->left; src->top += crop->top; src->bottom += crop->top; src->width = src->right - src->left; src->height = src->bottom - src->top; dst->width = dst->right - dst->left; dst->height = dst->bottom - dst->top; } /** * Generates a mouse movement message if those are enable and sends it * to the "main" MPlayer. * * \param posx new x position of mouse * \param posy new y position of mouse */ void vo_mouse_movement(struct vo *vo, int posx, int posy) { char cmd_str[40]; if (!enable_mouse_movements) return; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(cmd_str)); }