summaryrefslogtreecommitdiff
path: root/command/marks.h
blob: 8ea4a99491600b418aa5be381eb85bcfd31ca1fc (plain)
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
/*
 * marks.h: A program for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#ifndef __marks_h_
#define __marks_h_

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdint.h>
#include <fcntl.h>

class clMark
{
private:
    clMark *next;
    clMark *prev;
public:
    int type;
    int position;
    char *comment;
    clMark(int Type=0, int Position = 0, const char *Comment = NULL);
    ~clMark();
    clMark *Next()
    {
        return next;
    };
    clMark *Prev()
    {
        return prev;
    };
    void Set(clMark *Prev, clMark *Next)
    {
        prev=Prev;
        next=Next;
    }
    void SetNext(clMark *Next)
    {
        next=Next;
    }
    void SetPrev(clMark *Prev)
    {
        prev=Prev;
    }
};

class clMarks
{
private:
    struct tIndexVDR
    {
        int offset;
        unsigned char type;
        unsigned char number;
        short reserved;
    };

    struct tIndexTS
    {
uint64_t offset:
        40;
int reserved:
        7;
int independent:
        1;
uint16_t number:
        16;
    };

    char filename[1024];
    clMark *first,*last;
    char *IndexToHMSF(int Index, double FramesPerSecond);
    int count;
    int savedcount;
public:
    clMarks()
    {
        strcpy(filename,"marks");
        first=last=NULL;
        savedcount=0;
        count=0;
    }
    ~clMarks();
    int Count(int Type=0xFF);
    void SetFileName(const char *FileName)
    {
        if (FileName)
        {
            strncpy(filename,FileName,sizeof(filename)-1);
            filename[sizeof(filename)-1]=0;
        }
    }
    clMark *Add(int Type, int Position, const char *Comment = NULL);
    void Clear();
    void Del(clMark *Mark);
    void Del(int Type);
    clMark *Get(int Position);
    clMark *GetPrev(int Position,int Type=0xFF);
    clMark *GetNext(int Position,int Type=0xFF);
    clMark *GetFirst()
    {
        return first;
    }
    clMark *GetLast()
    {
        return last;
    }
    bool Backup(const char *Directory, bool isTS);
    bool Save(const char *Directory, double FrameRate, bool isTS);
    bool CheckIndex(const char *Directory, bool isTS, bool *IndexError);
};

#endif