1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
/*
* markad-standalone.h: A program for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __markad_standalone_h_
#define __markad_standalone_h_
#include "global.h"
#include "demux.h"
#include "decoder.h"
#include "video.h"
#include "audio.h"
#include "streaminfo.h"
#include "marks.h"
#define tr(s) dgettext("markad",s)
#define IGNORE_VIDEOINFO 1
#define IGNORE_AUDIOINFO 2
#define IGNORE_TIMERINFO 4
#define DELTATIME 20000 /* equals to 222ms (base is 90kHz PTS) */
#define MAXRANGE 120 /* range to search for start/stop marks in seconds */
class cOSDMessage
{
private:
const char *host;
int port;
char *msg;
pthread_t tid;
static void *send(void *osd);
bool readreply(int fd);
public:
int Send(const char *format, ...);
cOSDMessage(const char *Host, int Port);
~cOSDMessage();
};
class cMarkAdStandalone
{
private:
struct PAT
{
unsigned table_id:
8;
unsigned section_length_H:
4;
unsigned reserved1:
2;
unsigned zero:
1;
unsigned section_syntax_indicator:
1;
unsigned section_length_L:
8;
unsigned transport_stream_id_H:
8;
unsigned transport_stream_id_L:
8;
unsigned current_next_indicator:
1;
unsigned version_number:
5;
unsigned reserved2:
2;
unsigned section_number:
8;
unsigned last_section_number:
8;
unsigned program_number_H:
8;
unsigned program_number_L:
8;
unsigned pid_H:
5;
unsigned reserved3:
3;
unsigned pid_L:
8;
};
struct PMT
{
unsigned table_id:
8;
unsigned section_length_H:
4;
unsigned reserved1:
2;
unsigned zero:
1;
unsigned section_syntax_indicator:
1;
unsigned section_length_L:
8;
unsigned program_number_H:
8;
unsigned program_number_L:
8;
unsigned current_next_indicator:
1;
unsigned version_number:
5;
unsigned reserved2:
2;
unsigned section_number:
8;
unsigned last_section_number:
8;
unsigned PCR_PID_H:
5;
unsigned reserved3:
3;
unsigned PCR_PID_L:
8;
unsigned program_info_length_H:
4;
unsigned reserved4:
4;
unsigned program_info_length_L:
8;
};
#pragma pack(1)
struct STREAMINFO
{
unsigned stream_type:
8;
unsigned PID_H:
5;
unsigned reserved1:
3;
unsigned PID_L:
8;
unsigned ES_info_length_H:
4;
unsigned reserved2:
4;
unsigned ES_info_length_L:
8;
};
#pragma pack()
struct ES_DESCRIPTOR
{
unsigned Descriptor_Tag:
8;
unsigned Descriptor_Length:
8;
};
enum { mSTART=0x1, mBEFORE, mAFTER };
static const char frametypes[8];
const char *directory;
cDemux *demux;
cMarkAdDecoder *decoder;
cMarkAdVideo *video;
cMarkAdAudio *audio;
cMarkAdStreamInfo *streaminfo;
cOSDMessage *osd;
AvPacket pkt;
MarkAdContext macontext;
char title[80],*ptitle;
bool CreatePidfile();
void RemovePidfile();
bool duplicate; // are we a dup?
bool isTS;
int MaxFiles;
int lastiframe;
int iframe;
int framecnt;
int framecnt2; // 2nd pass
bool abort;
bool gotendmark;
int waittime;
int iwaittime;
struct timeval tv1,tv2;
struct timezone tz;
bool noticeVDR_MP2;
bool noticeVDR_AC3;
bool noticeHEADER;
bool noticeFILLER;
bool bDecodeVideo;
bool bDecodeAudio;
bool bIgnoreAudioInfo;
bool bIgnoreVideoInfo;
bool bIgnoreTimerInfo;
time_t startTime; // starttime of broadcast
int length; // length of broadcast in seconds
int tStart; // pretimer in seconds
int iStart; // pretimer in frames (negative if unset)
int iStop; // endposition in frames (negative if unset)
void CheckStop();
void CheckStart();
void CalculateCheckPositions(int startframe);
int chkSTART;
int chkSTOP;
int skipped; // skipped bytes in whole file
bool inBroadCast; // are we in a broadcast (or ad)?
time_t GetBroadcastStart(time_t start, int fd);
void CheckIndexGrowing();
char *indexFile;
int sleepcnt;
void SaveFrame(int Frame);
clMarks marks;
char *IndexToHMSF(int Index);
void AddMark(MarkAdMark *Mark);
bool Reset(bool FirstPass=true);
void ChangeMarks(clMark **Mark1, clMark **Mark2, MarkAdPos *NewPos);
bool CheckVDRHD();
off_t SeekPATPMT();
bool CheckPATPMT(off_t Offset=0);
bool CheckTS();
bool LoadInfo();
bool SaveInfo();
bool SetFileUID(char *File);
bool RegenerateIndex();
bool ProcessFile2ndPass(clMark **Mark1, clMark **Mark2, int Number, off_t Offset, int Frame, int Frames);
bool ProcessFile(int Number);
void ProcessFile();
public:
void SetAbort()
{
abort=true;
}
void Process2ndPass();
void Process();
cMarkAdStandalone(const char *Directory, const MarkAdConfig *config);
~cMarkAdStandalone();
};
#endif
|