www.pudn.com > MPEG2systemsrc.rar > PESConsumer.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.
*/
/* PESConsumer class */
#ifndef pesconsumer_h
#define pesconsumer_h
#include "Consumer.H"
#include "PES.H"
#include "OutputPort.H"
// PESConsumer CState values
#define PCHEAD1 1
#define PCHEAD2 2
#define PCPAYLOAD 3
class PESConsumer : public Consumer
{
public:
PESConsumer (Decoder*, PES*);
PES* pes;
virtual int read_partial (int);
void read_pes_header ();
int pes_out_flag;
OutputPort* esport;
virtual void flush ();
private:
char* buf;
int buf_index;
int header_length;
void read_trick_mode ();
void read_field_id ();
void read_frequency_truncation ();
void read_extension ();
void write_elementary_stream_chunk (char*, int);
};
/*
DOCUMENTATION
PESConsumers will read PES packets from InputPorts. The member
variable, iport, is inherited from the base class Consumer.
Payload from the PES packets is written to the OutputPort, esport.
The member esport can either be set by the application or it will be
set internally. The actual payload bytes are ignored. Entire PES
packets are written to esport if the flag pes_out_flag is TRUE.
Public members are:
PESConsumer (Decoder*, PES*);
The only constructor.
PES* pes;
pes is set during the parse of the pes packet to reflect the
structure of the packet. Thus an application can call
read_pes_header and then examine the pes member to determine the
structure of the packet.
virtual int read_partial (int);
Will read a specified number of bytes into the buffer buf. When
the end of the PES header is reached the header is parsed and a
PESHeaderParsed event is triggered.
void read_pes_header ();
This function can be called directly by an application but is also
used internally by the member function read_partial to parse the
PES header when the entire header has arrived.
int pes_out_flag;
When set to TRUE the PES header is output with the elementary
stream onto the port esport.
OutputPort* esport;
Payload from the PES packet is output to esport. If it has a null
value when it is needed, then it is set with the call:
esport = new OPortToFile(fileName, 0);
where fileName is set to "stream" where is set to the
decoder's current pid value.
virtual void flush ();
This will flush the esport.
*/
#endif