drone-path 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +17 -24
- package/THIRD-PARTY-NOTICES.md +7 -0
- package/app/main.mjs +82 -28
- package/app/preload.cjs +3 -0
- package/dist/appassets.js +2 -11
- package/dist/apppaths.js +2 -10
- package/dist/appsession.js +59 -25
- package/dist/appstate.js +0 -18
- package/dist/assets.js +0 -7
- package/dist/buildinfo.js +71 -0
- package/dist/cammeta.js +123 -84
- package/dist/changeset-gate.js +0 -7
- package/dist/cli.js +0 -15
- package/dist/config.js +40 -52
- package/dist/configfile.js +0 -8
- package/dist/decimate.js +2 -12
- package/dist/exportjob.js +3 -19
- package/dist/ff.js +0 -8
- package/dist/fftools.js +0 -10
- package/dist/geo.js +3 -13
- package/dist/inputs.js +0 -4
- package/dist/manual/anchors.js +1 -7
- package/dist/manual/build.js +0 -6
- package/dist/manual/cliref.js +0 -6
- package/dist/manual/links.js +0 -17
- package/dist/manual/markdown.js +2 -10
- package/dist/manual/model.js +0 -3
- package/dist/manual/module.js +0 -3
- package/dist/manual/nav.js +0 -2
- package/dist/manual/reference.js +1 -4
- package/dist/page.js +3 -26
- package/dist/paths.js +0 -12
- package/dist/plan.js +1 -18
- package/dist/png.js +0 -3
- package/dist/proto.js +4 -4
- package/dist/range.js +0 -8
- package/dist/render.js +3 -53
- package/dist/renderer/dom.js +0 -6
- package/dist/renderer/framemath.js +0 -4
- package/dist/renderer/leaflet.js +0 -4
- package/dist/renderer/scene.js +10 -34
- package/dist/renderer/theme.js +58 -10
- package/dist/renderer/tilesources.js +0 -10
- package/dist/renderer/trail.js +1 -12
- package/dist/restyle.js +1 -9
- package/dist/run.js +45 -46
- package/dist/serve.js +0 -13
- package/dist/srt.js +30 -8
- package/dist/summary.js +0 -3
- package/dist/telemetry-json-schema.js +23 -0
- package/dist/telemetry-json.js +107 -0
- package/dist/telemetry-math.js +9 -45
- package/dist/telemetry.js +52 -9
- package/dist/tilecache.js +0 -5
- package/dist/tiles.js +1 -31
- package/dist/tracing.js +3 -27
- package/package.json +9 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { VERSION } from './version.js';
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
export function defaultBuildinfoPaths(root) {
|
|
9
|
+
return {
|
|
10
|
+
moduleFile: path.join(root, 'ui', 'lib', 'buildinfo', 'generated', 'buildinfo.ts'),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function resolveBuildGit(version, probe) {
|
|
14
|
+
const commit = probe?.headCommit?.trim() ?? '';
|
|
15
|
+
if (probe === null || commit === '')
|
|
16
|
+
return null;
|
|
17
|
+
// Only the matching v<version> tag marks a formal release; any other state
|
|
18
|
+
// keeps the commit hash visible.
|
|
19
|
+
return { tagged: probe.tagsAtHead.includes(`v${version}`), commit: commit.slice(0, 8) };
|
|
20
|
+
}
|
|
21
|
+
export function buildinfoModuleSource(version, git) {
|
|
22
|
+
return ('// Generated by src/buildinfo.ts at build time. Do not edit.\n' +
|
|
23
|
+
"import type { BuildGit } from '../../buildversion.js';\n" +
|
|
24
|
+
'\n' +
|
|
25
|
+
`export const BUILD_VERSION = ${JSON.stringify(version)};\n` +
|
|
26
|
+
`export const BUILD_GIT: BuildGit | null = ${JSON.stringify(git)};\n`);
|
|
27
|
+
}
|
|
28
|
+
export function buildBuildinfo(paths, version, probe) {
|
|
29
|
+
const git = resolveBuildGit(version, probe);
|
|
30
|
+
fs.mkdirSync(path.dirname(paths.moduleFile), { recursive: true });
|
|
31
|
+
fs.writeFileSync(paths.moduleFile, buildinfoModuleSource(version, git));
|
|
32
|
+
return git;
|
|
33
|
+
}
|
|
34
|
+
async function tryGit(args) {
|
|
35
|
+
try {
|
|
36
|
+
const { stdout } = await execFileAsync('git', [...args]);
|
|
37
|
+
return stdout;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export async function probeGit() {
|
|
44
|
+
const head = await tryGit(['rev-parse', 'HEAD']);
|
|
45
|
+
if (head === null)
|
|
46
|
+
return null;
|
|
47
|
+
// A missing tag list only means HEAD is untagged, not that git is gone.
|
|
48
|
+
const tags = await tryGit(['tag', '--points-at', 'HEAD']);
|
|
49
|
+
return {
|
|
50
|
+
headCommit: head.trim(),
|
|
51
|
+
tagsAtHead: (tags ?? '')
|
|
52
|
+
.split('\n')
|
|
53
|
+
.map((tag) => tag.trim())
|
|
54
|
+
.filter((tag) => tag !== ''),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function main() {
|
|
58
|
+
try {
|
|
59
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
60
|
+
const git = buildBuildinfo(defaultBuildinfoPaths(root), VERSION, await probeGit());
|
|
61
|
+
const detail = git === null ? 'no git' : git.tagged ? 'tagged' : `commit ${git.commit}`;
|
|
62
|
+
process.stderr.write(`[drone-path] buildinfo: ${VERSION} (${detail})\n`);
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
process.stderr.write(`[drone-path] ERROR: ${e.message}\n`);
|
|
66
|
+
process.exitCode = 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
70
|
+
void main();
|
|
71
|
+
}
|
package/dist/cammeta.js
CHANGED
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
// Format (reverse-engineered and verified value-by-value against .SRT data):
|
|
2
|
-
// * the MP4 carries a `data` stream, sample-entry fourcc `djmd`, handler
|
|
3
|
-
// "CAM meta"; its payload is DJI's internal "DVTM" (DJI Video Metadata)
|
|
4
|
-
// protobuf: one ProductMeta message per MP4 sample = one video frame.
|
|
5
|
-
// Messages are VARIABLE length (e.g. 299-563 B on DJI Neo 2) - never
|
|
6
|
-
// assume a fixed stride; split the raw dump by ffprobe packet sizes so
|
|
7
|
-
// each message aligns to its packet PTS (= frame time).
|
|
8
|
-
// * ProductMeta { 1 clip_meta, 2 stream_meta, 3 frame_meta } (clip/stream
|
|
9
|
-
// meta appear only in the first sample).
|
|
10
|
-
// * frame_meta { 1 header, 2 camera, 3 imu (absent on Neo 2), 4 drone,
|
|
11
|
-
// 5 gimbal }:
|
|
12
|
-
// - camera.11 AbsoluteAltitude { 1 float32 meters MSL }
|
|
13
|
-
// - drone.3 EulerAngle { 1 pitch, 2 roll, 3 yaw } varint deci-degrees
|
|
14
|
-
// (yaw = drone heading, valid even while hovering)
|
|
15
|
-
// - drone.4 GpsBasic { 1 PositionCoord { 2 lat, 3 lon } doubles WGS84,
|
|
16
|
-
// 2 gps_altitude_mm varint }
|
|
17
|
-
// - drone.5 RelativeAltitude { 1 float32 millimeters above takeoff }
|
|
18
|
-
// * No epoch timestamp in-stream (frame_timestamp is microseconds since
|
|
19
|
-
// power-up); sample index == frame index.
|
|
20
|
-
// * Schemas: recovered DJI .proto files in AdrianEddy/telemetry-parser
|
|
21
|
-
// (MIT/Apache-2.0, dvtm_library.proto / dvtm_eagle4_wa530.proto);
|
|
22
|
-
// there is no official DJI spec and no public dvtm_NEO2.proto, but the
|
|
23
|
-
// Neo 2 layout matches those schemas.
|
|
24
|
-
//
|
|
25
|
-
// Robustness: a per-packet protobuf walk is the primary path; a whole-buffer
|
|
26
|
-
// byte scan of the GPS double pair (tag 0x11 lat / 0x19 lon) is the fallback
|
|
27
|
-
// for firmware layouts we do not understand.
|
|
28
1
|
import { execFile } from 'node:child_process';
|
|
29
2
|
import fs from 'node:fs';
|
|
30
3
|
import os from 'node:os';
|
|
@@ -32,11 +5,17 @@ import path from 'node:path';
|
|
|
32
5
|
import { promisify } from 'node:util';
|
|
33
6
|
import { ffprobeJson } from './ff.js';
|
|
34
7
|
import { gpsFix } from './geo.js';
|
|
35
|
-
import { firstDouble, firstFloat, firstVarint, parseProtoFields, subMessage, } from './proto.js';
|
|
8
|
+
import { firstDouble, firstFloat, firstString, firstVarint, parseProtoFields, subMessage, } from './proto.js';
|
|
36
9
|
const execFileAsync = promisify(execFile);
|
|
37
|
-
// DVTM field numbers
|
|
10
|
+
// DVTM field numbers; the message layout is documented in docs/telemetry-protobuf.md.
|
|
11
|
+
const CLIP_META = 1;
|
|
12
|
+
const CLIP_META_HEADER = 1;
|
|
13
|
+
const PROTO_FILE_NAME = 1;
|
|
14
|
+
const PRODUCT_PROTO_VERSION = 3;
|
|
38
15
|
const FRAME_META = 3;
|
|
39
16
|
const CAMERA = 2;
|
|
17
|
+
const ISO = 3;
|
|
18
|
+
const WHITE_BALANCE_CCT = 6;
|
|
40
19
|
const ABSOLUTE_ALTITUDE = 11;
|
|
41
20
|
const DRONE = 4;
|
|
42
21
|
const GPS_BASIC = 4;
|
|
@@ -44,13 +23,22 @@ const POSITION_COORD = 1;
|
|
|
44
23
|
const GPS_ALTITUDE_MM = 2;
|
|
45
24
|
const RELATIVE_ALTITUDE = 5;
|
|
46
25
|
const EULER_ANGLE = 3;
|
|
26
|
+
const GIMBAL = 5;
|
|
27
|
+
const GIMBAL_DEVICE_HEADER = 1;
|
|
28
|
+
const GIMBAL_EULER_ANGLE = 2;
|
|
29
|
+
const DEVICE_ID = 1;
|
|
30
|
+
const DEVICE_TYPE = 2;
|
|
31
|
+
const DEVICE_SUB_TYPE = 3;
|
|
32
|
+
const DEVICE_NAME = 4;
|
|
33
|
+
const DEVICE_FREQUENCY = 5;
|
|
34
|
+
const DEVICE_TIMESTAMP = 6;
|
|
47
35
|
const VALUE = 1;
|
|
48
36
|
const PITCH = 1;
|
|
49
37
|
const ROLL = 2;
|
|
50
38
|
const YAW = 3;
|
|
51
39
|
const LAT = 2;
|
|
52
40
|
const LON = 3;
|
|
53
|
-
//
|
|
41
|
+
// GPS double-pair wire signature (0x11 lat f64, 0x19 lon f64); see docs/telemetry-protobuf.md.
|
|
54
42
|
const GPS_PAIR_SPAN = 18;
|
|
55
43
|
const FFMPEG_MAX_BUFFER = 64 * 1024 * 1024;
|
|
56
44
|
function emptyProductMeta() {
|
|
@@ -62,6 +50,13 @@ function emptyProductMeta() {
|
|
|
62
50
|
yawDeg: null,
|
|
63
51
|
pitchDeg: null,
|
|
64
52
|
rollDeg: null,
|
|
53
|
+
gpsAltMm: null,
|
|
54
|
+
gimbalPitchDeg: null,
|
|
55
|
+
gimbalRollDeg: null,
|
|
56
|
+
gimbalYawDeg: null,
|
|
57
|
+
gimbalDeviceTimestampMs: null,
|
|
58
|
+
iso: null,
|
|
59
|
+
whiteBalanceCctK: null,
|
|
65
60
|
};
|
|
66
61
|
}
|
|
67
62
|
async function findCamMetaIndex(tools, videoPath) {
|
|
@@ -89,29 +84,53 @@ async function findCamMetaIndex(tools, videoPath) {
|
|
|
89
84
|
export function decodeProductMeta(buf, start = 0, end = buf.length) {
|
|
90
85
|
const top = parseProtoFields(buf, start, end);
|
|
91
86
|
const frameMeta = subMessage(buf, top, FRAME_META);
|
|
92
|
-
const
|
|
87
|
+
const camera = frameMeta ? subMessage(buf, frameMeta, CAMERA) : null;
|
|
93
88
|
const drone = frameMeta ? subMessage(buf, frameMeta, DRONE) : null;
|
|
89
|
+
const gimbal = frameMeta ? subMessage(buf, frameMeta, GIMBAL) : null;
|
|
90
|
+
const absAlt = camera ? decodeAbsoluteAltitude(buf, camera) : null;
|
|
94
91
|
const gps = drone ? decodeGps(buf, drone) : null;
|
|
95
|
-
const euler = drone ? decodeEulerAngles(buf, drone) : null;
|
|
92
|
+
const euler = drone ? decodeEulerAngles(buf, drone, EULER_ANGLE) : null;
|
|
93
|
+
const gimbalEuler = gimbal
|
|
94
|
+
? decodeEulerAngles(buf, gimbal, GIMBAL_EULER_ANGLE)
|
|
95
|
+
: null;
|
|
96
|
+
const gimbalHeader = gimbal
|
|
97
|
+
? subMessage(buf, gimbal, GIMBAL_DEVICE_HEADER)
|
|
98
|
+
: null;
|
|
96
99
|
return {
|
|
97
100
|
fix: gps?.fix ?? null,
|
|
98
101
|
noLock: gps?.noLock ?? false,
|
|
99
102
|
relAlt: drone ? decodeRelativeAltitude(buf, drone) : null,
|
|
100
|
-
|
|
101
|
-
absAlt: absAlt ?? gps?.gpsAltM ?? null,
|
|
103
|
+
absAlt: absAlt ?? gpsAltMeters(gps?.gpsAltMm ?? null),
|
|
102
104
|
yawDeg: euler?.yawDeg ?? null,
|
|
103
105
|
pitchDeg: euler?.pitchDeg ?? null,
|
|
104
106
|
rollDeg: euler?.rollDeg ?? null,
|
|
107
|
+
gpsAltMm: gps?.gpsAltMm ?? null,
|
|
108
|
+
gimbalPitchDeg: gimbalEuler?.pitchDeg ?? null,
|
|
109
|
+
gimbalRollDeg: gimbalEuler?.rollDeg ?? null,
|
|
110
|
+
gimbalYawDeg: gimbalEuler?.yawDeg ?? null,
|
|
111
|
+
gimbalDeviceTimestampMs: gimbalHeader
|
|
112
|
+
? (firstVarint(gimbalHeader, DEVICE_TIMESTAMP) ?? 0)
|
|
113
|
+
: null,
|
|
114
|
+
iso: camera ? decodeCameraVarint(buf, camera, ISO) : null,
|
|
115
|
+
whiteBalanceCctK: camera ? decodeCameraVarint(buf, camera, WHITE_BALANCE_CCT) : null,
|
|
105
116
|
};
|
|
106
117
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
function decodeCameraVarint(buf, camera, fieldNumber) {
|
|
119
|
+
const message = subMessage(buf, camera, fieldNumber);
|
|
120
|
+
return message ? (firstVarint(message, VALUE) ?? 0) : null;
|
|
121
|
+
}
|
|
122
|
+
function decodeAbsoluteAltitude(buf, camera) {
|
|
123
|
+
const absoluteAltitude = subMessage(buf, camera, ABSOLUTE_ALTITUDE);
|
|
124
|
+
if (!absoluteAltitude)
|
|
125
|
+
return null;
|
|
126
|
+
const meters = firstFloat(absoluteAltitude, VALUE) ?? 0;
|
|
127
|
+
return Number.isFinite(meters) ? meters : null;
|
|
128
|
+
}
|
|
129
|
+
function gpsAltMeters(gpsAltMm) {
|
|
130
|
+
return gpsAltMm !== null ? gpsAltMm / 1000 : null;
|
|
112
131
|
}
|
|
113
132
|
function decodeGps(buf, drone) {
|
|
114
|
-
const out = { fix: null, noLock: false,
|
|
133
|
+
const out = { fix: null, noLock: false, gpsAltMm: null };
|
|
115
134
|
const gps = subMessage(buf, drone, GPS_BASIC);
|
|
116
135
|
if (!gps)
|
|
117
136
|
return out;
|
|
@@ -119,7 +138,6 @@ function decodeGps(buf, drone) {
|
|
|
119
138
|
if (coord) {
|
|
120
139
|
const lat = firstDouble(coord, LAT);
|
|
121
140
|
const lon = firstDouble(coord, LON);
|
|
122
|
-
// Only a present pair is an event: a fix, or exactly one no-lock count.
|
|
123
141
|
if (lat !== null && lon !== null) {
|
|
124
142
|
const fix = gpsFix(lat, lon);
|
|
125
143
|
if (fix !== null)
|
|
@@ -128,36 +146,62 @@ function decodeGps(buf, drone) {
|
|
|
128
146
|
out.noLock = true;
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
|
-
|
|
132
|
-
if (altitudeMm !== null)
|
|
133
|
-
out.gpsAltM = altitudeMm / 1000;
|
|
149
|
+
out.gpsAltMm = firstVarint(gps, GPS_ALTITUDE_MM) ?? 0;
|
|
134
150
|
return out;
|
|
135
151
|
}
|
|
136
|
-
// drone.5 RelativeAltitude { 1 float32 millimeters above takeoff }.
|
|
137
152
|
function decodeRelativeAltitude(buf, drone) {
|
|
138
153
|
const relative = subMessage(buf, drone, RELATIVE_ALTITUDE);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
if (!relative)
|
|
155
|
+
return null;
|
|
156
|
+
const millimeters = firstFloat(relative, VALUE) ?? 0;
|
|
157
|
+
return Number.isFinite(millimeters) ? millimeters / 1000 : null;
|
|
143
158
|
}
|
|
144
|
-
function decodeEulerAngles(buf,
|
|
145
|
-
const euler = subMessage(buf,
|
|
159
|
+
function decodeEulerAngles(buf, fields, fieldNumber) {
|
|
160
|
+
const euler = subMessage(buf, fields, fieldNumber);
|
|
146
161
|
if (!euler)
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
162
|
+
return null;
|
|
163
|
+
return {
|
|
164
|
+
pitchDeg: (firstVarint(euler, PITCH) ?? 0) / 10,
|
|
165
|
+
rollDeg: (firstVarint(euler, ROLL) ?? 0) / 10,
|
|
166
|
+
yawDeg: (firstVarint(euler, YAW) ?? 0) / 10,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export function decodeProvenance(buf, start = 0, end = buf.length) {
|
|
170
|
+
const top = parseProtoFields(buf, start, end);
|
|
151
171
|
return {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
172
|
+
protoFile: decodeProtoFile(buf, top),
|
|
173
|
+
gimbalDevice: decodeGimbalDevice(buf, top),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function decodeProtoFile(buf, top) {
|
|
177
|
+
const clipMeta = subMessage(buf, top, CLIP_META);
|
|
178
|
+
const header = clipMeta && subMessage(buf, clipMeta, CLIP_META_HEADER);
|
|
179
|
+
if (!header)
|
|
180
|
+
return null;
|
|
181
|
+
const name = nonEmptyString(buf, header, PROTO_FILE_NAME);
|
|
182
|
+
const version = nonEmptyString(buf, header, PRODUCT_PROTO_VERSION);
|
|
183
|
+
if (!name)
|
|
184
|
+
return null;
|
|
185
|
+
return version ? `${name} ${version}` : name;
|
|
186
|
+
}
|
|
187
|
+
function nonEmptyString(buf, fields, fieldNumber) {
|
|
188
|
+
const value = firstString(buf, fields, fieldNumber)?.trim() ?? '';
|
|
189
|
+
return value === '' ? null : value;
|
|
190
|
+
}
|
|
191
|
+
function decodeGimbalDevice(buf, top) {
|
|
192
|
+
const frameMeta = subMessage(buf, top, FRAME_META);
|
|
193
|
+
const gimbal = frameMeta && subMessage(buf, frameMeta, GIMBAL);
|
|
194
|
+
const header = gimbal && subMessage(buf, gimbal, GIMBAL_DEVICE_HEADER);
|
|
195
|
+
if (!header)
|
|
196
|
+
return null;
|
|
197
|
+
return {
|
|
198
|
+
id: firstVarint(header, DEVICE_ID) ?? 0,
|
|
199
|
+
type: firstVarint(header, DEVICE_TYPE) ?? 0,
|
|
200
|
+
subType: firstVarint(header, DEVICE_SUB_TYPE) ?? 0,
|
|
201
|
+
name: firstString(buf, header, DEVICE_NAME) ?? '',
|
|
202
|
+
frequency: firstFloat(header, DEVICE_FREQUENCY) ?? 0,
|
|
155
203
|
};
|
|
156
204
|
}
|
|
157
|
-
// Byte-scan fallback: the 0x11/0x19 fixed64 GPS double pair. It judges
|
|
158
|
-
// coordinates through src/geo.ts's gpsFix - the same rule as the protobuf
|
|
159
|
-
// path, so a genuine fix is never accepted by one path and dropped by the
|
|
160
|
-
// other.
|
|
161
205
|
export function scanGpsPair(buf, offset = 0, end = buf.length) {
|
|
162
206
|
for (let i = offset; i <= end - GPS_PAIR_SPAN; i++) {
|
|
163
207
|
if (buf[i] === 0x11 && buf[i + 9] === 0x19) {
|
|
@@ -168,8 +212,6 @@ export function scanGpsPair(buf, offset = 0, end = buf.length) {
|
|
|
168
212
|
}
|
|
169
213
|
return null;
|
|
170
214
|
}
|
|
171
|
-
// A probe failure is operational, not absence: it surfaces with its cause so
|
|
172
|
-
// a missing or broken ffprobe is never mistaken for a stream without data.
|
|
173
215
|
async function listCamMetaPackets(tools, videoPath, streamIndex) {
|
|
174
216
|
let probe;
|
|
175
217
|
try {
|
|
@@ -212,16 +254,19 @@ async function dumpCamMetaStream(tools, videoPath, streamIndex) {
|
|
|
212
254
|
function toCamSample(meta, tSec) {
|
|
213
255
|
return { tSec, ...meta };
|
|
214
256
|
}
|
|
215
|
-
// Primary path: walk the dump packet by packet so each ProductMeta message
|
|
216
|
-
// aligns to its packet PTS. No-lock packets are counted like SRT counts
|
|
217
|
-
// no-lock cues so summaries agree across telemetry sources; they join the
|
|
218
|
-
// samples only under keepAll.
|
|
219
257
|
export function decodePacketSamples(buf, packets, keepAll) {
|
|
220
258
|
const samples = [];
|
|
221
259
|
let noLock = 0;
|
|
222
260
|
let offset = 0;
|
|
261
|
+
let protoFile = null;
|
|
262
|
+
let gimbalDevice = null;
|
|
223
263
|
for (const packet of packets) {
|
|
224
264
|
const end = offset + packet.size;
|
|
265
|
+
if (protoFile === null || gimbalDevice === null) {
|
|
266
|
+
const declared = decodeProvenance(buf, offset, end);
|
|
267
|
+
protoFile ??= declared.protoFile;
|
|
268
|
+
gimbalDevice ??= declared.gimbalDevice;
|
|
269
|
+
}
|
|
225
270
|
let meta = decodeProductMeta(buf, offset, end);
|
|
226
271
|
if (meta.fix === null) {
|
|
227
272
|
const hit = scanGpsPair(buf, offset, end);
|
|
@@ -231,16 +276,13 @@ export function decodePacketSamples(buf, packets, keepAll) {
|
|
|
231
276
|
if (meta.noLock)
|
|
232
277
|
noLock++;
|
|
233
278
|
if (meta.fix !== null || keepAll) {
|
|
234
|
-
// No PTS: pretend "same time as the first sample" rather than
|
|
235
|
-
// fabricating a timeline out of a sample count (unit mismatch).
|
|
236
279
|
const tSec = Number.isFinite(packet.tSec) ? packet.tSec : 0;
|
|
237
280
|
samples.push(toCamSample(meta, tSec));
|
|
238
281
|
}
|
|
239
282
|
offset = end;
|
|
240
283
|
}
|
|
241
|
-
return { samples, noLock };
|
|
284
|
+
return { samples, noLock, provenance: { protoFile, gimbalDevice } };
|
|
242
285
|
}
|
|
243
|
-
// Fallback path: no frame alignment.
|
|
244
286
|
function scanBufferForGpsPairs(buf) {
|
|
245
287
|
const samples = [];
|
|
246
288
|
for (let i = 0; i <= buf.length - GPS_PAIR_SPAN; i++) {
|
|
@@ -254,7 +296,6 @@ function scanBufferForGpsPairs(buf) {
|
|
|
254
296
|
}
|
|
255
297
|
return samples;
|
|
256
298
|
}
|
|
257
|
-
// Best effort: scan-found samples carry no real timestamps.
|
|
258
299
|
function spreadSampleTimes(samples, durationSec) {
|
|
259
300
|
const span = Number.isFinite(durationSec) && durationSec > 0
|
|
260
301
|
? durationSec
|
|
@@ -263,13 +304,7 @@ function spreadSampleTimes(samples, durationSec) {
|
|
|
263
304
|
sample.tSec = (k / Math.max(1, samples.length - 1)) * span;
|
|
264
305
|
});
|
|
265
306
|
}
|
|
266
|
-
// opts.keepAll keeps every per-frame message even without a GPS fix (frame
|
|
267
|
-
// index then stays aligned to video frames; lat stays null). Default false
|
|
268
|
-
// keeps only GPS-bearing frames.
|
|
269
307
|
export async function parseCamMeta(tools, videoPath, durationSec, opts = {}) {
|
|
270
|
-
const keepAll = opts.keepAll === true;
|
|
271
|
-
// Null returns below mark a genuine absence ("no CAM meta stream"); tool
|
|
272
|
-
// failures have already thrown with their cause by this point.
|
|
273
308
|
const streamIndex = await findCamMetaIndex(tools, videoPath);
|
|
274
309
|
if (streamIndex === null)
|
|
275
310
|
return null;
|
|
@@ -279,14 +314,18 @@ export async function parseCamMeta(tools, videoPath, durationSec, opts = {}) {
|
|
|
279
314
|
return null;
|
|
280
315
|
const sizeSum = packets.reduce((sum, packet) => sum + (Number.isFinite(packet.size) ? packet.size : 0), 0);
|
|
281
316
|
if (packets.length > 0 && sizeSum === buf.length) {
|
|
282
|
-
const { samples, noLock } = decodePacketSamples(buf, packets, keepAll);
|
|
283
|
-
return { samples, noLock, method: 'dvtm-packets' };
|
|
317
|
+
const { samples, noLock, provenance } = decodePacketSamples(buf, packets, opts.keepAll === true);
|
|
318
|
+
return { samples, noLock, method: 'dvtm-packets', ...provenance };
|
|
284
319
|
}
|
|
285
320
|
const samples = scanBufferForGpsPairs(buf);
|
|
286
321
|
if (samples.length === 0)
|
|
287
322
|
return null;
|
|
288
323
|
spreadSampleTimes(samples, durationSec);
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
324
|
+
return {
|
|
325
|
+
samples,
|
|
326
|
+
noLock: 0,
|
|
327
|
+
method: 'cammeta-scan',
|
|
328
|
+
protoFile: null,
|
|
329
|
+
gimbalDevice: null,
|
|
330
|
+
};
|
|
292
331
|
}
|
package/dist/changeset-gate.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
// Strict Conventional Commits: lowercase feat/fix only; broader spellings
|
|
2
|
-
// stay exempt on purpose.
|
|
3
1
|
const PR_TITLE_NEEDS_CHANGESET = /^(feat|fix)(\([^)]+\))?!?:/;
|
|
4
|
-
// Release PRs carry the version fold, so CHANGELOG.md must change there.
|
|
5
2
|
const PR_TITLE_NEEDS_CHANGELOG = /^release(\([^)]+\))?:/;
|
|
6
|
-
// A fragment is a top-level .changeset/*.md file; the README documents the
|
|
7
|
-
// convention and never counts as a change entry.
|
|
8
3
|
const CHANGESET_FRAGMENT_PATH = /^\.changeset\/([^/]+)\.md$/;
|
|
9
4
|
const CHANGELOG_PATH = /^CHANGELOG\.md$/;
|
|
10
5
|
export function prNeedsChangeset(prTitle) {
|
|
@@ -13,8 +8,6 @@ export function prNeedsChangeset(prTitle) {
|
|
|
13
8
|
export function prNeedsChangelogUpdate(prTitle) {
|
|
14
9
|
return PR_TITLE_NEEDS_CHANGELOG.test(prTitle.trim());
|
|
15
10
|
}
|
|
16
|
-
// The shell skips git entirely for ungated titles: an exempt PR must never go
|
|
17
|
-
// red because listing changed files failed.
|
|
18
11
|
export function prNeedsArtifact(prTitle) {
|
|
19
12
|
return prNeedsChangeset(prTitle) || prNeedsChangelogUpdate(prTitle);
|
|
20
13
|
}
|
package/dist/cli.js
CHANGED
|
@@ -22,8 +22,6 @@ export function buildProgram() {
|
|
|
22
22
|
const option = new Option(row.cli.flags, row.cli.help);
|
|
23
23
|
if (row.cli.choices)
|
|
24
24
|
option.choices([...row.cli.choices]);
|
|
25
|
-
// An empty CLI default means "not set"; commander would print a noisy
|
|
26
|
-
// (default: "") for it, and the override layer reads only given flags.
|
|
27
25
|
const defaultValue = cliDefaultOf(row.key);
|
|
28
26
|
if (defaultValue !== '')
|
|
29
27
|
option.default(defaultValue);
|
|
@@ -32,21 +30,13 @@ export function buildProgram() {
|
|
|
32
30
|
program.option(CONFIG_FILE_OPTION.flags, CONFIG_FILE_OPTION.help);
|
|
33
31
|
return program;
|
|
34
32
|
}
|
|
35
|
-
// Commander's built-in defaults must never leak into the override layer:
|
|
36
|
-
// resolveConfig would then let "CLI" always win over the config file and
|
|
37
|
-
// silently break the documented "CLI flags > config file > defaults"
|
|
38
|
-
// precedence.
|
|
39
33
|
function givenOnCommandLine(program, name) {
|
|
40
34
|
return program.getOptionValueSource(name) === 'cli';
|
|
41
35
|
}
|
|
42
|
-
// The documented long flag of an option's spelling ("--quiet" for
|
|
43
|
-
// "-q, --quiet"), so error contexts never name a short alias.
|
|
44
36
|
export function longFlagOf(flags) {
|
|
45
37
|
const tokens = flags.split(/[ ,|]+/);
|
|
46
38
|
return tokens.find((token) => token.startsWith('--')) ?? tokens[0];
|
|
47
39
|
}
|
|
48
|
-
// Collect only the flags the user actually set, each through its table
|
|
49
|
-
// normalizer, so a config-file value can still win over a CLI default.
|
|
50
40
|
function collectOverrides(program) {
|
|
51
41
|
const opts = program.opts();
|
|
52
42
|
const cli = {};
|
|
@@ -77,7 +67,6 @@ function isCommanderExit(e) {
|
|
|
77
67
|
typeof (e).code === 'string' &&
|
|
78
68
|
e.code.startsWith('commander.'));
|
|
79
69
|
}
|
|
80
|
-
// --help / --version already printed and count as success.
|
|
81
70
|
function commanderExitCode(e) {
|
|
82
71
|
return e.code === 'commander.helpDisplayed' || e.code === 'commander.version'
|
|
83
72
|
? 0
|
|
@@ -97,8 +86,6 @@ function createLogger(config) {
|
|
|
97
86
|
process.stderr.write(`[drone-path] ${msg}\n`);
|
|
98
87
|
};
|
|
99
88
|
}
|
|
100
|
-
// The pipeline stage: tools, inputs, output folder, batch, summary, and the
|
|
101
|
-
// batch's effect on the exit code.
|
|
102
89
|
async function runPipeline(invocation, tracing, log) {
|
|
103
90
|
const { inputs, config, configPath } = invocation;
|
|
104
91
|
const tools = resolveFfTools(config);
|
|
@@ -110,7 +97,6 @@ async function runPipeline(invocation, tracing, log) {
|
|
|
110
97
|
(configPath ? ` (config: ${configPath})` : ''));
|
|
111
98
|
const emit = (summary) => {
|
|
112
99
|
if (config.json) {
|
|
113
|
-
// Flush synchronously: the summary must survive any later I/O hiccups.
|
|
114
100
|
fs.writeSync(1, `${JSON.stringify(summary)}\n`);
|
|
115
101
|
}
|
|
116
102
|
};
|
|
@@ -131,7 +117,6 @@ async function withTracingShutdown(tracing, log, body) {
|
|
|
131
117
|
await tracing.shutdown();
|
|
132
118
|
}
|
|
133
119
|
catch (e) {
|
|
134
|
-
// A shutdown hiccup must not replace the error that is unwinding.
|
|
135
120
|
log(`warning: tracing shutdown failed: ${errorMessage(e)}`);
|
|
136
121
|
}
|
|
137
122
|
}
|