@mentra/sdk 2.1.27 โ 2.1.28
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/dist/app/session/api-client.d.ts.map +1 -1
- package/dist/app/session/dashboard.d.ts +5 -8
- package/dist/app/session/dashboard.d.ts.map +1 -1
- package/dist/app/session/events.d.ts +2 -1
- package/dist/app/session/events.d.ts.map +1 -1
- package/dist/app/session/index.d.ts +62 -3
- package/dist/app/session/index.d.ts.map +1 -1
- package/dist/app/session/modules/audio.d.ts +33 -4
- package/dist/app/session/modules/audio.d.ts.map +1 -1
- package/dist/app/session/modules/camera-managed-extension.d.ts +2 -3
- package/dist/app/session/modules/camera-managed-extension.d.ts.map +1 -1
- package/dist/app/session/modules/camera.d.ts +5 -5
- package/dist/app/session/modules/camera.d.ts.map +1 -1
- package/dist/app/session/modules/led.d.ts +141 -0
- package/dist/app/session/modules/led.d.ts.map +1 -0
- package/dist/app/session/modules/location.d.ts +1 -2
- package/dist/app/session/modules/location.d.ts.map +1 -1
- package/dist/app/session/modules/simple-storage.d.ts.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5347 -112
- package/dist/index.js.map +45 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/types/capabilities.d.ts +3 -0
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/message-types.d.ts +8 -1
- package/dist/types/message-types.d.ts.map +1 -1
- package/dist/types/messages/app-to-cloud.d.ts +48 -2
- package/dist/types/messages/app-to-cloud.d.ts.map +1 -1
- package/dist/types/messages/cloud-to-app.d.ts +16 -6
- package/dist/types/messages/cloud-to-app.d.ts.map +1 -1
- package/dist/types/messages/cloud-to-glasses.d.ts +29 -1
- package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -1
- package/dist/types/messages/glasses-to-cloud.d.ts +24 -1
- package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -1
- package/dist/types/rtmp-stream.d.ts +1 -1
- package/dist/types/rtmp-stream.d.ts.map +1 -1
- package/dist/types/streams.d.ts +28 -1
- package/dist/types/streams.d.ts.map +1 -1
- package/package.json +9 -3
- package/dist/app/index.js +0 -24
- package/dist/app/server/index.js +0 -658
- package/dist/app/session/api-client.js +0 -101
- package/dist/app/session/dashboard.js +0 -149
- package/dist/app/session/events.js +0 -315
- package/dist/app/session/index.js +0 -1573
- package/dist/app/session/layouts.js +0 -372
- package/dist/app/session/modules/audio.js +0 -321
- package/dist/app/session/modules/camera-managed-extension.js +0 -310
- package/dist/app/session/modules/camera.js +0 -607
- package/dist/app/session/modules/index.js +0 -19
- package/dist/app/session/modules/location.js +0 -61
- package/dist/app/session/modules/simple-storage.js +0 -232
- package/dist/app/session/settings.js +0 -358
- package/dist/app/token/index.js +0 -22
- package/dist/app/token/utils.js +0 -144
- package/dist/app/webview/index.js +0 -382
- package/dist/constants/index.js +0 -16
- package/dist/constants/log-messages/color.js +0 -14
- package/dist/constants/log-messages/logos.js +0 -48
- package/dist/constants/log-messages/updates.js +0 -55
- package/dist/constants/log-messages/warning.js +0 -89
- package/dist/examples/managed-rtmp-streaming-example.js +0 -158
- package/dist/examples/managed-rtmp-streaming-with-restream-example.js +0 -124
- package/dist/examples/rtmp-streaming-example.js +0 -102
- package/dist/logging/logger.js +0 -79
- package/dist/types/capabilities.js +0 -9
- package/dist/types/dashboard/index.js +0 -12
- package/dist/types/enums.js +0 -75
- package/dist/types/index.js +0 -101
- package/dist/types/layouts.js +0 -3
- package/dist/types/message-types.js +0 -212
- package/dist/types/messages/app-to-cloud.js +0 -95
- package/dist/types/messages/base.js +0 -3
- package/dist/types/messages/cloud-to-app.js +0 -78
- package/dist/types/messages/cloud-to-glasses.js +0 -68
- package/dist/types/messages/glasses-to-cloud.js +0 -140
- package/dist/types/models.js +0 -101
- package/dist/types/photo-data.js +0 -2
- package/dist/types/rtmp-stream.js +0 -3
- package/dist/types/streams.js +0 -306
- package/dist/types/token.js +0 -7
- package/dist/types/webhooks.js +0 -28
- package/dist/utils/animation-utils.js +0 -340
- package/dist/utils/bitmap-utils.js +0 -475
- package/dist/utils/permissions-utils.js +0 -263
- package/dist/utils/resource-tracker.js +0 -153
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ๐ท Camera Module Managed Streaming Extension
|
|
4
|
-
*
|
|
5
|
-
* Extends the camera module with managed streaming capabilities.
|
|
6
|
-
* Apps can request managed streams and receive HLS/DASH URLs without managing RTMP endpoints.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.CameraManagedExtension = void 0;
|
|
10
|
-
const types_1 = require("../../../types");
|
|
11
|
-
/**
|
|
12
|
-
* ๐น Managed Streaming Extension for Camera Module
|
|
13
|
-
*
|
|
14
|
-
* Provides managed streaming capabilities where the cloud handles
|
|
15
|
-
* RTMP endpoints and returns HLS/DASH URLs for viewing.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // Start a managed stream
|
|
20
|
-
* const urls = await session.camera.startManagedStream({
|
|
21
|
-
* quality: '720p',
|
|
22
|
-
* enableWebRTC: true
|
|
23
|
-
* });
|
|
24
|
-
* console.log('HLS URL:', urls.hlsUrl);
|
|
25
|
-
* console.log('DASH URL:', urls.dashUrl);
|
|
26
|
-
* console.log('Player URL:', urls.previewUrl);
|
|
27
|
-
* console.log('Thumbnail:', urls.thumbnailUrl);
|
|
28
|
-
*
|
|
29
|
-
* // Monitor managed stream status
|
|
30
|
-
* session.camera.onManagedStreamStatus((status) => {
|
|
31
|
-
* console.log('Managed stream status:', status.status);
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* // Stop managed stream
|
|
35
|
-
* await session.camera.stopManagedStream();
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
class CameraManagedExtension {
|
|
39
|
-
constructor(packageName, sessionId, send, logger, session) {
|
|
40
|
-
// Managed streaming state
|
|
41
|
-
this.isManagedStreaming = false;
|
|
42
|
-
this.packageName = packageName;
|
|
43
|
-
this.sessionId = sessionId;
|
|
44
|
-
this.send = send;
|
|
45
|
-
this.logger = logger.child({ module: "CameraManagedExtension" });
|
|
46
|
-
this.session = session;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* ๐น Start a managed stream
|
|
50
|
-
*
|
|
51
|
-
* The cloud will handle the RTMP endpoint and return HLS/DASH URLs for viewing.
|
|
52
|
-
* Multiple apps can consume the same managed stream simultaneously.
|
|
53
|
-
*
|
|
54
|
-
* @param options - Configuration options for the managed stream
|
|
55
|
-
* @returns Promise that resolves with viewing URLs when the stream is ready
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const urls = await session.camera.startManagedStream({
|
|
60
|
-
* quality: '1080p',
|
|
61
|
-
* enableWebRTC: true,
|
|
62
|
-
* video: { fps: 30 },
|
|
63
|
-
* audio: { sampleRate: 48000 }
|
|
64
|
-
* });
|
|
65
|
-
*
|
|
66
|
-
* // Access all available URLs
|
|
67
|
-
* console.log('HLS URL:', urls.hlsUrl);
|
|
68
|
-
* console.log('DASH URL:', urls.dashUrl);
|
|
69
|
-
* console.log('Player URL:', urls.previewUrl); // Embeddable player
|
|
70
|
-
* console.log('Thumbnail:', urls.thumbnailUrl);
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
async startManagedStream(options = {}) {
|
|
74
|
-
this.logger.info({ options }, "๐น Managed stream request starting");
|
|
75
|
-
if (this.isManagedStreaming) {
|
|
76
|
-
this.logger.error({
|
|
77
|
-
currentStreamId: this.currentManagedStreamId,
|
|
78
|
-
}, "๐น Already managed streaming error");
|
|
79
|
-
throw new Error("Already streaming. Stop the current managed stream before starting a new one.");
|
|
80
|
-
}
|
|
81
|
-
// Create the request message
|
|
82
|
-
const request = {
|
|
83
|
-
type: types_1.AppToCloudMessageType.MANAGED_STREAM_REQUEST,
|
|
84
|
-
packageName: this.packageName,
|
|
85
|
-
quality: options.quality,
|
|
86
|
-
enableWebRTC: options.enableWebRTC,
|
|
87
|
-
video: options.video,
|
|
88
|
-
audio: options.audio,
|
|
89
|
-
stream: options.stream,
|
|
90
|
-
restreamDestinations: options.restreamDestinations,
|
|
91
|
-
};
|
|
92
|
-
// Send the request
|
|
93
|
-
this.send(request);
|
|
94
|
-
this.isManagedStreaming = true;
|
|
95
|
-
// Create promise to wait for URLs
|
|
96
|
-
return new Promise((resolve, reject) => {
|
|
97
|
-
this.pendingManagedStreamRequest = { resolve, reject };
|
|
98
|
-
// Set a timeout
|
|
99
|
-
setTimeout(() => {
|
|
100
|
-
if (this.pendingManagedStreamRequest) {
|
|
101
|
-
this.pendingManagedStreamRequest = undefined;
|
|
102
|
-
this.isManagedStreaming = false;
|
|
103
|
-
reject(new Error("Managed stream request timeout"));
|
|
104
|
-
}
|
|
105
|
-
}, 30000); // 30 second timeout
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* ๐ Stop the current managed stream
|
|
110
|
-
*
|
|
111
|
-
* This will stop streaming for this app only. If other apps are consuming
|
|
112
|
-
* the same managed stream, it will continue for them.
|
|
113
|
-
*
|
|
114
|
-
* @returns Promise that resolves when the stop request is sent
|
|
115
|
-
*/
|
|
116
|
-
async stopManagedStream() {
|
|
117
|
-
// Always send the stop request - the cloud will handle whether there's actually
|
|
118
|
-
// a stream to stop. This ensures the stop works even after reload/reconnection
|
|
119
|
-
this.logger.info({
|
|
120
|
-
streamId: this.currentManagedStreamId,
|
|
121
|
-
hasInternalState: this.isManagedStreaming,
|
|
122
|
-
}, "๐น Sending managed stream stop request");
|
|
123
|
-
const request = {
|
|
124
|
-
type: types_1.AppToCloudMessageType.MANAGED_STREAM_STOP,
|
|
125
|
-
packageName: this.packageName,
|
|
126
|
-
};
|
|
127
|
-
this.send(request);
|
|
128
|
-
// Don't clean up state immediately - wait for the 'stopped' status from cloud
|
|
129
|
-
// This ensures we can retry stop if needed and maintains accurate state
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* ๐ Check for any existing streams (managed or unmanaged) for the current user
|
|
133
|
-
*
|
|
134
|
-
* @returns Promise that resolves with stream information if a stream exists
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```typescript
|
|
138
|
-
* const streamInfo = await session.camera.checkExistingStream();
|
|
139
|
-
* if (streamInfo.hasActiveStream) {
|
|
140
|
-
* console.log('Stream type:', streamInfo.streamInfo?.type);
|
|
141
|
-
* if (streamInfo.streamInfo?.type === 'managed') {
|
|
142
|
-
* console.log('HLS URL:', streamInfo.streamInfo.hlsUrl);
|
|
143
|
-
* }
|
|
144
|
-
* }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
async checkExistingStream() {
|
|
148
|
-
return new Promise((resolve) => {
|
|
149
|
-
// Store the resolver for the response
|
|
150
|
-
const requestId = `stream_check_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
151
|
-
// Store a pending request that will be resolved when we get the response
|
|
152
|
-
if (!this.pendingStreamChecks) {
|
|
153
|
-
this.pendingStreamChecks = new Map();
|
|
154
|
-
}
|
|
155
|
-
const timeoutId = setTimeout(() => {
|
|
156
|
-
this.pendingStreamChecks?.delete(requestId);
|
|
157
|
-
resolve({ hasActiveStream: false });
|
|
158
|
-
}, 5000); // 5 second timeout
|
|
159
|
-
this.pendingStreamChecks.set(requestId, {
|
|
160
|
-
resolve,
|
|
161
|
-
timeoutId,
|
|
162
|
-
});
|
|
163
|
-
// Send the check request with the requestId
|
|
164
|
-
const request = {
|
|
165
|
-
type: types_1.AppToCloudMessageType.STREAM_STATUS_CHECK,
|
|
166
|
-
packageName: this.packageName,
|
|
167
|
-
sessionId: this.sessionId,
|
|
168
|
-
};
|
|
169
|
-
this.send(request);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* ๐ Check if currently managed streaming
|
|
174
|
-
*
|
|
175
|
-
* @returns true if a managed stream is active
|
|
176
|
-
*/
|
|
177
|
-
isManagedStreamActive() {
|
|
178
|
-
return this.isManagedStreaming;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* ๐ Get current managed stream URLs
|
|
182
|
-
*
|
|
183
|
-
* @returns Current stream URLs or undefined if not streaming
|
|
184
|
-
*/
|
|
185
|
-
getManagedStreamUrls() {
|
|
186
|
-
return this.currentManagedStreamUrls;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* ๐ Get current managed stream status
|
|
190
|
-
*
|
|
191
|
-
* @returns Current stream status or undefined
|
|
192
|
-
*/
|
|
193
|
-
getManagedStreamStatus() {
|
|
194
|
-
return this.managedStreamStatus;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* ๐ Register a handler for managed stream status updates
|
|
198
|
-
*
|
|
199
|
-
* @param handler - Function to call when stream status changes
|
|
200
|
-
* @returns Cleanup function to unregister the handler
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* ```typescript
|
|
204
|
-
* const cleanup = session.camera.onManagedStreamStatus((status) => {
|
|
205
|
-
* console.log('Status:', status.status);
|
|
206
|
-
* if (status.status === 'active') {
|
|
207
|
-
* console.log('Stream is live!');
|
|
208
|
-
* }
|
|
209
|
-
* });
|
|
210
|
-
*
|
|
211
|
-
* // Later, unregister the handler
|
|
212
|
-
* cleanup();
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
215
|
-
onManagedStreamStatus(handler) {
|
|
216
|
-
if (!this.session) {
|
|
217
|
-
this.logger.error("Cannot listen for managed status updates: session reference not available");
|
|
218
|
-
return () => { };
|
|
219
|
-
}
|
|
220
|
-
this.session.subscribe(types_1.StreamType.MANAGED_STREAM_STATUS);
|
|
221
|
-
// Register the handler using the session's event system
|
|
222
|
-
return this.session.on(types_1.StreamType.MANAGED_STREAM_STATUS, handler);
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Handle incoming stream status check response
|
|
226
|
-
* Called by the parent AppSession when a response is received
|
|
227
|
-
*/
|
|
228
|
-
handleStreamCheckResponse(response) {
|
|
229
|
-
// Find and resolve any pending stream check
|
|
230
|
-
if (this.pendingStreamChecks && this.pendingStreamChecks.size > 0) {
|
|
231
|
-
const firstEntry = this.pendingStreamChecks.entries().next();
|
|
232
|
-
if (!firstEntry.done && firstEntry.value) {
|
|
233
|
-
const [requestId, pending] = firstEntry.value;
|
|
234
|
-
if (pending) {
|
|
235
|
-
clearTimeout(pending.timeoutId);
|
|
236
|
-
this.pendingStreamChecks.delete(requestId);
|
|
237
|
-
pending.resolve(response);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Handle incoming managed stream status messages
|
|
244
|
-
* Called by the parent AppSession when messages are received
|
|
245
|
-
*/
|
|
246
|
-
handleManagedStreamStatus(status) {
|
|
247
|
-
this.logger.info({
|
|
248
|
-
status: status.status,
|
|
249
|
-
streamId: status.streamId,
|
|
250
|
-
}, "๐น Received managed stream status");
|
|
251
|
-
this.managedStreamStatus = status;
|
|
252
|
-
// Handle initializing status - stream is starting
|
|
253
|
-
if (status.status === "initializing" && status.streamId) {
|
|
254
|
-
this.isManagedStreaming = true;
|
|
255
|
-
this.currentManagedStreamId = status.streamId;
|
|
256
|
-
}
|
|
257
|
-
// Handle initial stream ready status
|
|
258
|
-
if (status.status === "active") {
|
|
259
|
-
// Always update state when stream is active
|
|
260
|
-
this.isManagedStreaming = true;
|
|
261
|
-
this.currentManagedStreamId = status.streamId;
|
|
262
|
-
if (status.hlsUrl && status.dashUrl) {
|
|
263
|
-
const result = {
|
|
264
|
-
hlsUrl: status.hlsUrl,
|
|
265
|
-
dashUrl: status.dashUrl,
|
|
266
|
-
webrtcUrl: status.webrtcUrl,
|
|
267
|
-
previewUrl: status.previewUrl,
|
|
268
|
-
thumbnailUrl: status.thumbnailUrl,
|
|
269
|
-
streamId: status.streamId || "",
|
|
270
|
-
};
|
|
271
|
-
this.currentManagedStreamUrls = result;
|
|
272
|
-
// Resolve pending promise if exists
|
|
273
|
-
if (this.pendingManagedStreamRequest) {
|
|
274
|
-
this.pendingManagedStreamRequest.resolve(result);
|
|
275
|
-
this.pendingManagedStreamRequest = undefined;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// Handle error status
|
|
280
|
-
if ((status.status === "error" || status.status === "stopped") &&
|
|
281
|
-
this.pendingManagedStreamRequest) {
|
|
282
|
-
this.pendingManagedStreamRequest.reject(new Error(status.message || "Managed stream failed"));
|
|
283
|
-
this.pendingManagedStreamRequest = undefined;
|
|
284
|
-
this.isManagedStreaming = false;
|
|
285
|
-
}
|
|
286
|
-
// Clean up on stopped status
|
|
287
|
-
if (status.status === "stopped") {
|
|
288
|
-
this.isManagedStreaming = false;
|
|
289
|
-
this.currentManagedStreamId = undefined;
|
|
290
|
-
this.currentManagedStreamUrls = undefined;
|
|
291
|
-
}
|
|
292
|
-
// Notify handlers (would use event emitter in real implementation)
|
|
293
|
-
// this.emit('managedStreamStatus', status);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* ๐งน Clean up all managed streaming state
|
|
297
|
-
*/
|
|
298
|
-
cleanup() {
|
|
299
|
-
if (this.pendingManagedStreamRequest) {
|
|
300
|
-
this.pendingManagedStreamRequest.reject(new Error("Camera module cleanup"));
|
|
301
|
-
this.pendingManagedStreamRequest = undefined;
|
|
302
|
-
}
|
|
303
|
-
this.isManagedStreaming = false;
|
|
304
|
-
this.currentManagedStreamId = undefined;
|
|
305
|
-
this.currentManagedStreamUrls = undefined;
|
|
306
|
-
this.managedStreamStatus = undefined;
|
|
307
|
-
this.logger.info("๐น Managed streaming extension cleaned up");
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
exports.CameraManagedExtension = CameraManagedExtension;
|