Esempio n. 1
0
int main()
{
  int fd_pat=0;
  int fd_pmt=0;
  int fd_a=0;
  int fd_v=0;
  int fd_pcr=0;
  int fda=0;
  int fdv=0;

  int len = 0;
  int i;
  int ProgramCount = 0;
  int length;

  int Pnumber=0;

  int afile, vfile;
  int alen,vlen;
  unsigned char  audio_buffer[65536];
  unsigned char* video_buffer =audio_buffer;
  char key;

  if ((afile = open("audio_tmp", O_CREAT|O_TRUNC|O_RDWR)) < 0)
  {
    printf("Creat audio file Fail\n");
    goto exit;
  }

  if ((vfile = open("video_tmp", O_CREAT|O_TRUNC|O_RDWR)) < 0)
  {
    printf("Creat video file Fail\n");
    goto exit;
  }

  if ((fdv = open("/dev/vdec_dev", O_RDWR)) < 0)
  {
    printf("Open Video Fail\n");
    goto exit;
  }

  if ((fda = open("/dev/adec_dev", O_RDWR)) < 0)
  {
    printf("Open audio fail\n");
    goto exit;
  }


  if ((fd_pat = open("/dev/demuxapi0", O_RDONLY)) < 0)
  {
    printf("Error open demuxapi\n");
    goto exit;
  }

  if ((fd_pmt = open("/dev/demuxapi0", O_RDONLY)) < 0)
  {
    printf("Error open demuxapi\n");
    goto exit;
  }

  if ((fd_a = open("/dev/demuxapi0", O_RDONLY|O_NONBLOCK)) < 0)
  {
    printf("Error open demuxapi\n");
    goto exit;
  }

  if ((fd_v = open("/dev/demuxapi0", O_RDONLY|O_NONBLOCK)) < 0)
  {
    printf("Error open demuxapi\n");
    goto exit;
  }


  if ((fd_pcr = open("/dev/demuxapi0", O_RDONLY|O_NONBLOCK)) < 0)
  {
    printf("Error open demuxapi\n");
    goto exit;
  }


  if( ioctl( fdv, MPEG_VID_SELECT_SOURCE, 0) < 0)
  {
    printf("video clip mode init error\n");
    goto exit;
  }

  if( ioctl( fda, MPEG_AUD_SELECT_SOURCE, 0) < 0)
  {
    printf("audio clip mode init error\n");
    goto exit;
  }

  if( ioctl( fda, MPEG_AUD_SET_STREAM_TYPE, AUD_STREAM_TYPE_PES) < 0)
  {
    printf("select audio format error\n");
    goto exit;
  }

  ioctl(fda, MPEG_AUD_PLAY, 0);
  ioctl(fdv, MPEG_VID_PLAY, 0);
  ProgramCount = get_program_count(fd_pat);

  printf("Please choose a program to record (0-n)\n");
  Pnumber = getchar()-'0';

  if(Pnumber<0 || Pnumber>=ProgramCount)
  {
    printf("Invalid program number, please rechoose...\n");
    Pnumber = getchar()-'0';
  }

  printf("Pnumber = %d\n",Pnumber);

  if(0 > fcntl(0,F_SETFL,O_NONBLOCK))         //change the standard input to Non-block mode
  {
    printf("error change stdin mode\n");
    goto exit;
  }


  if(ProgramCount >0)
  {
    if(start_program(fd_pmt,fd_a,fd_v,fd_pcr,Pnumber,PLAY_TO_MEMORY))
      goto exit;

    while(1)
    {
      alen = read(fd_a,audio_buffer,65536);
      if (alen>0)
      {
//        printf("alen = %d\n",alen);
//        printf("PES packet = %d\n",(audio_buffer[4]*256 + audio_buffer[5] + 6));
        write(afile,audio_buffer, alen);
      }

      vlen = read(fd_v,video_buffer,65536);
      if (vlen>0)
      {
        write(vfile,video_buffer, vlen);
//        printf("vlen = %d\n", vlen);
      }

      if((read(0,&key,1) > 0) && key == 'q')
        break;
    }
  }

exit:
  if(fd_a)
    close(fd_a);
  if(fd_v)
    close(fd_v);
  if(fd_pmt)
    close(fd_pmt);
  if(fd_pcr)
    close(fd_pcr);
  if(fd_pat)
    close(fd_pat);
  if(afile)
    close(afile);
  if(vfile)
    close(vfile);

  return 0;
}
Esempio n. 2
0
File: main.c Progetto: bernds/UAE
void real_main (int argc, char **argv)
{
    FILE *hf;

#ifdef USE_SDL
    SDL_Init (SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE);
#endif

    default_prefs (&currprefs);

#ifdef SYSTEM_CFGDIR
    scan_configs (SYSTEM_CFGDIR);
#endif

    /* Can be overriden in graphics_setup, although there's not much of a
       point.  Fullscreen modes are filled in by graphics_setup.  */
    gfx_windowed_modes = default_windowed_modes;
    n_windowed_modes = sizeof default_windowed_modes / sizeof *default_windowed_modes;

    if (! graphics_setup ()) {
	exit (1);
    }

    rtarea_init ();
    hardfile_install ();
    scsidev_install ();

    parse_cmdline_and_init_file (argc, argv);

    machdep_init ();
    init_gtod ();

    if (! setup_sound ()) {
	write_log ("Sound driver unavailable: Sound output disabled\n");
	currprefs.produce_sound = 0;
    }
    inputdevice_init ();

    changed_prefs = currprefs;
    no_gui = ! currprefs.start_gui;
    if (! no_gui) {
	int err = gui_init (1);
	currprefs = changed_prefs;
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	} else if (err == -2) {
	    exit (0);
	}
    }
    if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) {
	write_log ("Sound driver unavailable: Sound output disabled\n");
	currprefs.produce_sound = 0;
    }

    fixup_prefs (&currprefs);
    changed_prefs = currprefs;

#ifdef SYSTEM_ROMDIR
    scan_roms (SYSTEM_ROMDIR, ROMLOC_SYSTEM);
#endif
    scan_roms (currprefs.path_rom, ROMLOC_USER);
    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();

    keybuf_init (); /* Must come after init_joystick */

    expansion_init ();
    memory_init ();

    filesys_install ();
    bsdlib_install ();
    emulib_install ();
    uaeexe_install ();
    native2amiga_install ();

    custom_init (); /* Must come after memory_init */
    serial_init ();
    DISK_init ();

    reset_frame_rate_hack ();
    init_m68k(); /* must come after reset_frame_rate_hack (); */

    gui_update ();

    if (graphics_init ()) {
	reset_drawing ();
	setup_brkhandler ();
	if (currprefs.start_debugger && debuggable ())
	    activate_debugger ();

	start_program ();
    }
    leave_program ();
}
Esempio n. 3
0
static int real_main2 (int argc, TCHAR **argv)
{

#ifdef USE_SDL
	SDL_Init (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);
#endif
	set_config_changed ();
	if (restart_config[0]) {
		default_prefs (&currprefs, 0);
		fixup_prefs (&currprefs);
	}

	if (! graphics_setup ()) {
		exit (1);
	}

#ifdef NATMEM_OFFSET
#ifdef FSUAE
	preinit_shm ();
#else
	//preinit_shm ();
#endif
#endif

	if (restart_config[0])
		parse_cmdline_and_init_file (argc, argv);
	else
		currprefs = changed_prefs;

	if (!machdep_init ()) {
		restart_program = 0;
		return -1;
	}

	if (console_emulation) {
		consolehook_config (&currprefs);
		fixup_prefs (&currprefs);
	}

	if (! setup_sound ()) {
		write_log (_T("Sound driver unavailable: Sound output disabled\n"));
		currprefs.produce_sound = 0;
	}
	inputdevice_init ();

	changed_prefs = currprefs;
	no_gui = ! currprefs.start_gui;
	if (restart_program == 2)
		no_gui = 1;
	else if (restart_program == 3)
		no_gui = 0;
	restart_program = 0;
	if (! no_gui) {
		int err = gui_init ();
		currprefs = changed_prefs;
		set_config_changed ();
		if (err == -1) {
			write_log (_T("Failed to initialize the GUI\n"));
			return -1;
		} else if (err == -2) {
			return 1;
		}
	}

	memset (&gui_data, 0, sizeof gui_data);
	gui_data.cd = -1;
	gui_data.hd = -1;
	gui_data.md = (currprefs.cs_cd32nvram || currprefs.cs_cdtvram) ? 0 : -1;
	logging_init (); /* Yes, we call this twice - the first case handles when the user has loaded
						 a config using the cmd-line.  This case handles loads through the GUI. */

#ifdef NATMEM_OFFSET
	init_shm ();
#endif
#ifdef WITH_LUA
	uae_lua_init ();
#endif
#ifdef PICASSO96
	picasso_reset ();
#endif

#if 0
#ifdef JIT
	if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize))
		canbang = 0;
#endif
#endif

	fixup_prefs (&currprefs);
#ifdef RETROPLATFORM
	rp_fixup_options (&currprefs);
#endif
	changed_prefs = currprefs;
	target_run ();
	/* force sound settings change */
	currprefs.produce_sound = 0;

	savestate_init ();
	keybuf_init (); /* Must come after init_joystick */

	memory_hardreset (2);
	memory_reset ();

#ifdef AUTOCONFIG
	native2amiga_install ();
#endif
	custom_init (); /* Must come after memory_init */
#ifdef SERIAL_PORT
	serial_init ();
#endif
	DISK_init ();
#ifdef WITH_PPC
	uae_ppc_reset(true);
#endif

	reset_frame_rate_hack ();
	init_m68k (); /* must come after reset_frame_rate_hack (); */

	gui_update ();

	if (graphics_init (true)) {
		setup_brkhandler ();
		if (currprefs.start_debugger && debuggable ())
			activate_debugger ();

		if (!init_audio ()) {
			if (sound_available && currprefs.produce_sound > 1) {
				write_log (_T("Sound driver unavailable: Sound output disabled\n"));
			}
			currprefs.produce_sound = 0;
		}
		start_program ();
	}
	return 0;
}