2008-12-13 18:40:19 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "config.h"
|
2006-03-30 06:40:58 +00:00
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "help_mp.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2007-05-20 16:10:45 +00:00
|
|
|
#include "mplayer.h"
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "mp_msg.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "libmpcodecs/img_format.h"
|
|
|
|
#include "libmpcodecs/mp_image.h"
|
|
|
|
#include "libmpcodecs/vf.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "libvo/fastmemcpy.h"
|
|
|
|
#include "libvo/video_out.h"
|
|
|
|
#include "libvo/font_load.h"
|
2007-11-15 01:07:56 +00:00
|
|
|
#include "libvo/sub.h"
|
2005-10-26 00:07:43 +00:00
|
|
|
#include "input/input.h"
|
|
|
|
#include "m_struct.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
#include "menu.h"
|
2007-02-21 18:28:48 +00:00
|
|
|
#include "access_mpcontext.h"
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
static struct vf_priv_s* st_priv = NULL;
|
|
|
|
|
|
|
|
static mp_image_t* pause_mpi = NULL;
|
|
|
|
static int go2pause = 0;
|
2004-09-15 13:37:49 +00:00
|
|
|
/// if nonzero display menu at startup
|
2008-10-16 18:08:18 +00:00
|
|
|
int menu_startup = 0;
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
struct vf_priv_s {
|
|
|
|
menu_t* root;
|
|
|
|
menu_t* current;
|
2007-01-04 16:46:15 +00:00
|
|
|
int passthrough;
|
2002-11-14 23:47:11 +00:00
|
|
|
};
|
|
|
|
|
2006-03-21 22:31:49 +00:00
|
|
|
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts);
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
void vf_menu_pause_update(struct vf_instance_s* vf) {
|
2007-12-02 14:24:23 +00:00
|
|
|
const vo_functions_t *video_out = mpctx_get_video_out(vf->priv->current->ctx);
|
2002-11-14 23:47:11 +00:00
|
|
|
if(pause_mpi) {
|
2006-03-21 22:31:49 +00:00
|
|
|
put_image(vf,pause_mpi, MP_NOPTS_VALUE);
|
2002-11-14 23:47:11 +00:00
|
|
|
// Don't draw the osd atm
|
|
|
|
//vf->control(vf,VFCTRL_DRAW_OSD,NULL);
|
|
|
|
video_out->flip_page();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
|
|
|
|
|
|
|
|
switch(cmd->id) {
|
|
|
|
case MP_CMD_MENU : { // Convert txt cmd from the users into libmenu stuff
|
|
|
|
char* arg = cmd->args[0].v.s;
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2007-12-25 04:30:16 +00:00
|
|
|
if (!priv->current->show && strcmp(arg,"hide"))
|
2002-11-14 23:47:11 +00:00
|
|
|
priv->current->show = 1;
|
|
|
|
else if(strcmp(arg,"up") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_UP);
|
|
|
|
else if(strcmp(arg,"down") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_DOWN);
|
2006-03-25 17:32:10 +00:00
|
|
|
else if(strcmp(arg,"left") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_LEFT);
|
|
|
|
else if(strcmp(arg,"right") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_RIGHT);
|
2002-11-14 23:47:11 +00:00
|
|
|
else if(strcmp(arg,"ok") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_OK);
|
|
|
|
else if(strcmp(arg,"cancel") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_CANCEL);
|
2007-12-04 10:42:59 +00:00
|
|
|
else if(strcmp(arg,"home") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_HOME);
|
|
|
|
else if(strcmp(arg,"end") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_END);
|
|
|
|
else if(strcmp(arg,"pageup") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_PAGE_UP);
|
|
|
|
else if(strcmp(arg,"pagedown") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_PAGE_DOWN);
|
2007-12-22 06:14:38 +00:00
|
|
|
else if(strcmp(arg,"click") == 0)
|
|
|
|
menu_read_cmd(priv->current,MENU_CMD_CLICK);
|
2006-08-22 19:40:50 +00:00
|
|
|
else if(strcmp(arg,"hide") == 0 || strcmp(arg,"toggle") == 0)
|
2002-11-14 23:47:11 +00:00
|
|
|
priv->current->show = 0;
|
|
|
|
else
|
2006-03-30 06:40:58 +00:00
|
|
|
mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuCommand,arg);
|
2002-11-14 23:47:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case MP_CMD_SET_MENU : {
|
|
|
|
char* menu = cmd->args[0].v.s;
|
|
|
|
menu_t* l = priv->current;
|
|
|
|
priv->current = menu_open(menu);
|
|
|
|
if(!priv->current) {
|
2006-03-30 06:40:58 +00:00
|
|
|
mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToOpenMenu,menu);
|
2002-11-14 23:47:11 +00:00
|
|
|
priv->current = l;
|
|
|
|
priv->current->show = 0;
|
|
|
|
} else {
|
|
|
|
priv->current->show = 1;
|
|
|
|
priv->current->parent = l;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
|
|
|
mp_image_t *dmpi;
|
|
|
|
|
|
|
|
if(mpi->type == MP_IMGTYPE_TEMP && (!(mpi->flags&MP_IMGFLAG_PRESERVE)) ) {
|
|
|
|
dmpi = vf_get_image(vf->next,mpi->imgfmt,mpi->type, mpi->flags, mpi->w, mpi->h);
|
2007-06-05 15:09:49 +00:00
|
|
|
memcpy(mpi->planes,dmpi->planes,MP_MAX_PLANES*sizeof(unsigned char*));
|
|
|
|
memcpy(mpi->stride,dmpi->stride,MP_MAX_PLANES*sizeof(unsigned int));
|
2002-11-14 23:47:11 +00:00
|
|
|
mpi->flags|=MP_IMGFLAG_DIRECT;
|
|
|
|
mpi->priv=(void*)dmpi;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2007-12-26 13:13:48 +00:00
|
|
|
static int key_cb(int code) {
|
|
|
|
return menu_read_key(st_priv->current,code);
|
2002-11-14 23:47:11 +00:00
|
|
|
}
|
|
|
|
|
2006-03-21 22:31:49 +00:00
|
|
|
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
|
2002-11-14 23:47:11 +00:00
|
|
|
mp_image_t *dmpi = NULL;
|
|
|
|
|
2007-01-04 16:46:15 +00:00
|
|
|
if (vf->priv->passthrough) {
|
|
|
|
dmpi=vf_get_image(vf->next, IMGFMT_MPEGPES, MP_IMGTYPE_EXPORT,
|
|
|
|
0, mpi->w, mpi->h);
|
|
|
|
dmpi->planes[0]=mpi->planes[0];
|
|
|
|
return vf_next_put_image(vf,dmpi, pts);
|
|
|
|
}
|
|
|
|
|
2002-11-14 23:47:11 +00:00
|
|
|
// Close all menu who requested it
|
|
|
|
while(vf->priv->current->cl && vf->priv->current != vf->priv->root) {
|
|
|
|
menu_t* m = vf->priv->current;
|
|
|
|
vf->priv->current = m->parent ? m->parent : vf->priv->root;
|
|
|
|
menu_close(m);
|
|
|
|
}
|
|
|
|
|
2007-11-15 01:07:56 +00:00
|
|
|
// Try to capture the last frame before pause, or fallback to use
|
|
|
|
// last captured frame.
|
2002-11-14 23:47:11 +00:00
|
|
|
if(pause_mpi && (mpi->w != pause_mpi->w || mpi->h != pause_mpi->h ||
|
|
|
|
mpi->imgfmt != pause_mpi->imgfmt)) {
|
|
|
|
free_mp_image(pause_mpi);
|
|
|
|
pause_mpi = NULL;
|
|
|
|
}
|
2007-11-15 01:07:56 +00:00
|
|
|
if (!pause_mpi) {
|
|
|
|
pause_mpi = alloc_mpi(mpi->w,mpi->h,mpi->imgfmt);
|
2002-11-14 23:47:11 +00:00
|
|
|
copy_mpi(pause_mpi,mpi);
|
|
|
|
}
|
2007-11-15 01:07:56 +00:00
|
|
|
else if (mpctx_get_osd_function(vf->priv->root->ctx) == OSD_PAUSE)
|
|
|
|
copy_mpi(pause_mpi,mpi);
|
2002-11-14 23:47:11 +00:00
|
|
|
|
2007-11-15 01:07:56 +00:00
|
|
|
if (vf->priv->current->show) {
|
|
|
|
if (!mp_input_key_cb)
|
|
|
|
mp_input_key_cb = key_cb;
|
2002-11-14 23:47:11 +00:00
|
|
|
|
|
|
|
if(mpi->flags&MP_IMGFLAG_DIRECT)
|
|
|
|
dmpi = mpi->priv;
|
|
|
|
else {
|
|
|
|
dmpi = vf_get_image(vf->next,mpi->imgfmt,
|
|
|
|
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
|
|
|
|
mpi->w,mpi->h);
|
|
|
|
copy_mpi(dmpi,mpi);
|
|
|
|
}
|
|
|
|
menu_draw(vf->priv->current,dmpi);
|
|
|
|
|
2002-11-21 18:31:21 +00:00
|
|
|
} else {
|
|
|
|
if(mp_input_key_cb)
|
|
|
|
mp_input_key_cb = NULL;
|
2007-01-16 13:24:03 +00:00
|
|
|
|
|
|
|
if(mpi->flags&MP_IMGFLAG_DIRECT)
|
|
|
|
dmpi = mpi->priv;
|
|
|
|
else {
|
2007-01-16 13:28:22 +00:00
|
|
|
dmpi = vf_get_image(vf->next,mpi->imgfmt,
|
|
|
|
MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
|
|
|
|
mpi->w,mpi->h);
|
|
|
|
|
|
|
|
dmpi->stride[0] = mpi->stride[0];
|
|
|
|
dmpi->stride[1] = mpi->stride[1];
|
|
|
|
dmpi->stride[2] = mpi->stride[2];
|
|
|
|
dmpi->planes[0] = mpi->planes[0];
|
|
|
|
dmpi->planes[1] = mpi->planes[1];
|
|
|
|
dmpi->planes[2] = mpi->planes[2];
|
|
|
|
dmpi->priv = mpi->priv;
|
|
|
|
}
|
2007-01-16 13:24:03 +00:00
|
|
|
}
|
2006-03-21 22:31:49 +00:00
|
|
|
return vf_next_put_image(vf,dmpi, pts);
|
2002-11-14 23:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uninit(vf_instance_t *vf) {
|
|
|
|
vf->priv=NULL;
|
|
|
|
if(pause_mpi) {
|
|
|
|
free_mp_image(pause_mpi);
|
|
|
|
pause_mpi = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-18 00:09:37 +00:00
|
|
|
static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height,
|
2009-05-13 02:58:57 +00:00
|
|
|
unsigned int flags, unsigned int outfmt) {
|
2008-08-07 10:36:07 +00:00
|
|
|
#ifdef CONFIG_FREETYPE
|
2002-11-18 00:09:37 +00:00
|
|
|
// here is the right place to get screen dimensions
|
|
|
|
if (force_load_font) {
|
|
|
|
force_load_font = 0;
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(width,height,&vo_font,font_name,osd_font_scale_factor);
|
2002-11-18 00:09:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
2007-01-04 16:46:15 +00:00
|
|
|
if(outfmt == IMGFMT_MPEGPES)
|
|
|
|
vf->priv->passthrough = 1;
|
2002-11-18 00:09:37 +00:00
|
|
|
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
|
|
|
|
}
|
2007-01-04 16:46:15 +00:00
|
|
|
|
|
|
|
static int query_format(struct vf_instance_s* vf, unsigned int fmt){
|
2008-05-16 09:42:28 +00:00
|
|
|
return vf_next_query_format(vf,fmt);
|
2007-01-04 16:46:15 +00:00
|
|
|
}
|
|
|
|
|
2007-05-25 10:26:39 +00:00
|
|
|
static int open_vf(vf_instance_t *vf, char* args){
|
2002-11-14 23:47:11 +00:00
|
|
|
if(!st_priv) {
|
|
|
|
st_priv = calloc(1,sizeof(struct vf_priv_s));
|
|
|
|
st_priv->root = st_priv->current = menu_open(args);
|
|
|
|
if(!st_priv->current) {
|
|
|
|
free(st_priv);
|
|
|
|
st_priv = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
2004-09-15 13:37:49 +00:00
|
|
|
st_priv->root->show = menu_startup;
|
2002-11-14 23:47:11 +00:00
|
|
|
mp_input_add_cmd_filter((mp_input_cmd_filter)cmd_filter,st_priv);
|
|
|
|
}
|
|
|
|
|
2002-11-18 00:09:37 +00:00
|
|
|
vf->config = config;
|
2007-01-04 16:46:15 +00:00
|
|
|
vf->query_format=query_format;
|
2002-11-14 23:47:11 +00:00
|
|
|
vf->put_image = put_image;
|
|
|
|
vf->get_image = get_image;
|
|
|
|
vf->uninit=uninit;
|
|
|
|
vf->priv=st_priv;
|
|
|
|
go2pause=0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vf_info_t vf_info_menu = {
|
|
|
|
"Internal filter for libmenu",
|
|
|
|
"menu",
|
|
|
|
"Albeu",
|
|
|
|
"",
|
2007-05-25 10:26:39 +00:00
|
|
|
open_vf,
|
2003-03-30 17:15:19 +00:00
|
|
|
NULL
|
2002-11-14 23:47:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|