-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathMP4.cc
More file actions
114 lines (57 loc) · 1.97 KB
/
MP4.cc
File metadata and controls
114 lines (57 loc) · 1.97 KB
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
#include <aux.h>
#include "MP4.h"
std::string MP4_labeler::traverse(Node &node){
std::string output;
for(int i=0; i < node.children().size(); i++){
Node &child = tree->get_node(node.children()[i]);
output += traverse(child);
}
uint32_t size;
if(node.get_id() == 0){
size = 20;
}else{
size = node.get_label().size() + output.size() + 4;
}
std::string label = node.get_label();
uint32_t label_size = label.size();
output = uint32_to_string_BE(size) + label + output;
return output;
}
MP4_labeler::MP4_labeler(RandomTree *in_tree) {
this->tree = in_tree;
priv_name = "MP4";
Node &root = this->tree->get_node(0);
std::string root_label = "ftyp";
root_label += "dash";
root_label += "AAAABBBB";
root.set_label(root_label);
for(int i=1; i < this->tree->size(); i++){
Node &node = this->tree->get_node(i);
uint32_t fourcc;
uint32_t padding;
uint32_t random_data;
if(node.children().size() == 0){
//LEAF
uint32_t random = rand_uint32(0, FOURCC_LIST_SIZE-1);
fourcc = FOURCC_LIST[random].fourcc;
padding = FOURCC_LIST[random].min_size;
random_data = rand_uint32(4, 16);
}else{
//CONTAINER
uint32_t random = rand_uint32(0, CONTAINER_LIST_SIZE-1);
fourcc = CONTAINER_LIST[random].fourcc;
padding = CONTAINER_LIST[random].min_size;
random_data = 0;
}
std::string label = uint32_to_string(fourcc);
label += std::string(padding, '\x00');
label += std::string(random_data, '\x41');
node.set_label(label);
}
}
std::string MP4_labeler::serialize(){
std::string output;
Node &root = tree->get_node(0);
output = traverse(root);
return output;
}