File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
- # TODO: Implement GPMF parsing
2
- # see https://github.com/gopro/gpmf-parser#gmfp-deeper-dive for format details
1
+ """Parses the FOURCC data in GPMF stream into fields"""
3
2
import construct
4
3
5
4
TYPES = construct .Enum (
32
31
"data" / construct .Aligned (4 , construct .Bytes (construct .this .size * construct .this .repeat ))
33
32
)
34
33
35
- def recursive ():
36
- pass
34
+
35
+ def recursive (data , parents = tuple ()):
36
+ """Recursive parser returns depth-first traversing generator yielding fields and list of their parent keys"""
37
+ elements = FOURCC [:].parse (data )
38
+ for element in elements :
39
+ if element .type == 0 :
40
+ subparents = parents + (element .key ,)
41
+ for subyield in recursive (element .data , subparents ):
42
+ yield subyield
43
+ else :
44
+ yield (element , parents )
You can’t perform that action at this time.
0 commit comments