// AVI & MPEG Player v0.18 (C) 2000-2001. by A'rpi/ESP-team
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <time.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "version.h"
#include "config.h"
#ifdef __FreeBSD__
#include <sys/cdrio.h>
#endif
#ifdef sun
#define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0"
#else
#define DEFAULT_CDROM_DEVICE "/dev/cdrom"
#endif
#include "cfgparser.h"
#include "cfg-mplayer-def.h"
#include "subreader.h"
#include "libvo/video_out.h"
#include "libvo/sub.h"
#include "libao2/audio_out.h"
#include "libmpeg2/mpeg2.h"
#include "libmpeg2/mpeg2_internal.h"
#include "loader.h"
#include "wine/avifmt.h"
#include "codec-cfg.h"
#include "dvdauth.h"
#include "spudec.h"
extern char* win32_codec_name; // must be set before calling DrvOpen() !!!
#include "linux/getch2.h"
#include "linux/keycodes.h"
#include "linux/timer.h"
#include "linux/shmem.h"
#ifdef HAVE_LIRC
#include "lirc_mp.h"
#endif
#include "help_mp.h"
#ifdef STREAMING
#include "url.h"
#include "network.h"
static URL_t* url;
#endif
#define DEBUG if(0)
#ifdef HAVE_GUI
int nogui=1;
#endif
int verbose=0;
#define ABS(x) (((x)>=0)?(x):(-(x)))
void find_sub(subtitle* subtitles,int key);
static int
usec_sleep(int usec_delay)
{
#if 1
struct timespec ts;
ts.tv_sec = usec_delay / 1000000;
ts.tv_nsec = (usec_delay % 1000000) * 1000;
return nanosleep(&ts, NULL);
#else
return usleep(usec_delay);
#endif
}
//**************************************************************************//
// Config file
//**************************************************************************//
static int cfg_inc_verbose(struct config *conf){
++verbose;
return 0;
}
static int cfg_include(struct config *conf, char *filename){
return parse_config_file(conf, filename);
}
char *get_path(char *filename){
char *homedir;
char *buff;
static char *config_dir = "/.mplayer";
int len;
if ((homedir = getenv("HOME")) == NULL)
return NULL;
len = strlen(homedir) + strlen(config_dir) + 1;
if (filename == NULL) {
if ((buff = (char *) malloc(len)) == NULL)
return NULL;
sprintf(buff, "%s%s", homedir, config_dir);
} else {
len += strlen(filename) + 1;
if ((buff = (char *) malloc(len)) == NULL)
return NULL;
sprintf(buff, "%s%s/%s", homedir, config_dir, filename);
}
return buff;
}
//**************************************************************************//
//**************************************************************************//
// Input media streaming & demultiplexer:
//**************************************************************************//
static int max_framesize=0;
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
char* encode_name=NULL;
char* encode_index_name=NULL;
int encode_bitrate=0;
extern int asf_packetsize; // for seeking
extern float avi_audio_pts;
extern float avi_video_pts;
extern float avi_video_ftime;
extern int skip_video_frames;
void read_avi_header(demuxer_t *demuxer,int index_mode);
demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id);
int asf_check_header(demuxer_t *demuxer);
int read_asf_header(demuxer_t *demuxer);
demuxer_t* demux_open(stream_t *stream,int file_format);
int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
// MPEG video stream parser:
#include "parse_es.h"
extern int num_elementary_packets100; // for MPEG-ES fileformat detection
extern int num_elementary_packets101;
extern int num_elementary_packetsPES;
extern picture_t *picture; // exported from libmpeg2/decode.c
int frameratecode2framerate[16] = {
0,
// Official mpeg1/2 framerates:
24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, 60*10000,
// libmpeg3's "Unofficial economy rates":
1*10000,5*10000,10*10000,12*10000,15*10000,0,0
};
//**************************************************************************//
//**************************************************************************//
// Common FIFO functions, and keyboard/event FIFO code
#include "fifo.c"
//**************************************************************************//
static vo_functions_t *video_out=NULL;
static ao_functions_t *audio_out=NULL;
float c_total=0;
double video_time_usage=0;
double vout_time_usage=0;
static double audio_time_usage=0;
static int total_time_usage_start=0;
static int benchmark=0;
static int play_in_bg=0;
extern void avi_fixate();
#ifdef HAVE_GUI
#include "../Gui/mplayer/psignal.h"
#define GUI_MSG(x) if ( !nogui ) { mplSendMessage( x ); usec_sleep( 10000 ); }
#else
#define GUI_
|