-
Notifications
You must be signed in to change notification settings - Fork 3
/
checkmarks.cpp
executable file
·108 lines (103 loc) · 2.85 KB
/
checkmarks.cpp
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
#include "vdr_cl.h"
int SysLogLevel = 3;
bool logcon=false;
int marksInfo(const char *recDir, int Info)
{
if( Info )
fprintf(stdout, "check marks in %s\n", recDir);
int iRet = 0;
bool bIsPes = isPESRecording(recDir);
double framesPerSec = DEFAULTFRAMESPERSECOND;
if( !bIsPes)
{
cRecordingInfo cri(recDir);
if( cri.Read() )
framesPerSec = cri.FramesPerSecond();
else
fprintf(stdout,"can't read info-File in %s, assume 25.0 FPS\n",recDir);
}
cMarks marks;
setMarkfileSuffix(bIsPes);
if( !marks.Load(recDir,framesPerSec,bIsPes) )
{
if( Info )
fprintf(stdout, "no marks for %s\n", recDir);
return 0;
}
cIndexFile cif(recDir,false,bIsPes);
cMark *m = marks.First();
while( m )
{
uint16_t FileNumber = 0;
off_t FileOffset = 0;
bool Independent = false;
int Length = 0;
if( !cif.Get(m->position, &FileNumber, &FileOffset, &Independent, &Length) )
{
if( Info )
fprintf(stdout, "can't get index for mark, position is %d\n",m->position);
}
if( !Independent )
iRet = 1;
//qint64 rpos = 0;
//int i = 1;
//while( i < FileNumber )
//{
// rpos += l[i-1].size();
// i++;
//}
//rpos += FileOffset;
//qDebug() << m->Index() << " " << m->position << " " << FileNumber << " " << FileOffset << " ==> " << rpos;
if(Info>1)
{
fprintf(stdout, "%s\n", (const char *)(m->ToText(false,true)));
fprintf(stdout, " File : %u\n", FileNumber);
fprintf(stdout, " Offset: %ld\n", FileOffset);
fprintf(stdout, " Index#: %d\n", m->position);
fprintf(stdout, " Independed Frame: %s\n", (Independent?"yes":"no"));;
}
m = marks.Next(m);
}
if( Info )
{
if( iRet == 1 )
fprintf(stdout, "marks in %s are faulty\n", recDir);
else
fprintf(stdout, "marks in %s are ok\n", recDir);
}
return iRet;
}
void usage()
{
printf("Usage: checkMarks <record> [0|1|2]\n"
" 0 (default) - no infos print to stdout\n"
" 1 show info about marks-state (ok or faulty)\n"
" 2 show detailed info for each mark found\n"
" returns 0 if marks are ok\n"
" returns 1 if marks are faulty\n"
);
}
int main(int argc, char *argv[])
{
openlog("checkMarks", LOG_PID | LOG_CONS, LOG_USER);
if( argc < 2 )
{
usage();
return 0;
}
#ifdef _MSC_VER
_set_fmode( O_BINARY );
#endif
char *cp = argv[1];
if( cp[strlen(cp)-1] == '/' )
cp[strlen(cp)-1] = '\0';
if( !isRecording(argv[1]) )
{
fprintf(stdout, "%s is not a vdr-dir\n", argv[1]);
return 2;
}
int i = 0;
if( argc > 2 )
i = atoi(argv[2]);
return marksInfo(argv[1], i);
}