3
* interact.h: Program/System stream packet generator
5
* Copyright (C) 2003 Andrew Stevens <andrew.stevens@philips.com>
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of version 2 of the GNU General Public License
10
* as published by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
#ifndef __SYSTEMS_HH__
23
#define __SYSTEMS_HH__
25
#include "inputstrm.hpp"
26
#include "outputstrm.hpp"
31
/* Buffer size parameters */
33
#define MAX_SECTOR_SIZE 16384
34
#define MAX_PACK_HEADER_SIZE 255
35
#define MAX_SYS_HEADER_SIZE 255
38
typedef struct sector_struc /* Ein Sektor, kann Pack, Sys Header */
39
/* und Packet enthalten. */
40
{ unsigned char buf [MAX_SECTOR_SIZE] ;
41
unsigned int length_of_packet_data ;
45
struct Pack_struc /* Pack Info */
47
uint8_t buf[MAX_PACK_HEADER_SIZE];
52
struct Sys_header_struc /* System Header Info */
54
uint8_t buf[MAX_SYS_HEADER_SIZE];
62
PS_Stream( unsigned _mpeg,
63
unsigned int _sector_size,
64
OutputStream &_output_strm,
65
off_t max_segment_size // 0 = No Limit
69
unsigned int PacketPayload( MuxStream &strm,
70
Sys_header_struc *sys_header,
71
Pack_struc *pack_header,
72
int buffers, int PTSstamp, int DTSstamp );
74
unsigned int CreateSector (Pack_struc *pack,
75
Sys_header_struc *sys_header,
76
unsigned int max_packet_data_size,
84
static void BufferSectorHeader( uint8_t *buf,
86
Sys_header_struc *sys_header,
87
uint8_t *&header_end );
88
static void BufferPacketHeader( uint8_t *buf,
90
unsigned int mpeg_version,
92
unsigned int buffer_size,
97
unsigned int min_pes_hdr_len,
99
uint8_t *&header_end );
102
BufferPacketSize( uint8_t *size_field, uint8_t *packet_end )
104
unsigned int packet_size = packet_end-size_field-2;
105
size_field[0] = static_cast<uint8_t>(packet_size>>8);
106
size_field[1] = static_cast<uint8_t>(packet_size&0xff);
110
virtual void CreatePack ( Pack_struc *pack,
112
unsigned int mux_rate
114
virtual void CreateSysHeader ( Sys_header_struc *sys_header,
115
unsigned int rate_bound,
120
vector<MuxStream *> &streams
123
inline int Open() { return output_strm.Open(); }
124
inline void Close() { output_strm.Close(); }
125
inline void RawWrite(uint8_t *data, unsigned int len)
127
return output_strm.Write( data, len );
129
inline void NextSegment() { output_strm.NextSegment(); }
130
bool SegmentLimReached();
135
BufferDtsPtsMpeg1ScrTimecode (clockticks timecode,
138
static void BufferMpeg2ScrTimecode( clockticks timecode,
140
void BufferPaddingPacket( int padding,
143
OutputStream &output_strm;
144
unsigned int mpeg_version;
145
unsigned int sector_size;
146
off_t max_segment_size;
149
#endif // __SYSTEMS_HH__
154
* c-file-style: "stroustrup"
156
* indent-tabs-mode: nil