diff -Naur MPlayer-20021011/cfg-common.h MPlayer-20021011-dvb/cfg-common.h --- MPlayer-20021011/cfg-common.h Sun Oct 6 13:23:00 2002 +++ MPlayer-20021011-dvb/cfg-common.h Sat Oct 12 00:13:05 2002 @@ -77,6 +77,10 @@ #else {"tv", "MPlayer was compiled without TV Interface support\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, #endif +#ifdef HAVE_DVB + {"dvbin", dvbin_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, +#endif + {"vivo", vivoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, // ------------------------- a-v sync options -------------------- @@ -236,6 +240,20 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; #endif + +#ifdef HAVE_DVB +#include "libmpdemux/dvbin.h" +struct config dvbin_opts_conf[] = { + {"on", &dvbin_param_on, CONF_TYPE_INT, 0, 0, 1, NULL}, + {"freq", &dvbin_param_freq, CONF_TYPE_INT, 0, 0, 1, NULL}, + {"pol", &dvbin_param_pol, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"srate", &dvbin_param_srate, CONF_TYPE_INT, 0, 0, 1, NULL}, + {"vid", &dvbin_param_vid, CONF_TYPE_INT, 0, 0, 1, NULL}, + {"aid", &dvbin_param_aid, CONF_TYPE_INT, 0, 0, 1, NULL}, + {NULL, NULL, 0, 0, 0, 0, NULL} +}; +#endif + extern int sws_chr_vshift; extern int sws_chr_hshift; diff -Naur MPlayer-20021011/config.h MPlayer-20021011-dvb/config.h --- MPlayer-20021011/config.h Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/config.h Sat Oct 12 00:26:20 2002 @@ -0,0 +1,403 @@ +/* -------- This file has been automatically generated by configure --------- + Note: Any changes in it will be lost when you run configure again. */ + +/* use GNU internationalization */ +#define USE_I18N 1 + +/* use setlocale() function */ +#define USE_SETLOCALE 1 + +/* Runtime CPU detection */ +#undef RUNTIME_CPUDETECT + +/* "restrict" keyword */ +#define restrict __restrict + +#define PREFIX "/usr/local" + +/* define this to use simple idct with patched libavcodec */ +#define SIMPLE_IDCT 1 + +#define USE_OSD 1 +#define USE_SUB 1 + +/* enable/disable SIGHANDLER */ +#define ENABLE_SIGHANDLER 1 + +/* Toggles debugging informations */ +#undef MP_DEBUG + +/* Indicates that Ogle's libdvdread is available for DVD playback */ +#define USE_DVDREAD 1 + +/* Indicates that dvdread is from libmpdvdkit */ +#define USE_MPDVDKIT 2 + +/* Additional options for libmpdvdkit*/ +#undef DVD_STRUCT_IN_DVD_H +#define DVD_STRUCT_IN_LINUX_CDROM_H 1 +#undef DVD_STRUCT_IN_SYS_CDIO_H +#undef DVD_STRUCT_IN_SYS_DVDIO_H +#undef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H +#undef HAVE_BSD_DVD_STRUCT +#define HAVE_LINUX_DVD_STRUCT 1 +#undef HAVE_OPENBSD_DVD_STRUCT +#undef SOLARIS_USCSI +#undef HPUX_SCTL +#define HAVE_STDDEF_H 1 + +/* Common data directory (for fonts, etc) */ +#define DATADIR "/usr/local/share/mplayer" +#define CONFDIR "/usr/local/etc/mplayer" +#define LIBDIR "/usr/local/lib" + +/* Define this to compile stream-caching support, it can be enabled via + -cache */ +#define USE_STREAM_CACHE 1 + +/* Define to include support for XviD/Divx4Linux/OpenDivx */ +#define USE_DIVX 1 + +/* Define to use the new XviD/DivX4Linux library instead of open source OpenDivX */ +/* You have to change DECORE_LIBS in config.mak, too! */ +#define NEW_DECORE 1 + +/* Define if you are using DivX5Linux Decore library */ +#undef DECORE_DIVX5 + +/* Define if you are using XviD library */ +#define HAVE_XVID 1 + +/* Define if you have divx4.h in place of decore.h */ +#define HAVE_DIVX4_H 1 + +/* Define to include support for libdv-0.9.5 */ +#undef HAVE_LIBDV095 + +/* If build mencoder */ +#define HAVE_MENCODER + +/* Indicates if XviD/Divx4linux encore is available + Note: for mencoder */ +#define HAVE_DIVX4ENCORE 1 + +/* Indicates if libmp3lame is available + Note: for mencoder */ +#define HAVE_MP3LAME 1 + +/* Define libmp1e for realtime mpeg encoding (for DXR3 and DVB cards) */ +#undef USE_MP1E + +/* Define this to enable avg. byte/sec-based AVI sync method by default: + (use -bps or -nobps commandline option for run-time method selection) + -bps gives better sync for vbr mp3 audio, it is now default */ +#define AVI_SYNC_BPS 1 + +/* Undefine this if you do not want to select mono audio (left or right) + with a stereo MPEG layer 2/3 audio stream. The command line option + -stereo has three possible values (0 for stereo, 1 for left-only, 2 for + right-only), with 0 being the default. + */ +#define USE_FAKE_MONO 1 + +/* Undefine this if your sound card driver has no working select(). + If you have kernel Oops, player hangups, or just no audio, you should + try to recompile MPlayer with this option disabled! */ +#define HAVE_AUDIO_SELECT 1 + +/* define this to use iconv(3) function to codepage conversions */ +#define USE_ICONV 1 + +/* define this to use RTC (/dev/rtc) for video timers (LINUX only) */ +#define HAVE_RTC 1 + +/* set up max. outburst. use 65536 for ALSA 0.5, for others 16384 is enough */ +#define MAX_OUTBURST 65536 + +/* set up audio OUTBURST. Do not change this! */ +#define OUTBURST 512 + +/* Define this if your system has the header file for the OSS sound interface */ +#define HAVE_SYS_SOUNDCARD_H 1 + +/* Define this if your system has the header file for the OSS sound interface + * in /usr/include */ +#undef HAVE_SOUNDCARD_H + +/* Define this if your system has the sysinfo header */ +#define HAVE_SYS_SYSINFO_H 1 + +/* Define this if your system uses ftello() for off_t seeking */ + +#define HAVE_FTELLO 1 +#ifndef HAVE_FTELLO +# define ftello(a) ftell(a) +#endif + +/* Define this if your system has the "malloc.h" header file */ +#define HAVE_MALLOC_H 1 + +/* memalign is mapped to malloc if unsupported */ +#define HAVE_MEMALIGN 1 +#ifndef HAVE_MEMALIGN +# define memalign(a,b) malloc(b) +#endif + +/* Define this if your system has the "alloca.h" header file */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your system has the "sys/mman.h" header file */ +#define HAVE_SYS_MMAN_H 1 + +/* Define this if you have the elf dynamic linker -ldl library */ +#define HAVE_LIBDL 1 + +/* Define this if you have the kstat kernel statistics library */ +#undef HAVE_LIBKSTAT + +/* Define this if you have zlib */ +#define HAVE_ZLIB 1 + +/* Define this if you have shm support */ +#define HAVE_SHM 1 + +/* Define this if your system has strsep */ +#define HAVE_STRSEP 1 + +/* Define this if your system has vsscanf */ +#define HAVE_VSSCANF 1 + +/* LIRC (remote control, see www.lirc.org) support: */ +#undef HAVE_LIRC + +/* DeCSS support using libcss */ +#undef HAVE_LIBCSS + +/* DVD navigation support using libdvdnav */ +#undef USE_DVDNAV + + +/* Define this to enable MPEG 1/2 image postprocessing (requires a FAST CPU!) */ +#define MPEG12_POSTPROC 1 + +/* Define this to enable image postprocessing in libavcodec (requires a FAST CPU!) */ +#undef FF_POSTPROCESS + +/* Define to include support for OpenDivx postprocessing */ +#undef HAVE_ODIVX_POSTPROCESS + +/* Win32 DLL support */ +#define USE_WIN32DLL 1 + +/* DirectShow support */ +#define USE_DIRECTSHOW 1 + +/* ffmpeg's libavcodec support (requires libavcodec source) */ +#undef USE_LIBAVCODEC +#undef USE_LIBAVCODEC_SO + +/* Use libavcodec's decoders */ +#define CONFIG_DECODERS 1 +/* Use libavcodec's encoders */ +#define CONFIG_ENCODERS 1 + +/* Use libfame encoder filter */ +#define USE_LIBFAME 1 + +/* XAnim DLL support */ +#undef USE_XANIM +/* Default search path */ +#undef XACODEC_PATH + +/* RealPlayer DLL support */ +#define USE_REALCODECS 1 +/* Default search path */ +#define REALCODEC_PATH "/usr/local/RealPlayer8/Codecs" + +/* LIVE.COM Streaming Media library support */ +#undef STREAMING_LIVE_DOT_COM + +/* Use 3dnow/mmxext/sse/mmx optimized fast memcpy() [maybe buggy... signal 4]*/ +#define USE_FASTMEMCPY 1 + +/* Use unrarlib for Vobsubs */ +#define USE_UNRARLIB 1 + +/* gui support, please do not edit this option */ +#undef HAVE_NEW_GUI + +/* Audio output drivers */ +#define USE_OSS_AUDIO 1 +#define PATH_DEV_DSP "/dev/dsp" +#define PATH_DEV_MIXER "/dev/mixer" +#define HAVE_ALSA5 1 +#undef HAVE_ALSA9 + +#define HAVE_SYS_ASOUNDLIB_H 1 +#undef HAVE_ALSA_ASOUNDLIB_H +#undef USE_SUN_AUDIO +#undef USE_SGI_AUDIO +#undef HAVE_NAS + +/* Enable fast OSD/SUB renderer (looks ugly, but uses less CPU power) */ +#undef FAST_OSD +#undef FAST_OSD_TABLE + +/* Enable TV Interface support */ +#define USE_TV 1 + +/* Enable Video 4 Linux TV interface support */ +#undef HAVE_TV_V4L + +/* Enable *BSD BrookTree TV interface support */ +#undef HAVE_TV_BSDBT848 + +/* Define if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +#define ARCH_X86 1 + +/* Define this for Cygwin build for win32 */ + + +/* Define this to any prefered value from 386 up to infinity with step 100 */ +#define __CPU__ 686 + +#define MP_WORDSIZE 32 + +#define TARGET_LINUX 1 + +#define HAVE_VCD 1 + +#ifdef sun +#define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" +#define DEFAULT_DVD_DEVICE DEFAULT_CDROM_DEVICE +#elif defined(HPUX) +#define DEFAULT_CDROM_DEVICE "/dev/cdrom" +#define DEFAULT_DVD_DEVICE "/dev/dvd" +#elif defined(WIN32) +#define DEFAULT_CDROM_DEVICE "D:" +#define DEFAULT_DVD_DEVICE "D:" +#else +#define DEFAULT_CDROM_DEVICE "/dev/cdrom" +#define DEFAULT_DVD_DEVICE "/dev/dvd" +#endif + + +/*---------------------------------------------------------------------------- +** +** NOTE: Instead of modifying these definitions here, use the +** --enable/--disable options of the ./configure script! +** See ./configure --help for details. +** +*---------------------------------------------------------------------------*/ + +/* nanosleep support */ +#define HAVE_NANOSLEEP 1 + +/* termcap flag for getch2.c */ +#undef USE_TERMCAP + +/* termios flag for getch2.c */ +#define HAVE_TERMIOS 1 +#undef HAVE_TERMIOS_H +#define HAVE_SYS_TERMIOS_H 1 + +/* enable PNG support */ +#define HAVE_PNG 1 + +/* enable JPEG support */ +#define HAVE_JPEG 1 + +/* enable GIF support */ +#define HAVE_GIF 1 +#define HAVE_GIF_4 1 + +/* enable FreeType support */ +#undef HAVE_FREETYPE + +/* libmad support */ +#define USE_LIBMAD 1 + +/* enable OggVorbis support */ +#define HAVE_OGGVORBIS 1 + +/* enable FAAD (AAC) support */ +#define HAVE_FAAD 1 + +/* enable streaming */ +#define STREAMING 1 + +/* define this to use inet_aton() instead of inet_pton() */ +#undef USE_ATON + +/* enables / disables cdparanoia support */ +#undef HAVE_CDDA + +/* enables / disables vidix usage */ +#define CONFIG_VIDIX 1 + +/* enables / disables new input joystick support */ +#undef HAVE_JOYSTICK + +/* Extension defines */ +#define HAVE_3DNOW 1 // only define if you have 3DNOW (AMD k6-2, AMD Athlon, iDT WinChip, etc.) +#define HAVE_3DNOWEX 1 // only define if you have 3DNOWEX (AMD Athlon, etc.) +#define HAVE_MMX 1 // only define if you have MMX (newer x86 chips, not P54C/PPro) +#define HAVE_MMX2 1 // only define if you have MMX2 (Athlon/PIII/4/CelII) +#define HAVE_SSE 1 // only define if you have SSE (Intel Pentium III/4 or Celeron II) +#undef HAVE_SSE2 // only define if you have SSE2 (Intel Pentium 4) + +#ifdef HAVE_MMX +#define USE_MMX_IDCT 1 +#endif + +#undef HAVE_MLIB // Sun mediaLib, available only on solaris + +/* libmpeg2 uses a different feature test macro for mediaLib */ +#ifdef HAVE_MLIB +#define LIBMPEG2_MLIB 1 +#endif + +/* libvo options */ +#define SCREEN_SIZE_X 1 +#define SCREEN_SIZE_Y 1 +#define HAVE_X11 1 +#define HAVE_XV 1 +#define HAVE_XF86VM 1 +#define HAVE_XINERAMA 1 +#define HAVE_GL 1 +#define HAVE_DGA 1 +#define HAVE_DGA2 1 +#define HAVE_SDL 1 +/* defined for SDLlib with keyrepeat bugs (before 1.2.1) */ +#undef BUGGY_SDL +#undef HAVE_DIRECTX +#undef HAVE_GGI +#undef HAVE_3DFX +#undef HAVE_TDFXFB +#undef HAVE_DIRECTFB + +#undef HAVE_ZR +#undef HAVE_BL +#undef HAVE_MGA +#undef HAVE_XMGA + +#define HAVE_FBDEV 1 + +#undef HAVE_DXR2 +#undef HAVE_DXR3 +#define HAVE_DVB 1 +#undef HAVE_SVGALIB +#define HAVE_VESA 1 +#define HAVE_XDPMS 1 +#undef HAVE_AA + +/* used by GUI: */ + + +#if defined(HAVE_GL) || defined(HAVE_X11) || defined(HAVE_XV) +#define X11_FULLSCREEN 1 +#endif + diff -Naur MPlayer-20021011/config.mak MPlayer-20021011-dvb/config.mak --- MPlayer-20021011/config.mak Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/config.mak Sat Oct 12 00:26:20 2002 @@ -0,0 +1,122 @@ +# -------- Generated by configure ----------- + +LANG = C +TARGET_OS = Linux +DESTDIR = +prefix = $(DESTDIR)/usr/local +BINDIR = $(DESTDIR)/usr/local/bin +DATADIR = $(DESTDIR)/usr/local/share/mplayer +MANDIR = $(DESTDIR)/usr/local/man +CONFDIR = $(DESTDIR)/usr/local/etc/mplayer +LIBDIR = $(DESTDIR)/usr/local/lib +#AR = ar +CC = gcc +AWK = gawk +RANLIB = ranlib +# OPTFLAGS = -O4 -march=athlon -mcpu=athlon -pipe -fomit-frame-pointer -ffast-math +OPTFLAGS = -O4 -march=athlon -mcpu=athlon -pipe -ffast-math -fomit-frame-pointer -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +EXTRA_INC = +WIN32_PATH = -DWIN32_PATH=\"/usr/lib/win32\" +STRIPBINARIES = yes + + + +STREAMING = yes +STREAMING_LIVE_DOT_COM = no +STREAMING_LIB = -lnsl +VIDIX = yes + +OPENDIVX = no + +UNRARLIB = yes + +PNG = yes +JPEG = yes +GIF = yes + +EXTRA_LIB = +Z_LIB = -lz +HAVE_MLIB = no +STATIC_LIB = + +X11_INC = +X11DIR = -L/usr/X11R6/lib -lXext -lX11 -lnsl + +# for libavcodec: +SRC_PATH=. + +# video output +X_LIB = -lGL -lXxf86dga -lXv -lXxf86vm -lXinerama -L/usr/X11R6/lib -lXext -lX11 -lnsl -lmad -lnsl +GGI_LIB = +MLIB_LIB = +MLIB_INC = +DXR2_INC = +DVB_INC = +PNG_LIB = -lpng -lz +JPEG_LIB = -ljpeg +GIF_LIB = -lgif +SDL_LIB = -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -lpthread +DIRECTX_LIB = +SVGA_LIB = +AA_LIB = + +# audio output +ALSA_LIB = -lasound -ldl -lpthread +NAS_LIB = +MAD_LIB = -lmad +ARTS_LIB = +ARTS_INC = +VORBIS_LIB = -lvorbis -logg +FAAD_LIB = -lfaad +SGIAUDIO_LIB = + +# input +TERMCAP_LIB = +LIRC_LIB = +CSS_USE = no +CSS_LIB = -Llibmpdvdkit2 -lmpdvdkit +DVDKIT = no +DVDKIT2 = yes +DVDKIT_SHARED = no +SDL_INC = -I/usr/local/include -I/usr/local/include/SDL -D_REENTRANT +W32_DEP = loader/libloader.a +W32_LIB = loader/libloader.a +DS_DEP = loader/dshow/libDS_Filter.a +DS_LIB = loader/dshow/libDS_Filter.a +AV_DEP = +AV_LIB = +FAME = yes +FAME_LIB = libfame/libfame.a +MP1E_DEP = +MP1E_LIB = +ARCH_LIB = -lpthread -ldl -rdynamic +DIVX4LINUX = no +XVID = yes +XVID_LIB = -lxvidcore +DECORE_LIB = +MENCODER = yes +ENCORE_LIB = -lxvidcore -lmp3lame -lvorbis -logg +DIRECTFB_INC = +DIRECTFB_LIB = +CDPARANOIA_INC = +CDPARANOIA_LIB = +FREETYPE_INC = +FREETYPE_LIB = + +# --- Some stuff for autoconfigure ---- +TARGET_ARCH_X86 = yes +TARGET_CYGWIN = no +TARGET_CPU=686 +TARGET_MMX = yes +TARGET_MMX2 = yes +TARGET_3DNOW = yes +TARGET_3DNOWEX = yes +TARGET_SSE = yes + +# --- GUI stuff --- +GTKLIB = +GLIBLIB = +GTK_LIBS = +GUI = no +DEBUG = -DDEBUG + diff -Naur MPlayer-20021011/help_mp.h MPlayer-20021011-dvb/help_mp.h --- MPlayer-20021011/help_mp.h Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/help_mp.h Sat Oct 12 00:26:20 2002 @@ -0,0 +1,5 @@ +// +// WARNING! This is a generated file. Do NOT edit. +// See the help/ subdir for the editable files. +// +#include "help/help_mp-en.h" diff -Naur MPlayer-20021011/libao2/config.mak MPlayer-20021011-dvb/libao2/config.mak --- MPlayer-20021011/libao2/config.mak Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libao2/config.mak Sat Oct 12 00:26:20 2002 @@ -0,0 +1,3 @@ +include ../config.mak +OPTIONAL_SRCS = ao_sdl.c ao_oss.c ao_alsa5.c +OPTIONAL_OBJS = ao_sdl.o ao_oss.o ao_alsa5.o diff -Naur MPlayer-20021011/libmpdemux/Makefile MPlayer-20021011-dvb/libmpdemux/Makefile --- MPlayer-20021011/libmpdemux/Makefile Tue Sep 17 21:53:04 2002 +++ MPlayer-20021011-dvb/libmpdemux/Makefile Sat Oct 12 00:18:13 2002 @@ -17,6 +17,14 @@ endif endif +DVBIN = yes +ifeq ($(DVBIN),yes) +SRCS += dvbin.c +SRCS += dvb_conf.c +SRCS += ts2ps.c +else +endif + OBJS = $(SRCS:.c=.o) OBJS += $(CPLUSPLUSSRCS:.cpp=.o) INCLUDE = -I../loader $(CSS_INC) $(EXTRA_INC) diff -Naur MPlayer-20021011/libmpdemux/dvb_conf.c MPlayer-20021011-dvb/libmpdemux/dvb_conf.c --- MPlayer-20021011/libmpdemux/dvb_conf.c Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libmpdemux/dvb_conf.c Fri Oct 4 22:52:16 2002 @@ -0,0 +1,89 @@ +#include +#include + +#include "dvbin.h" + +dvb_channels_list *dvb_get_channels(char *filename, dvb_channels_list *list) +{ + FILE *f; + uint8_t apid1, apid2, dpid1, dpid2, i, line[128]; + int fields, row_count; + dvb_channel_t *ptr; + char *p, *pname, *apidbuf; + + fprintf(stderr, "CONFIG_READ : %s\n", filename); + if((f=fopen(filename, "r"))==NULL) + { + fprintf(stderr, "CAN'T READ CONFIG FILE %s\n", filename); + return NULL; + } + + list->NUM_CHANNELS = 0; + row_count = 0; + while(! feof(f) && row_count < 512) + { + if( fgets(line, 128, f) == NULL ) continue; + + + + i = 0; + while(isspace(line[i]) && (i < 128)) i++; + + if(i >= 128) + continue; //empty line + + + if(line[i] == '#') + continue; //comment line + + if(! strlen(&line[i])) + continue; + + ptr = &(list->channels[ list->NUM_CHANNELS ]); + + + if(line[i] == ':') + continue; + + pname = index(&line[i], ':'); + if(pname) + { + int len = (int) (pname - (char *) &line[i]); + strncpy(ptr->name, &line[i], len); + } + fields = sscanf(pname+1, "%d :%c:%d :%d :%d :%d:%d :%d :%d ", &ptr->freq, &ptr->pol, &ptr->diseqc, &ptr->srate, &ptr->vpid, &ptr->apid1, &ptr->tpid, &ptr->ca, &ptr->progid); + + ptr->pol = toupper(ptr->pol); + ptr->freq *= 1000UL; + ptr->srate *= 1000UL; + + /* + + ptr->apid1 = ptr->apid2 = 0; + if(p = strchr(apidbuf, ';')) + { + *p++ = 0; + sscanf(apidbuf, "%d ,%d ", &ptr->apid1, &ptr->apid2); + if (p) + sscanf(p, "%d ,%d ", &ptr->dpid1, &ptr->dpid2); + } + else + { + ptr->apid1 = atoi(apidbuf); + ptr->apid1 = 0; + } + + */ + + fprintf(stderr, "NAME: %s, FREQ: %d, SRATE: %d, POL: %c, VPID: %d, APID1: %d, APID2: %d, TPID: %d, PROGID: %d, NUM: %d\n", + ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->vpid, ptr->apid1, ptr->apid2, ptr->tpid, ptr->progid, list->NUM_CHANNELS); + + list->NUM_CHANNELS++; + row_count++; + } + + fclose(f); + fprintf(stderr, "ESCO \n"); + return list; +} + diff -Naur MPlayer-20021011/libmpdemux/dvb_conf.h MPlayer-20021011-dvb/libmpdemux/dvb_conf.h --- MPlayer-20021011/libmpdemux/dvb_conf.h Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libmpdemux/dvb_conf.h Fri Oct 4 20:44:16 2002 @@ -0,0 +1,22 @@ + +#ifndef __DVB_CONF_H__ +#define __DVB_CONF_H__ + + +#define uint8_t unsigned char +#define uint16_t unsigned short int +typedef struct { + char name[128]; + int freq, srate, diseqc; + char pol; + int vpid, apid1, apid2, tpid, dpid1, dpid2, progid, ca; +} dvb_channel_t; + +typedef struct { + uint16_t NUM_CHANNELS, current = 0; + dvb_channel_t channels[512]; +} dvb_channels_list; + +dvb_channels_list *dvb_get_channels(char *, dvb_channels_list *); + +#endif diff -Naur MPlayer-20021011/libmpdemux/dvbin.c MPlayer-20021011-dvb/libmpdemux/dvbin.c --- MPlayer-20021011/libmpdemux/dvbin.c Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libmpdemux/dvbin.c Fri Oct 11 23:15:11 2002 @@ -0,0 +1,715 @@ +/* + +dvbstream +(C) Dave Chapman 2001, 2002. + +The latest version can be found at http://www.linuxstb.org/dvbstream + +Copyright notice: + +This program 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. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +// Linux includes: +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// DVB includes: +#include +#include +#include +#include "stream.h" +#include "../cfgparser.h" +#include "dvbin.h" + +extern void ts_to_pes(int, int, int, int); +extern int video_id, audio_id; + + +#define slof (11700*1000UL) +#define lof1 (9750*1000UL) +#define lof2 (10600*1000UL) +#define MAX_CHANNELS 8 + + +int dvbin_param_on, dvbin_param_freq, dvbin_param_srate, dvbin_param_vid, dvbin_param_aid, dvbin_is_active = 0; +char *dvbin_param_pol = "V"; + +char* frontenddev[4]={"/dev/ost/frontend0", "/dev/ost/frontend1", "/dev/ost/frontend2", "/dev/ost/frontend3"}; +char* dvrdev[4]={"/dev/ost/dvr0", "/dev/ost/dvr1", "/dev/ost/dvr2", "/dev/ost/dvr3"}; +char* secdev[4]={"/dev/ost/sec0", "/dev/ost/sec1", "/dev/ost/sec2", "/dev/ost/sec3"}; +char* demuxdev[4]={"/dev/ost/demux0", "/dev/ost/demux1", "/dev/ost/demux2", "/dev/ost/demux3"}; +int card=0; +int pipe_fd[2], pipe_fd2[2]; + + +int dvb_streaming_seek(int fd, off_t pos, streaming_ctrl_t *stream_ctrl) +{ + return -1; +} + + + +int open_fe(int* fd_frontend, int* fd_sec) +{ + if((*fd_frontend = open(frontenddev[card], O_RDWR)) < 0) + { + perror("ERROR IN OPENING FRONTEND DEVICE: "); + return -1; + } + + if (fd_sec != 0) + { + if((*fd_sec = open(secdev[card], O_RDWR)) < 0) + { + perror("ERROR IN OPENING SEC DEVICE: "); + return -1; + } + } + return 1; +} + + +long getmsec() +{ + struct timeval tv; + gettimeofday(&tv, (struct timezone*) NULL); + return(tv.tv_sec%1000000)*1000 + tv.tv_usec/1000; +} + + + + +int set_ts_filt(int fd, uint16_t pid, dmxPesType_t pestype) +{ + int i; + struct dmxPesFilterParams pesFilterParams; + + pesFilterParams.pid = pid; + pesFilterParams.input = DMX_IN_FRONTEND; + pesFilterParams.output = DMX_OUT_TS_TAP; + pesFilterParams.pesType = pestype; + pesFilterParams.flags = DMX_IMMEDIATE_START; + + if ((i = ioctl(fd, DMX_SET_PES_FILTER, &pesFilterParams)) < 0) + { + mp_msg(MSGT_DEMUX, MSGL_DBG2, "ERROR IN SETTING DMX_FILTER %i: ", pid); + perror("DMX SET PES FILTER"); + } + + fprintf(stderr, "SET PES FILTER ON PID %d, RESULT: %d\n", pid, i ); + return 1; +} + + +static int demux_stop(int fd) +{ + int i; + i = ioctl(fd, DMX_STOP); + + fprintf(stderr, "STOPPING FD: %d, RESULT: %d\n", fd, i); + + return (i==0); +} + + + +void make_nonblock(int f) +{ + int oldflags; + + if ((oldflags=fcntl(f, F_GETFL, 0)) < 0) + { + perror("ERROR IN F_GETFL"); + } + + oldflags|=O_NONBLOCK; + if (fcntl(f, F_SETFL, oldflags) < 0) + { + perror("F_SETFL"); + } +} + + + +int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate) +{ + /* INPUT: frequency, polarization, srate */ + if(freq > 100000000) + { + if(open_fe(&(priv->fe_fd), 0)) + { + + tune_it(priv->fe_fd, 0, freq, 0, 0); + + close(priv->fe_fd); + } + else + return 0; + } + else if ((freq != 0) && (pol != 0) && (srate != 0)) + { + if (open_fe(&(priv->fe_fd), &(priv->sec_fd))) + { + + tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol); + close(priv->fe_fd); + close(priv->sec_fd); + } + else + return 0; + } + + priv->freq = freq; + priv->srate = srate; + priv->pol = pol; + + return 1; +} + + + + +int dvb_streaming_read(int fd, char *buffer, unsigned int size, dvb_priv_t *priv) +{ + uint8_t tmp[188]; + struct pollfd pfds[1], p[1]; + uint8_t hlen; + int ok = 0, pos = 0, count, k, tot = 0, rk, mpid; + + mp_msg(MSGT_DEMUX, MSGL_V, "dvb_streaming_read(%u), PIPE: %d, %d\n", fd, priv->input, priv->output); + + + while(pos < size) + { + ok = 0; + tot = 0; + pfds[0].fd = fd; + pfds[0].events = POLLIN | POLLPRI; + + mp_msg(MSGT_DEMUX, MSGL_V, "DEVICE: %d, DVR: %d, PIPE: %d <-> %d\n", fd, priv->dvr_fd, priv->input, priv->output); + while(! ok) + { + poll(pfds, 1, 500); + if((rk = read(fd, tmp, 188)) > 0) + { + tot += rk; + + mpid = ((tmp[1] & 0x1f) << 8) | (tmp[2]); + tmp[1] &= 0xE0; + if(mpid == priv->vpid) + tmp[2] = 1; + else + tmp[2] = 2; + + + mp_msg(MSGT_DEMUX, MSGL_V, "SCRIVO %x....", tot); + + while((k = write(priv->output, tmp, rk)) < 0) + { + mp_msg(MSGT_DEMUX, MSGL_V, "SCRITTURA SU PIPE FALLITA: %d\n", errno); + } + ok = 1; + + + k = read(priv->input, &buffer[pos], size-pos); + if(k > 0) + { + pos += k; + mp_msg(MSGT_DEMUX, MSGL_V, "OKOKOK LETTI DA PIPE %d BYTES, posizione %d \n", k, pos); + } + else + mp_msg(MSGT_DEMUX, MSGL_V, "LETTURA DA PIPE FALLITA: %d\n", errno); + } + } + } + + mp_msg(MSGT_DEMUX, MSGL_V, "RETURN %d BYTES \n", pos); + + return pos; +} + + + +int tune_it(int fd_frontend, int fd_sec, unsigned long freq, unsigned long srate, char pol) +{ + int i,res; + int32_t strength; + FrontendStatus festatus; + FrontendEvent event; + FrontendParameters feparams; + secToneMode tone; + secVoltage voltage; + + if (freq > 100000000) + { + mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %u\n",freq); + feparams.Frequency=freq; + feparams.u.ofdm.bandWidth=BANDWIDTH_8_MHZ; // WAS: 8 + feparams.u.ofdm.HP_CodeRate=FEC_2_3; + feparams.u.ofdm.LP_CodeRate=FEC_1_2; + feparams.u.ofdm.Constellation=QAM_64; // WAS: 16 + feparams.u.ofdm.TransmissionMode=TRANSMISSION_MODE_2K; + feparams.u.ofdm.guardInterval=GUARD_INTERVAL_1_32; + feparams.u.ofdm.HierarchyInformation=HIERARCHY_NONE; + } + else + { + mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-S to %d%c %d\n",freq,pol,srate); + if (freq < slof) + { + feparams.Frequency=(freq-lof1); + tone = SEC_TONE_OFF; + } + else + { + feparams.Frequency=(freq-lof2); + tone = SEC_TONE_ON; + } + feparams.Inversion=INVERSION_AUTO; + + if ((pol=='h') || (pol=='H')) + { + voltage = SEC_VOLTAGE_18; + } + else + { + voltage = SEC_VOLTAGE_13; + } + + feparams.u.qpsk.SymbolRate=srate; + feparams.u.qpsk.FEC_inner=FEC_AUTO; + + if (ioctl(fd_sec,SEC_SET_TONE,tone) < 0) + { + perror("ERROR setting tone\n"); + } + + if (ioctl(fd_sec,SEC_SET_VOLTAGE,voltage) < 0) + { + perror("ERROR setting voltage\n"); + } + usleep(200000); + } + + if (ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0) + { + perror("ERROR tuning channel\n"); + } + else + { + fprintf(stderr, "Channel tuned\n"); + } + + usleep(5000000); + i=10; + + res = ioctl(fd_frontend, FE_GET_EVENT, &event); + while ((i<10) && (res < 0)) + { + res = ioctl(fd_frontend, FE_GET_EVENT, &event); + i--; + } + + if (res < 0) + perror("qpsk get event"); + else + switch (event.type) + { + case FE_UNEXPECTED_EV: fprintf(stderr, "FE_UNEXPECTED_EV\n"); + break; + case FE_COMPLETION_EV: fprintf(stderr, "FE_COMPLETION_EV\n"); + break; + case FE_FAILURE_EV: fprintf(stderr, "FE_FAILURE_EV\n"); + break; + } + + if (freq > 100000000) + { + fprintf(stderr, "Event: iFrequency: %ld\n",event.u.completionEvent.Frequency); + } + else + { + fprintf(stderr, "Event: iFrequency: %ld\n",(event.u.completionEvent.Frequency)+(tone==SEC_TONE_OFF ? lof1 : lof2)); + fprintf(stderr, " SymbolRate: %ld\n",event.u.completionEvent.u.qpsk.SymbolRate); + fprintf(stderr, " FEC_inner: %d\n",event.u.completionEvent.u.qpsk.FEC_inner); + fprintf(stderr, "\n"); + + ioctl(fd_frontend, FE_READ_STATUS, &feparams); + fprintf(stderr, "Status: iFrequency: %ld\n", (feparams.Frequency)+(tone==SEC_TONE_OFF ? lof1 : lof2)); + fprintf(stderr, " SymbolRate: %ld\n", feparams.u.qpsk.SymbolRate); + fprintf(stderr, " FEC_inner: %d\n", feparams.u.qpsk.FEC_inner); + } + + strength=0; + ioctl(fd_frontend,FE_READ_BER,&strength); + fprintf(stderr, "Bit error rate: %ld\n", strength); + + strength=0; + ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength); + fprintf(stderr, "Signal strength: %ld\n", strength); + + strength=0; + ioctl(fd_frontend, FE_READ_SNR, &strength); + fprintf(stderr, "SNR: %ld\n", strength); + + festatus=0; + ioctl(fd_frontend, FE_READ_STATUS, &festatus); + + fprintf(stderr,"FE_STATUS:"); + if (festatus & FE_HAS_POWER) fprintf(stderr," FE_HAS_POWER"); + if (festatus & FE_HAS_SIGNAL) fprintf(stderr," FE_HAS_SIGNAL"); + if (festatus & FE_SPECTRUM_INV) fprintf(stderr," FE_SPECTRUM_INV"); + if (festatus & FE_HAS_LOCK) fprintf(stderr," FE_HAS_LOCK"); + if (festatus & FE_HAS_CARRIER) fprintf(stderr," FE_HAS_CARRIER"); + if (festatus & FE_HAS_VITERBI) fprintf(stderr," FE_HAS_VITERBI"); + if (festatus & FE_HAS_SYNC) fprintf(stderr," FE_HAS_SYNC"); + if (festatus & FE_TUNER_HAS_LOCK) fprintf(stderr," FE_TUNER_HAS_LOCK"); + fprintf(stderr,"\nTUNING SUCCESSFUL, EXITING\n\n"); + + return 1; +} + + +int dvb_clear_buffers(dvb_priv_t *priv) +{ + char tmp[188]; + + fprintf(stderr, "CLEARING DVR BUFFER\n"); + while(read(priv->dvr_fd, tmp, 188) > 0); + + fprintf(stderr, "CLEARING TS2PS BUFFER\n"); + while(read(priv->input, tmp, 188) > 0); + + fprintf(stderr, "EXIT\n"); +} + + +int dvb_step_channel(dvb_priv_t *priv, int dir) +{ + int new_freq, new_srate, new_vpid, new_apid, new_current; + char new_pol; + dvb_channel_t *next; + dvb_channels_list *list; + + if(priv == NULL) + { + fprintf(stderr, "dvb_step_channel: PRIV NULL PTR, quit\n"); + return 0; + } + + list = priv->list; + if(list == NULL) + { + fprintf(stderr, "dvb_step_channel: LIST NULL PTR, quit\n"); + return 0; + } + + fprintf(stderr, "DVB_STEP_CHANNEL direzione %d\n", dir); + + if(dir == DVB_CHANNEL_HIGHER) + { + if(list->current == list->NUM_CHANNELS) + return 0; + + new_current = list->current + 1; + next = &(list->channels[new_current]); + + } + else + { + if(list->current == 0) + return 0; + + new_current = list->current - 1; + next = &(list->channels[new_current]); + + } + + new_freq = next->freq; + new_srate = next->srate; + new_pol = next->pol; + new_vpid = next->vpid; + new_apid = next->apid1; + + demux_stop(priv->demux_fd[0]); + demux_stop(priv->demux_fd[1]); + + //LET'S CLEAR THE BUFFERS + dvb_clear_buffers(priv); + + + if((new_freq != priv->freq) || (new_srate != priv->srate) || (new_pol != priv->pol)) + { + fprintf(stderr, "TUNE OLD: %d %d %c, NEW: %d %d %c\n", priv->freq, priv->srate, priv->pol, new_freq, new_srate, new_pol); + + if(! dvb_tune(priv, new_freq, new_pol, new_srate)) + return 0; + + } + + fprintf(stderr, "PIDS: [%d, %d] ---> [%d, %d]\n", priv->vpid, priv->apid, new_vpid, new_apid); + + if(! set_ts_filt(priv->demux_fd[0], new_vpid, DMX_PES_VIDEO)) + return 0; + if(! set_ts_filt(priv->demux_fd[1], new_apid, DMX_PES_AUDIO)) + return 0; + + + priv->freq = new_freq; + priv->srate = new_srate; + priv->pol = new_pol; + priv->vpid = new_vpid; + priv->apid = new_apid; + + + list->current = new_current; + + + + fprintf(stderr, "DVB_STEP_CHANNEL, NAME: %s, CURRENT: %d FREQ: %d, POL: %c, SRATE: %d, VPID: %d, APID: %d\n\n", next->name, priv->list->current, new_freq, new_pol, new_srate, new_vpid, new_apid); + return 1; +} + +extern char *get_path(char *); + +int dvb_streaming_start(stream_t *stream) +{ + int pids[MAX_CHANNELS]; + int pestypes[MAX_CHANNELS]; + int npids, i; + unsigned char c; + char *filename; + + unsigned long freq = 0; + char pol = 0; + unsigned long srate = 0; + + char* ch; + dmxPesType_t pestype; + + FILE *f, *f2; + dvb_priv_t *priv; + dvb_channels_list list, *list_ptr; + + + streaming_ctrl_t *str_ctrl; + + stream->priv = (dvb_priv_t*) malloc(sizeof(dvb_priv_t)); + if(stream->priv == NULL) + return 0; + priv = (dvb_priv_t*) stream->priv; + + filename = get_path("channels.conf"); + + if(filename) + { + if((list_ptr = dvb_get_channels(filename, &list)) == NULL) + fprintf(stderr, "EMPTY CHANNELS LIST!\n"); + else + { + priv->list = list_ptr; + priv->list->current = 0; + + } + } + else + { + list_ptr = NULL; + fprintf(stderr, "NO CHANNELS FILE FOUND!\n"); + } + + mp_msg(MSGT_DEMUX, MSGL_V, "code taken from dvbstream for mplayer v0.4pre1 - (C) Dave Chapman 2001\n"); + mp_msg(MSGT_DEMUX, MSGL_V, "Released under the GPL.\n"); + mp_msg(MSGT_DEMUX, MSGL_V, "Latest version available from http://www.linuxstb.org/\n"); + mp_msg(MSGT_DEMUX, MSGL_V, "ON: %d, FREQ: %d, SRATE: %d, POL: %c, VID: %d, AID: %d\n", dvbin_param_on, + dvbin_param_freq, dvbin_param_srate, dvbin_param_pol, dvbin_param_vid, dvbin_param_aid); + + npids = 0; + if(dvbin_param_vid > 0) + { + mp_msg(MSGT_DEMUX, MSGL_V, "VID: dvbin_param_vid\n"); + priv->vpid = dvbin_param_vid; + pestypes[npids] = DMX_PES_VIDEO; + pids[npids] = dvbin_param_vid; + npids++; + } + + if(dvbin_param_aid > 0) + { + mp_msg(MSGT_DEMUX, MSGL_V, "AVID: dvbin_param_vid\n"); + priv->apid = dvbin_param_aid; + pestypes[npids] = DMX_PES_AUDIO; + pids[npids] = dvbin_param_aid; + npids++; + } + + if(pipe(pipe_fd)) + { + fprintf(stderr, "CAN'T PIPE(1), QUIT\n"); + exit(-1); + } + mp_msg(MSGT_DEMUX, MSGL_V, "PIPE1: %d, %d\n", pipe_fd[0], pipe_fd[1]); + + if(pipe(pipe_fd2)) + { + fprintf(stderr, "CAN'T PIPE(2), QUIT\n"); + exit(-1); + } + + if(fork()) + { + char tmp[6]; + priv->input = pipe_fd[0]; + priv->output = pipe_fd2[1]; + //close(pipe_fd[1]); + //close(pipe_fd2[0]); + + + + fcntl(priv->input, F_SETFL, O_NONBLOCK); //add + + fcntl(priv->output, F_SETFL, O_NONBLOCK); + + mp_msg(MSGT_DEMUX, MSGL_V, "PARENT: PIPE: %d, %d\n", pipe_fd[0], pipe_fd2[1]); + + + mp_msg(MSGT_DEMUX, MSGL_V, "PASSO 1\n"); + + pestype = DMX_PES_OTHER; // Default PES type + + freq = dvbin_param_freq * 1000UL; + srate = dvbin_param_srate * 1000UL; + mp_msg(MSGT_DEMUX, MSGL_DBG2, "PASSO 2\n"); + if(! strcmp(dvbin_param_pol, "V")) pol = 'V'; + else pol='H'; + + mp_msg(MSGT_DEMUX, MSGL_DBG2, "PASSO 3\n"); + card = 0; + + + //if(video_id && audio_id) + dvbin_param_on = 1; + + mp_msg(MSGT_DEMUX, MSGL_DBG2, "FREQ: %d, POL: %c, SRATE: %d, VPID: %d, APID: %d\n", freq, pol, srate, pids[0], pids[1]); + + priv->freq = freq; + priv->srate = srate; + priv->pol = pol; + + if(freq && pol && srate) + dvb_tune(priv, freq, pol, srate); + + for (i=0; i < npids; i++) + { + if((priv->demux_fd[i] = open(demuxdev[card], O_RDWR)) < 0) + { + fprintf(stderr, "ERROR OPENING DEMUX %i: ", i); + perror("DEMUX DEVICE: "); + return -1; + } + } + + if((priv->dvr_fd = open(dvrdev[card], O_RDONLY| O_NONBLOCK)) < 0) + { + perror("DVR DEVICE: "); + return -1; + } + + + /* Now we set the filters */ + for (i=0; i< npids; i++) + { + set_ts_filt(priv->demux_fd[i], pids[i], pestypes[i]); + //make_nonblock(fd[i]); + mp_msg(MSGT_DEMUX, MSGL_DBG2, "FD: %d, PIDS: %d, TYPES: %d\n", priv->demux_fd[i], pids[i], pestypes[i]); + } + + + + if((stream->streaming_ctrl = streaming_ctrl_new()) < 0) return -1; + mp_msg(MSGT_DEMUX, MSGL_DBG2, "HO LO STR_CTRL: %p\n", stream->streaming_ctrl); + + + stream->streaming_ctrl->streaming_read = dvb_streaming_read; + stream->streaming_ctrl->streaming_seek = dvb_streaming_seek; + stream->streaming_ctrl->status = streaming_playing_e; + + stream->fd = priv->dvr_fd; + + dvbin_is_active = 1; + + /* + signal(SIGALRM, change_channel); + alarm(10); + */ + + mp_msg(MSGT_DEMUX, MSGL_V, "ESCO da dvb_streaming_start(s)\n"); + + return 1; + } + else + { + //child + int k, in, out; + char tmp[6]; + + mp_msg(MSGT_DEMUX, MSGL_V, "CHILD: PIPE: %d, %d\n", pipe_fd2[0], pipe_fd[1]); + priv->input = pipe_fd2[0]; + priv->output = pipe_fd[1]; + //close(pipe_fd[0]); + //close(pipe_fd2[1]); + + + fcntl(priv->output, F_SETFL, O_NONBLOCK); + fclose(stdin); + in = dup(priv->input); + fprintf(stderr, "dup(1): %d\n", in); + + fclose(stdout); + out = dup(priv->output); + fprintf(stderr, "dup(2): %d\n", out); + + ts_to_pes(priv->input, 1, 2, 0); + exit; + + } +} + +int dvbin_close(dvb_priv_t *priv) +{ + fprintf(stderr, "DVBIN-CLOSE\n"); + //close(priv->dvr_fd); + close(priv->demux_fd[0]); + close(priv->demux_fd[1]); +} diff -Naur MPlayer-20021011/libmpdemux/dvbin.h MPlayer-20021011-dvb/libmpdemux/dvbin.h --- MPlayer-20021011/libmpdemux/dvbin.h Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libmpdemux/dvbin.h Sun Oct 6 19:51:11 2002 @@ -0,0 +1,62 @@ + +#ifndef DVBIN_H +#define DVBIN_H + +#include + +extern int dvbin_param_on; +extern int dvbin_param_stdout; +extern int dvbin_param_freq; +extern int dvbin_param_srate; +extern char *dvbin_param_pol; +extern int dvbin_param_vid; +extern int dvbin_param_aid; +extern int dvbin_is_active; + + +#define DVB_CHANNEL_LOWER -1 +#define DVB_CHANNEL_HIGHER 1 + + +typedef struct { + char name[128]; + int freq, srate, diseqc; + char pol; + int vpid, apid1, apid2, tpid, dpid1, dpid2, progid, ca; +} dvb_channel_t; + + +typedef struct { + uint16_t NUM_CHANNELS; + uint16_t current; + dvb_channel_t channels[512]; +} dvb_channels_list; + + + +typedef struct { + int vpid, apid, tpid; + int fe_fd; + int sec_fd; + int demux_fd[3]; + int dvr_fd; + int freq, srate; + char pol; + int input; + int output; + dvb_channels_list *list; +} dvb_priv_t; + + +/* +extern dvbin_handle_t *dvbin_begin(void); +extern int dvbin_init(); +extern int dvbin_uninit(dvbin_handle_t *); +*/ + +extern int dvb_step_channel(dvb_priv_t*, int); + +extern dvb_channels_list *dvb_get_channels(char *, dvb_channels_list *); + + +#endif diff -Naur MPlayer-20021011/libmpdemux/open.c MPlayer-20021011-dvb/libmpdemux/open.c --- MPlayer-20021011/libmpdemux/open.c Sun Oct 6 20:03:12 2002 +++ MPlayer-20021011-dvb/libmpdemux/open.c Sat Oct 12 00:20:48 2002 @@ -72,6 +72,12 @@ extern int stream_open_tv(stream_t *stream, tvi_handle_t *tvh); #endif +#ifdef HAVE_DVB +#include "dvbin.h" +#endif + + + #ifdef HAVE_CDDA stream_t* open_cdda(char* dev,char* track); #ifdef STREAMING @@ -428,6 +434,20 @@ mp_msg(MSGT_DVD,MSGL_V,"DVD start=%d end=%d \n",d->cur_pack,d->cur_pgc->cell_playback[d->last_cell-1].last_sector); stream->priv=(void*)d; return stream; +} +#endif + +#ifdef HAVE_DVB +if(dvbin_param_on == 1) +{ + stream = new_stream(-1, STREAMTYPE_DVB); + if (!stream) + return(NULL); + + if (!dvb_streaming_start(stream)) + return NULL; + + return stream; } #endif diff -Naur MPlayer-20021011/libmpdemux/stream.c MPlayer-20021011-dvb/libmpdemux/stream.c --- MPlayer-20021011/libmpdemux/stream.c Sun Oct 6 20:03:12 2002 +++ MPlayer-20021011-dvb/libmpdemux/stream.c Sat Oct 12 00:24:42 2002 @@ -100,6 +100,14 @@ case STREAMTYPE_DS: len = demux_read_data((demux_stream_t*)s->priv,s->buffer,STREAM_BUFFER_SIZE); break; +#ifdef HAVE_DVB + case STREAMTYPE_DVB: + if(s->streaming_ctrl != NULL) + { + len = s->streaming_ctrl->streaming_read(s->fd, s->buffer, STREAM_BUFFER_SIZE, s->priv); + break; + } +#endif default: len=0; } if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; } @@ -297,6 +305,12 @@ case STREAMTYPE_DVD: dvd_close(s->priv); #endif +#ifdef HAVE_DVB + case STREAMTYPE_DVB: + dvbin_close(s->priv); + break; +#endif + } if(s->priv) free(s->priv); free(s); diff -Naur MPlayer-20021011/libmpdemux/stream.h MPlayer-20021011-dvb/libmpdemux/stream.h --- MPlayer-20021011/libmpdemux/stream.h Sun Oct 6 20:03:12 2002 +++ MPlayer-20021011-dvb/libmpdemux/stream.h Sat Oct 12 00:21:49 2002 @@ -17,6 +17,7 @@ #define STREAMTYPE_DVDNAV 9 // we cannot safely "seek" in this... #define STREAMTYPE_CDDA 10 // raw audio CD reader #define STREAMTYPE_SMB 11 // smb:// url, using libsmbclient (samba) +#define STREAMTYPE_DVB 12 // MPEG2-TS #define STREAM_BUFFER_SIZE 2048 diff -Naur MPlayer-20021011/libmpdemux/ts2ps.c MPlayer-20021011-dvb/libmpdemux/ts2ps.c --- MPlayer-20021011/libmpdemux/ts2ps.c Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libmpdemux/ts2ps.c Sat Oct 12 00:49:55 2002 @@ -0,0 +1,757 @@ + +#include "ts2ps.h" +#include +#include +//#include "_ctools.h" + + + +uint32_t trans_pts_dts(uint8_t *pts) +{ + uint32_t wts; + + wts = (((pts[0] & 0x06) << 4) | + ((pts[1] & 0xFC) >> 2)) << 24; + wts |= (((pts[1] & 0x03) << 6) | + ((pts[2] & 0xFC) >> 2)) << 16; + wts |= (((pts[2] & 0x02) << 6) | + ((pts[3] & 0xFE) >> 1)) << 8; + wts |= (((pts[3] & 0x01) << 7) | + ((pts[4] & 0xFE) >> 1)); + return wts; +} + + +uint16_t get_pid(uint8_t *pid) +{ + uint16_t pp = 0; + + pp = (pid[0] & PID_MASK_HI)<<8; + pp |= pid[1]; + + return pp; +} + +#define IN_SIZE TS_SIZE*10 +#define IPACKS 2048 +#define TS_SIGNATURE 0x47 +#define TS_PAYLOAD_HAS_PES_OR_PSI 0x40 +#define TS_HAS_ADAPTION_FIELD 0x20 +#define TS_HAS_PAYLOAD 0x10 + +unsigned int bitrates[3][16]; +uint32_t freq[4]; + +void find_bavpids(uint8_t *buf, int count, uint16_t *vpid, uint16_t *apid) +{ + int i; + int founda = 0; + int foundb = 0; + int off = 0; + + *vpid = 0; + *apid = 0; + for (i = 0; i < count-7; i++) + { + if (buf[i] == TS_SIGNATURE) + { + if(buf[i+1] & TS_PAYLOAD_HAS_PES_OR_PSI) + //if ((buf[i+1] & 0xF0) == 0x40) + { + off = 0; + if ( buf[3+i] & TS_HAS_ADAPTION_FIELD) // adaptation field? + off = buf[4+i] + 1; + + if (buf[off+i+4] == 0x00 && + buf[off+i+5] == 0x00 && + buf[off+i+6] == 0x01) //IT'S A PES SIGNATURE? + { + switch(buf[off+i+7]) + { + case VIDEO_STREAM_S ... VIDEO_STREAM_E: + *vpid = get_pid(buf+i+1); + foundb=1; + break; + case PRIVATE_STREAM1: + case AUDIO_STREAM_S ... AUDIO_STREAM_E: + *apid = get_pid(buf+i+1); + founda=1; + break; + } + } + } + i += 187; + } + if (founda && foundb) break; + } +} + +#include "dvbin.h" +extern int pipe_fd[2], pipe_fd2[2]; +extern dvb_priv_t priv; +FILE *fuf; + +void write_out(uint8_t *buf, int size, void *priv) +{ + int k, tot = 0; + while(tot < size) + { + k = write(1, buf, size); + if(k < 0); + else + { + tot += k; + } + //write(fileno(fuf), buf, size); + } +} + + +void ts_to_pes(int fdin, uint16_t pida, uint16_t pidv, int ps) +{ + uint8_t buf[IN_SIZE]; + uint8_t mbuf[TS_SIZE]; + int i; + int count = 1, tot = 0; + uint16_t pid; + uint16_t dummy; + ipack pa, pv; + ipack *p; + FILE *f; + + + fprintf(stderr, "---------------TS_TO_PES: %d, %d, %d, %d\n", fdin, pida, pidv, ps); + + init_ipack(&pa, IPACKS, write_out, ps); + init_ipack(&pv, IPACKS, write_out, ps); + + if ((count = read(fdin, mbuf, TS_SIZE))<0) + perror("reading"); + tot += count; + + f = fdopen(fdin, "r"); + //fuf = fopen("ts.dump", "w"); + + for (i = 0; i < 188 ; i++) + { + if ( mbuf[i] == 0x47 ) break; + } + if (i == 188) + { + fprintf(stderr,"Not a TS\n"); + return; + } + else + { + memcpy(buf, mbuf+i, TS_SIZE-i); + + while((count = read(fdin, mbuf, i))<0); + tot += count; + + + memcpy(buf+TS_SIZE-i, mbuf, i); + i = 188; + } + count = 1; + while (count > 0 && (! feof(f))) + { + while ((count = read(fdin, buf+i, IN_SIZE-i))<0) + tot += count; + + if (!pidv) + { + find_bavpids(buf+i, IN_SIZE-i, &pidv, &dummy); + } + + if (!pida) + { + find_bavpids(buf+i, IN_SIZE-i, &dummy, &pida); + } + + + for( i = 0; i < count; i+= TS_SIZE) //CONSECUTIVE READ OF 188 BYTES OF TS PACKETS + { + uint8_t off = 0; + + if ( count - i < TS_SIZE) break; + + pid = get_pid(buf+i+1); + if (!(buf[3+i] & TS_HAS_PAYLOAD)) // no payload? + { + continue; + } + + if (pid == pidv) + { + p = &pv; + } + else + { + if (pid == pida) + { + p = &pa; + } + else continue; + } + + if (buf[1+i] & TS_PAYLOAD_HAS_PES_OR_PSI) + { + if (p->plength == MMAX_PLENGTH-6) + { + p->plength = p->found-6; + p->found = 0; + send_ipack(p); + reset_ipack(p); + } + } + + if (buf[3+i] & TS_HAS_ADAPTION_FIELD) + { + off = buf[4+i] + 1; + } + + instant_repack(buf+4+off+i, TS_SIZE-4-off, p); + } + i = 0; + } + return; +} + + + +void reset_ipack(ipack *p) +{ + p->found = 0; + p->cid = 0; + p->plength = 0; + p->flag1 = 0; + p->flag2 = 0; + p->hlength = 0; + p->mpeg = 0; + p->check = 0; + p->which = 0; + p->done = 0; + p->count = 0; + p->size = p->size_orig; +} + + +void init_ipack(ipack *p, int size, void (*func)(uint8_t *buf, int size, void *priv), int ps) +{ + if ( !(p->buf = malloc(size)) ) + { + //fprintf(stderr,"Couldn't allocate memory for ipack\n"); + exit(1); + } + p->ps = ps; + p->size_orig = size; + p->func = func; + reset_ipack(p); + p->has_ai = 0; + p->has_vi = 0; + p->start = 0; +} + +void free_ipack(ipack * p) +{ + if (p->buf) free(p->buf); +} + + +unsigned int ac3_bitrates[32] = + {32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640, + 0,0,0,0,0,0,0,0,0,0,0,0,0}; + +uint32_t ac3_freq[4] = {480, 441, 320, 0}; +uint32_t ac3_frames[3][32] = + {{64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024, + 1152,1280,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {69,87,104,121,139,174,208,243,278,348,417,487,557,696,835,975,1114, + 1253,1393,0,0,0,0,0,0,0,0,0,0,0,0,0}, + {96,120,144,168,192,240,288,336,384,480,576,672,768,960,1152,1344, + 1536,1728,1920,0,0,0,0,0,0,0,0,0,0,0,0,0}}; + +int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr) +{ + uint8_t *headr; + int found = 0; + int c = 0; + uint8_t frame; + int fr = 0; + + while ( !found && c < count) + { + uint8_t *b = mbuf+c; + if ( b[0] == 0x0b && b[1] == 0x77 ) + found = 1; + else + { + c++; + } + } + + + if (!found) + { + return -1; + } + ai->off = c; + + if (c+5 >= count) return -1; + + ai->layer = 0; // 0 for AC3 + headr = mbuf+c+2; + + frame = (headr[2]&0x3f); + ai->bit_rate = ac3_bitrates[frame>>1]*1000; + + if (pr) fprintf (stderr," BRate: %d kb/s", ai->bit_rate/1000); + + fr = (headr[2] & 0xc0 ) >> 6; + ai->frequency = freq[fr]*100; + if (pr) fprintf (stderr," Freq: %d Hz\n", ai->frequency); + + ai->framesize = ac3_frames[fr][frame >> 1]; + if ((frame & 1) && (fr == 1)) ai->framesize++; + ai->framesize = ai->framesize << 1; + if (pr) fprintf (stderr," Framesize %d\n", ai->framesize); + + return c; +} + + +void send_ipack(ipack *p) +{ + int streamid=0; + int off; + int ac3_off = 0; + AudioInfo ai; + int nframes= 0; + int f=0; + + if (p->count < 10) return; + p->buf[3] = p->cid; + p->buf[4] = (uint8_t)(((p->count-6) & 0xFF00) >> 8); + p->buf[5] = (uint8_t)((p->count-6) & 0x00FF); + + + if (p->cid == PRIVATE_STREAM1) + { + off = 9+p->buf[8]; + streamid = p->buf[off]; + if ((streamid & 0xF8) == 0x80) + { + ai.off = 0; + ac3_off = ((p->buf[off+2] << 8)| p->buf[off+3]); + if (ac3_off < p->count) + f=get_ac3info(p->buf+off+3+ac3_off, p->count-ac3_off, &ai, 0); + if ( !f ) + { + nframes = (p->count-off-3-ac3_off)/ + ai.framesize + 1; + p->buf[off+2] = (ac3_off >> 8)& 0xFF; + p->buf[off+3] = (ac3_off)& 0xFF; + p->buf[off+1] = nframes; + + ac3_off += nframes * ai.framesize - p->count; + } + } + } + + //if (p->ps) ps_pes(p); + //else + p->func(p->buf, p->count, p->data); + + switch (p->mpeg) + { + case 2: + + p->buf[6] = 0x80; + p->buf[7] = 0x00; + p->buf[8] = 0x00; + p->count = 9; + + if (p->cid == PRIVATE_STREAM1 && (streamid & 0xF8)==0x80) + { + p->buf[9] = streamid; + p->buf[10] = (ac3_off >> 8)& 0xFF; + p->buf[11] = (ac3_off)& 0xFF; + p->buf[12] = 0; + p->count += 4; + } + break; + + case 1: + p->buf[6] = 0x0F; + p->count = 7; + break; + } + +} + + +static void write_ipack(ipack *p, uint8_t *data, int count) +{ + + uint8_t headr[3] = { 0x00, 0x00, 0x01} ; + int diff =0; + + if (p->count < 6) + { + if (trans_pts_dts(p->pts) > trans_pts_dts(p->last_pts)) + memcpy(p->last_pts, p->pts, 5); + p->count = 0; + memcpy(p->buf+p->count, headr, 3); + p->count += 6; + } + + if ( p->size == p->size_orig && p->plength && + (diff = 6+p->plength - p->found + p->count +count) > p->size && + diff < 3*p->size/2) + { + + p->size = diff/2; +// fprintf(stderr,"size: %d \n",p->size); + } + if (p->count + count < p->size) + { + memcpy(p->buf+p->count, data, count); + p->count += count; + } + else + { + int rest = p->size - p->count; + if (rest < 0) rest = 0; + memcpy(p->buf+p->count, data, rest); + p->count += rest; +// fprintf(stderr,"count: %d \n",p->count); + send_ipack(p); + if (count - rest > 0) + write_ipack(p, data+rest, count-rest); + } +} + + +void instant_repack (uint8_t *buf, int count, ipack *p) +{ + + int l; + unsigned short *pl; + int c=0; + static int chg; + + //fprintf(stderr, "INSTANT-REPACK START da posizione %p per %d bytes, FOUND: %d\n", buf, count, p->found); + while (c < count && (p->mpeg == 0 || + (p->mpeg == 1 && p->found < 7) || + (p->mpeg == 2 && p->found < 9)) + && (p->found < 5 || !p->done)) + { + switch ( p->found ) + { + case 0: + + case 1: + if (buf[c] == 0x00) {p->found++;} + else p->found = 0; + c++; + break; + case 2: + if (buf[c] == 0x01) {p->found++;} + else if (buf[c] == 0) + { + p->found = 2; + } + else p->found = 0; + c++; + break; + + case 3: + p->cid = 0; + switch (buf[c]) + { + case PROG_STREAM_MAP: + case PRIVATE_STREAM2: + case PROG_STREAM_DIR: + case ECM_STREAM : + case EMM_STREAM : + case PADDING_STREAM : + case DSM_CC_STREAM : + case ISO13522_STREAM: + p->done = 1; + //fprintf(stderr, "STREAM VARI: %x in posizione %p\n", buf[c], &buf[c]); + case PRIVATE_STREAM1: + case VIDEO_STREAM_S ... VIDEO_STREAM_E: + case AUDIO_STREAM_S ... AUDIO_STREAM_E: + p->found++; + p->cid = buf[c]; + //fprintf(stderr, "A-V STREAM: %x in posizione %p, DIM: %d, %d\n", p->cid, &buf[c], buf[c+1], buf[c+2]); + c++; + break; + default: + p->found = 0; + break; + } + break; + + case 4: + if (count-c > 1) + { + pl = (unsigned short *) (buf+c); + p->plength = ntohs(*pl); + p->plen[0] = buf[c]; + c++; + p->plen[1] = buf[c]; + c++; + p->found+=2; + //fprintf(stderr, "PLENGTH: %d, %d, %d\n", p->plength, p->plen[0], p->plen[1]); + } + else + { + p->plen[0] = buf[c]; + p->found++; + //fprintf(stderr, "ELSE(4): %d\n", p->plen[0]); + return; + } + break; + + case 5: + p->plen[1] = buf[c]; + c++; + pl = (unsigned short *) p->plen; + p->plength = ntohs(*pl); + p->found++; + //fprintf(stderr, "ELSE(5): %d\n, plength: %d", p->plen[1], p->plength); + break; + case 6: + if (!p->done) + { + p->flag1 = buf[c]; + c++; + p->found++; + if ((p->flag1 & 0xC0) == 0x80) + { + p->mpeg = 2; + //fprintf(stderr, "MPEG2\n"); + } + else + { + p->hlength = 0; + p->which = 0; + p->mpeg = 1; + p->flag2 = 0; + //fprintf(stderr, "MPEG1\n"); + } + } + break; + + case 7: + if ( !p->done && p->mpeg == 2) + { + p->flag2 = buf[c]; + c++; + p->found++; + } + break; + + case 8: + if ( !p->done && p->mpeg == 2) + { + p->hlength = buf[c]; //lunghezza dell'header del pacchetto pes + //fprintf(stderr, "HLENGTH: %d\n", p->hlength); + c++; + p->found++; + } + break; + + default: + break; + } + } + + + if (c == count) return; + + if (!p->plength) + { + p->plength = MMAX_PLENGTH-6; + //fprintf(stderr, "UPDATE PLENGTH: %d (%d-6)\n", p->plength, MMAX_PLENGTH); + } + + + if ( p->done || ((p->mpeg == 2 && p->found >= 9) || + (p->mpeg == 1 && p->found >= 7)) ) + { + switch (p->cid) + { + case AUDIO_STREAM_S ... AUDIO_STREAM_E: + case VIDEO_STREAM_S ... VIDEO_STREAM_E: + case PRIVATE_STREAM1: + if (p->mpeg == 2 && p->found == 9) + { + write_ipack(p, &p->flag1, 1); + write_ipack(p, &p->flag2, 1); + write_ipack(p, &p->hlength, 1); + } + + if (p->mpeg == 1 && p->found == 7) + { + write_ipack(p, &p->flag1, 1); + } + + + if (p->mpeg == 2 && (p->flag2 & PTS_ONLY) && p->found < 14) + { + while (c < count && p->found < 14) + { + p->pts[p->found-9] = buf[c]; + //fprintf(stderr, "PTS_ONLY: %d\n", buf[c]); + write_ipack(p, buf+c, 1); + c++; + p->found++; + } + if (c == count) return; + } + + if (p->mpeg == 1 && p->which < 2000) + { + if (p->found == 7) + { + p->check = p->flag1; + p->hlength = 1; + } + + while (!p->which && c < count && p->check == 0xFF) + { + p->check = buf[c]; + write_ipack(p, buf+c, 1); + c++; + p->found++; + p->hlength++; + } + + if ( c == count) return; + + if ( (p->check & 0xC0) == 0x40 && !p->which) + { + p->check = buf[c]; + write_ipack(p, buf+c, 1); + c++; + p->found++; + p->hlength++; + + p->which = 1; + if ( c == count) return; + p->check = buf[c]; + write_ipack(p, buf+c, 1); + c++; + p->found++; + p->hlength++; + p->which = 2; + if ( c == count) return; + } + + if (p->which == 1) + { + p->check = buf[c]; + write_ipack(p, buf+c, 1); + c++; + p->found++; + p->hlength++; + p->which = 2; + if ( c == count) return; + } + + if ( (p->check & 0x30) && p->check != 0xFF) + { + p->flag2 = (p->check & 0xF0) << 2; + p->pts[0] = p->check; + p->which = 3; + } + + if ( c == count) return; + + if (p->which > 2) + { + if ((p->flag2 & PTS_DTS_FLAGS) == PTS_ONLY) + { + //fprintf(stderr, "PTS_DTS_only..."); + while (c < count && p->which < 7) + { + p->pts[p->which-2] = buf[c]; + //fprintf(stderr, " PTS: %d ", buf[c]); + write_ipack(p, buf+c, 1); + c++; + p->found++; + p->which++; + p->hlength++; + } + //fprintf(stderr, "\n"); + if ( c == count) return; + } + else if ((p->flag2 & PTS_DTS_FLAGS) == PTS_DTS) + { + //fprintf(stderr, "PTS_DTS..."); + while (c < count && p->which < 12) + { + if (p->which< 7) + p->pts[p->which-2] = buf[c]; + //fprintf(stderr, " PTS: %d ", buf[c]); + write_ipack(p, buf+c, 1); + c++; + p->found++; + p->which++; + p->hlength++; + } + //fprintf(stderr, ": %d ", buf[c]); + if ( c == count) return; + } + p->which = 2000; + } + } + + while (c < count && p->found < p->plength+6) + { + l = count -c; + if (l+p->found > p->plength+6) + l = p->plength+6-p->found; + write_ipack(p, buf+c, l); + p->found += l; + c += l; + } + + break; + } + + + if ( p->done ) + { + if( p->found + count - c < p->plength+6) + { + p->found += count-c; + c = count; + } + else + { + c += p->plength+6 - p->found; + p->found = p->plength+6; + } + } + + if (p->plength && p->found == p->plength+6) + { + send_ipack(p); + reset_ipack(p); + if (c < count) + instant_repack(buf+c, count-c, p); + } + } + return; +} + +/* +int main(int argc, char *argv[]) +{ + ts_to_pes(fileno(stdin), atoi(argv[2-1]), atoi(argv[3-1]), 0); +} +*/ + diff -Naur MPlayer-20021011/libmpdemux/ts2ps.h MPlayer-20021011-dvb/libmpdemux/ts2ps.h --- MPlayer-20021011/libmpdemux/ts2ps.h Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libmpdemux/ts2ps.h Wed Oct 9 22:00:10 2002 @@ -0,0 +1,334 @@ +/* + * mpegtools for the Siemens Fujitsu DVB PCI card + * + * Copyright (C) 2000, 2001 Marcus Metzler + * for convergence integrated media GmbH + * + * This program 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. + * + + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html + * + + * The author can be reached at marcus@convergence.de, + + * the project's page is at http://linuxtv.org/dvb/ + */ + +#ifndef _TS_TRANSFORM_H_ +#define _TS_TRANSFORM_H_ + +#include +#include +#include +#include +//#include "remux.h" + + +/*PES HEADER STREAM IDS*/ +#define PROG_STREAM_MAP 0xBC +#ifndef PRIVATE_STREAM1 +#define PRIVATE_STREAM1 0xBD +#endif +#define PADDING_STREAM 0xBE +#ifndef PRIVATE_STREAM2 +#define PRIVATE_STREAM2 0xBF +#endif +#define AUDIO_STREAM_S 0xC0 +#define AUDIO_STREAM_E 0xDF +#define VIDEO_STREAM_S 0xE0 +#define VIDEO_STREAM_E 0xEF +#define ECM_STREAM 0xF0 +#define EMM_STREAM 0xF1 +#define DSM_CC_STREAM 0xF2 +#define ISO13522_STREAM 0xF3 +#define PROG_STREAM_DIR 0xFF +/*...END*/ + +#define BUFFYSIZE 10*MAX_PLENGTH +#define MAX_PTS 8192 +#define MAX_FRAME 8192 +#define MAX_PACK_L 4096 +#define PS_HEADER_L1 14 +#define PS_HEADER_L2 (PS_HEADER_L1+18) +#define MAX_H_SIZE (PES_H_MIN + PS_HEADER_L1 + 5) +#define PES_MIN 7 +#define PES_H_MIN 9 + +//flags2 +#define PTS_DTS_FLAGS 0xC0 +#define ESCR_FLAG 0x20 +#define ES_RATE_FLAG 0x10 +#define DSM_TRICK_FLAG 0x08 +#define ADD_CPY_FLAG 0x04 +#define PES_CRC_FLAG 0x02 +#define PES_EXT_FLAG 0x01 + +//pts_dts flags +#define PTS_ONLY 0x80 +#define PTS_DTS 0xC0 + +#define TS_SIZE 188 +#define TRANS_ERROR 0x80 +#define PAY_START 0x40 +#define TRANS_PRIO 0x20 +#define PID_MASK_HI 0x1F +//flags +#define TRANS_SCRMBL1 0x80 +#define TRANS_SCRMBL2 0x40 +#define ADAPT_FIELD 0x20 +#define PAYLOAD 0x10 +#define COUNT_MASK 0x0F + +// adaptation flags +#define DISCON_IND 0x80 +#define RAND_ACC_IND 0x40 +#define ES_PRI_IND 0x20 +#define PCR_FLAG 0x10 +#define OPCR_FLAG 0x08 +#define SPLICE_FLAG 0x04 +#define TRANS_PRIV 0x02 +#define ADAP_EXT_FLAG 0x01 + +// adaptation extension flags +#define LTW_FLAG 0x80 +#define PIECE_RATE 0x40 +#define SEAM_SPLICE 0x20 + + +#define MAX_PLENGTH 0xFFFF +#define MMAX_PLENGTH (8*MAX_PLENGTH) + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define P2P_LENGTH 2048 + + +#define FULL_BUFFER -1000 +typedef struct ringbuffy{ + int read_pos; + int write_pos; + int size; + char *buffy; +} ringbuffy; + + + + + typedef struct video_i{ + uint32_t horizontal_size; + uint32_t vertical_size; + uint32_t aspect_ratio; + double framerate; + uint32_t video_format; + uint32_t bit_rate; + uint32_t comp_bit_rate; + uint32_t vbv_buffer_size; + uint32_t CSPF; + uint32_t off; + } VideoInfo; + + typedef struct audio_i{ + int layer; + uint32_t bit_rate; + uint32_t frequency; + uint32_t mode; + uint32_t mode_extension; + uint32_t emphasis; + uint32_t framesize; + uint32_t off; + } AudioInfo; + + + + typedef + struct PTS_list_struct{ + uint32_t PTS; + int pos; + uint32_t dts; + int spos; + } PTS_List; + + typedef + struct frame_list_struct{ + int type; + int pos; + uint32_t FRAME; + uint32_t time; + uint32_t pts; + uint32_t dts; + } FRAME_List; + + typedef + struct remux_struct{ + ringbuffy vid_buffy; + ringbuffy aud_buffy; + PTS_List vpts_list[MAX_PTS]; + PTS_List apts_list[MAX_PTS]; + FRAME_List vframe_list[MAX_FRAME]; + FRAME_List aframe_list[MAX_FRAME]; + int vptsn; + int aptsn; + int vframen; + int aframen; + long apes; + long vpes; + uint32_t vframe; + uint32_t aframe; + uint32_t vcframe; + uint32_t acframe; + uint32_t vpts; + uint32_t vdts; + uint32_t apts; + uint32_t vpts_old; + uint32_t apts_old; + uint32_t SCR; + uint32_t apts_off; + uint32_t vpts_off; + uint32_t apts_delay; + uint32_t vpts_delay; + uint32_t dts_delay; + AudioInfo audio_info; + VideoInfo video_info; + int fin; + int fout; + long int awrite; + long int vwrite; + long int aread; + long int vread; + uint32_t group; + uint32_t groupframe; + uint32_t muxr; + int pack_size; + uint32_t time_off; + } Remux; + + enum { NONE, I_FRAME, P_FRAME, B_FRAME, D_FRAME }; + + +////////////////////////////////////////////////////////////////////////// + + + enum{NOPES, AUDIO, VIDEO}; + + typedef struct p2pstruct { + int found; + uint8_t buf[MMAX_PLENGTH]; + uint8_t cid; + uint32_t plength; + uint8_t plen[2]; + uint8_t flag1; + uint8_t flag2; + uint8_t hlength; + uint8_t pts[5]; + int mpeg; + uint8_t check; + int fd1; + int fd2; + int es; + int filter; + int which; + int done; + int repack; + uint16_t bigend_repack; + void (*func)(uint8_t *buf, int count, struct p2pstruct *p); + int startv; + int starta; + int64_t apts; + int64_t vpts; + uint16_t pid; + uint16_t pida; + uint16_t pidv; + uint8_t acounter; + uint8_t vcounter; + uint8_t count0; + uint8_t count1; + void *data; + } p2p; + + + uint32_t trans_pts_dts(uint8_t *pts); + uint16_t get_pid(uint8_t *pid); + + void ts_to_pes( int fdin, uint16_t pida, uint16_t pidv, int pad); + int get_ainfo(uint8_t *mbuf, int count, AudioInfo *ai, int pr); + int get_vinfo(uint8_t *mbuf, int count, VideoInfo *vi, int pr); + int get_ac3info(uint8_t *mbuf, int count, AudioInfo *ai, int pr); + + +//instant repack + + typedef struct ipack_s { + int size; + int size_orig; + int found; + int ps; + int has_ai; + int has_vi; + AudioInfo ai; + VideoInfo vi; + uint8_t *buf; + uint8_t cid; + uint32_t plength; + uint8_t plen[2]; + uint8_t flag1; + uint8_t flag2; + uint8_t hlength; + uint8_t pts[5]; + uint8_t last_pts[5]; + int mpeg; + uint8_t check; + int which; + int done; + void *data; + void (*func)(uint8_t *buf, int size, void *priv); + int count; + int start; + int fd; + } ipack; + + void instant_repack (uint8_t *buf, int count, ipack *p); + void init_ipack(ipack *p, int size, + void (*func)(uint8_t *buf, int size, void *priv), + int pad); + void free_ipack(ipack * p); + void send_ipack(ipack *p); + void reset_ipack(ipack *p); + void ps_pes(ipack *p); + // use with ipack structure, repack size and callback func + + int64_t ts_demux(int fd_in, int fdv_out,int fda_out,uint16_t pida, + uint16_t pidv, int es); + + void ts2es(int fdin, uint16_t pidv); + void insert_pat_pmt( int fdin, int fdout); + void change_aspect(int fdin, int fdout, int aspect); + + + + + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _TS_TRANSFORM_H_*/ + + + diff -Naur MPlayer-20021011/libvo/config.mak MPlayer-20021011-dvb/libvo/config.mak --- MPlayer-20021011/libvo/config.mak Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/libvo/config.mak Sat Oct 12 00:26:20 2002 @@ -0,0 +1,3 @@ +include ../config.mak +OPTIONAL_SRCS = x11_common.c vo_x11.c vo_xv.c vo_dga.c vo_gl.c vo_gl2.c vo_fbdev.c vo_png.c vo_jpeg.c vo_gif89a.c vo_vesa.c vesa_lvo.c vo_sdl.c vo_xvidix.c +OPTIONAL_OBJS = x11_common.o vo_x11.o vo_xv.o vo_dga.o vo_gl.o vo_gl2.o vo_fbdev.o vo_png.o vo_jpeg.o vo_gif89a.o vo_vesa.o vesa_lvo.o vo_sdl.o vo_xvidix.o diff -Naur MPlayer-20021011/mplayer.c MPlayer-20021011-dvb/mplayer.c --- MPlayer-20021011/mplayer.c Wed Oct 9 03:13:40 2002 +++ MPlayer-20021011-dvb/mplayer.c Sat Oct 12 00:17:46 2002 @@ -80,6 +80,12 @@ extern int tv_param_on; #endif +#ifdef HAVE_DVB +#include "libmpdemux/dvbin.h" +#endif + + + //**************************************************************************// // Playtree //**************************************************************************// @@ -668,7 +674,12 @@ } - if(!filename && !vcd_track && !dvd_title && !dvd_nav && !tv_param_on){ + if(!filename && !vcd_track && !dvd_title && !dvd_nav && !tv_param_on +#ifdef HAVE_DVB + && !dvbin_param_on +#endif + ) +{ if(!use_gui){ // no file/vcd/dvd -> show HELP: mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text); @@ -2149,7 +2160,19 @@ else tv_step_channel((tvi_handle_t*)(demuxer->priv), TV_CHANNEL_LOWER); } - } break; + } +#ifdef HAVE_DVB + if(dvbin_param_on == 1) + { + int v = cmd->args[0].v.i; + fprintf(stderr, "\n\ndvb change, V: %d\n\n", v); + if(v > 0) + dvb_step_channel((dvb_priv_t*)(demuxer->stream->priv), DVB_CHANNEL_HIGHER); + else + dvb_step_channel((dvb_priv_t*)(demuxer->stream->priv), DVB_CHANNEL_LOWER); + } +#endif + break; case MP_CMD_TV_STEP_NORM : { if (tv_param_on == 1) tv_step_norm((tvi_handle_t*)(demuxer->priv)); diff -Naur MPlayer-20021011/version.h MPlayer-20021011-dvb/version.h --- MPlayer-20021011/version.h Thu Jan 1 01:00:00 1970 +++ MPlayer-20021011-dvb/version.h Sat Oct 12 00:26:38 2002 @@ -0,0 +1 @@ +#define VERSION "CVS-021011-06:00-2.96 "