@wemap/camera 3.2.3 → 3.2.4
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/package.json +3 -3
- package/src/Camera.js +1 -0
- package/src/CameraLogger.js +52 -10
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "packages/camera"
|
|
12
12
|
},
|
|
13
13
|
"name": "@wemap/camera",
|
|
14
|
-
"version": "3.2.
|
|
14
|
+
"version": "3.2.4",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
17
17
|
},
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@wemap/navigation-logger": "^3.2.
|
|
26
|
+
"@wemap/navigation-logger": "^3.2.4",
|
|
27
27
|
"events": "^3.1.0"
|
|
28
28
|
},
|
|
29
29
|
"type": "module",
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "2b6080727464a2b671cd173a317ffd7bb196f789"
|
|
31
31
|
}
|
package/src/Camera.js
CHANGED
package/src/CameraLogger.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { NavigationLogger } from '@wemap/navigation-logger';
|
|
2
|
+
import { TimeUtils } from '@wemap/utils';
|
|
2
3
|
|
|
3
4
|
class CameraLogger {
|
|
4
5
|
|
|
6
|
+
static _videoPart = 0;
|
|
7
|
+
|
|
5
8
|
_videoStream = null;
|
|
6
|
-
_loggerParams = null;
|
|
7
9
|
|
|
8
10
|
constructor() {
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
NavigationLogger.on('started', ({ params }) => {
|
|
13
|
-
this._loggerParams = params;
|
|
12
|
+
NavigationLogger.on('started', () => {
|
|
13
|
+
CameraLogger._videoPart = 0;
|
|
14
14
|
if (this._videoStream !== null) {
|
|
15
15
|
this._start();
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
NavigationLogger.on('stopped', () => {
|
|
20
|
-
this._loggerParams = null;
|
|
21
20
|
this._stop();
|
|
22
21
|
});
|
|
23
22
|
|
|
@@ -35,7 +34,12 @@ class CameraLogger {
|
|
|
35
34
|
this._stop();
|
|
36
35
|
}
|
|
37
36
|
|
|
37
|
+
set fov(fov) {
|
|
38
|
+
this._fov = fov;
|
|
39
|
+
}
|
|
40
|
+
|
|
38
41
|
_start() {
|
|
42
|
+
CameraLogger._videoPart++;
|
|
39
43
|
|
|
40
44
|
if (!('MediaRecorder' in window)) {
|
|
41
45
|
return;
|
|
@@ -47,20 +51,31 @@ class CameraLogger {
|
|
|
47
51
|
|
|
48
52
|
const options = {
|
|
49
53
|
mimeType: 'video/webm;codecs=vp8',
|
|
50
|
-
bitsPerSecond:
|
|
54
|
+
bitsPerSecond: NavigationLogger.params.videoBitrate
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
let isFirstChunck = true;
|
|
58
|
+
|
|
59
|
+
const startTime = TimeUtils.preciseTime;
|
|
54
60
|
|
|
55
61
|
// https://stackoverflow.com/questions/56826079/how-to-concat-chunks-of-incoming-binary-into-video-webm-file-node-js
|
|
56
62
|
this.mediaRecorder = new MediaRecorder(this._videoStream, options);
|
|
57
63
|
this.mediaRecorder.ondataavailable = event => {
|
|
58
64
|
if (event.data && event.data.size > 0) {
|
|
59
|
-
|
|
65
|
+
if (isFirstChunck) {
|
|
66
|
+
this._sendEvent('video-start', {
|
|
67
|
+
// startTime: TimeUtils.preciseTime - NavigationLogger.params.flushInterval,
|
|
68
|
+
startTime,
|
|
69
|
+
part: CameraLogger._videoPart,
|
|
70
|
+
fov: this._fov
|
|
71
|
+
});
|
|
72
|
+
isFirstChunck = false;
|
|
73
|
+
}
|
|
74
|
+
this._sendChunck(CameraLogger._videoPart, event.data);
|
|
60
75
|
}
|
|
61
76
|
};
|
|
62
77
|
|
|
63
|
-
this.mediaRecorder.start(
|
|
78
|
+
this.mediaRecorder.start(NavigationLogger.params.flushInterval);
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
|
|
@@ -70,9 +85,36 @@ class CameraLogger {
|
|
|
70
85
|
return;
|
|
71
86
|
}
|
|
72
87
|
|
|
88
|
+
this._sendEvent('video-end', {
|
|
89
|
+
time: TimeUtils.preciseTime,
|
|
90
|
+
part: CameraLogger._videoPart
|
|
91
|
+
});
|
|
92
|
+
|
|
73
93
|
this.mediaRecorder.stop();
|
|
74
94
|
this.mediaRecorder = null;
|
|
75
95
|
}
|
|
96
|
+
|
|
97
|
+
_sendChunck(videoPart, chunck) {
|
|
98
|
+
fetch(NavigationLogger.getVideoChunckUrl(videoPart), {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers: { 'Content-Type': 'application/octet-stream' },
|
|
101
|
+
body: chunck
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_sendEvent(eventName, data) {
|
|
106
|
+
fetch(NavigationLogger.getVideoConfigUrl(), {
|
|
107
|
+
method: 'POST',
|
|
108
|
+
headers: {
|
|
109
|
+
'Accept': 'application/json',
|
|
110
|
+
'Content-Type': 'application/json'
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify({
|
|
113
|
+
eventName,
|
|
114
|
+
data
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
}
|
|
76
118
|
}
|
|
77
119
|
|
|
78
120
|
export default CameraLogger;
|