forked from wlanjie/mp4
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatomfactory.h
88 lines (64 loc) · 2.09 KB
/
atomfactory.h
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
//
// Created by wlanjie on 2018/2/7.
//
#ifndef MP4_ATOMFACTORY_H
#define MP4_ATOMFACTORY_H
#include "atom.h"
#include "array.h"
namespace mp4 {
class AtomFactory {
public:
// types
class TypeHandler {
public:
virtual ~TypeHandler() {};
virtual Result createAtom(Atom::Type type,
UI32 size,
ByteStream &stream,
Atom::Type context,
Atom *&atom) = 0;
};
// constructor
AtomFactory() {}
// destructor
virtual ~AtomFactory();
// methods
Result addTypeHandler(TypeHandler *handler);
Result removeTypeHandler(TypeHandler *handler);
Result createAtomFromStream(ByteStream &stream,
LargeSize &bytesAvailable,
Atom *&atom);
virtual Result createAtomFromStream(ByteStream &stream,
UI32 type,
UI32 size32,
UI64 size64,
Atom *&atom);
Result createAtomFromStream(ByteStream &stream,
Atom *&atom);
Result createAtomsFromStream(ByteStream &stream,
AtomParent &atoms);
Result createAtomsFromStream(ByteStream &stream,
LargeSize bytes_available,
AtomParent &atoms);
// context
void pushContext(Atom::Type context);
void popContext();
Atom::Type getContext(Ordinal depth = 0);
private:
// members
Array<Atom::Type> m_ContextStack;
List<TypeHandler> m_TypeHandlers;
};
class DefaultAtomFactory : public AtomFactory {
public:
// class members
static DefaultAtomFactory Instance_;
// constructor
DefaultAtomFactory();
// this member is used to detect the situation where the
// platform's code loader does not construct static C++ objects
bool initialized;
Result initialize();
};
}
#endif //MP4_ATOMFACTORY_H