www.pudn.com > MPEG2systemsrc.rar > Encoder.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.
*/
/* Encoder class */
#ifndef encoder_h
#define encoder_h
#include "Events.H"
#include "Producer.H"
#include "Directory.H"
#include "OutputPort.H"
#include "TS.H"
class TSProducer;
class ProducerRecord;
class TS;
class PES;
enum ProdType {ELEM, PSI, NULLPROD};
class Encoder
{
public:
Encoder (EventManager*);
// connect and send
void connect (OutputPort*);
void send_scheduled_packet ();
void send_packet (int);
// access functions
void set_bitrate (int);
void install_dir (Directory*);
Directory* get_dir ();
TS* get_ts (int);
PES* get_pes (int);
int packet_number;
TimeStamp27 sys_time;
TimeStamp27 sys_const;
// other utilities
int new_pid ();
private:
EventManager* manager;
Directory* dir;
TSProducer* tsprod;
OutputPort* oport;
int bitrate; // bits per second in 1000's
int psi_rate;
TimeStamp27 packet_time;
ProducerRecord* head_prec;
void send_packet (ProducerRecord*);
ProducerRecord* add_prod (TS*, Producer*, ProdType, int);
void delete_prod (int);
Producer* get_prod (int);
ProducerRecord* find_prec (int);
void build_records ();
int recalc_mux ();
};
class ProducerRecord
{
public:
ProducerRecord (TS*, Producer*, ProdType);
ProdType type;
TS* ts;
int pcr_flag;
TimeStamp27 next_pcr; // nonzero only for pcr_pids
Producer* prod;
int stream_band;
double gap;
double cur_gap;
ProducerRecord* next_prec;
};
/*
DOCUMENTATION
An Encoder is basically an encapsulation of the environment present
during a transport stream multiplex operation. The Encoder object
manages such global information as the overall tranport stream
bitrate, the OutputPort, the Network Table pid value and the number
of programs and number of streams per program (as represented in a
Directory structure).
Internally an Encoder manages a lookup table associating each
active pid value with a Producer and other pid-specific information.
The multiplex algorithm will calculate the next outgoing pid value by
examining this table and will then use the corresponding Producer to
produce the payload for that pid value. At this time a TS object
associated with the current pid value will also be installed as the
Encoder's current TS object.
The Encoder also maintains a 27MHz system clock. This clock is
incremented each time a transport packet is produced (in constant
increments depending on the overall bitrate) and can be queried by
other modules (such as the PES packet generator when PTS and DTS are
generated). The encoder increments a packet_number field.
The Encoder supports two packet-producing functions:
void send_scheduled_packet ();
Will call the scheduling algorithm to determine the next pid value
to be sent in the mux and send a packet with that pid value.
void send_packet (int n);
Will not invoke the scheduling algorithm but will send a packet
with pid value n.
*/
#endif