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

📄 mplayer_novideo_0.00.c

📁 自己移植的linux下的流媒体播放器原代码,支持mms协议,支持ftp和http协议.
💻 C
📖 第 1 页 / 共 5 页
字号:
#endifif(slave_mode)#ifndef __MINGW32__   mp_input_add_cmd_fd(0,1,NULL,NULL);#else  mp_input_add_cmd_fd(0,0,mp_input_win32_slave_cmd_func,NULL);#endifelse if(!noconsolecontrols)#ifndef HAVE_NO_POSIX_SELECT  mp_input_add_key_fd(0,1,NULL,NULL);#else  mp_input_add_key_fd(0,0,NULL,NULL);#endifinited_flags|=INITED_INPUT;current_module = NULL;#ifdef HAVE_MENU if(use_menu) {   if(menu_cfg && menu_init(menu_cfg))     mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitialized, menu_cfg);   else {     menu_cfg = get_path("menu.conf");     if(menu_init(menu_cfg))       mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitialized, menu_cfg);     else {       if(menu_init(MPLAYER_CONFDIR "/menu.conf"))         mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitialized, MPLAYER_CONFDIR"/menu.conf");       else {         mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_MenuInitFailed);         use_menu = 0;       }     }   } }#endif    /// Catch signals#ifndef __MINGW32__  signal(SIGCHLD,child_sighandler);#endif#ifdef CRASH_DEBUG  prog_path = argv[0];#endif  //========= Catch terminate signals: ================  // terminate requests:  signal(SIGTERM,exit_sighandler); // kill  signal(SIGHUP,exit_sighandler);  // kill -HUP  /  xterm closed  signal(SIGINT,exit_sighandler);  // Interrupt from keyboard  signal(SIGQUIT,exit_sighandler); // Quit from keyboard#ifdef ENABLE_SIGHANDLER  // fatal errors:  signal(SIGBUS,exit_sighandler);  // bus error  signal(SIGSEGV,exit_sighandler); // segfault  signal(SIGILL,exit_sighandler);  // illegal instruction  signal(SIGFPE,exit_sighandler);  // floating point exc.  signal(SIGABRT,exit_sighandler); // abort()#ifdef CRASH_DEBUG  if (crash_debug)    signal(SIGTRAP,exit_sighandler);#endif#endif#ifdef HAVE_NEW_GUI  if(use_gui){       guiInit();       inited_flags|=INITED_GUI;       guiGetEvent( guiCEvent,(char *)((gui_no_filename) ? 0 : 1) );  }#endif// ******************* Now, let's see the per-file stuff ********************play_next_file:  // init global sub numbers  global_sub_size = 0;  { int i; for (i = 0; i < SUB_SOURCES; i++) global_sub_indices[i] = -1; }  global_sub_quiet_osd_hack = 1;  if (filename) load_per_file_config (mconfig, filename);// We must enable getch2 here to be able to interrupt network connection// or cache fillingif(!noconsolecontrols && !slave_mode){  if(inited_flags&INITED_GETCH2)    mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_Getch2InitializedTwice);  else    getch2_enable();  // prepare stdin for hotkeys...  inited_flags|=INITED_GETCH2;  mp_msg(MSGT_CPLAYER,MSGL_DBG2,"\n[[[init getch2]]]\n");}// =================== GUI idle loop (STOP state) ===========================#ifdef HAVE_NEW_GUI    if ( use_gui ) {      file_format=DEMUXER_TYPE_UNKNOWN;      guiGetEvent( guiSetDefaults,0 );      while ( guiIntfStruct.Playing != 1 )       {        mp_cmd_t* cmd;                                                                                   	usec_sleep(20000);	guiEventHandling();	guiGetEvent( guiReDraw,NULL );	if ( (cmd = mp_input_get_cmd(0,0,0)) != NULL) guiGetEvent( guiIEvent,(char *)cmd->id );       }       guiGetEvent( guiSetParameters,NULL );      if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM )       {        play_tree_t * entry = play_tree_new();        play_tree_add_file( entry,guiIntfStruct.Filename );        if ( playtree ) play_tree_free_list( playtree->child,1 );         else playtree=play_tree_new();        play_tree_set_child( playtree,entry );        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);	   }         }       }     }#endif//---------------------------------------------------------------------------    if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);//==================== Open VOB-Sub ============================    current_module="vobsub";    if (vobsub_name){      vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec);      if(vo_vobsub==NULL)        mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name);    }else if(sub_auto && filename && (strlen(filename)>=5)){      /* try to autodetect vobsub from movie filename ::atmos */      char *buf = malloc((strlen(filename)-3) * sizeof(char));      memset(buf,0,strlen(filename)-3); // make sure string is terminated      strncpy(buf, filename, strlen(filename)-4);       vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec);      free(buf);    }    if(vo_vobsub){      inited_flags|=INITED_VOBSUB;      vobsub_set_from_lang(vo_vobsub, dvdsub_lang);      // check if vobsub requested only to display forced subtitles      forced_subs_only=vobsub_get_forced_subs_flag(vo_vobsub);      // setup global sub numbering      global_sub_indices[SUB_SOURCE_VOBSUB] = global_sub_size; // the global # of the first vobsub.      global_sub_size += vobsub_get_indexes_count(vo_vobsub);    }//============ Open & Sync STREAM --- fork cache2 ====================  stream=NULL;  demuxer=NULL;  if (d_audio) {    //free_demuxer_stream(d_audio);    d_audio=NULL;  }  if (d_video) {    //free_demuxer_stream(d_video);    d_video=NULL;  }  sh_audio=NULL;  sh_video=NULL;  current_module="open_stream";  stream=open_stream(filename,0,&file_format);  if(!stream) { // error...    eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY);    goto goto_next_file;  }  inited_flags|=INITED_STREAM;#ifdef HAVE_NEW_GUI  if ( use_gui ) guiGetEvent( guiSetStream,(char *)stream );#endif  if(file_format == DEMUXER_TYPE_PLAYLIST) {    play_tree_t* entry;    // Handle playlist    current_module="handle_playlist";    mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",filename);    entry = parse_playtree(stream,0);    eof=playtree_add_playlist(entry);    goto goto_next_file;  }  stream->start_pos+=seek_to_byte;if(stream_dump_type==5){  unsigned char buf[4096];  int len;  FILE *f;  current_module="dumpstream";  if(stream->type==STREAMTYPE_STREAM && stream->fd<0){    mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_DumpstreamFdUnavailable);    exit_player(MSGTR_Exit_error);  }  stream_reset(stream);  stream_seek(stream,stream->start_pos);  f=fopen(stream_dump_name,"wb");  if(!f){    mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CantOpenDumpfile);    exit_player(MSGTR_Exit_error);  }  while(!stream->eof){      len=stream_read(stream,buf,4096);      if(len>0) {        if(fwrite(buf,len,1,f) != 1) {          mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile,stream_dump_name);          exit_player(MSGTR_Exit_error);        }      }  }  if(fclose(f)) {    mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile,stream_dump_name);    exit_player(MSGTR_Exit_error);  }  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CoreDumped);  exit_player_with_rc(MSGTR_Exit_eof, 0);}#ifdef USE_DVDREADif(stream->type==STREAMTYPE_DVD){  current_module="dvd lang->id";  if(audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang);  if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang);  // setup global sub numbering  global_sub_indices[SUB_SOURCE_DEMUX] = global_sub_size; // the global # of the first demux-specific sub.  global_sub_size += dvd_number_of_subs(stream);  current_module=NULL;}#endif#ifdef USE_DVDNAV  if (stream->type==STREAMTYPE_DVDNAV) stream_cache_size=0;	// must disable caching...#endif// CACHE2: initial prefill: 20%  later: 5%  (should be set by -cacheopts)#ifdef HAS_DVBIN_SUPPORTgoto_enable_cache:#endifif(stream_cache_size>0){  current_module="enable_cache";  if(!stream_enable_cache(stream,stream_cache_size*1024,stream_cache_size*1024*(stream_cache_min_percent / 100.0),stream_cache_size*1024*(stream_cache_prefill_percent / 100.0)))    if((eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file;}//============ Open DEMUXERS --- DETECT file type =======================current_module="demux_open";demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id,filename);// HACK to get MOV Reference Files workingif (demuxer && demuxer->type==DEMUXER_TYPE_PLAYLIST){   unsigned char* playlist_entry;  play_tree_t *list = NULL, *entry = NULL;  current_module="handle_demux_playlist";  while (ds_get_packet(demuxer->video,&playlist_entry)>0)  {	     char *temp, *bname;        mp_msg(MSGT_CPLAYER,MSGL_V,"Adding file %s to element entry.\n",playlist_entry);    bname=mp_basename(playlist_entry);    if ((strlen(bname)>10) && !strncmp(bname,"qt",2) && !strncmp(bname+3,"gateQT",6))        continue;    if (!strncmp(bname,mp_basename(filename),strlen(bname))) // ignoring self-reference        continue;    entry = play_tree_new();        if (filename && !strcmp(mp_basename(playlist_entry),playlist_entry)) // add reference path of current file    {      temp=malloc((strlen(filename)-strlen(mp_basename(filename))+strlen(playlist_entry)+1)*sizeof(char));      if (temp)      {	strncpy(temp, filename, strlen(filename)-strlen(mp_basename(filename)));	temp[strlen(filename)-strlen(mp_basename(filename))]='\0';	strcat(temp, playlist_entry);	play_tree_add_file(entry,temp);	mp_msg(MSGT_CPLAYER,MSGL_V,"Resolving reference to %s.\n",temp);	free(temp);      }    }    else      play_tree_add_file(entry,playlist_entry);        if(!list)      list = entry;    else      play_tree_append_entry(list,entry);  }  free_demuxer(demuxer);  demuxer = NULL;  if (list)  {    entry = play_tree_new();    play_tree_set_child(entry,list);    eof=playtree_add_playlist(entry);    goto goto_next_file;  }}if(!demuxer) {#if 0  play_tree_t* entry;  // Handle playlist  current_module="handle_playlist";  switch(stream->type){  case STREAMTYPE_VCD:  case STREAMTYPE_DVD:  case STREAMTYPE_DVDNAV:  case STREAMTYPE_CDDA:  case STREAMTYPE_VCDBINCUE:    // don't try to parse raw media as playlist, it's unlikely    goto goto_next_file;  }  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_FallingBackOnPlaylist,filename);  stream_reset(stream);  stream_seek(stream,stream->start_pos);  entry = parse_playtree(stream,0);  if(!entry)    mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);  else    eof=playtree_add_playlist(entry);#endif  goto goto_next_file;}inited_flags|=INITED_DEMUXER;#ifdef HAVE_MATROSKAif (demuxer->type==DEMUXER_TYPE_MATROSKA) {  // setup global sub numbering  global_sub_indices[SUB_SOURCE_DEMUX] = global_sub_size; // the global # of the first demux-specific sub.  global_sub_size += demux_mkv_num_subs(demuxer);}#endif#ifdef HAVE_OGGVORBISif (demuxer->type==DEMUXER_TYPE_OGG) {  // setup global sub numbering  global_sub_indices[SUB_SOURCE_DEMUX] = global_sub_size; // the global # of the first demux-specific sub.  global_sub_size += demux_ogg_num_subs(demuxer);}#endifcurrent_module="demux_open2";//file_format=demuxer->file_format;d_audio=demuxer->audio;d_video=demuxer->video;d_dvdsub=demuxer->sub;// DUMP STREAMS:if((stream_dump_type)&&(stream_dump_type<4)){  FILE *f;  demux_stream_t *ds=NULL;  current_module="dump";  // select stream to dump  switch(stream_dump_type){  case 1: ds=d_audio;break;  case 2: ds=d_video;break;  case 3: ds=d_dvdsub;break;  }  if(!ds){              mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_DumpSelectedStreamMissing);      exit_player(MSGTR_Exit_error);  }  // disable other streams:  if(d_audio && d_audio!=ds) {ds_free_packs(d_audio); d_audio->id=-2; }  if(d_video && d_video!=ds) {ds_free_packs(d_video); d_video->id=-2; }  if(d_dvdsub && d_dvdsub!=ds) {ds_free_packs(d_dvdsub); d_dvdsub->id=-2; }  // let's dump it!  f=fopen(stream_dump_name,"wb");  if(!f){    mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CantOpenDumpfile);    exit_player(MSGTR_Exit_error);  }  while(!ds->eof){    unsigned char* start;    int in_size=ds_get_packet(ds,&start);    if( (demuxer->file_format==DEMUXER_TYPE_AVI || demuxer->file_format==DEMUXER_TYPE_ASF || demuxer->file_format==DEMUXER_TYPE_MOV)	&& stream_dump_type==2) fwrite(&in_size,1,4,f);    if(in_size>0) fwrite(start,in_size,1,f);  }  fclose(f);  mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CoreDumped);  exit_player_with_rc(MSGTR_Exit_eof, 0);}sh_audio=d_audio->sh;sh_video=d_video->sh;if(sh_video){  current_module="video_read_properties";  if(!video_read_properties(sh_video)) {    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotReadVideoProperties);    sh_video=d_video->sh=NULL;  } else {    mp_msg(MSGT_CPLAYER,MSGL_V,"[V] filefmt:%d  fourcc:0x%X  size:%dx%d  fps:%5.2f  ftime:=%6.4f\n",	   demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h,	   sh_video->fps,sh_video->frametime	   );    /* need to set fps here for output encoders to pick it up in their init */    if(force_fps){      sh_video->fps=force_fps;      sh_video->frametime=1.0f/sh_video->fps;    }    vo_fps = sh_video->fps;#ifdef HAVE_X11    vo_mouse_timer_const=(int)sh_video->fps;#endif    if(!sh_video->fps && !force_fps){      mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_FPSnotspecified);      sh_video=d_video->sh=NULL;    }  }}fflush(stdout);if(!sh_video && !sh_audio){    mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NoStreamFound);#ifdef HAS_DVBIN_SUPPORT	if((stream->type == STREAMTYPE_DVB) && stream->priv)	{	  dvb_priv_t *priv = (dvb_priv_t*) stream->priv;	  if(priv->is_on)	  {		int dir;		int v = last_dvb_step;		if(v > 0)			dir = DVB_CHANNEL_HIGHER;		else

⌨️ 快捷键说明

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