⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mplayer_novideo_0.21.c

📁 自己移植的linux下的流媒体播放器原代码,支持mms协议,支持ftp和http协议.
💻 C
📖 第 1 页 / 共 4 页
字号:
#endif  }  mp_msg(MSGT_CPLAYER,MSGL_FATAL,"\n" MSGTR_IntBySignal,x,      current_module?current_module:mp_gettext("unknown")  );  if(sig_count<=1)  switch(x){  case SIGINT:  case SIGQUIT:  case SIGTERM:  case SIGKILL:      break;  // killed from keyboard (^C) or killed [-9]  case SIGILL:#ifdef RUNTIME_CPUDETECT      mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGILL_RTCpuSel);#else      mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGILL);#endif  case SIGFPE:  case SIGSEGV:      mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGSEGV_SIGFPE);  default:      mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGCRASH);  }  exit_player(NULL);}//extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height);extern void mp_input_register_options(m_config_t* cfg);#include "mixer.h"mixer_t mixer;/// step size of mixer changesint volstep = 3;#include "cfg-mplayer.h"void parse_cfgfiles( m_config_t* conf ){char *conffile;int conffile_fd;if (m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mplayer.conf") < 0)  exit_player(NULL);if ((conffile = get_path("")) == NULL) {  mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir);} else {#ifdef __MINGW32__  mkdir(conffile);#else  mkdir(conffile, 0777);#endif  free(conffile);  if ((conffile = get_path("config")) == NULL) {    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);  } else {    if ((conffile_fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY, 0666)) != -1) {      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CreatingCfgFile, conffile);      write(conffile_fd, default_config, strlen(default_config));      close(conffile_fd);    }    if (m_config_parse_config_file(conf, conffile) < 0)      exit_player(NULL);    free(conffile);  }}}void load_per_file_config (m_config_t* conf, const char *const file){    char *confpath;    char cfg[strlen(file)+10];    struct stat st;    char *name;    sprintf (cfg, "%s.conf", file);        if (!stat (cfg, &st))    {	mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingConfig, cfg);	m_config_parse_config_file (conf, cfg);	return;    }    if ((name = strrchr (cfg, '/')) == NULL)	name = cfg;    else	name++;    if ((confpath = get_path (name)) != NULL)    {	if (!stat (confpath, &st))	{	    mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_LoadingConfig, confpath);	    m_config_parse_config_file (conf, confpath);	}	free (confpath);    }}// When libmpdemux perform a blocking operation (network connection or cache filling)// if the operation fail we use this function to check if it was interrupted by the user.// The function return a new value for eof.static int libmpdemux_was_interrupted(int eof) {  mp_cmd_t* cmd;  if((cmd = mp_input_get_cmd(0,0,0)) != NULL) {       switch(cmd->id) {       case MP_CMD_QUIT:	 exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0)? cmd->args[0].v.i : 0);       case MP_CMD_PLAY_TREE_STEP: {	 eof = (cmd->args[0].v.i > 0) ? PT_NEXT_ENTRY : PT_PREV_ENTRY;       } break;       case MP_CMD_PLAY_TREE_UP_STEP: {	 eof = (cmd->args[0].v.i > 0) ? PT_UP_NEXT : PT_UP_PREV;       } break;	         case MP_CMD_PLAY_ALT_SRC_STEP: {	 eof = (cmd->args[0].v.i > 0) ?  PT_NEXT_SRC : PT_PREV_SRC;       } break;       }       mp_cmd_free(cmd);  }  return eof;}#define mp_basename2(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))#define mp_basename(s) (strrchr(s,'\\')==NULL?(mp_basename2(s)):(strrchr(s,'\\')+1))int playtree_add_playlist(play_tree_t* entry){  play_tree_add_bpf(entry,filename);  if(!entry) {          entry = playtree_iter->tree;    if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {        return PT_NEXT_ENTRY;    }    if(playtree_iter->tree == entry ) { // Loop with a single file      if(play_tree_iter_up_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {	return PT_NEXT_ENTRY;      }    }    play_tree_remove(entry,1,1);    return PT_NEXT_SRC;  }  play_tree_insert_entry(playtree_iter->tree,entry);  play_tree_set_params_from(entry,playtree_iter->tree);  entry = playtree_iter->tree;  if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) {    return PT_NEXT_ENTRY;  }        play_tree_remove(entry,1,1);  return PT_NEXT_SRC;}static int play_tree_step = 1;int sub_source(){    int source = -1;    int top = -1;    int i;    for (i = 0; i < SUB_SOURCES; i++) {        int j = global_sub_indices[i];        if ((j >= 0) && (j > top) && (global_sub_pos >= j)) {            source = i;            top = j;        }    }    return source;}/* * In Mac OS X the SDL-lib is built upon Cocoa. The easiest way to * make it all work is to use the builtin SDL-bootstrap code, which  * will be done automatically by replacing our main() if we include SDL.h. *//** * \brief append a formatted string * \param buf buffer to print into * \param pos position of terminating 0 in buf * \param len maximum number of characters in buf, not including terminating 0 * \param format printf format string */static void saddf(char *buf, unsigned *pos, int len, const char *format, ...){  va_list va;  va_start(va, format);  *pos += vsnprintf(&buf[*pos], len - *pos, format, va);  va_end(va);  if (*pos >= len ) {    buf[len] = 0;    *pos = len;  }}/** * \brief print the status line * \param a_pos audio position * \param a_v A-V desynchronization * \param corr amount out A-V synchronization */static void print_status(float a_pos, float a_v, float corr){  int width;  char *line;  unsigned pos = 0;  get_screen_size();  if (screen_width > 0)    width = screen_width;  else  width = 80;#ifdef WIN32  // windows command line is broken (MinGW's rxvt works though, but we  // should not depend on that).  width--;#endif  line = malloc(width + 1); // one additional for terminating null    // Audio time  if (sh_audio) {    saddf(line, &pos, width, "A:%6.1f ", a_pos);    if (!sh_video) {      // convert time to HH:MM:SS.F format      long tenths = 10 * a_pos;      int f1 = tenths % 10;      int ss = (tenths /  10) % 60;      int mm = (tenths / 600) % 60;      int hh = (tenths / 36000) % 100;      saddf(line, &pos, width, "(");      if (hh > 0)        saddf(line, &pos, width, "%2d:", hh);      if (hh > 0 || mm > 0)        saddf(line, &pos, width, "%02d:", mm);      saddf(line, &pos, width, "%02d.", ss);      saddf(line, &pos, width, "%1d", f1);      saddf(line, &pos, width, ") ");    }  }  // Video time  if (sh_video)    saddf(line, &pos, width, "V:%6.1f ", sh_video->pts);  // A-V sync  if (sh_audio && sh_video)    saddf(line, &pos, width, "A-V:%7.3f ct:%7.3f ", a_v, corr);  // Video stats  if (sh_video)    saddf(line, &pos, width, "%3d/%3d ",      (int)sh_video->num_frames,      (int)sh_video->num_frames_decoded);  // CPU usage  if (sh_video) {    if (sh_video->timer > 0.5)      saddf(line, &pos, width, "%2d%% %2d%% %4.1f%% ",        (int)(100.0*video_time_usage*playback_speed/(double)sh_video->timer),        (int)(100.0*vout_time_usage*playback_speed/(double)sh_video->timer),        (100.0*audio_time_usage*playback_speed/(double)sh_video->timer));    else      saddf(line, &pos, width, "??%% ??%% ??,?%% ");  } else if (sh_audio) {    if (sh_audio->delay > 0.5)      saddf(line, &pos, width, "%4.1f%% ",        100.0*audio_time_usage/(double)sh_audio->delay);    else      saddf(line, &pos, width, "??,?%% ");  }  // VO stats  if (sh_video)     saddf(line, &pos, width, "%d %d ", drop_frame_cnt, output_quality);#ifdef USE_STREAM_CACHE  // cache stats  if (stream_cache_size > 0)    saddf(line, &pos, width, "%d%% ", cache_fill_status);#endif  // other  if (playback_speed != 1)    saddf(line, &pos, width, "%4.2fx ", playback_speed);  // end  memset(&line[pos], ' ', width - pos);  line[width] = 0;  mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s\r", line);  free(line);}/** * \brief build a chain of audio filters that converts the input format * to the ao's format, taking into account the current playback_speed. * \param sh_audio describes the requested input format of the chain. * \param ao_data describes the requested output format of the chain. */static int build_afilter_chain(sh_audio_t *sh_audio, ao_data_t *ao_data){  int new_srate;  int result;  if (!sh_audio)  {    mixer.afilter = NULL;    return 0;  }  new_srate = sh_audio->samplerate * playback_speed;  if (new_srate != ao_data->samplerate) {    // limits are taken from libaf/af_resample.c    if (new_srate < 8000)      new_srate = 8000;    if (new_srate > 192000)      new_srate = 192000;    playback_speed = (float)new_srate / (float)sh_audio->samplerate;  }  result =  init_audio_filters(sh_audio, new_srate,           sh_audio->channels, sh_audio->sample_format,           ao_data->samplerate, ao_data->channels, ao_data->format,           ao_data->outburst * 4, ao_data->buffersize);  mixer.afilter = sh_audio->afilter;  return result;}int main(int argc,char* argv[]){char * mem_ptr;static demux_stream_t *d_audio=NULL;static demux_stream_t *d_video=NULL;static demux_stream_t *d_dvdsub=NULL;int file_format=DEMUXER_TYPE_UNKNOWN;int delay_corrected=1;// movie info:int osd_function=OSD_PLAY;int osd_last_pts=-303;int osd_show_av_delay = 0;int osd_show_text = 0;int osd_show_speed = 0;int osd_show_sub_delay = 0;int osd_show_sub_pos = 0;int osd_show_sub_visibility = 0;int osd_show_sub_alignment = 0;int osd_show_vobsub_changed = 0;int osd_show_sub_changed = 0;int osd_show_percentage = 0;int osd_show_tv_channel = 25;int osd_show_ontop = 0;int osd_show_rootwin = 0;int osd_show_framedropping = 0;int rtc_fd=-1;//float a_frame=0;    // Audioint i;char *tmp;int gui_no_filename=0;  srand((int) time(NULL));   mp_msg_init();  mp_msg_set_level(MSGL_STATUS);  mp_msg(MSGT_CPLAYER,MSGL_INFO, "MPlayer " VERSION " (C) 2000-2005 MPlayer Team\n");  /* Test for cpu capabilities (and corresponding OS support) for optimizing */  GetCpuCaps(&gCpuCaps);#if defined(ARCH_X86) || defined(ARCH_X86_64)  mp_msg(MSGT_CPLAYER,MSGL_INFO,"CPUflags:  MMX: %d MMX2: %d 3DNow: %d 3DNow2: %d SSE: %d SSE2: %d\n",      gCpuCaps.hasMMX,gCpuCaps.hasMMX2,      gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,      gCpuCaps.hasSSE, gCpuCaps.hasSSE2);#ifdef RUNTIME_CPUDETECT  mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_CompiledWithRuntimeDetection);#else  mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_CompiledWithCPUExtensions);#ifdef HAVE_MMX  mp_msg(MSGT_CPLAYER,MSGL_INFO," MMX");#endif#ifdef HAVE_MMX2  mp_msg(MSGT_CPLAYER,MSGL_INFO," MMX2");#endif#ifdef HAVE_3DNOW  mp_msg(MSGT_CPLAYER,MSGL_INFO," 3DNow");#endif#ifdef HAVE_3DNOWEX  mp_msg(MSGT_CPLAYER,MSGL_INFO," 3DNowEx");#endif#ifdef HAVE_SSE  mp_msg(MSGT_CPLAYER,MSGL_INFO," SSE");#endif#ifdef HAVE_SSE2  mp_msg(MSGT_CPLAYER,MSGL_INFO," SSE2");#endif  mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n\n");#endif#endif#if defined(WIN32) && defined(USE_WIN32DLL){  /*make our codec dirs available for LoadLibraryA()*/  char tmppath[MAX_PATH*2 + 1];  char win32path[MAX_PATH];  char realpath[MAX_PATH];#ifdef __CYGWIN__  cygwin_conv_to_full_win32_path(WIN32_PATH,win32path);  strcpy(tmppath,win32path);#ifdef USE_REALCODECS  cygwin_conv_to_full_win32_path(REALCODEC_PATH,realpath);  sprintf(tmppath,"%s;%s",win32path,realpath);#endif /*USE_REALCODECS*/#else  if(!strstr(WIN32_PATH,":")){    GetModuleFileNameA(NULL, win32path, MAX_PATH);    strcpy(win32path + strlen(win32path) - strlen("mplayer.exe"), WIN32_PATH);  }  else strcpy(win32path,WIN32_PATH);  strcpy(tmppath,win32path);#ifdef USE_REALCODECS  if(!strstr(REALCODEC_PATH,":")){    GetModuleFileNameA(NULL, realpath, MAX_PATH);    strcpy(realpath + strlen(realpath) - strlen("mplayer.exe"), REALCODEC_PATH);  }  else strcpy(realpath,REALCODEC_PATH);  sprintf(tmppath,"%s;%s",win32path,realpath);#endif /*USE_REALCODECS*/#endif /*__CYGWIN__*/  SetEnvironmentVariableA("PATH", tmppath);}#endif /*WIN32 && USE_WIN32DLL*/if ( argv[0] )    mconfig = m_config_new();    m_config_register_options(mconfig,mplayer_opts);    // TODO : add something to let modules register their options    mp_input_register_options(mconfig);    parse_cfgfiles(mconfig);    playtree = m_config_parse_mp_command_line(mconfig, argc, argv);    if(playtree == NULL)      exit_player(NULL);    playtree = play_tree_cleanup(playtree);    if(playtree) {      playtree_iter = play_tree_iter_new(playtree,mconfig);      if(playtree_iter) {  	if(play_tree_iter_step(playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) {	  play_tree_iter_free(playtree_iter);	  playtree_iter = NULL;	}	filename = play_tree_iter_get_file(playtree_iter,1);      }    }	#ifdef WIN32	if(proc_priority){		int i;        	for(i=0; priority_presets_defs[i].name; i++){        		if(strcasecmp(priority_presets_defs[i].name, proc_priority) == 0)				break;		}		mp_msg(MSGT_CPLAYER,MSGL_STATUS,"Setting process priority: %s\n",				priority_presets_defs[i].name);		SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio);	}#endif	    if(use_gui){      mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui);      use_gui=0;    }    if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){      list_audio_out();      exit_player_with_rc(NULL, 0);    }// check codec.confif(!codecs_file || !parse_codec_cfg(codecs_file)){  if(!parse_codec_cfg(mem_ptr=get_path("codecs.conf"))){    if(!parse_codec_cfg(MPLAYER_CONFDIR "/codecs.conf")){      if(!parse_codec_cfg(NULL)){	mp_msg(MSGT_CPLAYER,MSGL_HINT,MSGTR_CopyCodecsConf);        exit_player_with_rc(NULL, 0);      }      mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_BuiltinCodecsConf);    }  }  free( mem_ptr ); // release the buffer created by get_path()}    if(audio_codec_list && strcmp(audio_codec_list[0],"help")==0){      mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableAudioCodecs);      list_codecs(1);      mp_msg(MSGT_FIXME, MSGL_FIXME, "\n");      exit_player_with_rc(NULL, 0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -