Mercurial > mplayer.hg
changeset 10626:fd97f3727f15
Finnaly commit Nico's dvb menu. Sorry for committing this
months later :(
author | albeu |
---|---|
date | Sat, 16 Aug 2003 09:51:05 +0000 |
parents | 620cc649f519 |
children | f7df841c8b74 |
files | input/input.c libmenu/Makefile libmenu/menu.c libmenu/menu_dvbin.c |
diffstat | 4 files changed, 204 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/input/input.c Fri Aug 15 19:13:23 2003 +0000 +++ b/input/input.c Sat Aug 16 09:51:05 2003 +0000 @@ -93,6 +93,9 @@ { MP_CMD_TV_SET_HUE, "tv_set_hue", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }}, { MP_CMD_TV_SET_SATURATION, "tv_set_saturation", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }}, #endif +#ifdef HAS_DVBIN_SUPPORT + { MP_CMD_DVB_SET_CHANNEL, "dvb_set_channel", 1, { { MP_CMD_ARG_INT, {0}}, {-1,{0}} }}, +#endif { MP_CMD_VO_FULLSCREEN, "vo_fullscreen", 0, { {-1,{0}} } }, { MP_CMD_SCREENSHOT, "screenshot", 0, { {-1,{0}} } }, { MP_CMD_PANSCAN, "panscan",1, { {MP_CMD_ARG_FLOAT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
--- a/libmenu/Makefile Fri Aug 15 19:13:23 2003 +0000 +++ b/libmenu/Makefile Sat Aug 16 09:51:05 2003 +0000 @@ -4,6 +4,9 @@ LIBNAME = libmenu.a SRCS= menu.c vf_menu.c menu_cmdlist.c menu_pt.c menu_list.c menu_filesel.c menu_txt.c menu_console.c menu_param.c +ifeq ($(DVBIN),yes) +SRCS += menu_dvbin.c +endif OBJS=$(SRCS:.c=.o) CFLAGS = $(OPTFLAGS) -I. -I.. -I../libmpcodecs $(EXTRA_INC) -Wall
--- a/libmenu/menu.c Fri Aug 15 19:13:23 2003 +0000 +++ b/libmenu/menu.c Sat Aug 16 09:51:05 2003 +0000 @@ -25,6 +25,10 @@ extern menu_info_t menu_info_txt; extern menu_info_t menu_info_console; extern menu_info_t menu_info_pref; +#ifdef HAS_DVBIN_SUPPORT +extern menu_info_t menu_info_dvbsel; +#endif + menu_info_t* menu_info_list[] = { &menu_info_pt, @@ -32,6 +36,9 @@ &menu_info_filesel, &menu_info_txt, &menu_info_console, +#ifdef HAS_DVBIN_SUPPORT + &menu_info_dvbsel, +#endif &menu_info_pref, NULL };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmenu/menu_dvbin.c Sat Aug 16 09:51:05 2003 +0000 @@ -0,0 +1,191 @@ + +#include <stdlib.h> +#include <stdio.h> +#include <dirent.h> +#include <errno.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <ctype.h> +#include <unistd.h> +#include <limits.h> + + +#include "../config.h" + +#include "../m_struct.h" +#include "../m_option.h" + +#include "img_format.h" +#include "mp_image.h" + +#include "menu.h" +#include "menu_list.h" +#include "../input/input.h" +#include "../osdep/keycodes.h" + +#include "../libmpdemux/dvbin.h" + + + +struct list_entry_s { + struct list_entry p; + int num; //the position of the chosen channel in the list +}; + +struct menu_priv_s { + menu_list_priv_t p; + char* title; + char* file; + int card; +}; + + +#define ST_OFF(m) M_ST_OFF(struct menu_priv_s, m) +#define mpriv (menu->priv) + +static m_option_t cfg_fields[] = { + MENU_LIST_PRIV_FIELDS, + { "title", ST_OFF(title), CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "file", ST_OFF(file), CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "card", ST_OFF(card), CONF_TYPE_INT, 0, 0, 0, NULL }, + { NULL, NULL, NULL, 0,0,0,NULL } +}; + + +static struct menu_priv_s cfg_dflt = { + MENU_LIST_PRIV_DFLT, + "Select a channel: %p", + "channels.conf", + 1, + NULL, +}; + + + + +static void free_entry(list_entry_t* entry) +{ + free(entry->p.txt); + free(entry); +} + + +static int fill_menu(menu_t* menu) +{ + int n; + list_entry_t* elem; + char *name; + extern dvb_channels_list *dvb_list_ptr; + dvb_channel_t *channel; + + menu_list_init(menu); + + mpriv->p.title = mpriv->title; + + if(dvb_list_ptr == NULL) + { + mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_set_channel: LIST NULL PTR, quit\n"); + n = 1; + if((elem = malloc(sizeof(list_entry_t))) != NULL) + { + name = malloc(80); + sprintf(name, "Empty channel list from file %s; \nrun mplayer dvb:// to load the list", mpriv->file); + elem->p.next = NULL; + elem->p.txt = name; + + menu_list_add_entry(menu, elem); + } + } + else + { + n = dvb_list_ptr->NUM_CHANNELS; + for(n = 0; n < dvb_list_ptr->NUM_CHANNELS; n++) + { + channel = &(dvb_list_ptr->channels[n]); + if((elem = malloc(sizeof(list_entry_t))) != NULL) + { + name = malloc(80); + strncpy(name, channel->name, 79); + name[79] = 0; + elem->p.next = NULL; + elem->p.txt = name; + elem->num = n; + + + menu_list_add_entry(menu, elem); + } + else + { + mp_msg(MSGT_DEMUX, MSGL_ERR, "dvb_menu: fill_menu: couldn't malloc %d bytes for menu item: %s, exit\n", + sizeof(list_entry_t), strerror(errno)); + + if(n) + return 1; + + return 0; + } + } + } + + return 1; +} + + +static void read_cmd(menu_t* menu, int cmd) +{ + list_entry_t *p; + mp_cmd_t* c; + char *cmd_name; + switch(cmd) + { + case MENU_CMD_OK: + { + p = mpriv->p.current; + mp_msg(MSGT_DEMUX, MSGL_V, "CHOSEN DVB CHANNEL %d\n\n", p->num); + + cmd_name = malloc(30); + sprintf(cmd_name, "dvb_set_channel %d", p->num); + c = mp_input_parse_cmd(cmd_name); + if(c) + mp_input_queue_cmd(c); + } + break; + + default: + menu_list_read_cmd(menu, cmd); + } +} + + +static void close_menu(menu_t* menu) +{ + menu_list_uninit(menu, free_entry); + //free(mpriv->dir); +} + + +static int open_dvb_sel(menu_t* menu, char* args) +{ + menu->draw = menu_list_draw; + menu->read_cmd = read_cmd; + //menu->read_key = read_key; + menu->close = close_menu; + + return fill_menu(menu); +} + +const menu_info_t menu_info_dvbsel = +{ + "DVB channels menu", //descr + "dvbsel", //name + "Nico", //author + "dvb_sel", + { //m_struct_t priv_st= + "dvb_cfg", //name + sizeof(dvb_channels_list), //size + &cfg_dflt, //defaults + cfg_fields //settable fields + }, + open_dvb_sel //open function +};