Debian Codegraph @

src/types.h

raw
1 /* dvbcut
2 Copyright (c) 2005 Sven Over <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 /* $Id$ */
20
21 #ifndef _DVBCUT_TYPES_H
22 #define _DVBCUT_TYPES_H
23
24 #include <sys/types.h>
25 #include <stdint.h>
26
27 #include "port.h"
28
29 class filepos_t
30 {
31 private:
32 uint64_t p;
33 public:
34 filepos_t(dvbcut_off_t pos, uint32_t offset):p((pos<<24)|(offset&0xffffff))
35 {}
36 filepos_t(uint64_t pos) : p(pos)
37 {}
38 ~filepos_t()
39 {}
40
41 dvbcut_off_t packetposition() const
42 {
43 return (p>>24);
44 }
45 uint32_t packetoffset() const
46 {
47 return uint32_t(p)&0xffffff;
48 }
49 dvbcut_off_t fileposition() const
50 {
51 return packetposition()+packetoffset();
52 }
53 operator uint64_t() const
54 {
55 return fileposition();
56 }
57
58 filepos_t &operator+=(uint32_t a)
59 {
60 p+=a;
61 return *this;
62 }
63 filepos_t operator+(uint32_t a) const
64 {
65 return filepos_t(p+a);
66 }
67 bool operator<(filepos_t a) const
68 {
69 return p<a.p;
70 }
71 bool operator<=(filepos_t a) const
72 {
73 return p<=a.p;
74 }
75 bool operator>(filepos_t a) const
76 {
77 return p>a.p;
78 }
79 bool operator>=(filepos_t a) const
80 {
81 return p>=a.p;
82 }
83 bool operator==(filepos_t a) const
84 {
85 return p==a.p;
86 }
87 bool operator!=(filepos_t a) const
88 {
89 return p!=a.p;
90 }
91 };
92
93 namespace streamtype
94 {
95 enum type { unknown, mpeg2video, mpegaudio, ac3audio };
96 };
97
98 #endif