-
Notifications
You must be signed in to change notification settings - Fork 4
/
smhd.cc
44 lines (37 loc) · 999 Bytes
/
smhd.cc
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
//
// Created by wlanjie on 2018/3/9.
//
#include "smhd.h"
namespace mp4 {
Smhd *Smhd::create(Size size, ByteStream &stream) {
UI08 version;
UI32 flags;
if (size < FULL_ATOM_HEADER_SIZE) {
return nullptr;
}
if (FAILED(Atom::readFullHeader(stream, version, flags))) {
return nullptr;
}
if (version != 0) {
return nullptr;
}
return new Smhd(size, version, flags, stream);
}
Smhd::Smhd(UI16 balance) :
Atom(ATOM_TYPE_SMHD, FULL_ATOM_HEADER_SIZE + 4, 0, 0),
balance(balance) {
reserved = 0;
}
Smhd::Smhd(UI32 size, UI08 version, UI32 flags, ByteStream &stream) :
Atom(ATOM_TYPE_SMHD, size, version, flags) {
stream.readUI16(balance);
stream.readUI16(reserved);
}
Result Smhd::writeFields(ByteStream &stream) {
Result result = stream.writeUI16(balance);
if (FAILED(result)) return result;
result = stream.writeUI16(reserved);
if (FAILED(result)) return result;
return SUCCESS;
}
}