www.pudn.com > MPEG2systemsrc.rar > pesout.C


/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved.
 *
 *   Usage Restrictions
 *
 * License is granted to copy, to use, and to make and to use derivative
 * works for research and evaluation purposes only.
 *
 *   Disclaimer of Warranty
 *
 * These software programs are available to the user without any license
 * fee or royalty on an "as is" basis.  Tektronix Inc. disclaims any and
 * all warranties, whether express, implied, or statuary, including any
 * implied warranties or merchantability or of fitness for a particular
 * purpose.  In no event shall the copyright-holder be liable for any 
 * incidental, punitive, or consequential damages of any kind whatsoever
 * arising from the use of these programs.
 *
 * This disclaimer of warranty extends to the user of these programs and
 * user's customers, employees, agents, transferees, successors, and
 * assigns.
 *
 * The Tektronix Inc. does not represent or warrant that the programs
 * furnished hereunder are free of infringement of any third-party
 * patents.
*/

/* pes stream generator */

#include "Events.H"
#include "Directory.H"
#include "Encoder.H"
#include "OPortToFile.H"
#include "PESProducer.H"

extern "C"
{
void exit (int);
}

main (int argc, char* argv[])
{
  if ((argc != 2) && (argc != 3))
    {
      printf("syntax is encode \n");
      exit(0);
    }

  // create EventManager
  EventManager* manager = new EventManager();

  // create a Encoder
  Encoder* encoder = new Encoder(manager);
  
  // build consumer, port and connect
  PES* pes = new PES();
  PESProducer* pprod = new PESProducer(encoder, pes);
  OPortToFile* oport = new OPortToFile(argv[1], (argc == 3));
  pprod->connect(oport);
  pprod->timestamp_lock = TRUE;
  
  // configure pes
  pes->file_name = "streama";
  
  // send some packets
  for (int i = 0; i < 100; i++)
    {
      if (i == (i / 10) * 10)
	pes->config_basic(int(id_video_stream_0 + 1),
			  4090 + 100*i, '0', 'H', '0', '0', '0',
			  new TimeStamp90(688+i), new TimeStamp90(650+i),
			  NULL, NULL, NULL, NULL, 0);
      else
	pes->config_basic(int(id_video_stream_0 + 1),
			  4090 + 100*i, '0', 'H', '0', '0', '0',
			  NULL, NULL, NULL, NULL, NULL, NULL, 0);
      
      pprod->send_pes_packet();
    }

  printf("\ndone\n");
  delete oport;
}