-
Notifications
You must be signed in to change notification settings - Fork 0
/
goprometa.h
95 lines (84 loc) · 2.19 KB
/
goprometa.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
89
90
91
92
93
94
95
#ifndef _GOPROMETA_H
#define _GOPROMETA_H
//
// class-based wrapper to the gpmf parser project from GoPro
// and pruned down to my specific use case around GPS data extraction
//
// Author: Robert Wolff
// Copyright 2020 Robert Wolff with MIT license
//
#include <iostream>
#include <iomanip>
#include <vector>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <time.h>
#include "gpmf-parser/GPMF_parser.h"
#include "gpmf-parser/GPMF_mp4reader.h"
class TD {
public:
TD();
~TD();
friend std::ostream& operator<<(std::ostream& os, const TD& dt);
friend bool operator<(TD& lhs, TD& rhs);
void readGPMeta(char* gp);
int getSeconds();
time_t getTime();
std::string getDateOnly();
bool isValid() { return bIsSet; };
void setToCurrentTime(); // get current time and set values from there.
protected:
void calcTime();
int year, month, day, hour, minute, second;
time_t theTime;
bool bIsSet;
};
class GPSSample {
public:
GPSSample(TD &_t, double _lat, double _lon, double _ele);
~GPSSample();
friend std::ostream& operator<<(std::ostream& os, const GPSSample& gs);
friend bool operator<(GPSSample& lhs, GPSSample& rhs);
time_t getTime() { return t.getTime(); };
std::string getDateOnly();
double getLat() { return lat; };
double getLon() { return lon; };
double getEle() { return ele; };
TD getTD() { return t; };
protected:
TD t;
double lat, lon, ele;
};
class GoProMeta {
public:
GoProMeta();
~GoProMeta();
void setSecondsBetweenSamples(unsigned int newtiming);
bool openFile(const char* filename);
bool processFile();
void getOutputPoints(std::vector<GPSSample> &samps);
protected:
bool processGPS5();
bool processGPSU();
bool processGPSF();
bool processGPSP();
void recordSample(double* ptr);
void recordSampleIfAppropriate(double* ptr);
uint8_t lockState; // 0=No_Lock, 2=2D_Lock, 3=3D_Lock
uint16_t GPSPrecision;
uint32_t samplesProcessed;
uint32_t samplesSkippedForNoLock;
uint32_t samplesSkippedForPoorPrecision;
size_t mp4;
GPMF_stream metadata_stream, *ms;
double metadatalength;
uint32_t *payload;
unsigned int secondsBetweenSamples;
uint32_t numPayloads;
TD currentTime;
time_t nextSampleTime;
std::vector<GPSSample> GPSSamples;
std::string fName;
};
#endif