www.pudn.com > MPEG2systemsrc.rar > TS.H


/* 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.
*/

/* TS class and AdaptationField class */
#ifndef ts_h
#define ts_h

#include "TimeStamp.H"

class AdaptationField;

#define NOCC -2

class TS
{
public:
  TS ();
  char transport_error_code;            // (E,0) - Error
  char payload_unit_start_code;         // (A,0) - Aligned
  char priority_code;                   // (H,L) - High or Low
  int pid;                              // 0..2^13-1
  char scrambling_code;                 // (S,0) - Scrambled
  int continuity_counter;               // 0..15
  AdaptationField* adaptation;          // may be NULL
  char payload_code;                    // (P,0) - Payload in packet
  int get_header_length ();             // total: adaptation field + 4

  void config_basic (char, char, char, char, int, char);
  // Error, Aligned, Priority, Scramble, continuity, Payload

  void config_adaptation (char, char, char, TimeStamp27*, TimeStamp27*,
			  int, int, int, int);
  // Dis., Random, Priority, PCR, OPCR, splice, data_len, ext_len, stuff_len

  void inc_cc ();
  void add_pcr (TimeStamp27);
  void delete_pcr ();    
  void print ();                                        
};

#define NOSPLICE 1023
#define NOLENGTH -1

class AdaptationField
{
public:
  AdaptationField ();
  int adaptation_field_length;          // 0..184 or NOLENGTH
  char discontinuity_code;              // (D,0) - Discontinuity
  char random_access_code;              // (R,0) - Random access
  char elem_stream_priority_code;       // (H,L) - High or Low
  TimeStamp27* PCR;                     // may be NULL
  TimeStamp27* OPCR;                    // may be NULL
  int splice_countdown;                 // -255..255 or NOSPLICE
  int transport_private_data_length;    // 1..255? or NULL
  int adaptation_extension_length;      // 1..255? or NULL
  int number_stuffing_bytes;            // 0..184?
  int get_fields_length ();             // total: just the flagged fields
  int get_length ();                    // total: adaptation_field_length + 1
  void print ();
};

/*
 DOCUMENTATION

 TS is an example of a syntax class; its objects encapsulate the
 structure of a transport stream packet.  When generating packets
 (say in an encoder application) TS objects are used as templates.
 Changing the template will change the structure of the packets being
 generated.  When parsing packets (say in a decoder application) TS
 objects are set to reflect the structure of the packet being parsed
 and can then be examined by the application. 

 Mnemonic chars are used to represent the various values of the fields (e.g.
 the priority_code can be 'H' or 'L' for High or Low).  These are
 listed in the above comments.

 All the fields are exposed as public members for simplicity.

 A function inc_cc is provided to increment the continuity_counter
 field (mod 16) and functions are provided for adding and deleting PCRs.

 Two configure methods are provided to easily set multiple fields.

 AdaptationFields are broken out as a separate class. 
*/

#endif