camstreamerlib 4.0.0-beta.70 → 4.0.0-beta.71
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.
|
@@ -168,13 +168,20 @@ class CamOverlayDrawingAPI extends events_1.EventEmitter {
|
|
|
168
168
|
throw new Error('No CamOverlay connection');
|
|
169
169
|
}
|
|
170
170
|
msgJson.call_id = ++this.callId;
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
171
|
+
const jsonString = JSON.stringify(msgJson);
|
|
172
|
+
const jsonByteLength = Buffer.byteLength(jsonString);
|
|
173
|
+
const headerLength = 5;
|
|
174
|
+
const totalLength = headerLength + jsonByteLength + data.byteLength;
|
|
175
|
+
const arrayBuffer = new ArrayBuffer(totalLength);
|
|
176
|
+
const view = new DataView(arrayBuffer);
|
|
177
|
+
view.setInt8(0, 1);
|
|
178
|
+
view.setInt32(1, jsonByteLength);
|
|
179
|
+
const jsonBuffer = new Uint8Array(arrayBuffer, 5, jsonByteLength);
|
|
180
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
181
|
+
jsonBuffer[i] = jsonString.charCodeAt(i);
|
|
182
|
+
}
|
|
183
|
+
const dataBuffer = new Uint8Array(arrayBuffer, 5 + jsonByteLength, data.byteLength);
|
|
184
|
+
data.copy(dataBuffer);
|
|
178
185
|
this.ws.send(arrayBuffer);
|
|
179
186
|
this.sendMessages[this.callId] = { resolve, reject, sentTimestamp: Date.now() };
|
|
180
187
|
}
|
|
@@ -165,13 +165,20 @@ export class CamOverlayDrawingAPI extends EventEmitter {
|
|
|
165
165
|
throw new Error('No CamOverlay connection');
|
|
166
166
|
}
|
|
167
167
|
msgJson.call_id = ++this.callId;
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
|
|
168
|
+
const jsonString = JSON.stringify(msgJson);
|
|
169
|
+
const jsonByteLength = Buffer.byteLength(jsonString);
|
|
170
|
+
const headerLength = 5;
|
|
171
|
+
const totalLength = headerLength + jsonByteLength + data.byteLength;
|
|
172
|
+
const arrayBuffer = new ArrayBuffer(totalLength);
|
|
173
|
+
const view = new DataView(arrayBuffer);
|
|
174
|
+
view.setInt8(0, 1);
|
|
175
|
+
view.setInt32(1, jsonByteLength);
|
|
176
|
+
const jsonBuffer = new Uint8Array(arrayBuffer, 5, jsonByteLength);
|
|
177
|
+
for (let i = 0; i < jsonString.length; i++) {
|
|
178
|
+
jsonBuffer[i] = jsonString.charCodeAt(i);
|
|
179
|
+
}
|
|
180
|
+
const dataBuffer = new Uint8Array(arrayBuffer, 5 + jsonByteLength, data.byteLength);
|
|
181
|
+
data.copy(dataBuffer);
|
|
175
182
|
this.ws.send(arrayBuffer);
|
|
176
183
|
this.sendMessages[this.callId] = { resolve, reject, sentTimestamp: Date.now() };
|
|
177
184
|
}
|