Index: access_mpcontext.h
===================================================================
--- access_mpcontext.h (revision 25332)
+++ access_mpcontext.h (working copy)
@@ -1,6 +1,7 @@
struct MPContext;
void *mpctx_get_video_out(struct MPContext *mpctx);
void *mpctx_get_audio_out(struct MPContext *mpctx);
+void *mpctx_get_demuxer(struct MPContext *mpctx);
void *mpctx_get_playtree_iter(struct MPContext *mpctx);
void *mpctx_get_mixer(struct MPContext *mpctx);
int mpctx_get_global_sub_size(struct MPContext *mpctx);
Index: etc/menu.conf
===================================================================
--- etc/menu.conf (revision 25332)
+++ etc/menu.conf (working copy)
@@ -27,6 +27,8 @@
filter="/etc/mplayer/extensions_filter"
actions="d:run 'mp_loader \'%p\' d',c:run 'mp_loader \'%p\' c'" />
+
+
Welcome to MPlayer
@@ -107,6 +109,8 @@
+
Index: libmenu/menu_chapsel.c
===================================================================
--- libmenu/menu_chapsel.c (revision 0)
+++ libmenu/menu_chapsel.c (revision 0)
@@ -0,0 +1,139 @@
+/*
+ * Support chapter list and selection.
+ *
+ * Copyright (C) 2006-2007 Benjanmin Zores
+ * Copyright (C) 2007 Ulion
+ *
+ * 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
+ */
+
+#include
+#include
+#include
+
+#include "config.h"
+
+#include "m_struct.h"
+#include "m_option.h"
+#include "input/input.h"
+
+#include "stream/stream.h"
+#include "libmpdemux/demuxer.h"
+#include "access_mpcontext.h"
+
+#include "libmpcodecs/mp_image.h"
+
+#include "menu.h"
+#include "menu_list.h"
+
+struct list_entry_s {
+ struct list_entry p;
+ int cid;
+};
+
+struct menu_priv_s {
+ menu_list_priv_t p;
+ char* title;
+ int auto_close;
+};
+
+static struct menu_priv_s cfg_dflt = {
+ MENU_LIST_PRIV_DFLT,
+ "Select chapter",
+ 0
+};
+
+#define ST_OFF(m) M_ST_OFF(struct menu_priv_s,m)
+
+static m_option_t cfg_fields[] = {
+ MENU_LIST_PRIV_FIELDS,
+ { "title", ST_OFF (title), CONF_TYPE_STRING, 0, 0, 0, NULL },
+ { "auto-close", ST_OFF (auto_close), CONF_TYPE_FLAG, 0, 0, 1, NULL },
+ { NULL, NULL, NULL, 0, 0, 0, NULL }
+};
+
+static int fill_menu (menu_t* menu)
+{
+ list_entry_t* e;
+ int cid, chapter_num = 0;
+ demuxer_t* demuxer = mpctx_get_demuxer(menu->ctx);
+
+ if (demuxer)
+ chapter_num = demuxer_chapter_count(demuxer);
+ if (chapter_num > 0) {
+ menu_list_init (menu);
+ for (cid = 0; cid < chapter_num; ++cid)
+ if ((e = calloc (1, sizeof (list_entry_t))) != NULL) {
+ e->cid = cid + 1;
+ e->p.next = NULL;
+ e->p.txt = demuxer_chapter_display_name(demuxer, cid);
+ menu_list_add_entry(menu, e);
+ }
+ }
+ else
+ menu_list_read_cmd(menu, MENU_CMD_CANCEL);
+
+ return 1;
+}
+
+static void read_cmd (menu_t* menu, int cmd)
+{
+ switch (cmd) {
+ case MENU_CMD_RIGHT:
+ case MENU_CMD_OK: {
+ char cmdbuf[26];
+ sprintf(cmdbuf, "seek_chapter %d 1", menu->priv->p.current->cid);
+ mp_input_queue_cmd(mp_input_parse_cmd(cmdbuf));
+ if (menu->priv->auto_close)
+ mp_input_queue_cmd(mp_input_parse_cmd("menu hide"));
+ break;
+ }
+ default:
+ menu_list_read_cmd (menu, cmd);
+ }
+}
+
+static void close_cs (menu_t* menu)
+{
+ menu_list_uninit (menu, NULL);
+}
+
+static int open_cs (menu_t* menu, char* args)
+{
+ args = NULL;
+
+ menu->draw = menu_list_draw;
+ menu->read_cmd = read_cmd;
+ menu->close = close_cs;
+ menu->priv->p.title = menu->priv->title;
+
+ return fill_menu (menu);
+}
+
+const menu_info_t menu_info_chapsel = {
+ "Chapter selector menu",
+ "chapsel",
+ "Benjamin Zores & Ulion",
+ "",
+ {
+ "chapsel_cfg",
+ sizeof(struct menu_priv_s),
+ &cfg_dflt,
+ cfg_fields
+ },
+ open_cs
+};
Index: libmenu/menu.c
===================================================================
--- libmenu/menu.c (revision 25332)
+++ libmenu/menu.c (working copy)
@@ -24,6 +24,7 @@
#include "menu.h"
extern menu_info_t menu_info_cmdlist;
+extern menu_info_t menu_info_chapsel;
extern menu_info_t menu_info_pt;
extern menu_info_t menu_info_filesel;
extern menu_info_t menu_info_txt;
@@ -37,6 +38,7 @@
menu_info_t* menu_info_list[] = {
&menu_info_pt,
&menu_info_cmdlist,
+ &menu_info_chapsel,
&menu_info_filesel,
&menu_info_txt,
&menu_info_console,
Index: libmenu/Makefile
===================================================================
--- libmenu/Makefile (revision 25332)
+++ libmenu/Makefile (working copy)
@@ -4,6 +4,7 @@
SRCS_MPLAYER = menu.c \
vf_menu.c \
+ menu_chapsel.c \
menu_cmdlist.c \
menu_pt.c \
menu_list.c \
Index: mplayer.c
===================================================================
--- mplayer.c (revision 25332)
+++ mplayer.c (working copy)
@@ -387,6 +387,11 @@
return mpctx->audio_out;
}
+void *mpctx_get_demuxer(MPContext *mpctx)
+{
+ return mpctx->demuxer;
+}
+
void *mpctx_get_playtree_iter(MPContext *mpctx)
{
return mpctx->playtree_iter;