easyproctor 0.0.67 → 0.0.68
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/esm/index.js +4381 -471
- package/index.js +3947 -37
- package/package.json +1 -1
- package/unpkg/easyproctor.min.js +327 -47
package/esm/index.js
CHANGED
|
@@ -25,6 +25,3634 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
};
|
|
26
26
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
27
27
|
|
|
28
|
+
// node_modules/recordrtc/RecordRTC.js
|
|
29
|
+
var require_RecordRTC = __commonJS({
|
|
30
|
+
"node_modules/recordrtc/RecordRTC.js"(exports, module) {
|
|
31
|
+
"use strict";
|
|
32
|
+
function RecordRTC(mediaStream, config2) {
|
|
33
|
+
if (!mediaStream) {
|
|
34
|
+
throw "First parameter is required.";
|
|
35
|
+
}
|
|
36
|
+
config2 = config2 || {
|
|
37
|
+
type: "video"
|
|
38
|
+
};
|
|
39
|
+
config2 = new RecordRTCConfiguration(mediaStream, config2);
|
|
40
|
+
var self2 = this;
|
|
41
|
+
function startRecording(config22) {
|
|
42
|
+
if (!config2.disableLogs) {
|
|
43
|
+
console.log("RecordRTC version: ", self2.version);
|
|
44
|
+
}
|
|
45
|
+
if (!!config22) {
|
|
46
|
+
config2 = new RecordRTCConfiguration(mediaStream, config22);
|
|
47
|
+
}
|
|
48
|
+
if (!config2.disableLogs) {
|
|
49
|
+
console.log("started recording " + config2.type + " stream.");
|
|
50
|
+
}
|
|
51
|
+
if (mediaRecorder) {
|
|
52
|
+
mediaRecorder.clearRecordedData();
|
|
53
|
+
mediaRecorder.record();
|
|
54
|
+
setState("recording");
|
|
55
|
+
if (self2.recordingDuration) {
|
|
56
|
+
handleRecordingDuration();
|
|
57
|
+
}
|
|
58
|
+
return self2;
|
|
59
|
+
}
|
|
60
|
+
initRecorder(function() {
|
|
61
|
+
if (self2.recordingDuration) {
|
|
62
|
+
handleRecordingDuration();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return self2;
|
|
66
|
+
}
|
|
67
|
+
function initRecorder(initCallback) {
|
|
68
|
+
if (initCallback) {
|
|
69
|
+
config2.initCallback = function() {
|
|
70
|
+
initCallback();
|
|
71
|
+
initCallback = config2.initCallback = null;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
var Recorder = new GetRecorderType(mediaStream, config2);
|
|
75
|
+
mediaRecorder = new Recorder(mediaStream, config2);
|
|
76
|
+
mediaRecorder.record();
|
|
77
|
+
setState("recording");
|
|
78
|
+
if (!config2.disableLogs) {
|
|
79
|
+
console.log("Initialized recorderType:", mediaRecorder.constructor.name, "for output-type:", config2.type);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function stopRecording(callback) {
|
|
83
|
+
callback = callback || function() {
|
|
84
|
+
};
|
|
85
|
+
if (!mediaRecorder) {
|
|
86
|
+
warningLog();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (self2.state === "paused") {
|
|
90
|
+
self2.resumeRecording();
|
|
91
|
+
setTimeout(function() {
|
|
92
|
+
stopRecording(callback);
|
|
93
|
+
}, 1);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (self2.state !== "recording" && !config2.disableLogs) {
|
|
97
|
+
console.warn('Recording state should be: "recording", however current state is: ', self2.state);
|
|
98
|
+
}
|
|
99
|
+
if (!config2.disableLogs) {
|
|
100
|
+
console.log("Stopped recording " + config2.type + " stream.");
|
|
101
|
+
}
|
|
102
|
+
if (config2.type !== "gif") {
|
|
103
|
+
mediaRecorder.stop(_callback);
|
|
104
|
+
} else {
|
|
105
|
+
mediaRecorder.stop();
|
|
106
|
+
_callback();
|
|
107
|
+
}
|
|
108
|
+
setState("stopped");
|
|
109
|
+
function _callback(__blob) {
|
|
110
|
+
if (!mediaRecorder) {
|
|
111
|
+
if (typeof callback.call === "function") {
|
|
112
|
+
callback.call(self2, "");
|
|
113
|
+
} else {
|
|
114
|
+
callback("");
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
Object.keys(mediaRecorder).forEach(function(key) {
|
|
119
|
+
if (typeof mediaRecorder[key] === "function") {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
self2[key] = mediaRecorder[key];
|
|
123
|
+
});
|
|
124
|
+
var blob = mediaRecorder.blob;
|
|
125
|
+
if (!blob) {
|
|
126
|
+
if (__blob) {
|
|
127
|
+
mediaRecorder.blob = blob = __blob;
|
|
128
|
+
} else {
|
|
129
|
+
throw "Recording failed.";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (blob && !config2.disableLogs) {
|
|
133
|
+
console.log(blob.type, "->", bytesToSize(blob.size));
|
|
134
|
+
}
|
|
135
|
+
if (callback) {
|
|
136
|
+
var url;
|
|
137
|
+
try {
|
|
138
|
+
url = URL2.createObjectURL(blob);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
}
|
|
141
|
+
if (typeof callback.call === "function") {
|
|
142
|
+
callback.call(self2, url);
|
|
143
|
+
} else {
|
|
144
|
+
callback(url);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (!config2.autoWriteToDisk) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
getDataURL(function(dataURL) {
|
|
151
|
+
var parameter = {};
|
|
152
|
+
parameter[config2.type + "Blob"] = dataURL;
|
|
153
|
+
DiskStorage.Store(parameter);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function pauseRecording() {
|
|
158
|
+
if (!mediaRecorder) {
|
|
159
|
+
warningLog();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (self2.state !== "recording") {
|
|
163
|
+
if (!config2.disableLogs) {
|
|
164
|
+
console.warn("Unable to pause the recording. Recording state: ", self2.state);
|
|
165
|
+
}
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
setState("paused");
|
|
169
|
+
mediaRecorder.pause();
|
|
170
|
+
if (!config2.disableLogs) {
|
|
171
|
+
console.log("Paused recording.");
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function resumeRecording() {
|
|
175
|
+
if (!mediaRecorder) {
|
|
176
|
+
warningLog();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (self2.state !== "paused") {
|
|
180
|
+
if (!config2.disableLogs) {
|
|
181
|
+
console.warn("Unable to resume the recording. Recording state: ", self2.state);
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
setState("recording");
|
|
186
|
+
mediaRecorder.resume();
|
|
187
|
+
if (!config2.disableLogs) {
|
|
188
|
+
console.log("Resumed recording.");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function readFile(_blob) {
|
|
192
|
+
postMessage(new FileReaderSync().readAsDataURL(_blob));
|
|
193
|
+
}
|
|
194
|
+
function getDataURL(callback, _mediaRecorder) {
|
|
195
|
+
if (!callback) {
|
|
196
|
+
throw "Pass a callback function over getDataURL.";
|
|
197
|
+
}
|
|
198
|
+
var blob = _mediaRecorder ? _mediaRecorder.blob : (mediaRecorder || {}).blob;
|
|
199
|
+
if (!blob) {
|
|
200
|
+
if (!config2.disableLogs) {
|
|
201
|
+
console.warn("Blob encoder did not finish its job yet.");
|
|
202
|
+
}
|
|
203
|
+
setTimeout(function() {
|
|
204
|
+
getDataURL(callback, _mediaRecorder);
|
|
205
|
+
}, 1e3);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (typeof Worker !== "undefined" && !navigator.mozGetUserMedia) {
|
|
209
|
+
var webWorker = processInWebWorker(readFile);
|
|
210
|
+
webWorker.onmessage = function(event) {
|
|
211
|
+
callback(event.data);
|
|
212
|
+
};
|
|
213
|
+
webWorker.postMessage(blob);
|
|
214
|
+
} else {
|
|
215
|
+
var reader = new FileReader();
|
|
216
|
+
reader.readAsDataURL(blob);
|
|
217
|
+
reader.onload = function(event) {
|
|
218
|
+
callback(event.target.result);
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function processInWebWorker(_function) {
|
|
222
|
+
try {
|
|
223
|
+
var blob2 = URL2.createObjectURL(new Blob([
|
|
224
|
+
_function.toString(),
|
|
225
|
+
"this.onmessage = function (eee) {" + _function.name + "(eee.data);}"
|
|
226
|
+
], {
|
|
227
|
+
type: "application/javascript"
|
|
228
|
+
}));
|
|
229
|
+
var worker = new Worker(blob2);
|
|
230
|
+
URL2.revokeObjectURL(blob2);
|
|
231
|
+
return worker;
|
|
232
|
+
} catch (e) {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function handleRecordingDuration(counter) {
|
|
237
|
+
counter = counter || 0;
|
|
238
|
+
if (self2.state === "paused") {
|
|
239
|
+
setTimeout(function() {
|
|
240
|
+
handleRecordingDuration(counter);
|
|
241
|
+
}, 1e3);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (self2.state === "stopped") {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (counter >= self2.recordingDuration) {
|
|
248
|
+
stopRecording(self2.onRecordingStopped);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
counter += 1e3;
|
|
252
|
+
setTimeout(function() {
|
|
253
|
+
handleRecordingDuration(counter);
|
|
254
|
+
}, 1e3);
|
|
255
|
+
}
|
|
256
|
+
function setState(state) {
|
|
257
|
+
if (!self2) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
self2.state = state;
|
|
261
|
+
if (typeof self2.onStateChanged.call === "function") {
|
|
262
|
+
self2.onStateChanged.call(self2, state);
|
|
263
|
+
} else {
|
|
264
|
+
self2.onStateChanged(state);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
var WARNING = 'It seems that recorder is destroyed or "startRecording" is not invoked for ' + config2.type + " recorder.";
|
|
268
|
+
function warningLog() {
|
|
269
|
+
if (config2.disableLogs === true) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
console.warn(WARNING);
|
|
273
|
+
}
|
|
274
|
+
var mediaRecorder;
|
|
275
|
+
var returnObject = {
|
|
276
|
+
startRecording,
|
|
277
|
+
stopRecording,
|
|
278
|
+
pauseRecording,
|
|
279
|
+
resumeRecording,
|
|
280
|
+
initRecorder,
|
|
281
|
+
setRecordingDuration: function(recordingDuration, callback) {
|
|
282
|
+
if (typeof recordingDuration === "undefined") {
|
|
283
|
+
throw "recordingDuration is required.";
|
|
284
|
+
}
|
|
285
|
+
if (typeof recordingDuration !== "number") {
|
|
286
|
+
throw "recordingDuration must be a number.";
|
|
287
|
+
}
|
|
288
|
+
self2.recordingDuration = recordingDuration;
|
|
289
|
+
self2.onRecordingStopped = callback || function() {
|
|
290
|
+
};
|
|
291
|
+
return {
|
|
292
|
+
onRecordingStopped: function(callback2) {
|
|
293
|
+
self2.onRecordingStopped = callback2;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
clearRecordedData: function() {
|
|
298
|
+
if (!mediaRecorder) {
|
|
299
|
+
warningLog();
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
mediaRecorder.clearRecordedData();
|
|
303
|
+
if (!config2.disableLogs) {
|
|
304
|
+
console.log("Cleared old recorded data.");
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
getBlob: function() {
|
|
308
|
+
if (!mediaRecorder) {
|
|
309
|
+
warningLog();
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
return mediaRecorder.blob;
|
|
313
|
+
},
|
|
314
|
+
getDataURL,
|
|
315
|
+
toURL: function() {
|
|
316
|
+
if (!mediaRecorder) {
|
|
317
|
+
warningLog();
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
return URL2.createObjectURL(mediaRecorder.blob);
|
|
321
|
+
},
|
|
322
|
+
getInternalRecorder: function() {
|
|
323
|
+
return mediaRecorder;
|
|
324
|
+
},
|
|
325
|
+
save: function(fileName) {
|
|
326
|
+
if (!mediaRecorder) {
|
|
327
|
+
warningLog();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
invokeSaveAsDialog2(mediaRecorder.blob, fileName);
|
|
331
|
+
},
|
|
332
|
+
getFromDisk: function(callback) {
|
|
333
|
+
if (!mediaRecorder) {
|
|
334
|
+
warningLog();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
RecordRTC.getFromDisk(config2.type, callback);
|
|
338
|
+
},
|
|
339
|
+
setAdvertisementArray: function(arrayOfWebPImages) {
|
|
340
|
+
config2.advertisement = [];
|
|
341
|
+
var length = arrayOfWebPImages.length;
|
|
342
|
+
for (var i = 0; i < length; i++) {
|
|
343
|
+
config2.advertisement.push({
|
|
344
|
+
duration: i,
|
|
345
|
+
image: arrayOfWebPImages[i]
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
blob: null,
|
|
350
|
+
bufferSize: 0,
|
|
351
|
+
sampleRate: 0,
|
|
352
|
+
buffer: null,
|
|
353
|
+
reset: function() {
|
|
354
|
+
if (self2.state === "recording" && !config2.disableLogs) {
|
|
355
|
+
console.warn("Stop an active recorder.");
|
|
356
|
+
}
|
|
357
|
+
if (mediaRecorder && typeof mediaRecorder.clearRecordedData === "function") {
|
|
358
|
+
mediaRecorder.clearRecordedData();
|
|
359
|
+
}
|
|
360
|
+
mediaRecorder = null;
|
|
361
|
+
setState("inactive");
|
|
362
|
+
self2.blob = null;
|
|
363
|
+
},
|
|
364
|
+
onStateChanged: function(state) {
|
|
365
|
+
if (!config2.disableLogs) {
|
|
366
|
+
console.log("Recorder state changed:", state);
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
state: "inactive",
|
|
370
|
+
getState: function() {
|
|
371
|
+
return self2.state;
|
|
372
|
+
},
|
|
373
|
+
destroy: function() {
|
|
374
|
+
var disableLogsCache = config2.disableLogs;
|
|
375
|
+
config2 = {
|
|
376
|
+
disableLogs: true
|
|
377
|
+
};
|
|
378
|
+
self2.reset();
|
|
379
|
+
setState("destroyed");
|
|
380
|
+
returnObject = self2 = null;
|
|
381
|
+
if (Storage.AudioContextConstructor) {
|
|
382
|
+
Storage.AudioContextConstructor.close();
|
|
383
|
+
Storage.AudioContextConstructor = null;
|
|
384
|
+
}
|
|
385
|
+
config2.disableLogs = disableLogsCache;
|
|
386
|
+
if (!config2.disableLogs) {
|
|
387
|
+
console.log("RecordRTC is destroyed.");
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
version: "5.6.2"
|
|
391
|
+
};
|
|
392
|
+
if (!this) {
|
|
393
|
+
self2 = returnObject;
|
|
394
|
+
return returnObject;
|
|
395
|
+
}
|
|
396
|
+
for (var prop in returnObject) {
|
|
397
|
+
this[prop] = returnObject[prop];
|
|
398
|
+
}
|
|
399
|
+
self2 = this;
|
|
400
|
+
return returnObject;
|
|
401
|
+
}
|
|
402
|
+
RecordRTC.version = "5.6.2";
|
|
403
|
+
if (typeof module !== "undefined") {
|
|
404
|
+
module.exports = RecordRTC;
|
|
405
|
+
}
|
|
406
|
+
if (typeof define === "function" && define.amd) {
|
|
407
|
+
define("RecordRTC", [], function() {
|
|
408
|
+
return RecordRTC;
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
RecordRTC.getFromDisk = function(type, callback) {
|
|
412
|
+
if (!callback) {
|
|
413
|
+
throw "callback is mandatory.";
|
|
414
|
+
}
|
|
415
|
+
console.log("Getting recorded " + (type === "all" ? "blobs" : type + " blob ") + " from disk!");
|
|
416
|
+
DiskStorage.Fetch(function(dataURL, _type) {
|
|
417
|
+
if (type !== "all" && _type === type + "Blob" && callback) {
|
|
418
|
+
callback(dataURL);
|
|
419
|
+
}
|
|
420
|
+
if (type === "all" && callback) {
|
|
421
|
+
callback(dataURL, _type.replace("Blob", ""));
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
RecordRTC.writeToDisk = function(options) {
|
|
426
|
+
console.log("Writing recorded blob(s) to disk!");
|
|
427
|
+
options = options || {};
|
|
428
|
+
if (options.audio && options.video && options.gif) {
|
|
429
|
+
options.audio.getDataURL(function(audioDataURL) {
|
|
430
|
+
options.video.getDataURL(function(videoDataURL) {
|
|
431
|
+
options.gif.getDataURL(function(gifDataURL) {
|
|
432
|
+
DiskStorage.Store({
|
|
433
|
+
audioBlob: audioDataURL,
|
|
434
|
+
videoBlob: videoDataURL,
|
|
435
|
+
gifBlob: gifDataURL
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
} else if (options.audio && options.video) {
|
|
441
|
+
options.audio.getDataURL(function(audioDataURL) {
|
|
442
|
+
options.video.getDataURL(function(videoDataURL) {
|
|
443
|
+
DiskStorage.Store({
|
|
444
|
+
audioBlob: audioDataURL,
|
|
445
|
+
videoBlob: videoDataURL
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
} else if (options.audio && options.gif) {
|
|
450
|
+
options.audio.getDataURL(function(audioDataURL) {
|
|
451
|
+
options.gif.getDataURL(function(gifDataURL) {
|
|
452
|
+
DiskStorage.Store({
|
|
453
|
+
audioBlob: audioDataURL,
|
|
454
|
+
gifBlob: gifDataURL
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
} else if (options.video && options.gif) {
|
|
459
|
+
options.video.getDataURL(function(videoDataURL) {
|
|
460
|
+
options.gif.getDataURL(function(gifDataURL) {
|
|
461
|
+
DiskStorage.Store({
|
|
462
|
+
videoBlob: videoDataURL,
|
|
463
|
+
gifBlob: gifDataURL
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
} else if (options.audio) {
|
|
468
|
+
options.audio.getDataURL(function(audioDataURL) {
|
|
469
|
+
DiskStorage.Store({
|
|
470
|
+
audioBlob: audioDataURL
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
} else if (options.video) {
|
|
474
|
+
options.video.getDataURL(function(videoDataURL) {
|
|
475
|
+
DiskStorage.Store({
|
|
476
|
+
videoBlob: videoDataURL
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
} else if (options.gif) {
|
|
480
|
+
options.gif.getDataURL(function(gifDataURL) {
|
|
481
|
+
DiskStorage.Store({
|
|
482
|
+
gifBlob: gifDataURL
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
function RecordRTCConfiguration(mediaStream, config2) {
|
|
488
|
+
if (!config2.recorderType && !config2.type) {
|
|
489
|
+
if (!!config2.audio && !!config2.video) {
|
|
490
|
+
config2.type = "video";
|
|
491
|
+
} else if (!!config2.audio && !config2.video) {
|
|
492
|
+
config2.type = "audio";
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (config2.recorderType && !config2.type) {
|
|
496
|
+
if (config2.recorderType === WhammyRecorder || config2.recorderType === CanvasRecorder || typeof WebAssemblyRecorder !== "undefined" && config2.recorderType === WebAssemblyRecorder) {
|
|
497
|
+
config2.type = "video";
|
|
498
|
+
} else if (config2.recorderType === GifRecorder) {
|
|
499
|
+
config2.type = "gif";
|
|
500
|
+
} else if (config2.recorderType === StereoAudioRecorder) {
|
|
501
|
+
config2.type = "audio";
|
|
502
|
+
} else if (config2.recorderType === MediaStreamRecorder) {
|
|
503
|
+
if (getTracks(mediaStream, "audio").length && getTracks(mediaStream, "video").length) {
|
|
504
|
+
config2.type = "video";
|
|
505
|
+
} else if (!getTracks(mediaStream, "audio").length && getTracks(mediaStream, "video").length) {
|
|
506
|
+
config2.type = "video";
|
|
507
|
+
} else if (getTracks(mediaStream, "audio").length && !getTracks(mediaStream, "video").length) {
|
|
508
|
+
config2.type = "audio";
|
|
509
|
+
} else {
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (typeof MediaStreamRecorder !== "undefined" && typeof MediaRecorder !== "undefined" && "requestData" in MediaRecorder.prototype) {
|
|
514
|
+
if (!config2.mimeType) {
|
|
515
|
+
config2.mimeType = "video/webm";
|
|
516
|
+
}
|
|
517
|
+
if (!config2.type) {
|
|
518
|
+
config2.type = config2.mimeType.split("/")[0];
|
|
519
|
+
}
|
|
520
|
+
if (!config2.bitsPerSecond) {
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
if (!config2.type) {
|
|
524
|
+
if (config2.mimeType) {
|
|
525
|
+
config2.type = config2.mimeType.split("/")[0];
|
|
526
|
+
}
|
|
527
|
+
if (!config2.type) {
|
|
528
|
+
config2.type = "audio";
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return config2;
|
|
532
|
+
}
|
|
533
|
+
function GetRecorderType(mediaStream, config2) {
|
|
534
|
+
var recorder;
|
|
535
|
+
if (isChrome || isEdge || isOpera) {
|
|
536
|
+
recorder = StereoAudioRecorder;
|
|
537
|
+
}
|
|
538
|
+
if (typeof MediaRecorder !== "undefined" && "requestData" in MediaRecorder.prototype && !isChrome) {
|
|
539
|
+
recorder = MediaStreamRecorder;
|
|
540
|
+
}
|
|
541
|
+
if (config2.type === "video" && (isChrome || isOpera)) {
|
|
542
|
+
recorder = WhammyRecorder;
|
|
543
|
+
if (typeof WebAssemblyRecorder !== "undefined" && typeof ReadableStream !== "undefined") {
|
|
544
|
+
recorder = WebAssemblyRecorder;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (config2.type === "gif") {
|
|
548
|
+
recorder = GifRecorder;
|
|
549
|
+
}
|
|
550
|
+
if (config2.type === "canvas") {
|
|
551
|
+
recorder = CanvasRecorder;
|
|
552
|
+
}
|
|
553
|
+
if (isMediaRecorderCompatible() && recorder !== CanvasRecorder && recorder !== GifRecorder && typeof MediaRecorder !== "undefined" && "requestData" in MediaRecorder.prototype) {
|
|
554
|
+
if (getTracks(mediaStream, "video").length || getTracks(mediaStream, "audio").length) {
|
|
555
|
+
if (config2.type === "audio") {
|
|
556
|
+
if (typeof MediaRecorder.isTypeSupported === "function" && MediaRecorder.isTypeSupported("audio/webm")) {
|
|
557
|
+
recorder = MediaStreamRecorder;
|
|
558
|
+
}
|
|
559
|
+
} else {
|
|
560
|
+
if (typeof MediaRecorder.isTypeSupported === "function" && MediaRecorder.isTypeSupported("video/webm")) {
|
|
561
|
+
recorder = MediaStreamRecorder;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (mediaStream instanceof Array && mediaStream.length) {
|
|
567
|
+
recorder = MultiStreamRecorder;
|
|
568
|
+
}
|
|
569
|
+
if (config2.recorderType) {
|
|
570
|
+
recorder = config2.recorderType;
|
|
571
|
+
}
|
|
572
|
+
if (!config2.disableLogs && !!recorder && !!recorder.name) {
|
|
573
|
+
console.log("Using recorderType:", recorder.name || recorder.constructor.name);
|
|
574
|
+
}
|
|
575
|
+
if (!recorder && isSafari2) {
|
|
576
|
+
recorder = MediaStreamRecorder;
|
|
577
|
+
}
|
|
578
|
+
return recorder;
|
|
579
|
+
}
|
|
580
|
+
function MRecordRTC(mediaStream) {
|
|
581
|
+
this.addStream = function(_mediaStream) {
|
|
582
|
+
if (_mediaStream) {
|
|
583
|
+
mediaStream = _mediaStream;
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
this.mediaType = {
|
|
587
|
+
audio: true,
|
|
588
|
+
video: true
|
|
589
|
+
};
|
|
590
|
+
this.startRecording = function() {
|
|
591
|
+
var mediaType = this.mediaType;
|
|
592
|
+
var recorderType;
|
|
593
|
+
var mimeType = this.mimeType || {
|
|
594
|
+
audio: null,
|
|
595
|
+
video: null,
|
|
596
|
+
gif: null
|
|
597
|
+
};
|
|
598
|
+
if (typeof mediaType.audio !== "function" && isMediaRecorderCompatible() && !getTracks(mediaStream, "audio").length) {
|
|
599
|
+
mediaType.audio = false;
|
|
600
|
+
}
|
|
601
|
+
if (typeof mediaType.video !== "function" && isMediaRecorderCompatible() && !getTracks(mediaStream, "video").length) {
|
|
602
|
+
mediaType.video = false;
|
|
603
|
+
}
|
|
604
|
+
if (typeof mediaType.gif !== "function" && isMediaRecorderCompatible() && !getTracks(mediaStream, "video").length) {
|
|
605
|
+
mediaType.gif = false;
|
|
606
|
+
}
|
|
607
|
+
if (!mediaType.audio && !mediaType.video && !mediaType.gif) {
|
|
608
|
+
throw "MediaStream must have either audio or video tracks.";
|
|
609
|
+
}
|
|
610
|
+
if (!!mediaType.audio) {
|
|
611
|
+
recorderType = null;
|
|
612
|
+
if (typeof mediaType.audio === "function") {
|
|
613
|
+
recorderType = mediaType.audio;
|
|
614
|
+
}
|
|
615
|
+
this.audioRecorder = new RecordRTC(mediaStream, {
|
|
616
|
+
type: "audio",
|
|
617
|
+
bufferSize: this.bufferSize,
|
|
618
|
+
sampleRate: this.sampleRate,
|
|
619
|
+
numberOfAudioChannels: this.numberOfAudioChannels || 2,
|
|
620
|
+
disableLogs: this.disableLogs,
|
|
621
|
+
recorderType,
|
|
622
|
+
mimeType: mimeType.audio,
|
|
623
|
+
timeSlice: this.timeSlice,
|
|
624
|
+
onTimeStamp: this.onTimeStamp
|
|
625
|
+
});
|
|
626
|
+
if (!mediaType.video) {
|
|
627
|
+
this.audioRecorder.startRecording();
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (!!mediaType.video) {
|
|
631
|
+
recorderType = null;
|
|
632
|
+
if (typeof mediaType.video === "function") {
|
|
633
|
+
recorderType = mediaType.video;
|
|
634
|
+
}
|
|
635
|
+
var newStream = mediaStream;
|
|
636
|
+
if (isMediaRecorderCompatible() && !!mediaType.audio && typeof mediaType.audio === "function") {
|
|
637
|
+
var videoTrack = getTracks(mediaStream, "video")[0];
|
|
638
|
+
if (isFirefox) {
|
|
639
|
+
newStream = new MediaStream();
|
|
640
|
+
newStream.addTrack(videoTrack);
|
|
641
|
+
if (recorderType && recorderType === WhammyRecorder) {
|
|
642
|
+
recorderType = MediaStreamRecorder;
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
newStream = new MediaStream();
|
|
646
|
+
newStream.addTrack(videoTrack);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
this.videoRecorder = new RecordRTC(newStream, {
|
|
650
|
+
type: "video",
|
|
651
|
+
video: this.video,
|
|
652
|
+
canvas: this.canvas,
|
|
653
|
+
frameInterval: this.frameInterval || 10,
|
|
654
|
+
disableLogs: this.disableLogs,
|
|
655
|
+
recorderType,
|
|
656
|
+
mimeType: mimeType.video,
|
|
657
|
+
timeSlice: this.timeSlice,
|
|
658
|
+
onTimeStamp: this.onTimeStamp,
|
|
659
|
+
workerPath: this.workerPath,
|
|
660
|
+
webAssemblyPath: this.webAssemblyPath,
|
|
661
|
+
frameRate: this.frameRate,
|
|
662
|
+
bitrate: this.bitrate
|
|
663
|
+
});
|
|
664
|
+
if (!mediaType.audio) {
|
|
665
|
+
this.videoRecorder.startRecording();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (!!mediaType.audio && !!mediaType.video) {
|
|
669
|
+
var self2 = this;
|
|
670
|
+
var isSingleRecorder = isMediaRecorderCompatible() === true;
|
|
671
|
+
if (mediaType.audio instanceof StereoAudioRecorder && !!mediaType.video) {
|
|
672
|
+
isSingleRecorder = false;
|
|
673
|
+
} else if (mediaType.audio !== true && mediaType.video !== true && mediaType.audio !== mediaType.video) {
|
|
674
|
+
isSingleRecorder = false;
|
|
675
|
+
}
|
|
676
|
+
if (isSingleRecorder === true) {
|
|
677
|
+
self2.audioRecorder = null;
|
|
678
|
+
self2.videoRecorder.startRecording();
|
|
679
|
+
} else {
|
|
680
|
+
self2.videoRecorder.initRecorder(function() {
|
|
681
|
+
self2.audioRecorder.initRecorder(function() {
|
|
682
|
+
self2.videoRecorder.startRecording();
|
|
683
|
+
self2.audioRecorder.startRecording();
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (!!mediaType.gif) {
|
|
689
|
+
recorderType = null;
|
|
690
|
+
if (typeof mediaType.gif === "function") {
|
|
691
|
+
recorderType = mediaType.gif;
|
|
692
|
+
}
|
|
693
|
+
this.gifRecorder = new RecordRTC(mediaStream, {
|
|
694
|
+
type: "gif",
|
|
695
|
+
frameRate: this.frameRate || 200,
|
|
696
|
+
quality: this.quality || 10,
|
|
697
|
+
disableLogs: this.disableLogs,
|
|
698
|
+
recorderType,
|
|
699
|
+
mimeType: mimeType.gif
|
|
700
|
+
});
|
|
701
|
+
this.gifRecorder.startRecording();
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
this.stopRecording = function(callback) {
|
|
705
|
+
callback = callback || function() {
|
|
706
|
+
};
|
|
707
|
+
if (this.audioRecorder) {
|
|
708
|
+
this.audioRecorder.stopRecording(function(blobURL) {
|
|
709
|
+
callback(blobURL, "audio");
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
if (this.videoRecorder) {
|
|
713
|
+
this.videoRecorder.stopRecording(function(blobURL) {
|
|
714
|
+
callback(blobURL, "video");
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
if (this.gifRecorder) {
|
|
718
|
+
this.gifRecorder.stopRecording(function(blobURL) {
|
|
719
|
+
callback(blobURL, "gif");
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
this.pauseRecording = function() {
|
|
724
|
+
if (this.audioRecorder) {
|
|
725
|
+
this.audioRecorder.pauseRecording();
|
|
726
|
+
}
|
|
727
|
+
if (this.videoRecorder) {
|
|
728
|
+
this.videoRecorder.pauseRecording();
|
|
729
|
+
}
|
|
730
|
+
if (this.gifRecorder) {
|
|
731
|
+
this.gifRecorder.pauseRecording();
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
this.resumeRecording = function() {
|
|
735
|
+
if (this.audioRecorder) {
|
|
736
|
+
this.audioRecorder.resumeRecording();
|
|
737
|
+
}
|
|
738
|
+
if (this.videoRecorder) {
|
|
739
|
+
this.videoRecorder.resumeRecording();
|
|
740
|
+
}
|
|
741
|
+
if (this.gifRecorder) {
|
|
742
|
+
this.gifRecorder.resumeRecording();
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
this.getBlob = function(callback) {
|
|
746
|
+
var output = {};
|
|
747
|
+
if (this.audioRecorder) {
|
|
748
|
+
output.audio = this.audioRecorder.getBlob();
|
|
749
|
+
}
|
|
750
|
+
if (this.videoRecorder) {
|
|
751
|
+
output.video = this.videoRecorder.getBlob();
|
|
752
|
+
}
|
|
753
|
+
if (this.gifRecorder) {
|
|
754
|
+
output.gif = this.gifRecorder.getBlob();
|
|
755
|
+
}
|
|
756
|
+
if (callback) {
|
|
757
|
+
callback(output);
|
|
758
|
+
}
|
|
759
|
+
return output;
|
|
760
|
+
};
|
|
761
|
+
this.destroy = function() {
|
|
762
|
+
if (this.audioRecorder) {
|
|
763
|
+
this.audioRecorder.destroy();
|
|
764
|
+
this.audioRecorder = null;
|
|
765
|
+
}
|
|
766
|
+
if (this.videoRecorder) {
|
|
767
|
+
this.videoRecorder.destroy();
|
|
768
|
+
this.videoRecorder = null;
|
|
769
|
+
}
|
|
770
|
+
if (this.gifRecorder) {
|
|
771
|
+
this.gifRecorder.destroy();
|
|
772
|
+
this.gifRecorder = null;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
this.getDataURL = function(callback) {
|
|
776
|
+
this.getBlob(function(blob) {
|
|
777
|
+
if (blob.audio && blob.video) {
|
|
778
|
+
getDataURL(blob.audio, function(_audioDataURL) {
|
|
779
|
+
getDataURL(blob.video, function(_videoDataURL) {
|
|
780
|
+
callback({
|
|
781
|
+
audio: _audioDataURL,
|
|
782
|
+
video: _videoDataURL
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
} else if (blob.audio) {
|
|
787
|
+
getDataURL(blob.audio, function(_audioDataURL) {
|
|
788
|
+
callback({
|
|
789
|
+
audio: _audioDataURL
|
|
790
|
+
});
|
|
791
|
+
});
|
|
792
|
+
} else if (blob.video) {
|
|
793
|
+
getDataURL(blob.video, function(_videoDataURL) {
|
|
794
|
+
callback({
|
|
795
|
+
video: _videoDataURL
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
function getDataURL(blob, callback00) {
|
|
801
|
+
if (typeof Worker !== "undefined") {
|
|
802
|
+
var webWorker = processInWebWorker(function readFile(_blob) {
|
|
803
|
+
postMessage(new FileReaderSync().readAsDataURL(_blob));
|
|
804
|
+
});
|
|
805
|
+
webWorker.onmessage = function(event) {
|
|
806
|
+
callback00(event.data);
|
|
807
|
+
};
|
|
808
|
+
webWorker.postMessage(blob);
|
|
809
|
+
} else {
|
|
810
|
+
var reader = new FileReader();
|
|
811
|
+
reader.readAsDataURL(blob);
|
|
812
|
+
reader.onload = function(event) {
|
|
813
|
+
callback00(event.target.result);
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function processInWebWorker(_function) {
|
|
818
|
+
var blob = URL2.createObjectURL(new Blob([
|
|
819
|
+
_function.toString(),
|
|
820
|
+
"this.onmessage = function (eee) {" + _function.name + "(eee.data);}"
|
|
821
|
+
], {
|
|
822
|
+
type: "application/javascript"
|
|
823
|
+
}));
|
|
824
|
+
var worker = new Worker(blob);
|
|
825
|
+
var url;
|
|
826
|
+
if (typeof URL2 !== "undefined") {
|
|
827
|
+
url = URL2;
|
|
828
|
+
} else if (typeof webkitURL !== "undefined") {
|
|
829
|
+
url = webkitURL;
|
|
830
|
+
} else {
|
|
831
|
+
throw "Neither URL nor webkitURL detected.";
|
|
832
|
+
}
|
|
833
|
+
url.revokeObjectURL(blob);
|
|
834
|
+
return worker;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
this.writeToDisk = function() {
|
|
838
|
+
RecordRTC.writeToDisk({
|
|
839
|
+
audio: this.audioRecorder,
|
|
840
|
+
video: this.videoRecorder,
|
|
841
|
+
gif: this.gifRecorder
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
this.save = function(args) {
|
|
845
|
+
args = args || {
|
|
846
|
+
audio: true,
|
|
847
|
+
video: true,
|
|
848
|
+
gif: true
|
|
849
|
+
};
|
|
850
|
+
if (!!args.audio && this.audioRecorder) {
|
|
851
|
+
this.audioRecorder.save(typeof args.audio === "string" ? args.audio : "");
|
|
852
|
+
}
|
|
853
|
+
if (!!args.video && this.videoRecorder) {
|
|
854
|
+
this.videoRecorder.save(typeof args.video === "string" ? args.video : "");
|
|
855
|
+
}
|
|
856
|
+
if (!!args.gif && this.gifRecorder) {
|
|
857
|
+
this.gifRecorder.save(typeof args.gif === "string" ? args.gif : "");
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
MRecordRTC.getFromDisk = RecordRTC.getFromDisk;
|
|
862
|
+
MRecordRTC.writeToDisk = RecordRTC.writeToDisk;
|
|
863
|
+
if (typeof RecordRTC !== "undefined") {
|
|
864
|
+
RecordRTC.MRecordRTC = MRecordRTC;
|
|
865
|
+
}
|
|
866
|
+
var browserFakeUserAgent = "Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";
|
|
867
|
+
(function(that) {
|
|
868
|
+
if (!that) {
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
if (typeof window !== "undefined") {
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
if (typeof global === "undefined") {
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
global.navigator = {
|
|
878
|
+
userAgent: browserFakeUserAgent,
|
|
879
|
+
getUserMedia: function() {
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
if (!global.console) {
|
|
883
|
+
global.console = {};
|
|
884
|
+
}
|
|
885
|
+
if (typeof global.console.log === "undefined" || typeof global.console.error === "undefined") {
|
|
886
|
+
global.console.error = global.console.log = global.console.log || function() {
|
|
887
|
+
console.log(arguments);
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
if (typeof document === "undefined") {
|
|
891
|
+
that.document = {
|
|
892
|
+
documentElement: {
|
|
893
|
+
appendChild: function() {
|
|
894
|
+
return "";
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
document.createElement = document.captureStream = document.mozCaptureStream = function() {
|
|
899
|
+
var obj = {
|
|
900
|
+
getContext: function() {
|
|
901
|
+
return obj;
|
|
902
|
+
},
|
|
903
|
+
play: function() {
|
|
904
|
+
},
|
|
905
|
+
pause: function() {
|
|
906
|
+
},
|
|
907
|
+
drawImage: function() {
|
|
908
|
+
},
|
|
909
|
+
toDataURL: function() {
|
|
910
|
+
return "";
|
|
911
|
+
},
|
|
912
|
+
style: {}
|
|
913
|
+
};
|
|
914
|
+
return obj;
|
|
915
|
+
};
|
|
916
|
+
that.HTMLVideoElement = function() {
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
if (typeof location === "undefined") {
|
|
920
|
+
that.location = {
|
|
921
|
+
protocol: "file:",
|
|
922
|
+
href: "",
|
|
923
|
+
hash: ""
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
if (typeof screen === "undefined") {
|
|
927
|
+
that.screen = {
|
|
928
|
+
width: 0,
|
|
929
|
+
height: 0
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
if (typeof URL2 === "undefined") {
|
|
933
|
+
that.URL = {
|
|
934
|
+
createObjectURL: function() {
|
|
935
|
+
return "";
|
|
936
|
+
},
|
|
937
|
+
revokeObjectURL: function() {
|
|
938
|
+
return "";
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
that.window = global;
|
|
943
|
+
})(typeof global !== "undefined" ? global : null);
|
|
944
|
+
var requestAnimationFrame = window.requestAnimationFrame;
|
|
945
|
+
if (typeof requestAnimationFrame === "undefined") {
|
|
946
|
+
if (typeof webkitRequestAnimationFrame !== "undefined") {
|
|
947
|
+
requestAnimationFrame = webkitRequestAnimationFrame;
|
|
948
|
+
} else if (typeof mozRequestAnimationFrame !== "undefined") {
|
|
949
|
+
requestAnimationFrame = mozRequestAnimationFrame;
|
|
950
|
+
} else if (typeof msRequestAnimationFrame !== "undefined") {
|
|
951
|
+
requestAnimationFrame = msRequestAnimationFrame;
|
|
952
|
+
} else if (typeof requestAnimationFrame === "undefined") {
|
|
953
|
+
lastTime = 0;
|
|
954
|
+
requestAnimationFrame = function(callback, element) {
|
|
955
|
+
var currTime = new Date().getTime();
|
|
956
|
+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
957
|
+
var id = setTimeout(function() {
|
|
958
|
+
callback(currTime + timeToCall);
|
|
959
|
+
}, timeToCall);
|
|
960
|
+
lastTime = currTime + timeToCall;
|
|
961
|
+
return id;
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
var lastTime;
|
|
966
|
+
var cancelAnimationFrame = window.cancelAnimationFrame;
|
|
967
|
+
if (typeof cancelAnimationFrame === "undefined") {
|
|
968
|
+
if (typeof webkitCancelAnimationFrame !== "undefined") {
|
|
969
|
+
cancelAnimationFrame = webkitCancelAnimationFrame;
|
|
970
|
+
} else if (typeof mozCancelAnimationFrame !== "undefined") {
|
|
971
|
+
cancelAnimationFrame = mozCancelAnimationFrame;
|
|
972
|
+
} else if (typeof msCancelAnimationFrame !== "undefined") {
|
|
973
|
+
cancelAnimationFrame = msCancelAnimationFrame;
|
|
974
|
+
} else if (typeof cancelAnimationFrame === "undefined") {
|
|
975
|
+
cancelAnimationFrame = function(id) {
|
|
976
|
+
clearTimeout(id);
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
var AudioContext = window.AudioContext;
|
|
981
|
+
if (typeof AudioContext === "undefined") {
|
|
982
|
+
if (typeof webkitAudioContext !== "undefined") {
|
|
983
|
+
AudioContext = webkitAudioContext;
|
|
984
|
+
}
|
|
985
|
+
if (typeof mozAudioContext !== "undefined") {
|
|
986
|
+
AudioContext = mozAudioContext;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
var URL2 = window.URL;
|
|
990
|
+
if (typeof URL2 === "undefined" && typeof webkitURL !== "undefined") {
|
|
991
|
+
URL2 = webkitURL;
|
|
992
|
+
}
|
|
993
|
+
if (typeof navigator !== "undefined" && typeof navigator.getUserMedia === "undefined") {
|
|
994
|
+
if (typeof navigator.webkitGetUserMedia !== "undefined") {
|
|
995
|
+
navigator.getUserMedia = navigator.webkitGetUserMedia;
|
|
996
|
+
}
|
|
997
|
+
if (typeof navigator.mozGetUserMedia !== "undefined") {
|
|
998
|
+
navigator.getUserMedia = navigator.mozGetUserMedia;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
var isEdge = navigator.userAgent.indexOf("Edge") !== -1 && (!!navigator.msSaveBlob || !!navigator.msSaveOrOpenBlob);
|
|
1002
|
+
var isOpera = !!window.opera || navigator.userAgent.indexOf("OPR/") !== -1;
|
|
1003
|
+
var isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1 && "netscape" in window && / rv:/.test(navigator.userAgent);
|
|
1004
|
+
var isChrome = !isOpera && !isEdge && !!navigator.webkitGetUserMedia || isElectron() || navigator.userAgent.toLowerCase().indexOf("chrome/") !== -1;
|
|
1005
|
+
var isSafari2 = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1006
|
+
if (isSafari2 && !isChrome && navigator.userAgent.indexOf("CriOS") !== -1) {
|
|
1007
|
+
isSafari2 = false;
|
|
1008
|
+
isChrome = true;
|
|
1009
|
+
}
|
|
1010
|
+
var MediaStream = window.MediaStream;
|
|
1011
|
+
if (typeof MediaStream === "undefined" && typeof webkitMediaStream !== "undefined") {
|
|
1012
|
+
MediaStream = webkitMediaStream;
|
|
1013
|
+
}
|
|
1014
|
+
if (typeof MediaStream !== "undefined") {
|
|
1015
|
+
if (typeof MediaStream.prototype.stop === "undefined") {
|
|
1016
|
+
MediaStream.prototype.stop = function() {
|
|
1017
|
+
this.getTracks().forEach(function(track) {
|
|
1018
|
+
track.stop();
|
|
1019
|
+
});
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function bytesToSize(bytes) {
|
|
1024
|
+
var k = 1e3;
|
|
1025
|
+
var sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
|
1026
|
+
if (bytes === 0) {
|
|
1027
|
+
return "0 Bytes";
|
|
1028
|
+
}
|
|
1029
|
+
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(k)), 10);
|
|
1030
|
+
return (bytes / Math.pow(k, i)).toPrecision(3) + " " + sizes[i];
|
|
1031
|
+
}
|
|
1032
|
+
function invokeSaveAsDialog2(file, fileName) {
|
|
1033
|
+
if (!file) {
|
|
1034
|
+
throw "Blob object is required.";
|
|
1035
|
+
}
|
|
1036
|
+
if (!file.type) {
|
|
1037
|
+
try {
|
|
1038
|
+
file.type = "video/webm";
|
|
1039
|
+
} catch (e) {
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
var fileExtension = (file.type || "video/webm").split("/")[1];
|
|
1043
|
+
if (fileExtension.indexOf(";") !== -1) {
|
|
1044
|
+
fileExtension = fileExtension.split(";")[0];
|
|
1045
|
+
}
|
|
1046
|
+
if (fileName && fileName.indexOf(".") !== -1) {
|
|
1047
|
+
var splitted = fileName.split(".");
|
|
1048
|
+
fileName = splitted[0];
|
|
1049
|
+
fileExtension = splitted[1];
|
|
1050
|
+
}
|
|
1051
|
+
var fileFullName = (fileName || Math.round(Math.random() * 9999999999) + 888888888) + "." + fileExtension;
|
|
1052
|
+
if (typeof navigator.msSaveOrOpenBlob !== "undefined") {
|
|
1053
|
+
return navigator.msSaveOrOpenBlob(file, fileFullName);
|
|
1054
|
+
} else if (typeof navigator.msSaveBlob !== "undefined") {
|
|
1055
|
+
return navigator.msSaveBlob(file, fileFullName);
|
|
1056
|
+
}
|
|
1057
|
+
var hyperlink = document.createElement("a");
|
|
1058
|
+
hyperlink.href = URL2.createObjectURL(file);
|
|
1059
|
+
hyperlink.download = fileFullName;
|
|
1060
|
+
hyperlink.style = "display:none;opacity:0;color:transparent;";
|
|
1061
|
+
(document.body || document.documentElement).appendChild(hyperlink);
|
|
1062
|
+
if (typeof hyperlink.click === "function") {
|
|
1063
|
+
hyperlink.click();
|
|
1064
|
+
} else {
|
|
1065
|
+
hyperlink.target = "_blank";
|
|
1066
|
+
hyperlink.dispatchEvent(new MouseEvent("click", {
|
|
1067
|
+
view: window,
|
|
1068
|
+
bubbles: true,
|
|
1069
|
+
cancelable: true
|
|
1070
|
+
}));
|
|
1071
|
+
}
|
|
1072
|
+
URL2.revokeObjectURL(hyperlink.href);
|
|
1073
|
+
}
|
|
1074
|
+
function isElectron() {
|
|
1075
|
+
if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
|
|
1076
|
+
return true;
|
|
1077
|
+
}
|
|
1078
|
+
if (typeof process !== "undefined" && typeof process.versions === "object" && !!process.versions.electron) {
|
|
1079
|
+
return true;
|
|
1080
|
+
}
|
|
1081
|
+
if (typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent.indexOf("Electron") >= 0) {
|
|
1082
|
+
return true;
|
|
1083
|
+
}
|
|
1084
|
+
return false;
|
|
1085
|
+
}
|
|
1086
|
+
function getTracks(stream, kind) {
|
|
1087
|
+
if (!stream || !stream.getTracks) {
|
|
1088
|
+
return [];
|
|
1089
|
+
}
|
|
1090
|
+
return stream.getTracks().filter(function(t) {
|
|
1091
|
+
return t.kind === (kind || "audio");
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
function setSrcObject(stream, element) {
|
|
1095
|
+
if ("srcObject" in element) {
|
|
1096
|
+
element.srcObject = stream;
|
|
1097
|
+
} else if ("mozSrcObject" in element) {
|
|
1098
|
+
element.mozSrcObject = stream;
|
|
1099
|
+
} else {
|
|
1100
|
+
element.srcObject = stream;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
function getSeekableBlob3(inputBlob, callback) {
|
|
1104
|
+
if (typeof EBML === "undefined") {
|
|
1105
|
+
throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");
|
|
1106
|
+
}
|
|
1107
|
+
var reader = new EBML.Reader();
|
|
1108
|
+
var decoder = new EBML.Decoder();
|
|
1109
|
+
var tools = EBML.tools;
|
|
1110
|
+
var fileReader = new FileReader();
|
|
1111
|
+
fileReader.onload = function(e) {
|
|
1112
|
+
var ebmlElms = decoder.decode(this.result);
|
|
1113
|
+
ebmlElms.forEach(function(element) {
|
|
1114
|
+
reader.read(element);
|
|
1115
|
+
});
|
|
1116
|
+
reader.stop();
|
|
1117
|
+
var refinedMetadataBuf = tools.makeMetadataSeekable(reader.metadatas, reader.duration, reader.cues);
|
|
1118
|
+
var body = this.result.slice(reader.metadataSize);
|
|
1119
|
+
var newBlob = new Blob([refinedMetadataBuf, body], {
|
|
1120
|
+
type: "video/webm"
|
|
1121
|
+
});
|
|
1122
|
+
callback(newBlob);
|
|
1123
|
+
};
|
|
1124
|
+
fileReader.readAsArrayBuffer(inputBlob);
|
|
1125
|
+
}
|
|
1126
|
+
if (typeof RecordRTC !== "undefined") {
|
|
1127
|
+
RecordRTC.invokeSaveAsDialog = invokeSaveAsDialog2;
|
|
1128
|
+
RecordRTC.getTracks = getTracks;
|
|
1129
|
+
RecordRTC.getSeekableBlob = getSeekableBlob3;
|
|
1130
|
+
RecordRTC.bytesToSize = bytesToSize;
|
|
1131
|
+
RecordRTC.isElectron = isElectron;
|
|
1132
|
+
}
|
|
1133
|
+
var Storage = {};
|
|
1134
|
+
if (typeof AudioContext !== "undefined") {
|
|
1135
|
+
Storage.AudioContext = AudioContext;
|
|
1136
|
+
} else if (typeof webkitAudioContext !== "undefined") {
|
|
1137
|
+
Storage.AudioContext = webkitAudioContext;
|
|
1138
|
+
}
|
|
1139
|
+
if (typeof RecordRTC !== "undefined") {
|
|
1140
|
+
RecordRTC.Storage = Storage;
|
|
1141
|
+
}
|
|
1142
|
+
function isMediaRecorderCompatible() {
|
|
1143
|
+
if (isFirefox || isSafari2 || isEdge) {
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
var nVer = navigator.appVersion;
|
|
1147
|
+
var nAgt = navigator.userAgent;
|
|
1148
|
+
var fullVersion = "" + parseFloat(navigator.appVersion);
|
|
1149
|
+
var majorVersion = parseInt(navigator.appVersion, 10);
|
|
1150
|
+
var nameOffset, verOffset, ix;
|
|
1151
|
+
if (isChrome || isOpera) {
|
|
1152
|
+
verOffset = nAgt.indexOf("Chrome");
|
|
1153
|
+
fullVersion = nAgt.substring(verOffset + 7);
|
|
1154
|
+
}
|
|
1155
|
+
if ((ix = fullVersion.indexOf(";")) !== -1) {
|
|
1156
|
+
fullVersion = fullVersion.substring(0, ix);
|
|
1157
|
+
}
|
|
1158
|
+
if ((ix = fullVersion.indexOf(" ")) !== -1) {
|
|
1159
|
+
fullVersion = fullVersion.substring(0, ix);
|
|
1160
|
+
}
|
|
1161
|
+
majorVersion = parseInt("" + fullVersion, 10);
|
|
1162
|
+
if (isNaN(majorVersion)) {
|
|
1163
|
+
fullVersion = "" + parseFloat(navigator.appVersion);
|
|
1164
|
+
majorVersion = parseInt(navigator.appVersion, 10);
|
|
1165
|
+
}
|
|
1166
|
+
return majorVersion >= 49;
|
|
1167
|
+
}
|
|
1168
|
+
function MediaStreamRecorder(mediaStream, config2) {
|
|
1169
|
+
var self2 = this;
|
|
1170
|
+
if (typeof mediaStream === "undefined") {
|
|
1171
|
+
throw 'First argument "MediaStream" is required.';
|
|
1172
|
+
}
|
|
1173
|
+
if (typeof MediaRecorder === "undefined") {
|
|
1174
|
+
throw "Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";
|
|
1175
|
+
}
|
|
1176
|
+
config2 = config2 || {
|
|
1177
|
+
mimeType: "video/webm"
|
|
1178
|
+
};
|
|
1179
|
+
if (config2.type === "audio") {
|
|
1180
|
+
if (getTracks(mediaStream, "video").length && getTracks(mediaStream, "audio").length) {
|
|
1181
|
+
var stream;
|
|
1182
|
+
if (!!navigator.mozGetUserMedia) {
|
|
1183
|
+
stream = new MediaStream();
|
|
1184
|
+
stream.addTrack(getTracks(mediaStream, "audio")[0]);
|
|
1185
|
+
} else {
|
|
1186
|
+
stream = new MediaStream(getTracks(mediaStream, "audio"));
|
|
1187
|
+
}
|
|
1188
|
+
mediaStream = stream;
|
|
1189
|
+
}
|
|
1190
|
+
if (!config2.mimeType || config2.mimeType.toString().toLowerCase().indexOf("audio") === -1) {
|
|
1191
|
+
config2.mimeType = isChrome ? "audio/webm" : "audio/ogg";
|
|
1192
|
+
}
|
|
1193
|
+
if (config2.mimeType && config2.mimeType.toString().toLowerCase() !== "audio/ogg" && !!navigator.mozGetUserMedia) {
|
|
1194
|
+
config2.mimeType = "audio/ogg";
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
var arrayOfBlobs = [];
|
|
1198
|
+
this.getArrayOfBlobs = function() {
|
|
1199
|
+
return arrayOfBlobs;
|
|
1200
|
+
};
|
|
1201
|
+
this.record = function() {
|
|
1202
|
+
self2.blob = null;
|
|
1203
|
+
self2.clearRecordedData();
|
|
1204
|
+
self2.timestamps = [];
|
|
1205
|
+
allStates = [];
|
|
1206
|
+
arrayOfBlobs = [];
|
|
1207
|
+
var recorderHints = config2;
|
|
1208
|
+
if (!config2.disableLogs) {
|
|
1209
|
+
console.log("Passing following config over MediaRecorder API.", recorderHints);
|
|
1210
|
+
}
|
|
1211
|
+
if (mediaRecorder) {
|
|
1212
|
+
mediaRecorder = null;
|
|
1213
|
+
}
|
|
1214
|
+
if (isChrome && !isMediaRecorderCompatible()) {
|
|
1215
|
+
recorderHints = "video/vp8";
|
|
1216
|
+
}
|
|
1217
|
+
if (typeof MediaRecorder.isTypeSupported === "function" && recorderHints.mimeType) {
|
|
1218
|
+
if (!MediaRecorder.isTypeSupported(recorderHints.mimeType)) {
|
|
1219
|
+
if (!config2.disableLogs) {
|
|
1220
|
+
console.warn("MediaRecorder API seems unable to record mimeType:", recorderHints.mimeType);
|
|
1221
|
+
}
|
|
1222
|
+
recorderHints.mimeType = config2.type === "audio" ? "audio/webm" : "video/webm";
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
try {
|
|
1226
|
+
mediaRecorder = new MediaRecorder(mediaStream, recorderHints);
|
|
1227
|
+
config2.mimeType = recorderHints.mimeType;
|
|
1228
|
+
} catch (e) {
|
|
1229
|
+
mediaRecorder = new MediaRecorder(mediaStream);
|
|
1230
|
+
}
|
|
1231
|
+
if (recorderHints.mimeType && !MediaRecorder.isTypeSupported && "canRecordMimeType" in mediaRecorder && mediaRecorder.canRecordMimeType(recorderHints.mimeType) === false) {
|
|
1232
|
+
if (!config2.disableLogs) {
|
|
1233
|
+
console.warn("MediaRecorder API seems unable to record mimeType:", recorderHints.mimeType);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
mediaRecorder.ondataavailable = function(e) {
|
|
1237
|
+
if (e.data) {
|
|
1238
|
+
allStates.push("ondataavailable: " + bytesToSize(e.data.size));
|
|
1239
|
+
}
|
|
1240
|
+
if (typeof config2.timeSlice === "number") {
|
|
1241
|
+
if (e.data && e.data.size) {
|
|
1242
|
+
arrayOfBlobs.push(e.data);
|
|
1243
|
+
updateTimeStamp();
|
|
1244
|
+
if (typeof config2.ondataavailable === "function") {
|
|
1245
|
+
var blob = config2.getNativeBlob ? e.data : new Blob([e.data], {
|
|
1246
|
+
type: getMimeType(recorderHints)
|
|
1247
|
+
});
|
|
1248
|
+
config2.ondataavailable(blob);
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
if (!e.data || !e.data.size || e.data.size < 100 || self2.blob) {
|
|
1254
|
+
if (self2.recordingCallback) {
|
|
1255
|
+
self2.recordingCallback(new Blob([], {
|
|
1256
|
+
type: getMimeType(recorderHints)
|
|
1257
|
+
}));
|
|
1258
|
+
self2.recordingCallback = null;
|
|
1259
|
+
}
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
self2.blob = config2.getNativeBlob ? e.data : new Blob([e.data], {
|
|
1263
|
+
type: getMimeType(recorderHints)
|
|
1264
|
+
});
|
|
1265
|
+
if (self2.recordingCallback) {
|
|
1266
|
+
self2.recordingCallback(self2.blob);
|
|
1267
|
+
self2.recordingCallback = null;
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
mediaRecorder.onstart = function() {
|
|
1271
|
+
allStates.push("started");
|
|
1272
|
+
};
|
|
1273
|
+
mediaRecorder.onpause = function() {
|
|
1274
|
+
allStates.push("paused");
|
|
1275
|
+
};
|
|
1276
|
+
mediaRecorder.onresume = function() {
|
|
1277
|
+
allStates.push("resumed");
|
|
1278
|
+
};
|
|
1279
|
+
mediaRecorder.onstop = function() {
|
|
1280
|
+
allStates.push("stopped");
|
|
1281
|
+
};
|
|
1282
|
+
mediaRecorder.onerror = function(error) {
|
|
1283
|
+
if (!error) {
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (!error.name) {
|
|
1287
|
+
error.name = "UnknownError";
|
|
1288
|
+
}
|
|
1289
|
+
allStates.push("error: " + error);
|
|
1290
|
+
if (!config2.disableLogs) {
|
|
1291
|
+
if (error.name.toString().toLowerCase().indexOf("invalidstate") !== -1) {
|
|
1292
|
+
console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.", error);
|
|
1293
|
+
} else if (error.name.toString().toLowerCase().indexOf("notsupported") !== -1) {
|
|
1294
|
+
console.error("MIME type (", recorderHints.mimeType, ") is not supported.", error);
|
|
1295
|
+
} else if (error.name.toString().toLowerCase().indexOf("security") !== -1) {
|
|
1296
|
+
console.error("MediaRecorder security error", error);
|
|
1297
|
+
} else if (error.name === "OutOfMemory") {
|
|
1298
|
+
console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.", error);
|
|
1299
|
+
} else if (error.name === "IllegalStreamModification") {
|
|
1300
|
+
console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.", error);
|
|
1301
|
+
} else if (error.name === "OtherRecordingError") {
|
|
1302
|
+
console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.", error);
|
|
1303
|
+
} else if (error.name === "GenericError") {
|
|
1304
|
+
console.error("The UA cannot provide the codec or recording option that has been requested.", error);
|
|
1305
|
+
} else {
|
|
1306
|
+
console.error("MediaRecorder Error", error);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
(function(looper) {
|
|
1310
|
+
if (!self2.manuallyStopped && mediaRecorder && mediaRecorder.state === "inactive") {
|
|
1311
|
+
delete config2.timeslice;
|
|
1312
|
+
mediaRecorder.start(10 * 60 * 1e3);
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
setTimeout(looper, 1e3);
|
|
1316
|
+
})();
|
|
1317
|
+
if (mediaRecorder.state !== "inactive" && mediaRecorder.state !== "stopped") {
|
|
1318
|
+
mediaRecorder.stop();
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
if (typeof config2.timeSlice === "number") {
|
|
1322
|
+
updateTimeStamp();
|
|
1323
|
+
mediaRecorder.start(config2.timeSlice);
|
|
1324
|
+
} else {
|
|
1325
|
+
mediaRecorder.start(36e5);
|
|
1326
|
+
}
|
|
1327
|
+
if (config2.initCallback) {
|
|
1328
|
+
config2.initCallback();
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
this.timestamps = [];
|
|
1332
|
+
function updateTimeStamp() {
|
|
1333
|
+
self2.timestamps.push(new Date().getTime());
|
|
1334
|
+
if (typeof config2.onTimeStamp === "function") {
|
|
1335
|
+
config2.onTimeStamp(self2.timestamps[self2.timestamps.length - 1], self2.timestamps);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
function getMimeType(secondObject) {
|
|
1339
|
+
if (mediaRecorder && mediaRecorder.mimeType) {
|
|
1340
|
+
return mediaRecorder.mimeType;
|
|
1341
|
+
}
|
|
1342
|
+
return secondObject.mimeType || "video/webm";
|
|
1343
|
+
}
|
|
1344
|
+
this.stop = function(callback) {
|
|
1345
|
+
callback = callback || function() {
|
|
1346
|
+
};
|
|
1347
|
+
self2.manuallyStopped = true;
|
|
1348
|
+
if (!mediaRecorder) {
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
this.recordingCallback = callback;
|
|
1352
|
+
if (mediaRecorder.state === "recording") {
|
|
1353
|
+
mediaRecorder.stop();
|
|
1354
|
+
}
|
|
1355
|
+
if (typeof config2.timeSlice === "number") {
|
|
1356
|
+
setTimeout(function() {
|
|
1357
|
+
self2.blob = new Blob(arrayOfBlobs, {
|
|
1358
|
+
type: getMimeType(config2)
|
|
1359
|
+
});
|
|
1360
|
+
self2.recordingCallback(self2.blob);
|
|
1361
|
+
}, 100);
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
this.pause = function() {
|
|
1365
|
+
if (!mediaRecorder) {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
if (mediaRecorder.state === "recording") {
|
|
1369
|
+
mediaRecorder.pause();
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
this.resume = function() {
|
|
1373
|
+
if (!mediaRecorder) {
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
if (mediaRecorder.state === "paused") {
|
|
1377
|
+
mediaRecorder.resume();
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
this.clearRecordedData = function() {
|
|
1381
|
+
if (mediaRecorder && mediaRecorder.state === "recording") {
|
|
1382
|
+
self2.stop(clearRecordedDataCB);
|
|
1383
|
+
}
|
|
1384
|
+
clearRecordedDataCB();
|
|
1385
|
+
};
|
|
1386
|
+
function clearRecordedDataCB() {
|
|
1387
|
+
arrayOfBlobs = [];
|
|
1388
|
+
mediaRecorder = null;
|
|
1389
|
+
self2.timestamps = [];
|
|
1390
|
+
}
|
|
1391
|
+
var mediaRecorder;
|
|
1392
|
+
this.getInternalRecorder = function() {
|
|
1393
|
+
return mediaRecorder;
|
|
1394
|
+
};
|
|
1395
|
+
function isMediaStreamActive() {
|
|
1396
|
+
if ("active" in mediaStream) {
|
|
1397
|
+
if (!mediaStream.active) {
|
|
1398
|
+
return false;
|
|
1399
|
+
}
|
|
1400
|
+
} else if ("ended" in mediaStream) {
|
|
1401
|
+
if (mediaStream.ended) {
|
|
1402
|
+
return false;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return true;
|
|
1406
|
+
}
|
|
1407
|
+
this.blob = null;
|
|
1408
|
+
this.getState = function() {
|
|
1409
|
+
if (!mediaRecorder) {
|
|
1410
|
+
return "inactive";
|
|
1411
|
+
}
|
|
1412
|
+
return mediaRecorder.state || "inactive";
|
|
1413
|
+
};
|
|
1414
|
+
var allStates = [];
|
|
1415
|
+
this.getAllStates = function() {
|
|
1416
|
+
return allStates;
|
|
1417
|
+
};
|
|
1418
|
+
if (typeof config2.checkForInactiveTracks === "undefined") {
|
|
1419
|
+
config2.checkForInactiveTracks = false;
|
|
1420
|
+
}
|
|
1421
|
+
var self2 = this;
|
|
1422
|
+
(function looper() {
|
|
1423
|
+
if (!mediaRecorder || config2.checkForInactiveTracks === false) {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
if (isMediaStreamActive() === false) {
|
|
1427
|
+
if (!config2.disableLogs) {
|
|
1428
|
+
console.log("MediaStream seems stopped.");
|
|
1429
|
+
}
|
|
1430
|
+
self2.stop();
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
setTimeout(looper, 1e3);
|
|
1434
|
+
})();
|
|
1435
|
+
this.name = "MediaStreamRecorder";
|
|
1436
|
+
this.toString = function() {
|
|
1437
|
+
return this.name;
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
if (typeof RecordRTC !== "undefined") {
|
|
1441
|
+
RecordRTC.MediaStreamRecorder = MediaStreamRecorder;
|
|
1442
|
+
}
|
|
1443
|
+
function StereoAudioRecorder(mediaStream, config2) {
|
|
1444
|
+
if (!getTracks(mediaStream, "audio").length) {
|
|
1445
|
+
throw "Your stream has no audio tracks.";
|
|
1446
|
+
}
|
|
1447
|
+
config2 = config2 || {};
|
|
1448
|
+
var self2 = this;
|
|
1449
|
+
var leftchannel = [];
|
|
1450
|
+
var rightchannel = [];
|
|
1451
|
+
var recording = false;
|
|
1452
|
+
var recordingLength = 0;
|
|
1453
|
+
var jsAudioNode;
|
|
1454
|
+
var numberOfAudioChannels = 2;
|
|
1455
|
+
var desiredSampRate = config2.desiredSampRate;
|
|
1456
|
+
if (config2.leftChannel === true) {
|
|
1457
|
+
numberOfAudioChannels = 1;
|
|
1458
|
+
}
|
|
1459
|
+
if (config2.numberOfAudioChannels === 1) {
|
|
1460
|
+
numberOfAudioChannels = 1;
|
|
1461
|
+
}
|
|
1462
|
+
if (!numberOfAudioChannels || numberOfAudioChannels < 1) {
|
|
1463
|
+
numberOfAudioChannels = 2;
|
|
1464
|
+
}
|
|
1465
|
+
if (!config2.disableLogs) {
|
|
1466
|
+
console.log("StereoAudioRecorder is set to record number of channels: " + numberOfAudioChannels);
|
|
1467
|
+
}
|
|
1468
|
+
if (typeof config2.checkForInactiveTracks === "undefined") {
|
|
1469
|
+
config2.checkForInactiveTracks = true;
|
|
1470
|
+
}
|
|
1471
|
+
function isMediaStreamActive() {
|
|
1472
|
+
if (config2.checkForInactiveTracks === false) {
|
|
1473
|
+
return true;
|
|
1474
|
+
}
|
|
1475
|
+
if ("active" in mediaStream) {
|
|
1476
|
+
if (!mediaStream.active) {
|
|
1477
|
+
return false;
|
|
1478
|
+
}
|
|
1479
|
+
} else if ("ended" in mediaStream) {
|
|
1480
|
+
if (mediaStream.ended) {
|
|
1481
|
+
return false;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
return true;
|
|
1485
|
+
}
|
|
1486
|
+
this.record = function() {
|
|
1487
|
+
if (isMediaStreamActive() === false) {
|
|
1488
|
+
throw "Please make sure MediaStream is active.";
|
|
1489
|
+
}
|
|
1490
|
+
resetVariables();
|
|
1491
|
+
isAudioProcessStarted = isPaused = false;
|
|
1492
|
+
recording = true;
|
|
1493
|
+
if (typeof config2.timeSlice !== "undefined") {
|
|
1494
|
+
looper();
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
function mergeLeftRightBuffers(config3, callback) {
|
|
1498
|
+
function mergeAudioBuffers(config4, cb) {
|
|
1499
|
+
var numberOfAudioChannels2 = config4.numberOfAudioChannels;
|
|
1500
|
+
var leftBuffers = config4.leftBuffers.slice(0);
|
|
1501
|
+
var rightBuffers = config4.rightBuffers.slice(0);
|
|
1502
|
+
var sampleRate2 = config4.sampleRate;
|
|
1503
|
+
var internalInterleavedLength = config4.internalInterleavedLength;
|
|
1504
|
+
var desiredSampRate2 = config4.desiredSampRate;
|
|
1505
|
+
if (numberOfAudioChannels2 === 2) {
|
|
1506
|
+
leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);
|
|
1507
|
+
rightBuffers = mergeBuffers(rightBuffers, internalInterleavedLength);
|
|
1508
|
+
if (desiredSampRate2) {
|
|
1509
|
+
leftBuffers = interpolateArray(leftBuffers, desiredSampRate2, sampleRate2);
|
|
1510
|
+
rightBuffers = interpolateArray(rightBuffers, desiredSampRate2, sampleRate2);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
if (numberOfAudioChannels2 === 1) {
|
|
1514
|
+
leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);
|
|
1515
|
+
if (desiredSampRate2) {
|
|
1516
|
+
leftBuffers = interpolateArray(leftBuffers, desiredSampRate2, sampleRate2);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
if (desiredSampRate2) {
|
|
1520
|
+
sampleRate2 = desiredSampRate2;
|
|
1521
|
+
}
|
|
1522
|
+
function interpolateArray(data, newSampleRate, oldSampleRate) {
|
|
1523
|
+
var fitCount = Math.round(data.length * (newSampleRate / oldSampleRate));
|
|
1524
|
+
var newData = [];
|
|
1525
|
+
var springFactor = Number((data.length - 1) / (fitCount - 1));
|
|
1526
|
+
newData[0] = data[0];
|
|
1527
|
+
for (var i2 = 1; i2 < fitCount - 1; i2++) {
|
|
1528
|
+
var tmp = i2 * springFactor;
|
|
1529
|
+
var before = Number(Math.floor(tmp)).toFixed();
|
|
1530
|
+
var after = Number(Math.ceil(tmp)).toFixed();
|
|
1531
|
+
var atPoint = tmp - before;
|
|
1532
|
+
newData[i2] = linearInterpolate(data[before], data[after], atPoint);
|
|
1533
|
+
}
|
|
1534
|
+
newData[fitCount - 1] = data[data.length - 1];
|
|
1535
|
+
return newData;
|
|
1536
|
+
}
|
|
1537
|
+
function linearInterpolate(before, after, atPoint) {
|
|
1538
|
+
return before + (after - before) * atPoint;
|
|
1539
|
+
}
|
|
1540
|
+
function mergeBuffers(channelBuffer, rLength) {
|
|
1541
|
+
var result = new Float64Array(rLength);
|
|
1542
|
+
var offset = 0;
|
|
1543
|
+
var lng2 = channelBuffer.length;
|
|
1544
|
+
for (var i2 = 0; i2 < lng2; i2++) {
|
|
1545
|
+
var buffer2 = channelBuffer[i2];
|
|
1546
|
+
result.set(buffer2, offset);
|
|
1547
|
+
offset += buffer2.length;
|
|
1548
|
+
}
|
|
1549
|
+
return result;
|
|
1550
|
+
}
|
|
1551
|
+
function interleave(leftChannel, rightChannel) {
|
|
1552
|
+
var length = leftChannel.length + rightChannel.length;
|
|
1553
|
+
var result = new Float64Array(length);
|
|
1554
|
+
var inputIndex = 0;
|
|
1555
|
+
for (var index2 = 0; index2 < length; ) {
|
|
1556
|
+
result[index2++] = leftChannel[inputIndex];
|
|
1557
|
+
result[index2++] = rightChannel[inputIndex];
|
|
1558
|
+
inputIndex++;
|
|
1559
|
+
}
|
|
1560
|
+
return result;
|
|
1561
|
+
}
|
|
1562
|
+
function writeUTFBytes(view2, offset, string) {
|
|
1563
|
+
var lng2 = string.length;
|
|
1564
|
+
for (var i2 = 0; i2 < lng2; i2++) {
|
|
1565
|
+
view2.setUint8(offset + i2, string.charCodeAt(i2));
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
var interleaved;
|
|
1569
|
+
if (numberOfAudioChannels2 === 2) {
|
|
1570
|
+
interleaved = interleave(leftBuffers, rightBuffers);
|
|
1571
|
+
}
|
|
1572
|
+
if (numberOfAudioChannels2 === 1) {
|
|
1573
|
+
interleaved = leftBuffers;
|
|
1574
|
+
}
|
|
1575
|
+
var interleavedLength = interleaved.length;
|
|
1576
|
+
var resultingBufferLength = 44 + interleavedLength * 2;
|
|
1577
|
+
var buffer = new ArrayBuffer(resultingBufferLength);
|
|
1578
|
+
var view = new DataView(buffer);
|
|
1579
|
+
writeUTFBytes(view, 0, "RIFF");
|
|
1580
|
+
view.setUint32(4, 36 + interleavedLength * 2, true);
|
|
1581
|
+
writeUTFBytes(view, 8, "WAVE");
|
|
1582
|
+
writeUTFBytes(view, 12, "fmt ");
|
|
1583
|
+
view.setUint32(16, 16, true);
|
|
1584
|
+
view.setUint16(20, 1, true);
|
|
1585
|
+
view.setUint16(22, numberOfAudioChannels2, true);
|
|
1586
|
+
view.setUint32(24, sampleRate2, true);
|
|
1587
|
+
view.setUint32(28, sampleRate2 * numberOfAudioChannels2 * 2, true);
|
|
1588
|
+
view.setUint16(32, numberOfAudioChannels2 * 2, true);
|
|
1589
|
+
view.setUint16(34, 16, true);
|
|
1590
|
+
writeUTFBytes(view, 36, "data");
|
|
1591
|
+
view.setUint32(40, interleavedLength * 2, true);
|
|
1592
|
+
var lng = interleavedLength;
|
|
1593
|
+
var index = 44;
|
|
1594
|
+
var volume = 1;
|
|
1595
|
+
for (var i = 0; i < lng; i++) {
|
|
1596
|
+
view.setInt16(index, interleaved[i] * (32767 * volume), true);
|
|
1597
|
+
index += 2;
|
|
1598
|
+
}
|
|
1599
|
+
if (cb) {
|
|
1600
|
+
return cb({
|
|
1601
|
+
buffer,
|
|
1602
|
+
view
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
postMessage({
|
|
1606
|
+
buffer,
|
|
1607
|
+
view
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
if (config3.noWorker) {
|
|
1611
|
+
mergeAudioBuffers(config3, function(data) {
|
|
1612
|
+
callback(data.buffer, data.view);
|
|
1613
|
+
});
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
var webWorker = processInWebWorker(mergeAudioBuffers);
|
|
1617
|
+
webWorker.onmessage = function(event) {
|
|
1618
|
+
callback(event.data.buffer, event.data.view);
|
|
1619
|
+
URL2.revokeObjectURL(webWorker.workerURL);
|
|
1620
|
+
webWorker.terminate();
|
|
1621
|
+
};
|
|
1622
|
+
webWorker.postMessage(config3);
|
|
1623
|
+
}
|
|
1624
|
+
function processInWebWorker(_function) {
|
|
1625
|
+
var workerURL = URL2.createObjectURL(new Blob([
|
|
1626
|
+
_function.toString(),
|
|
1627
|
+
";this.onmessage = function (eee) {" + _function.name + "(eee.data);}"
|
|
1628
|
+
], {
|
|
1629
|
+
type: "application/javascript"
|
|
1630
|
+
}));
|
|
1631
|
+
var worker = new Worker(workerURL);
|
|
1632
|
+
worker.workerURL = workerURL;
|
|
1633
|
+
return worker;
|
|
1634
|
+
}
|
|
1635
|
+
this.stop = function(callback) {
|
|
1636
|
+
callback = callback || function() {
|
|
1637
|
+
};
|
|
1638
|
+
recording = false;
|
|
1639
|
+
mergeLeftRightBuffers({
|
|
1640
|
+
desiredSampRate,
|
|
1641
|
+
sampleRate,
|
|
1642
|
+
numberOfAudioChannels,
|
|
1643
|
+
internalInterleavedLength: recordingLength,
|
|
1644
|
+
leftBuffers: leftchannel,
|
|
1645
|
+
rightBuffers: numberOfAudioChannels === 1 ? [] : rightchannel,
|
|
1646
|
+
noWorker: config2.noWorker
|
|
1647
|
+
}, function(buffer, view) {
|
|
1648
|
+
self2.blob = new Blob([view], {
|
|
1649
|
+
type: "audio/wav"
|
|
1650
|
+
});
|
|
1651
|
+
self2.buffer = new ArrayBuffer(view.buffer.byteLength);
|
|
1652
|
+
self2.view = view;
|
|
1653
|
+
self2.sampleRate = desiredSampRate || sampleRate;
|
|
1654
|
+
self2.bufferSize = bufferSize;
|
|
1655
|
+
self2.length = recordingLength;
|
|
1656
|
+
isAudioProcessStarted = false;
|
|
1657
|
+
if (callback) {
|
|
1658
|
+
callback(self2.blob);
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
};
|
|
1662
|
+
if (typeof RecordRTC.Storage === "undefined") {
|
|
1663
|
+
RecordRTC.Storage = {
|
|
1664
|
+
AudioContextConstructor: null,
|
|
1665
|
+
AudioContext: window.AudioContext || window.webkitAudioContext
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
if (!RecordRTC.Storage.AudioContextConstructor || RecordRTC.Storage.AudioContextConstructor.state === "closed") {
|
|
1669
|
+
RecordRTC.Storage.AudioContextConstructor = new RecordRTC.Storage.AudioContext();
|
|
1670
|
+
}
|
|
1671
|
+
var context = RecordRTC.Storage.AudioContextConstructor;
|
|
1672
|
+
var audioInput = context.createMediaStreamSource(mediaStream);
|
|
1673
|
+
var legalBufferValues = [0, 256, 512, 1024, 2048, 4096, 8192, 16384];
|
|
1674
|
+
var bufferSize = typeof config2.bufferSize === "undefined" ? 4096 : config2.bufferSize;
|
|
1675
|
+
if (legalBufferValues.indexOf(bufferSize) === -1) {
|
|
1676
|
+
if (!config2.disableLogs) {
|
|
1677
|
+
console.log("Legal values for buffer-size are " + JSON.stringify(legalBufferValues, null, " "));
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
if (context.createJavaScriptNode) {
|
|
1681
|
+
jsAudioNode = context.createJavaScriptNode(bufferSize, numberOfAudioChannels, numberOfAudioChannels);
|
|
1682
|
+
} else if (context.createScriptProcessor) {
|
|
1683
|
+
jsAudioNode = context.createScriptProcessor(bufferSize, numberOfAudioChannels, numberOfAudioChannels);
|
|
1684
|
+
} else {
|
|
1685
|
+
throw "WebAudio API has no support on this browser.";
|
|
1686
|
+
}
|
|
1687
|
+
audioInput.connect(jsAudioNode);
|
|
1688
|
+
if (!config2.bufferSize) {
|
|
1689
|
+
bufferSize = jsAudioNode.bufferSize;
|
|
1690
|
+
}
|
|
1691
|
+
var sampleRate = typeof config2.sampleRate !== "undefined" ? config2.sampleRate : context.sampleRate || 44100;
|
|
1692
|
+
if (sampleRate < 22050 || sampleRate > 96e3) {
|
|
1693
|
+
if (!config2.disableLogs) {
|
|
1694
|
+
console.log("sample-rate must be under range 22050 and 96000.");
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
if (!config2.disableLogs) {
|
|
1698
|
+
if (config2.desiredSampRate) {
|
|
1699
|
+
console.log("Desired sample-rate: " + config2.desiredSampRate);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
var isPaused = false;
|
|
1703
|
+
this.pause = function() {
|
|
1704
|
+
isPaused = true;
|
|
1705
|
+
};
|
|
1706
|
+
this.resume = function() {
|
|
1707
|
+
if (isMediaStreamActive() === false) {
|
|
1708
|
+
throw "Please make sure MediaStream is active.";
|
|
1709
|
+
}
|
|
1710
|
+
if (!recording) {
|
|
1711
|
+
if (!config2.disableLogs) {
|
|
1712
|
+
console.log("Seems recording has been restarted.");
|
|
1713
|
+
}
|
|
1714
|
+
this.record();
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
isPaused = false;
|
|
1718
|
+
};
|
|
1719
|
+
this.clearRecordedData = function() {
|
|
1720
|
+
config2.checkForInactiveTracks = false;
|
|
1721
|
+
if (recording) {
|
|
1722
|
+
this.stop(clearRecordedDataCB);
|
|
1723
|
+
}
|
|
1724
|
+
clearRecordedDataCB();
|
|
1725
|
+
};
|
|
1726
|
+
function resetVariables() {
|
|
1727
|
+
leftchannel = [];
|
|
1728
|
+
rightchannel = [];
|
|
1729
|
+
recordingLength = 0;
|
|
1730
|
+
isAudioProcessStarted = false;
|
|
1731
|
+
recording = false;
|
|
1732
|
+
isPaused = false;
|
|
1733
|
+
context = null;
|
|
1734
|
+
self2.leftchannel = leftchannel;
|
|
1735
|
+
self2.rightchannel = rightchannel;
|
|
1736
|
+
self2.numberOfAudioChannels = numberOfAudioChannels;
|
|
1737
|
+
self2.desiredSampRate = desiredSampRate;
|
|
1738
|
+
self2.sampleRate = sampleRate;
|
|
1739
|
+
self2.recordingLength = recordingLength;
|
|
1740
|
+
intervalsBasedBuffers = {
|
|
1741
|
+
left: [],
|
|
1742
|
+
right: [],
|
|
1743
|
+
recordingLength: 0
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
function clearRecordedDataCB() {
|
|
1747
|
+
if (jsAudioNode) {
|
|
1748
|
+
jsAudioNode.onaudioprocess = null;
|
|
1749
|
+
jsAudioNode.disconnect();
|
|
1750
|
+
jsAudioNode = null;
|
|
1751
|
+
}
|
|
1752
|
+
if (audioInput) {
|
|
1753
|
+
audioInput.disconnect();
|
|
1754
|
+
audioInput = null;
|
|
1755
|
+
}
|
|
1756
|
+
resetVariables();
|
|
1757
|
+
}
|
|
1758
|
+
this.name = "StereoAudioRecorder";
|
|
1759
|
+
this.toString = function() {
|
|
1760
|
+
return this.name;
|
|
1761
|
+
};
|
|
1762
|
+
var isAudioProcessStarted = false;
|
|
1763
|
+
function onAudioProcessDataAvailable(e) {
|
|
1764
|
+
if (isPaused) {
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
if (isMediaStreamActive() === false) {
|
|
1768
|
+
if (!config2.disableLogs) {
|
|
1769
|
+
console.log("MediaStream seems stopped.");
|
|
1770
|
+
}
|
|
1771
|
+
jsAudioNode.disconnect();
|
|
1772
|
+
recording = false;
|
|
1773
|
+
}
|
|
1774
|
+
if (!recording) {
|
|
1775
|
+
if (audioInput) {
|
|
1776
|
+
audioInput.disconnect();
|
|
1777
|
+
audioInput = null;
|
|
1778
|
+
}
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
if (!isAudioProcessStarted) {
|
|
1782
|
+
isAudioProcessStarted = true;
|
|
1783
|
+
if (config2.onAudioProcessStarted) {
|
|
1784
|
+
config2.onAudioProcessStarted();
|
|
1785
|
+
}
|
|
1786
|
+
if (config2.initCallback) {
|
|
1787
|
+
config2.initCallback();
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
var left = e.inputBuffer.getChannelData(0);
|
|
1791
|
+
var chLeft = new Float32Array(left);
|
|
1792
|
+
leftchannel.push(chLeft);
|
|
1793
|
+
if (numberOfAudioChannels === 2) {
|
|
1794
|
+
var right = e.inputBuffer.getChannelData(1);
|
|
1795
|
+
var chRight = new Float32Array(right);
|
|
1796
|
+
rightchannel.push(chRight);
|
|
1797
|
+
}
|
|
1798
|
+
recordingLength += bufferSize;
|
|
1799
|
+
self2.recordingLength = recordingLength;
|
|
1800
|
+
if (typeof config2.timeSlice !== "undefined") {
|
|
1801
|
+
intervalsBasedBuffers.recordingLength += bufferSize;
|
|
1802
|
+
intervalsBasedBuffers.left.push(chLeft);
|
|
1803
|
+
if (numberOfAudioChannels === 2) {
|
|
1804
|
+
intervalsBasedBuffers.right.push(chRight);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
jsAudioNode.onaudioprocess = onAudioProcessDataAvailable;
|
|
1809
|
+
if (context.createMediaStreamDestination) {
|
|
1810
|
+
jsAudioNode.connect(context.createMediaStreamDestination());
|
|
1811
|
+
} else {
|
|
1812
|
+
jsAudioNode.connect(context.destination);
|
|
1813
|
+
}
|
|
1814
|
+
this.leftchannel = leftchannel;
|
|
1815
|
+
this.rightchannel = rightchannel;
|
|
1816
|
+
this.numberOfAudioChannels = numberOfAudioChannels;
|
|
1817
|
+
this.desiredSampRate = desiredSampRate;
|
|
1818
|
+
this.sampleRate = sampleRate;
|
|
1819
|
+
self2.recordingLength = recordingLength;
|
|
1820
|
+
var intervalsBasedBuffers = {
|
|
1821
|
+
left: [],
|
|
1822
|
+
right: [],
|
|
1823
|
+
recordingLength: 0
|
|
1824
|
+
};
|
|
1825
|
+
function looper() {
|
|
1826
|
+
if (!recording || typeof config2.ondataavailable !== "function" || typeof config2.timeSlice === "undefined") {
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
if (intervalsBasedBuffers.left.length) {
|
|
1830
|
+
mergeLeftRightBuffers({
|
|
1831
|
+
desiredSampRate,
|
|
1832
|
+
sampleRate,
|
|
1833
|
+
numberOfAudioChannels,
|
|
1834
|
+
internalInterleavedLength: intervalsBasedBuffers.recordingLength,
|
|
1835
|
+
leftBuffers: intervalsBasedBuffers.left,
|
|
1836
|
+
rightBuffers: numberOfAudioChannels === 1 ? [] : intervalsBasedBuffers.right
|
|
1837
|
+
}, function(buffer, view) {
|
|
1838
|
+
var blob = new Blob([view], {
|
|
1839
|
+
type: "audio/wav"
|
|
1840
|
+
});
|
|
1841
|
+
config2.ondataavailable(blob);
|
|
1842
|
+
setTimeout(looper, config2.timeSlice);
|
|
1843
|
+
});
|
|
1844
|
+
intervalsBasedBuffers = {
|
|
1845
|
+
left: [],
|
|
1846
|
+
right: [],
|
|
1847
|
+
recordingLength: 0
|
|
1848
|
+
};
|
|
1849
|
+
} else {
|
|
1850
|
+
setTimeout(looper, config2.timeSlice);
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
if (typeof RecordRTC !== "undefined") {
|
|
1855
|
+
RecordRTC.StereoAudioRecorder = StereoAudioRecorder;
|
|
1856
|
+
}
|
|
1857
|
+
function CanvasRecorder(htmlElement, config2) {
|
|
1858
|
+
if (typeof html2canvas === "undefined") {
|
|
1859
|
+
throw "Please link: https://www.webrtc-experiment.com/screenshot.js";
|
|
1860
|
+
}
|
|
1861
|
+
config2 = config2 || {};
|
|
1862
|
+
if (!config2.frameInterval) {
|
|
1863
|
+
config2.frameInterval = 10;
|
|
1864
|
+
}
|
|
1865
|
+
var isCanvasSupportsStreamCapturing = false;
|
|
1866
|
+
["captureStream", "mozCaptureStream", "webkitCaptureStream"].forEach(function(item) {
|
|
1867
|
+
if (item in document.createElement("canvas")) {
|
|
1868
|
+
isCanvasSupportsStreamCapturing = true;
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
var _isChrome = (!!window.webkitRTCPeerConnection || !!window.webkitGetUserMedia) && !!window.chrome;
|
|
1872
|
+
var chromeVersion = 50;
|
|
1873
|
+
var matchArray = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
|
|
1874
|
+
if (_isChrome && matchArray && matchArray[2]) {
|
|
1875
|
+
chromeVersion = parseInt(matchArray[2], 10);
|
|
1876
|
+
}
|
|
1877
|
+
if (_isChrome && chromeVersion < 52) {
|
|
1878
|
+
isCanvasSupportsStreamCapturing = false;
|
|
1879
|
+
}
|
|
1880
|
+
if (config2.useWhammyRecorder) {
|
|
1881
|
+
isCanvasSupportsStreamCapturing = false;
|
|
1882
|
+
}
|
|
1883
|
+
var globalCanvas, mediaStreamRecorder;
|
|
1884
|
+
if (isCanvasSupportsStreamCapturing) {
|
|
1885
|
+
if (!config2.disableLogs) {
|
|
1886
|
+
console.log("Your browser supports both MediRecorder API and canvas.captureStream!");
|
|
1887
|
+
}
|
|
1888
|
+
if (htmlElement instanceof HTMLCanvasElement) {
|
|
1889
|
+
globalCanvas = htmlElement;
|
|
1890
|
+
} else if (htmlElement instanceof CanvasRenderingContext2D) {
|
|
1891
|
+
globalCanvas = htmlElement.canvas;
|
|
1892
|
+
} else {
|
|
1893
|
+
throw "Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";
|
|
1894
|
+
}
|
|
1895
|
+
} else if (!!navigator.mozGetUserMedia) {
|
|
1896
|
+
if (!config2.disableLogs) {
|
|
1897
|
+
console.error("Canvas recording is NOT supported in Firefox.");
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
var isRecording;
|
|
1901
|
+
this.record = function() {
|
|
1902
|
+
isRecording = true;
|
|
1903
|
+
if (isCanvasSupportsStreamCapturing && !config2.useWhammyRecorder) {
|
|
1904
|
+
var canvasMediaStream;
|
|
1905
|
+
if ("captureStream" in globalCanvas) {
|
|
1906
|
+
canvasMediaStream = globalCanvas.captureStream(25);
|
|
1907
|
+
} else if ("mozCaptureStream" in globalCanvas) {
|
|
1908
|
+
canvasMediaStream = globalCanvas.mozCaptureStream(25);
|
|
1909
|
+
} else if ("webkitCaptureStream" in globalCanvas) {
|
|
1910
|
+
canvasMediaStream = globalCanvas.webkitCaptureStream(25);
|
|
1911
|
+
}
|
|
1912
|
+
try {
|
|
1913
|
+
var mdStream = new MediaStream();
|
|
1914
|
+
mdStream.addTrack(getTracks(canvasMediaStream, "video")[0]);
|
|
1915
|
+
canvasMediaStream = mdStream;
|
|
1916
|
+
} catch (e) {
|
|
1917
|
+
}
|
|
1918
|
+
if (!canvasMediaStream) {
|
|
1919
|
+
throw "captureStream API are NOT available.";
|
|
1920
|
+
}
|
|
1921
|
+
mediaStreamRecorder = new MediaStreamRecorder(canvasMediaStream, {
|
|
1922
|
+
mimeType: config2.mimeType || "video/webm"
|
|
1923
|
+
});
|
|
1924
|
+
mediaStreamRecorder.record();
|
|
1925
|
+
} else {
|
|
1926
|
+
whammy.frames = [];
|
|
1927
|
+
lastTime2 = new Date().getTime();
|
|
1928
|
+
drawCanvasFrame();
|
|
1929
|
+
}
|
|
1930
|
+
if (config2.initCallback) {
|
|
1931
|
+
config2.initCallback();
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
this.getWebPImages = function(callback) {
|
|
1935
|
+
if (htmlElement.nodeName.toLowerCase() !== "canvas") {
|
|
1936
|
+
callback();
|
|
1937
|
+
return;
|
|
1938
|
+
}
|
|
1939
|
+
var framesLength = whammy.frames.length;
|
|
1940
|
+
whammy.frames.forEach(function(frame, idx) {
|
|
1941
|
+
var framesRemaining = framesLength - idx;
|
|
1942
|
+
if (!config2.disableLogs) {
|
|
1943
|
+
console.log(framesRemaining + "/" + framesLength + " frames remaining");
|
|
1944
|
+
}
|
|
1945
|
+
if (config2.onEncodingCallback) {
|
|
1946
|
+
config2.onEncodingCallback(framesRemaining, framesLength);
|
|
1947
|
+
}
|
|
1948
|
+
var webp = frame.image.toDataURL("image/webp", 1);
|
|
1949
|
+
whammy.frames[idx].image = webp;
|
|
1950
|
+
});
|
|
1951
|
+
if (!config2.disableLogs) {
|
|
1952
|
+
console.log("Generating WebM");
|
|
1953
|
+
}
|
|
1954
|
+
callback();
|
|
1955
|
+
};
|
|
1956
|
+
this.stop = function(callback) {
|
|
1957
|
+
isRecording = false;
|
|
1958
|
+
var that = this;
|
|
1959
|
+
if (isCanvasSupportsStreamCapturing && mediaStreamRecorder) {
|
|
1960
|
+
mediaStreamRecorder.stop(callback);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
this.getWebPImages(function() {
|
|
1964
|
+
whammy.compile(function(blob) {
|
|
1965
|
+
if (!config2.disableLogs) {
|
|
1966
|
+
console.log("Recording finished!");
|
|
1967
|
+
}
|
|
1968
|
+
that.blob = blob;
|
|
1969
|
+
if (that.blob.forEach) {
|
|
1970
|
+
that.blob = new Blob([], {
|
|
1971
|
+
type: "video/webm"
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
if (callback) {
|
|
1975
|
+
callback(that.blob);
|
|
1976
|
+
}
|
|
1977
|
+
whammy.frames = [];
|
|
1978
|
+
});
|
|
1979
|
+
});
|
|
1980
|
+
};
|
|
1981
|
+
var isPausedRecording = false;
|
|
1982
|
+
this.pause = function() {
|
|
1983
|
+
isPausedRecording = true;
|
|
1984
|
+
if (mediaStreamRecorder instanceof MediaStreamRecorder) {
|
|
1985
|
+
mediaStreamRecorder.pause();
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
};
|
|
1989
|
+
this.resume = function() {
|
|
1990
|
+
isPausedRecording = false;
|
|
1991
|
+
if (mediaStreamRecorder instanceof MediaStreamRecorder) {
|
|
1992
|
+
mediaStreamRecorder.resume();
|
|
1993
|
+
return;
|
|
1994
|
+
}
|
|
1995
|
+
if (!isRecording) {
|
|
1996
|
+
this.record();
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
this.clearRecordedData = function() {
|
|
2000
|
+
if (isRecording) {
|
|
2001
|
+
this.stop(clearRecordedDataCB);
|
|
2002
|
+
}
|
|
2003
|
+
clearRecordedDataCB();
|
|
2004
|
+
};
|
|
2005
|
+
function clearRecordedDataCB() {
|
|
2006
|
+
whammy.frames = [];
|
|
2007
|
+
isRecording = false;
|
|
2008
|
+
isPausedRecording = false;
|
|
2009
|
+
}
|
|
2010
|
+
this.name = "CanvasRecorder";
|
|
2011
|
+
this.toString = function() {
|
|
2012
|
+
return this.name;
|
|
2013
|
+
};
|
|
2014
|
+
function cloneCanvas() {
|
|
2015
|
+
var newCanvas = document.createElement("canvas");
|
|
2016
|
+
var context = newCanvas.getContext("2d");
|
|
2017
|
+
newCanvas.width = htmlElement.width;
|
|
2018
|
+
newCanvas.height = htmlElement.height;
|
|
2019
|
+
context.drawImage(htmlElement, 0, 0);
|
|
2020
|
+
return newCanvas;
|
|
2021
|
+
}
|
|
2022
|
+
function drawCanvasFrame() {
|
|
2023
|
+
if (isPausedRecording) {
|
|
2024
|
+
lastTime2 = new Date().getTime();
|
|
2025
|
+
return setTimeout(drawCanvasFrame, 500);
|
|
2026
|
+
}
|
|
2027
|
+
if (htmlElement.nodeName.toLowerCase() === "canvas") {
|
|
2028
|
+
var duration = new Date().getTime() - lastTime2;
|
|
2029
|
+
lastTime2 = new Date().getTime();
|
|
2030
|
+
whammy.frames.push({
|
|
2031
|
+
image: cloneCanvas(),
|
|
2032
|
+
duration
|
|
2033
|
+
});
|
|
2034
|
+
if (isRecording) {
|
|
2035
|
+
setTimeout(drawCanvasFrame, config2.frameInterval);
|
|
2036
|
+
}
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
html2canvas(htmlElement, {
|
|
2040
|
+
grabMouse: typeof config2.showMousePointer === "undefined" || config2.showMousePointer,
|
|
2041
|
+
onrendered: function(canvas) {
|
|
2042
|
+
var duration2 = new Date().getTime() - lastTime2;
|
|
2043
|
+
if (!duration2) {
|
|
2044
|
+
return setTimeout(drawCanvasFrame, config2.frameInterval);
|
|
2045
|
+
}
|
|
2046
|
+
lastTime2 = new Date().getTime();
|
|
2047
|
+
whammy.frames.push({
|
|
2048
|
+
image: canvas.toDataURL("image/webp", 1),
|
|
2049
|
+
duration: duration2
|
|
2050
|
+
});
|
|
2051
|
+
if (isRecording) {
|
|
2052
|
+
setTimeout(drawCanvasFrame, config2.frameInterval);
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
var lastTime2 = new Date().getTime();
|
|
2058
|
+
var whammy = new Whammy.Video(100);
|
|
2059
|
+
}
|
|
2060
|
+
if (typeof RecordRTC !== "undefined") {
|
|
2061
|
+
RecordRTC.CanvasRecorder = CanvasRecorder;
|
|
2062
|
+
}
|
|
2063
|
+
function WhammyRecorder(mediaStream, config2) {
|
|
2064
|
+
config2 = config2 || {};
|
|
2065
|
+
if (!config2.frameInterval) {
|
|
2066
|
+
config2.frameInterval = 10;
|
|
2067
|
+
}
|
|
2068
|
+
if (!config2.disableLogs) {
|
|
2069
|
+
console.log("Using frames-interval:", config2.frameInterval);
|
|
2070
|
+
}
|
|
2071
|
+
this.record = function() {
|
|
2072
|
+
if (!config2.width) {
|
|
2073
|
+
config2.width = 320;
|
|
2074
|
+
}
|
|
2075
|
+
if (!config2.height) {
|
|
2076
|
+
config2.height = 240;
|
|
2077
|
+
}
|
|
2078
|
+
if (!config2.video) {
|
|
2079
|
+
config2.video = {
|
|
2080
|
+
width: config2.width,
|
|
2081
|
+
height: config2.height
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
if (!config2.canvas) {
|
|
2085
|
+
config2.canvas = {
|
|
2086
|
+
width: config2.width,
|
|
2087
|
+
height: config2.height
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
canvas.width = config2.canvas.width || 320;
|
|
2091
|
+
canvas.height = config2.canvas.height || 240;
|
|
2092
|
+
context = canvas.getContext("2d");
|
|
2093
|
+
if (config2.video && config2.video instanceof HTMLVideoElement) {
|
|
2094
|
+
video = config2.video.cloneNode();
|
|
2095
|
+
if (config2.initCallback) {
|
|
2096
|
+
config2.initCallback();
|
|
2097
|
+
}
|
|
2098
|
+
} else {
|
|
2099
|
+
video = document.createElement("video");
|
|
2100
|
+
setSrcObject(mediaStream, video);
|
|
2101
|
+
video.onloadedmetadata = function() {
|
|
2102
|
+
if (config2.initCallback) {
|
|
2103
|
+
config2.initCallback();
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
video.width = config2.video.width;
|
|
2107
|
+
video.height = config2.video.height;
|
|
2108
|
+
}
|
|
2109
|
+
video.muted = true;
|
|
2110
|
+
video.play();
|
|
2111
|
+
lastTime2 = new Date().getTime();
|
|
2112
|
+
whammy = new Whammy.Video();
|
|
2113
|
+
if (!config2.disableLogs) {
|
|
2114
|
+
console.log("canvas resolutions", canvas.width, "*", canvas.height);
|
|
2115
|
+
console.log("video width/height", video.width || canvas.width, "*", video.height || canvas.height);
|
|
2116
|
+
}
|
|
2117
|
+
drawFrames(config2.frameInterval);
|
|
2118
|
+
};
|
|
2119
|
+
function drawFrames(frameInterval) {
|
|
2120
|
+
frameInterval = typeof frameInterval !== "undefined" ? frameInterval : 10;
|
|
2121
|
+
var duration = new Date().getTime() - lastTime2;
|
|
2122
|
+
if (!duration) {
|
|
2123
|
+
return setTimeout(drawFrames, frameInterval, frameInterval);
|
|
2124
|
+
}
|
|
2125
|
+
if (isPausedRecording) {
|
|
2126
|
+
lastTime2 = new Date().getTime();
|
|
2127
|
+
return setTimeout(drawFrames, 100);
|
|
2128
|
+
}
|
|
2129
|
+
lastTime2 = new Date().getTime();
|
|
2130
|
+
if (video.paused) {
|
|
2131
|
+
video.play();
|
|
2132
|
+
}
|
|
2133
|
+
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
2134
|
+
whammy.frames.push({
|
|
2135
|
+
duration,
|
|
2136
|
+
image: canvas.toDataURL("image/webp")
|
|
2137
|
+
});
|
|
2138
|
+
if (!isStopDrawing) {
|
|
2139
|
+
setTimeout(drawFrames, frameInterval, frameInterval);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function asyncLoop(o) {
|
|
2143
|
+
var i = -1, length = o.length;
|
|
2144
|
+
(function loop() {
|
|
2145
|
+
i++;
|
|
2146
|
+
if (i === length) {
|
|
2147
|
+
o.callback();
|
|
2148
|
+
return;
|
|
2149
|
+
}
|
|
2150
|
+
setTimeout(function() {
|
|
2151
|
+
o.functionToLoop(loop, i);
|
|
2152
|
+
}, 1);
|
|
2153
|
+
})();
|
|
2154
|
+
}
|
|
2155
|
+
function dropBlackFrames(_frames, _framesToCheck, _pixTolerance, _frameTolerance, callback) {
|
|
2156
|
+
var localCanvas = document.createElement("canvas");
|
|
2157
|
+
localCanvas.width = canvas.width;
|
|
2158
|
+
localCanvas.height = canvas.height;
|
|
2159
|
+
var context2d = localCanvas.getContext("2d");
|
|
2160
|
+
var resultFrames = [];
|
|
2161
|
+
var checkUntilNotBlack = _framesToCheck === -1;
|
|
2162
|
+
var endCheckFrame = _framesToCheck && _framesToCheck > 0 && _framesToCheck <= _frames.length ? _framesToCheck : _frames.length;
|
|
2163
|
+
var sampleColor = {
|
|
2164
|
+
r: 0,
|
|
2165
|
+
g: 0,
|
|
2166
|
+
b: 0
|
|
2167
|
+
};
|
|
2168
|
+
var maxColorDifference = Math.sqrt(Math.pow(255, 2) + Math.pow(255, 2) + Math.pow(255, 2));
|
|
2169
|
+
var pixTolerance = _pixTolerance && _pixTolerance >= 0 && _pixTolerance <= 1 ? _pixTolerance : 0;
|
|
2170
|
+
var frameTolerance = _frameTolerance && _frameTolerance >= 0 && _frameTolerance <= 1 ? _frameTolerance : 0;
|
|
2171
|
+
var doNotCheckNext = false;
|
|
2172
|
+
asyncLoop({
|
|
2173
|
+
length: endCheckFrame,
|
|
2174
|
+
functionToLoop: function(loop, f) {
|
|
2175
|
+
var matchPixCount, endPixCheck, maxPixCount;
|
|
2176
|
+
var finishImage = function() {
|
|
2177
|
+
if (!doNotCheckNext && maxPixCount - matchPixCount <= maxPixCount * frameTolerance) {
|
|
2178
|
+
} else {
|
|
2179
|
+
if (checkUntilNotBlack) {
|
|
2180
|
+
doNotCheckNext = true;
|
|
2181
|
+
}
|
|
2182
|
+
resultFrames.push(_frames[f]);
|
|
2183
|
+
}
|
|
2184
|
+
loop();
|
|
2185
|
+
};
|
|
2186
|
+
if (!doNotCheckNext) {
|
|
2187
|
+
var image = new Image();
|
|
2188
|
+
image.onload = function() {
|
|
2189
|
+
context2d.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
2190
|
+
var imageData = context2d.getImageData(0, 0, canvas.width, canvas.height);
|
|
2191
|
+
matchPixCount = 0;
|
|
2192
|
+
endPixCheck = imageData.data.length;
|
|
2193
|
+
maxPixCount = imageData.data.length / 4;
|
|
2194
|
+
for (var pix = 0; pix < endPixCheck; pix += 4) {
|
|
2195
|
+
var currentColor = {
|
|
2196
|
+
r: imageData.data[pix],
|
|
2197
|
+
g: imageData.data[pix + 1],
|
|
2198
|
+
b: imageData.data[pix + 2]
|
|
2199
|
+
};
|
|
2200
|
+
var colorDifference = Math.sqrt(Math.pow(currentColor.r - sampleColor.r, 2) + Math.pow(currentColor.g - sampleColor.g, 2) + Math.pow(currentColor.b - sampleColor.b, 2));
|
|
2201
|
+
if (colorDifference <= maxColorDifference * pixTolerance) {
|
|
2202
|
+
matchPixCount++;
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
finishImage();
|
|
2206
|
+
};
|
|
2207
|
+
image.src = _frames[f].image;
|
|
2208
|
+
} else {
|
|
2209
|
+
finishImage();
|
|
2210
|
+
}
|
|
2211
|
+
},
|
|
2212
|
+
callback: function() {
|
|
2213
|
+
resultFrames = resultFrames.concat(_frames.slice(endCheckFrame));
|
|
2214
|
+
if (resultFrames.length <= 0) {
|
|
2215
|
+
resultFrames.push(_frames[_frames.length - 1]);
|
|
2216
|
+
}
|
|
2217
|
+
callback(resultFrames);
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
var isStopDrawing = false;
|
|
2222
|
+
this.stop = function(callback) {
|
|
2223
|
+
callback = callback || function() {
|
|
2224
|
+
};
|
|
2225
|
+
isStopDrawing = true;
|
|
2226
|
+
var _this = this;
|
|
2227
|
+
setTimeout(function() {
|
|
2228
|
+
dropBlackFrames(whammy.frames, -1, null, null, function(frames) {
|
|
2229
|
+
whammy.frames = frames;
|
|
2230
|
+
if (config2.advertisement && config2.advertisement.length) {
|
|
2231
|
+
whammy.frames = config2.advertisement.concat(whammy.frames);
|
|
2232
|
+
}
|
|
2233
|
+
whammy.compile(function(blob) {
|
|
2234
|
+
_this.blob = blob;
|
|
2235
|
+
if (_this.blob.forEach) {
|
|
2236
|
+
_this.blob = new Blob([], {
|
|
2237
|
+
type: "video/webm"
|
|
2238
|
+
});
|
|
2239
|
+
}
|
|
2240
|
+
if (callback) {
|
|
2241
|
+
callback(_this.blob);
|
|
2242
|
+
}
|
|
2243
|
+
});
|
|
2244
|
+
});
|
|
2245
|
+
}, 10);
|
|
2246
|
+
};
|
|
2247
|
+
var isPausedRecording = false;
|
|
2248
|
+
this.pause = function() {
|
|
2249
|
+
isPausedRecording = true;
|
|
2250
|
+
};
|
|
2251
|
+
this.resume = function() {
|
|
2252
|
+
isPausedRecording = false;
|
|
2253
|
+
if (isStopDrawing) {
|
|
2254
|
+
this.record();
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
this.clearRecordedData = function() {
|
|
2258
|
+
if (!isStopDrawing) {
|
|
2259
|
+
this.stop(clearRecordedDataCB);
|
|
2260
|
+
}
|
|
2261
|
+
clearRecordedDataCB();
|
|
2262
|
+
};
|
|
2263
|
+
function clearRecordedDataCB() {
|
|
2264
|
+
whammy.frames = [];
|
|
2265
|
+
isStopDrawing = true;
|
|
2266
|
+
isPausedRecording = false;
|
|
2267
|
+
}
|
|
2268
|
+
this.name = "WhammyRecorder";
|
|
2269
|
+
this.toString = function() {
|
|
2270
|
+
return this.name;
|
|
2271
|
+
};
|
|
2272
|
+
var canvas = document.createElement("canvas");
|
|
2273
|
+
var context = canvas.getContext("2d");
|
|
2274
|
+
var video;
|
|
2275
|
+
var lastTime2;
|
|
2276
|
+
var whammy;
|
|
2277
|
+
}
|
|
2278
|
+
if (typeof RecordRTC !== "undefined") {
|
|
2279
|
+
RecordRTC.WhammyRecorder = WhammyRecorder;
|
|
2280
|
+
}
|
|
2281
|
+
var Whammy = function() {
|
|
2282
|
+
function WhammyVideo(duration) {
|
|
2283
|
+
this.frames = [];
|
|
2284
|
+
this.duration = duration || 1;
|
|
2285
|
+
this.quality = 0.8;
|
|
2286
|
+
}
|
|
2287
|
+
WhammyVideo.prototype.add = function(frame, duration) {
|
|
2288
|
+
if ("canvas" in frame) {
|
|
2289
|
+
frame = frame.canvas;
|
|
2290
|
+
}
|
|
2291
|
+
if ("toDataURL" in frame) {
|
|
2292
|
+
frame = frame.toDataURL("image/webp", this.quality);
|
|
2293
|
+
}
|
|
2294
|
+
if (!/^data:image\/webp;base64,/ig.test(frame)) {
|
|
2295
|
+
throw "Input must be formatted properly as a base64 encoded DataURI of type image/webp";
|
|
2296
|
+
}
|
|
2297
|
+
this.frames.push({
|
|
2298
|
+
image: frame,
|
|
2299
|
+
duration: duration || this.duration
|
|
2300
|
+
});
|
|
2301
|
+
};
|
|
2302
|
+
function processInWebWorker(_function) {
|
|
2303
|
+
var blob = URL2.createObjectURL(new Blob([
|
|
2304
|
+
_function.toString(),
|
|
2305
|
+
"this.onmessage = function (eee) {" + _function.name + "(eee.data);}"
|
|
2306
|
+
], {
|
|
2307
|
+
type: "application/javascript"
|
|
2308
|
+
}));
|
|
2309
|
+
var worker = new Worker(blob);
|
|
2310
|
+
URL2.revokeObjectURL(blob);
|
|
2311
|
+
return worker;
|
|
2312
|
+
}
|
|
2313
|
+
function whammyInWebWorker(frames) {
|
|
2314
|
+
function ArrayToWebM(frames2) {
|
|
2315
|
+
var info = checkFrames(frames2);
|
|
2316
|
+
if (!info) {
|
|
2317
|
+
return [];
|
|
2318
|
+
}
|
|
2319
|
+
var clusterMaxDuration = 3e4;
|
|
2320
|
+
var EBML2 = [{
|
|
2321
|
+
"id": 440786851,
|
|
2322
|
+
"data": [{
|
|
2323
|
+
"data": 1,
|
|
2324
|
+
"id": 17030
|
|
2325
|
+
}, {
|
|
2326
|
+
"data": 1,
|
|
2327
|
+
"id": 17143
|
|
2328
|
+
}, {
|
|
2329
|
+
"data": 4,
|
|
2330
|
+
"id": 17138
|
|
2331
|
+
}, {
|
|
2332
|
+
"data": 8,
|
|
2333
|
+
"id": 17139
|
|
2334
|
+
}, {
|
|
2335
|
+
"data": "webm",
|
|
2336
|
+
"id": 17026
|
|
2337
|
+
}, {
|
|
2338
|
+
"data": 2,
|
|
2339
|
+
"id": 17031
|
|
2340
|
+
}, {
|
|
2341
|
+
"data": 2,
|
|
2342
|
+
"id": 17029
|
|
2343
|
+
}]
|
|
2344
|
+
}, {
|
|
2345
|
+
"id": 408125543,
|
|
2346
|
+
"data": [{
|
|
2347
|
+
"id": 357149030,
|
|
2348
|
+
"data": [{
|
|
2349
|
+
"data": 1e6,
|
|
2350
|
+
"id": 2807729
|
|
2351
|
+
}, {
|
|
2352
|
+
"data": "whammy",
|
|
2353
|
+
"id": 19840
|
|
2354
|
+
}, {
|
|
2355
|
+
"data": "whammy",
|
|
2356
|
+
"id": 22337
|
|
2357
|
+
}, {
|
|
2358
|
+
"data": doubleToString(info.duration),
|
|
2359
|
+
"id": 17545
|
|
2360
|
+
}]
|
|
2361
|
+
}, {
|
|
2362
|
+
"id": 374648427,
|
|
2363
|
+
"data": [{
|
|
2364
|
+
"id": 174,
|
|
2365
|
+
"data": [{
|
|
2366
|
+
"data": 1,
|
|
2367
|
+
"id": 215
|
|
2368
|
+
}, {
|
|
2369
|
+
"data": 1,
|
|
2370
|
+
"id": 29637
|
|
2371
|
+
}, {
|
|
2372
|
+
"data": 0,
|
|
2373
|
+
"id": 156
|
|
2374
|
+
}, {
|
|
2375
|
+
"data": "und",
|
|
2376
|
+
"id": 2274716
|
|
2377
|
+
}, {
|
|
2378
|
+
"data": "V_VP8",
|
|
2379
|
+
"id": 134
|
|
2380
|
+
}, {
|
|
2381
|
+
"data": "VP8",
|
|
2382
|
+
"id": 2459272
|
|
2383
|
+
}, {
|
|
2384
|
+
"data": 1,
|
|
2385
|
+
"id": 131
|
|
2386
|
+
}, {
|
|
2387
|
+
"id": 224,
|
|
2388
|
+
"data": [{
|
|
2389
|
+
"data": info.width,
|
|
2390
|
+
"id": 176
|
|
2391
|
+
}, {
|
|
2392
|
+
"data": info.height,
|
|
2393
|
+
"id": 186
|
|
2394
|
+
}]
|
|
2395
|
+
}]
|
|
2396
|
+
}]
|
|
2397
|
+
}]
|
|
2398
|
+
}];
|
|
2399
|
+
var frameNumber = 0;
|
|
2400
|
+
var clusterTimecode = 0;
|
|
2401
|
+
while (frameNumber < frames2.length) {
|
|
2402
|
+
var clusterFrames = [];
|
|
2403
|
+
var clusterDuration = 0;
|
|
2404
|
+
do {
|
|
2405
|
+
clusterFrames.push(frames2[frameNumber]);
|
|
2406
|
+
clusterDuration += frames2[frameNumber].duration;
|
|
2407
|
+
frameNumber++;
|
|
2408
|
+
} while (frameNumber < frames2.length && clusterDuration < clusterMaxDuration);
|
|
2409
|
+
var clusterCounter = 0;
|
|
2410
|
+
var cluster = {
|
|
2411
|
+
"id": 524531317,
|
|
2412
|
+
"data": getClusterData(clusterTimecode, clusterCounter, clusterFrames)
|
|
2413
|
+
};
|
|
2414
|
+
EBML2[1].data.push(cluster);
|
|
2415
|
+
clusterTimecode += clusterDuration;
|
|
2416
|
+
}
|
|
2417
|
+
return generateEBML(EBML2);
|
|
2418
|
+
}
|
|
2419
|
+
function getClusterData(clusterTimecode, clusterCounter, clusterFrames) {
|
|
2420
|
+
return [{
|
|
2421
|
+
"data": clusterTimecode,
|
|
2422
|
+
"id": 231
|
|
2423
|
+
}].concat(clusterFrames.map(function(webp) {
|
|
2424
|
+
var block = makeSimpleBlock({
|
|
2425
|
+
discardable: 0,
|
|
2426
|
+
frame: webp.data.slice(4),
|
|
2427
|
+
invisible: 0,
|
|
2428
|
+
keyframe: 1,
|
|
2429
|
+
lacing: 0,
|
|
2430
|
+
trackNum: 1,
|
|
2431
|
+
timecode: Math.round(clusterCounter)
|
|
2432
|
+
});
|
|
2433
|
+
clusterCounter += webp.duration;
|
|
2434
|
+
return {
|
|
2435
|
+
data: block,
|
|
2436
|
+
id: 163
|
|
2437
|
+
};
|
|
2438
|
+
}));
|
|
2439
|
+
}
|
|
2440
|
+
function checkFrames(frames2) {
|
|
2441
|
+
if (!frames2[0]) {
|
|
2442
|
+
postMessage({
|
|
2443
|
+
error: "Something went wrong. Maybe WebP format is not supported in the current browser."
|
|
2444
|
+
});
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
var width = frames2[0].width, height = frames2[0].height, duration = frames2[0].duration;
|
|
2448
|
+
for (var i = 1; i < frames2.length; i++) {
|
|
2449
|
+
duration += frames2[i].duration;
|
|
2450
|
+
}
|
|
2451
|
+
return {
|
|
2452
|
+
duration,
|
|
2453
|
+
width,
|
|
2454
|
+
height
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function numToBuffer(num) {
|
|
2458
|
+
var parts = [];
|
|
2459
|
+
while (num > 0) {
|
|
2460
|
+
parts.push(num & 255);
|
|
2461
|
+
num = num >> 8;
|
|
2462
|
+
}
|
|
2463
|
+
return new Uint8Array(parts.reverse());
|
|
2464
|
+
}
|
|
2465
|
+
function strToBuffer(str) {
|
|
2466
|
+
return new Uint8Array(str.split("").map(function(e) {
|
|
2467
|
+
return e.charCodeAt(0);
|
|
2468
|
+
}));
|
|
2469
|
+
}
|
|
2470
|
+
function bitsToBuffer(bits) {
|
|
2471
|
+
var data = [];
|
|
2472
|
+
var pad = bits.length % 8 ? new Array(1 + 8 - bits.length % 8).join("0") : "";
|
|
2473
|
+
bits = pad + bits;
|
|
2474
|
+
for (var i = 0; i < bits.length; i += 8) {
|
|
2475
|
+
data.push(parseInt(bits.substr(i, 8), 2));
|
|
2476
|
+
}
|
|
2477
|
+
return new Uint8Array(data);
|
|
2478
|
+
}
|
|
2479
|
+
function generateEBML(json) {
|
|
2480
|
+
var ebml = [];
|
|
2481
|
+
for (var i = 0; i < json.length; i++) {
|
|
2482
|
+
var data = json[i].data;
|
|
2483
|
+
if (typeof data === "object") {
|
|
2484
|
+
data = generateEBML(data);
|
|
2485
|
+
}
|
|
2486
|
+
if (typeof data === "number") {
|
|
2487
|
+
data = bitsToBuffer(data.toString(2));
|
|
2488
|
+
}
|
|
2489
|
+
if (typeof data === "string") {
|
|
2490
|
+
data = strToBuffer(data);
|
|
2491
|
+
}
|
|
2492
|
+
var len = data.size || data.byteLength || data.length;
|
|
2493
|
+
var zeroes = Math.ceil(Math.ceil(Math.log(len) / Math.log(2)) / 8);
|
|
2494
|
+
var sizeToString = len.toString(2);
|
|
2495
|
+
var padded = new Array(zeroes * 7 + 7 + 1 - sizeToString.length).join("0") + sizeToString;
|
|
2496
|
+
var size = new Array(zeroes).join("0") + "1" + padded;
|
|
2497
|
+
ebml.push(numToBuffer(json[i].id));
|
|
2498
|
+
ebml.push(bitsToBuffer(size));
|
|
2499
|
+
ebml.push(data);
|
|
2500
|
+
}
|
|
2501
|
+
return new Blob(ebml, {
|
|
2502
|
+
type: "video/webm"
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
function toBinStrOld(bits) {
|
|
2506
|
+
var data = "";
|
|
2507
|
+
var pad = bits.length % 8 ? new Array(1 + 8 - bits.length % 8).join("0") : "";
|
|
2508
|
+
bits = pad + bits;
|
|
2509
|
+
for (var i = 0; i < bits.length; i += 8) {
|
|
2510
|
+
data += String.fromCharCode(parseInt(bits.substr(i, 8), 2));
|
|
2511
|
+
}
|
|
2512
|
+
return data;
|
|
2513
|
+
}
|
|
2514
|
+
function makeSimpleBlock(data) {
|
|
2515
|
+
var flags = 0;
|
|
2516
|
+
if (data.keyframe) {
|
|
2517
|
+
flags |= 128;
|
|
2518
|
+
}
|
|
2519
|
+
if (data.invisible) {
|
|
2520
|
+
flags |= 8;
|
|
2521
|
+
}
|
|
2522
|
+
if (data.lacing) {
|
|
2523
|
+
flags |= data.lacing << 1;
|
|
2524
|
+
}
|
|
2525
|
+
if (data.discardable) {
|
|
2526
|
+
flags |= 1;
|
|
2527
|
+
}
|
|
2528
|
+
if (data.trackNum > 127) {
|
|
2529
|
+
throw "TrackNumber > 127 not supported";
|
|
2530
|
+
}
|
|
2531
|
+
var out = [data.trackNum | 128, data.timecode >> 8, data.timecode & 255, flags].map(function(e) {
|
|
2532
|
+
return String.fromCharCode(e);
|
|
2533
|
+
}).join("") + data.frame;
|
|
2534
|
+
return out;
|
|
2535
|
+
}
|
|
2536
|
+
function parseWebP(riff) {
|
|
2537
|
+
var VP8 = riff.RIFF[0].WEBP[0];
|
|
2538
|
+
var frameStart = VP8.indexOf("\x9D*");
|
|
2539
|
+
for (var i = 0, c = []; i < 4; i++) {
|
|
2540
|
+
c[i] = VP8.charCodeAt(frameStart + 3 + i);
|
|
2541
|
+
}
|
|
2542
|
+
var width, height, tmp;
|
|
2543
|
+
tmp = c[1] << 8 | c[0];
|
|
2544
|
+
width = tmp & 16383;
|
|
2545
|
+
tmp = c[3] << 8 | c[2];
|
|
2546
|
+
height = tmp & 16383;
|
|
2547
|
+
return {
|
|
2548
|
+
width,
|
|
2549
|
+
height,
|
|
2550
|
+
data: VP8,
|
|
2551
|
+
riff
|
|
2552
|
+
};
|
|
2553
|
+
}
|
|
2554
|
+
function getStrLength(string, offset) {
|
|
2555
|
+
return parseInt(string.substr(offset + 4, 4).split("").map(function(i) {
|
|
2556
|
+
var unpadded = i.charCodeAt(0).toString(2);
|
|
2557
|
+
return new Array(8 - unpadded.length + 1).join("0") + unpadded;
|
|
2558
|
+
}).join(""), 2);
|
|
2559
|
+
}
|
|
2560
|
+
function parseRIFF(string) {
|
|
2561
|
+
var offset = 0;
|
|
2562
|
+
var chunks = {};
|
|
2563
|
+
while (offset < string.length) {
|
|
2564
|
+
var id = string.substr(offset, 4);
|
|
2565
|
+
var len = getStrLength(string, offset);
|
|
2566
|
+
var data = string.substr(offset + 4 + 4, len);
|
|
2567
|
+
offset += 4 + 4 + len;
|
|
2568
|
+
chunks[id] = chunks[id] || [];
|
|
2569
|
+
if (id === "RIFF" || id === "LIST") {
|
|
2570
|
+
chunks[id].push(parseRIFF(data));
|
|
2571
|
+
} else {
|
|
2572
|
+
chunks[id].push(data);
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
return chunks;
|
|
2576
|
+
}
|
|
2577
|
+
function doubleToString(num) {
|
|
2578
|
+
return [].slice.call(new Uint8Array(new Float64Array([num]).buffer), 0).map(function(e) {
|
|
2579
|
+
return String.fromCharCode(e);
|
|
2580
|
+
}).reverse().join("");
|
|
2581
|
+
}
|
|
2582
|
+
var webm = new ArrayToWebM(frames.map(function(frame) {
|
|
2583
|
+
var webp = parseWebP(parseRIFF(atob(frame.image.slice(23))));
|
|
2584
|
+
webp.duration = frame.duration;
|
|
2585
|
+
return webp;
|
|
2586
|
+
}));
|
|
2587
|
+
postMessage(webm);
|
|
2588
|
+
}
|
|
2589
|
+
WhammyVideo.prototype.compile = function(callback) {
|
|
2590
|
+
var webWorker = processInWebWorker(whammyInWebWorker);
|
|
2591
|
+
webWorker.onmessage = function(event) {
|
|
2592
|
+
if (event.data.error) {
|
|
2593
|
+
console.error(event.data.error);
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2596
|
+
callback(event.data);
|
|
2597
|
+
};
|
|
2598
|
+
webWorker.postMessage(this.frames);
|
|
2599
|
+
};
|
|
2600
|
+
return {
|
|
2601
|
+
Video: WhammyVideo
|
|
2602
|
+
};
|
|
2603
|
+
}();
|
|
2604
|
+
if (typeof RecordRTC !== "undefined") {
|
|
2605
|
+
RecordRTC.Whammy = Whammy;
|
|
2606
|
+
}
|
|
2607
|
+
var DiskStorage = {
|
|
2608
|
+
init: function() {
|
|
2609
|
+
var self2 = this;
|
|
2610
|
+
if (typeof indexedDB === "undefined" || typeof indexedDB.open === "undefined") {
|
|
2611
|
+
console.error("IndexedDB API are not available in this browser.");
|
|
2612
|
+
return;
|
|
2613
|
+
}
|
|
2614
|
+
var dbVersion = 1;
|
|
2615
|
+
var dbName = this.dbName || location.href.replace(/\/|:|#|%|\.|\[|\]/g, ""), db;
|
|
2616
|
+
var request = indexedDB.open(dbName, dbVersion);
|
|
2617
|
+
function createObjectStore(dataBase) {
|
|
2618
|
+
dataBase.createObjectStore(self2.dataStoreName);
|
|
2619
|
+
}
|
|
2620
|
+
function putInDB() {
|
|
2621
|
+
var transaction = db.transaction([self2.dataStoreName], "readwrite");
|
|
2622
|
+
if (self2.videoBlob) {
|
|
2623
|
+
transaction.objectStore(self2.dataStoreName).put(self2.videoBlob, "videoBlob");
|
|
2624
|
+
}
|
|
2625
|
+
if (self2.gifBlob) {
|
|
2626
|
+
transaction.objectStore(self2.dataStoreName).put(self2.gifBlob, "gifBlob");
|
|
2627
|
+
}
|
|
2628
|
+
if (self2.audioBlob) {
|
|
2629
|
+
transaction.objectStore(self2.dataStoreName).put(self2.audioBlob, "audioBlob");
|
|
2630
|
+
}
|
|
2631
|
+
function getFromStore(portionName) {
|
|
2632
|
+
transaction.objectStore(self2.dataStoreName).get(portionName).onsuccess = function(event) {
|
|
2633
|
+
if (self2.callback) {
|
|
2634
|
+
self2.callback(event.target.result, portionName);
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
getFromStore("audioBlob");
|
|
2639
|
+
getFromStore("videoBlob");
|
|
2640
|
+
getFromStore("gifBlob");
|
|
2641
|
+
}
|
|
2642
|
+
request.onerror = self2.onError;
|
|
2643
|
+
request.onsuccess = function() {
|
|
2644
|
+
db = request.result;
|
|
2645
|
+
db.onerror = self2.onError;
|
|
2646
|
+
if (db.setVersion) {
|
|
2647
|
+
if (db.version !== dbVersion) {
|
|
2648
|
+
var setVersion = db.setVersion(dbVersion);
|
|
2649
|
+
setVersion.onsuccess = function() {
|
|
2650
|
+
createObjectStore(db);
|
|
2651
|
+
putInDB();
|
|
2652
|
+
};
|
|
2653
|
+
} else {
|
|
2654
|
+
putInDB();
|
|
2655
|
+
}
|
|
2656
|
+
} else {
|
|
2657
|
+
putInDB();
|
|
2658
|
+
}
|
|
2659
|
+
};
|
|
2660
|
+
request.onupgradeneeded = function(event) {
|
|
2661
|
+
createObjectStore(event.target.result);
|
|
2662
|
+
};
|
|
2663
|
+
},
|
|
2664
|
+
Fetch: function(callback) {
|
|
2665
|
+
this.callback = callback;
|
|
2666
|
+
this.init();
|
|
2667
|
+
return this;
|
|
2668
|
+
},
|
|
2669
|
+
Store: function(config2) {
|
|
2670
|
+
this.audioBlob = config2.audioBlob;
|
|
2671
|
+
this.videoBlob = config2.videoBlob;
|
|
2672
|
+
this.gifBlob = config2.gifBlob;
|
|
2673
|
+
this.init();
|
|
2674
|
+
return this;
|
|
2675
|
+
},
|
|
2676
|
+
onError: function(error) {
|
|
2677
|
+
console.error(JSON.stringify(error, null, " "));
|
|
2678
|
+
},
|
|
2679
|
+
dataStoreName: "recordRTC",
|
|
2680
|
+
dbName: null
|
|
2681
|
+
};
|
|
2682
|
+
if (typeof RecordRTC !== "undefined") {
|
|
2683
|
+
RecordRTC.DiskStorage = DiskStorage;
|
|
2684
|
+
}
|
|
2685
|
+
function GifRecorder(mediaStream, config2) {
|
|
2686
|
+
if (typeof GIFEncoder === "undefined") {
|
|
2687
|
+
var script = document.createElement("script");
|
|
2688
|
+
script.src = "https://www.webrtc-experiment.com/gif-recorder.js";
|
|
2689
|
+
(document.body || document.documentElement).appendChild(script);
|
|
2690
|
+
}
|
|
2691
|
+
config2 = config2 || {};
|
|
2692
|
+
var isHTMLObject = mediaStream instanceof CanvasRenderingContext2D || mediaStream instanceof HTMLCanvasElement;
|
|
2693
|
+
this.record = function() {
|
|
2694
|
+
if (typeof GIFEncoder === "undefined") {
|
|
2695
|
+
setTimeout(self2.record, 1e3);
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
if (!isLoadedMetaData) {
|
|
2699
|
+
setTimeout(self2.record, 1e3);
|
|
2700
|
+
return;
|
|
2701
|
+
}
|
|
2702
|
+
if (!isHTMLObject) {
|
|
2703
|
+
if (!config2.width) {
|
|
2704
|
+
config2.width = video.offsetWidth || 320;
|
|
2705
|
+
}
|
|
2706
|
+
if (!config2.height) {
|
|
2707
|
+
config2.height = video.offsetHeight || 240;
|
|
2708
|
+
}
|
|
2709
|
+
if (!config2.video) {
|
|
2710
|
+
config2.video = {
|
|
2711
|
+
width: config2.width,
|
|
2712
|
+
height: config2.height
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2715
|
+
if (!config2.canvas) {
|
|
2716
|
+
config2.canvas = {
|
|
2717
|
+
width: config2.width,
|
|
2718
|
+
height: config2.height
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
canvas.width = config2.canvas.width || 320;
|
|
2722
|
+
canvas.height = config2.canvas.height || 240;
|
|
2723
|
+
video.width = config2.video.width || 320;
|
|
2724
|
+
video.height = config2.video.height || 240;
|
|
2725
|
+
}
|
|
2726
|
+
gifEncoder = new GIFEncoder();
|
|
2727
|
+
gifEncoder.setRepeat(0);
|
|
2728
|
+
gifEncoder.setDelay(config2.frameRate || 200);
|
|
2729
|
+
gifEncoder.setQuality(config2.quality || 10);
|
|
2730
|
+
gifEncoder.start();
|
|
2731
|
+
if (typeof config2.onGifRecordingStarted === "function") {
|
|
2732
|
+
config2.onGifRecordingStarted();
|
|
2733
|
+
}
|
|
2734
|
+
startTime = Date.now();
|
|
2735
|
+
function drawVideoFrame(time) {
|
|
2736
|
+
if (self2.clearedRecordedData === true) {
|
|
2737
|
+
return;
|
|
2738
|
+
}
|
|
2739
|
+
if (isPausedRecording) {
|
|
2740
|
+
return setTimeout(function() {
|
|
2741
|
+
drawVideoFrame(time);
|
|
2742
|
+
}, 100);
|
|
2743
|
+
}
|
|
2744
|
+
lastAnimationFrame = requestAnimationFrame(drawVideoFrame);
|
|
2745
|
+
if (typeof lastFrameTime === void 0) {
|
|
2746
|
+
lastFrameTime = time;
|
|
2747
|
+
}
|
|
2748
|
+
if (time - lastFrameTime < 90) {
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
if (!isHTMLObject && video.paused) {
|
|
2752
|
+
video.play();
|
|
2753
|
+
}
|
|
2754
|
+
if (!isHTMLObject) {
|
|
2755
|
+
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
2756
|
+
}
|
|
2757
|
+
if (config2.onGifPreview) {
|
|
2758
|
+
config2.onGifPreview(canvas.toDataURL("image/png"));
|
|
2759
|
+
}
|
|
2760
|
+
gifEncoder.addFrame(context);
|
|
2761
|
+
lastFrameTime = time;
|
|
2762
|
+
}
|
|
2763
|
+
lastAnimationFrame = requestAnimationFrame(drawVideoFrame);
|
|
2764
|
+
if (config2.initCallback) {
|
|
2765
|
+
config2.initCallback();
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
this.stop = function(callback) {
|
|
2769
|
+
callback = callback || function() {
|
|
2770
|
+
};
|
|
2771
|
+
if (lastAnimationFrame) {
|
|
2772
|
+
cancelAnimationFrame(lastAnimationFrame);
|
|
2773
|
+
}
|
|
2774
|
+
endTime = Date.now();
|
|
2775
|
+
this.blob = new Blob([new Uint8Array(gifEncoder.stream().bin)], {
|
|
2776
|
+
type: "image/gif"
|
|
2777
|
+
});
|
|
2778
|
+
callback(this.blob);
|
|
2779
|
+
gifEncoder.stream().bin = [];
|
|
2780
|
+
};
|
|
2781
|
+
var isPausedRecording = false;
|
|
2782
|
+
this.pause = function() {
|
|
2783
|
+
isPausedRecording = true;
|
|
2784
|
+
};
|
|
2785
|
+
this.resume = function() {
|
|
2786
|
+
isPausedRecording = false;
|
|
2787
|
+
};
|
|
2788
|
+
this.clearRecordedData = function() {
|
|
2789
|
+
self2.clearedRecordedData = true;
|
|
2790
|
+
clearRecordedDataCB();
|
|
2791
|
+
};
|
|
2792
|
+
function clearRecordedDataCB() {
|
|
2793
|
+
if (gifEncoder) {
|
|
2794
|
+
gifEncoder.stream().bin = [];
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
this.name = "GifRecorder";
|
|
2798
|
+
this.toString = function() {
|
|
2799
|
+
return this.name;
|
|
2800
|
+
};
|
|
2801
|
+
var canvas = document.createElement("canvas");
|
|
2802
|
+
var context = canvas.getContext("2d");
|
|
2803
|
+
if (isHTMLObject) {
|
|
2804
|
+
if (mediaStream instanceof CanvasRenderingContext2D) {
|
|
2805
|
+
context = mediaStream;
|
|
2806
|
+
canvas = context.canvas;
|
|
2807
|
+
} else if (mediaStream instanceof HTMLCanvasElement) {
|
|
2808
|
+
context = mediaStream.getContext("2d");
|
|
2809
|
+
canvas = mediaStream;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
var isLoadedMetaData = true;
|
|
2813
|
+
if (!isHTMLObject) {
|
|
2814
|
+
var video = document.createElement("video");
|
|
2815
|
+
video.muted = true;
|
|
2816
|
+
video.autoplay = true;
|
|
2817
|
+
video.playsInline = true;
|
|
2818
|
+
isLoadedMetaData = false;
|
|
2819
|
+
video.onloadedmetadata = function() {
|
|
2820
|
+
isLoadedMetaData = true;
|
|
2821
|
+
};
|
|
2822
|
+
setSrcObject(mediaStream, video);
|
|
2823
|
+
video.play();
|
|
2824
|
+
}
|
|
2825
|
+
var lastAnimationFrame = null;
|
|
2826
|
+
var startTime, endTime, lastFrameTime;
|
|
2827
|
+
var gifEncoder;
|
|
2828
|
+
var self2 = this;
|
|
2829
|
+
}
|
|
2830
|
+
if (typeof RecordRTC !== "undefined") {
|
|
2831
|
+
RecordRTC.GifRecorder = GifRecorder;
|
|
2832
|
+
}
|
|
2833
|
+
function MultiStreamsMixer(arrayOfMediaStreams, elementClass) {
|
|
2834
|
+
var browserFakeUserAgent2 = "Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";
|
|
2835
|
+
(function(that) {
|
|
2836
|
+
if (typeof RecordRTC !== "undefined") {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (!that) {
|
|
2840
|
+
return;
|
|
2841
|
+
}
|
|
2842
|
+
if (typeof window !== "undefined") {
|
|
2843
|
+
return;
|
|
2844
|
+
}
|
|
2845
|
+
if (typeof global === "undefined") {
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
global.navigator = {
|
|
2849
|
+
userAgent: browserFakeUserAgent2,
|
|
2850
|
+
getUserMedia: function() {
|
|
2851
|
+
}
|
|
2852
|
+
};
|
|
2853
|
+
if (!global.console) {
|
|
2854
|
+
global.console = {};
|
|
2855
|
+
}
|
|
2856
|
+
if (typeof global.console.log === "undefined" || typeof global.console.error === "undefined") {
|
|
2857
|
+
global.console.error = global.console.log = global.console.log || function() {
|
|
2858
|
+
console.log(arguments);
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
if (typeof document === "undefined") {
|
|
2862
|
+
that.document = {
|
|
2863
|
+
documentElement: {
|
|
2864
|
+
appendChild: function() {
|
|
2865
|
+
return "";
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
};
|
|
2869
|
+
document.createElement = document.captureStream = document.mozCaptureStream = function() {
|
|
2870
|
+
var obj = {
|
|
2871
|
+
getContext: function() {
|
|
2872
|
+
return obj;
|
|
2873
|
+
},
|
|
2874
|
+
play: function() {
|
|
2875
|
+
},
|
|
2876
|
+
pause: function() {
|
|
2877
|
+
},
|
|
2878
|
+
drawImage: function() {
|
|
2879
|
+
},
|
|
2880
|
+
toDataURL: function() {
|
|
2881
|
+
return "";
|
|
2882
|
+
},
|
|
2883
|
+
style: {}
|
|
2884
|
+
};
|
|
2885
|
+
return obj;
|
|
2886
|
+
};
|
|
2887
|
+
that.HTMLVideoElement = function() {
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
if (typeof location === "undefined") {
|
|
2891
|
+
that.location = {
|
|
2892
|
+
protocol: "file:",
|
|
2893
|
+
href: "",
|
|
2894
|
+
hash: ""
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2897
|
+
if (typeof screen === "undefined") {
|
|
2898
|
+
that.screen = {
|
|
2899
|
+
width: 0,
|
|
2900
|
+
height: 0
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
if (typeof URL3 === "undefined") {
|
|
2904
|
+
that.URL = {
|
|
2905
|
+
createObjectURL: function() {
|
|
2906
|
+
return "";
|
|
2907
|
+
},
|
|
2908
|
+
revokeObjectURL: function() {
|
|
2909
|
+
return "";
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
that.window = global;
|
|
2914
|
+
})(typeof global !== "undefined" ? global : null);
|
|
2915
|
+
elementClass = elementClass || "multi-streams-mixer";
|
|
2916
|
+
var videos = [];
|
|
2917
|
+
var isStopDrawingFrames = false;
|
|
2918
|
+
var canvas = document.createElement("canvas");
|
|
2919
|
+
var context = canvas.getContext("2d");
|
|
2920
|
+
canvas.style.opacity = 0;
|
|
2921
|
+
canvas.style.position = "absolute";
|
|
2922
|
+
canvas.style.zIndex = -1;
|
|
2923
|
+
canvas.style.top = "-1000em";
|
|
2924
|
+
canvas.style.left = "-1000em";
|
|
2925
|
+
canvas.className = elementClass;
|
|
2926
|
+
(document.body || document.documentElement).appendChild(canvas);
|
|
2927
|
+
this.disableLogs = false;
|
|
2928
|
+
this.frameInterval = 10;
|
|
2929
|
+
this.width = 360;
|
|
2930
|
+
this.height = 240;
|
|
2931
|
+
this.useGainNode = true;
|
|
2932
|
+
var self2 = this;
|
|
2933
|
+
var AudioContext2 = window.AudioContext;
|
|
2934
|
+
if (typeof AudioContext2 === "undefined") {
|
|
2935
|
+
if (typeof webkitAudioContext !== "undefined") {
|
|
2936
|
+
AudioContext2 = webkitAudioContext;
|
|
2937
|
+
}
|
|
2938
|
+
if (typeof mozAudioContext !== "undefined") {
|
|
2939
|
+
AudioContext2 = mozAudioContext;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
var URL3 = window.URL;
|
|
2943
|
+
if (typeof URL3 === "undefined" && typeof webkitURL !== "undefined") {
|
|
2944
|
+
URL3 = webkitURL;
|
|
2945
|
+
}
|
|
2946
|
+
if (typeof navigator !== "undefined" && typeof navigator.getUserMedia === "undefined") {
|
|
2947
|
+
if (typeof navigator.webkitGetUserMedia !== "undefined") {
|
|
2948
|
+
navigator.getUserMedia = navigator.webkitGetUserMedia;
|
|
2949
|
+
}
|
|
2950
|
+
if (typeof navigator.mozGetUserMedia !== "undefined") {
|
|
2951
|
+
navigator.getUserMedia = navigator.mozGetUserMedia;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
var MediaStream2 = window.MediaStream;
|
|
2955
|
+
if (typeof MediaStream2 === "undefined" && typeof webkitMediaStream !== "undefined") {
|
|
2956
|
+
MediaStream2 = webkitMediaStream;
|
|
2957
|
+
}
|
|
2958
|
+
if (typeof MediaStream2 !== "undefined") {
|
|
2959
|
+
if (typeof MediaStream2.prototype.stop === "undefined") {
|
|
2960
|
+
MediaStream2.prototype.stop = function() {
|
|
2961
|
+
this.getTracks().forEach(function(track) {
|
|
2962
|
+
track.stop();
|
|
2963
|
+
});
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
var Storage2 = {};
|
|
2968
|
+
if (typeof AudioContext2 !== "undefined") {
|
|
2969
|
+
Storage2.AudioContext = AudioContext2;
|
|
2970
|
+
} else if (typeof webkitAudioContext !== "undefined") {
|
|
2971
|
+
Storage2.AudioContext = webkitAudioContext;
|
|
2972
|
+
}
|
|
2973
|
+
function setSrcObject2(stream, element) {
|
|
2974
|
+
if ("srcObject" in element) {
|
|
2975
|
+
element.srcObject = stream;
|
|
2976
|
+
} else if ("mozSrcObject" in element) {
|
|
2977
|
+
element.mozSrcObject = stream;
|
|
2978
|
+
} else {
|
|
2979
|
+
element.srcObject = stream;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
this.startDrawingFrames = function() {
|
|
2983
|
+
drawVideosToCanvas();
|
|
2984
|
+
};
|
|
2985
|
+
function drawVideosToCanvas() {
|
|
2986
|
+
if (isStopDrawingFrames) {
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
var videosLength = videos.length;
|
|
2990
|
+
var fullcanvas = false;
|
|
2991
|
+
var remaining = [];
|
|
2992
|
+
videos.forEach(function(video) {
|
|
2993
|
+
if (!video.stream) {
|
|
2994
|
+
video.stream = {};
|
|
2995
|
+
}
|
|
2996
|
+
if (video.stream.fullcanvas) {
|
|
2997
|
+
fullcanvas = video;
|
|
2998
|
+
} else {
|
|
2999
|
+
remaining.push(video);
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
if (fullcanvas) {
|
|
3003
|
+
canvas.width = fullcanvas.stream.width;
|
|
3004
|
+
canvas.height = fullcanvas.stream.height;
|
|
3005
|
+
} else if (remaining.length) {
|
|
3006
|
+
canvas.width = videosLength > 1 ? remaining[0].width * 2 : remaining[0].width;
|
|
3007
|
+
var height = 1;
|
|
3008
|
+
if (videosLength === 3 || videosLength === 4) {
|
|
3009
|
+
height = 2;
|
|
3010
|
+
}
|
|
3011
|
+
if (videosLength === 5 || videosLength === 6) {
|
|
3012
|
+
height = 3;
|
|
3013
|
+
}
|
|
3014
|
+
if (videosLength === 7 || videosLength === 8) {
|
|
3015
|
+
height = 4;
|
|
3016
|
+
}
|
|
3017
|
+
if (videosLength === 9 || videosLength === 10) {
|
|
3018
|
+
height = 5;
|
|
3019
|
+
}
|
|
3020
|
+
canvas.height = remaining[0].height * height;
|
|
3021
|
+
} else {
|
|
3022
|
+
canvas.width = self2.width || 360;
|
|
3023
|
+
canvas.height = self2.height || 240;
|
|
3024
|
+
}
|
|
3025
|
+
if (fullcanvas && fullcanvas instanceof HTMLVideoElement) {
|
|
3026
|
+
drawImage(fullcanvas);
|
|
3027
|
+
}
|
|
3028
|
+
remaining.forEach(function(video, idx) {
|
|
3029
|
+
drawImage(video, idx);
|
|
3030
|
+
});
|
|
3031
|
+
setTimeout(drawVideosToCanvas, self2.frameInterval);
|
|
3032
|
+
}
|
|
3033
|
+
function drawImage(video, idx) {
|
|
3034
|
+
if (isStopDrawingFrames) {
|
|
3035
|
+
return;
|
|
3036
|
+
}
|
|
3037
|
+
var x = 0;
|
|
3038
|
+
var y = 0;
|
|
3039
|
+
var width = video.width;
|
|
3040
|
+
var height = video.height;
|
|
3041
|
+
if (idx === 1) {
|
|
3042
|
+
x = video.width;
|
|
3043
|
+
}
|
|
3044
|
+
if (idx === 2) {
|
|
3045
|
+
y = video.height;
|
|
3046
|
+
}
|
|
3047
|
+
if (idx === 3) {
|
|
3048
|
+
x = video.width;
|
|
3049
|
+
y = video.height;
|
|
3050
|
+
}
|
|
3051
|
+
if (idx === 4) {
|
|
3052
|
+
y = video.height * 2;
|
|
3053
|
+
}
|
|
3054
|
+
if (idx === 5) {
|
|
3055
|
+
x = video.width;
|
|
3056
|
+
y = video.height * 2;
|
|
3057
|
+
}
|
|
3058
|
+
if (idx === 6) {
|
|
3059
|
+
y = video.height * 3;
|
|
3060
|
+
}
|
|
3061
|
+
if (idx === 7) {
|
|
3062
|
+
x = video.width;
|
|
3063
|
+
y = video.height * 3;
|
|
3064
|
+
}
|
|
3065
|
+
if (typeof video.stream.left !== "undefined") {
|
|
3066
|
+
x = video.stream.left;
|
|
3067
|
+
}
|
|
3068
|
+
if (typeof video.stream.top !== "undefined") {
|
|
3069
|
+
y = video.stream.top;
|
|
3070
|
+
}
|
|
3071
|
+
if (typeof video.stream.width !== "undefined") {
|
|
3072
|
+
width = video.stream.width;
|
|
3073
|
+
}
|
|
3074
|
+
if (typeof video.stream.height !== "undefined") {
|
|
3075
|
+
height = video.stream.height;
|
|
3076
|
+
}
|
|
3077
|
+
context.drawImage(video, x, y, width, height);
|
|
3078
|
+
if (typeof video.stream.onRender === "function") {
|
|
3079
|
+
video.stream.onRender(context, x, y, width, height, idx);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
function getMixedStream() {
|
|
3083
|
+
isStopDrawingFrames = false;
|
|
3084
|
+
var mixedVideoStream = getMixedVideoStream();
|
|
3085
|
+
var mixedAudioStream = getMixedAudioStream();
|
|
3086
|
+
if (mixedAudioStream) {
|
|
3087
|
+
mixedAudioStream.getTracks().filter(function(t) {
|
|
3088
|
+
return t.kind === "audio";
|
|
3089
|
+
}).forEach(function(track) {
|
|
3090
|
+
mixedVideoStream.addTrack(track);
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
var fullcanvas;
|
|
3094
|
+
arrayOfMediaStreams.forEach(function(stream) {
|
|
3095
|
+
if (stream.fullcanvas) {
|
|
3096
|
+
fullcanvas = true;
|
|
3097
|
+
}
|
|
3098
|
+
});
|
|
3099
|
+
return mixedVideoStream;
|
|
3100
|
+
}
|
|
3101
|
+
function getMixedVideoStream() {
|
|
3102
|
+
resetVideoStreams();
|
|
3103
|
+
var capturedStream;
|
|
3104
|
+
if ("captureStream" in canvas) {
|
|
3105
|
+
capturedStream = canvas.captureStream();
|
|
3106
|
+
} else if ("mozCaptureStream" in canvas) {
|
|
3107
|
+
capturedStream = canvas.mozCaptureStream();
|
|
3108
|
+
} else if (!self2.disableLogs) {
|
|
3109
|
+
console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");
|
|
3110
|
+
}
|
|
3111
|
+
var videoStream = new MediaStream2();
|
|
3112
|
+
capturedStream.getTracks().filter(function(t) {
|
|
3113
|
+
return t.kind === "video";
|
|
3114
|
+
}).forEach(function(track) {
|
|
3115
|
+
videoStream.addTrack(track);
|
|
3116
|
+
});
|
|
3117
|
+
canvas.stream = videoStream;
|
|
3118
|
+
return videoStream;
|
|
3119
|
+
}
|
|
3120
|
+
function getMixedAudioStream() {
|
|
3121
|
+
if (!Storage2.AudioContextConstructor) {
|
|
3122
|
+
Storage2.AudioContextConstructor = new Storage2.AudioContext();
|
|
3123
|
+
}
|
|
3124
|
+
self2.audioContext = Storage2.AudioContextConstructor;
|
|
3125
|
+
self2.audioSources = [];
|
|
3126
|
+
if (self2.useGainNode === true) {
|
|
3127
|
+
self2.gainNode = self2.audioContext.createGain();
|
|
3128
|
+
self2.gainNode.connect(self2.audioContext.destination);
|
|
3129
|
+
self2.gainNode.gain.value = 0;
|
|
3130
|
+
}
|
|
3131
|
+
var audioTracksLength = 0;
|
|
3132
|
+
arrayOfMediaStreams.forEach(function(stream) {
|
|
3133
|
+
if (!stream.getTracks().filter(function(t) {
|
|
3134
|
+
return t.kind === "audio";
|
|
3135
|
+
}).length) {
|
|
3136
|
+
return;
|
|
3137
|
+
}
|
|
3138
|
+
audioTracksLength++;
|
|
3139
|
+
var audioSource = self2.audioContext.createMediaStreamSource(stream);
|
|
3140
|
+
if (self2.useGainNode === true) {
|
|
3141
|
+
audioSource.connect(self2.gainNode);
|
|
3142
|
+
}
|
|
3143
|
+
self2.audioSources.push(audioSource);
|
|
3144
|
+
});
|
|
3145
|
+
if (!audioTracksLength) {
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
self2.audioDestination = self2.audioContext.createMediaStreamDestination();
|
|
3149
|
+
self2.audioSources.forEach(function(audioSource) {
|
|
3150
|
+
audioSource.connect(self2.audioDestination);
|
|
3151
|
+
});
|
|
3152
|
+
return self2.audioDestination.stream;
|
|
3153
|
+
}
|
|
3154
|
+
function getVideo(stream) {
|
|
3155
|
+
var video = document.createElement("video");
|
|
3156
|
+
setSrcObject2(stream, video);
|
|
3157
|
+
video.className = elementClass;
|
|
3158
|
+
video.muted = true;
|
|
3159
|
+
video.volume = 0;
|
|
3160
|
+
video.width = stream.width || self2.width || 360;
|
|
3161
|
+
video.height = stream.height || self2.height || 240;
|
|
3162
|
+
video.play();
|
|
3163
|
+
return video;
|
|
3164
|
+
}
|
|
3165
|
+
this.appendStreams = function(streams) {
|
|
3166
|
+
if (!streams) {
|
|
3167
|
+
throw "First parameter is required.";
|
|
3168
|
+
}
|
|
3169
|
+
if (!(streams instanceof Array)) {
|
|
3170
|
+
streams = [streams];
|
|
3171
|
+
}
|
|
3172
|
+
streams.forEach(function(stream) {
|
|
3173
|
+
var newStream = new MediaStream2();
|
|
3174
|
+
if (stream.getTracks().filter(function(t) {
|
|
3175
|
+
return t.kind === "video";
|
|
3176
|
+
}).length) {
|
|
3177
|
+
var video = getVideo(stream);
|
|
3178
|
+
video.stream = stream;
|
|
3179
|
+
videos.push(video);
|
|
3180
|
+
newStream.addTrack(stream.getTracks().filter(function(t) {
|
|
3181
|
+
return t.kind === "video";
|
|
3182
|
+
})[0]);
|
|
3183
|
+
}
|
|
3184
|
+
if (stream.getTracks().filter(function(t) {
|
|
3185
|
+
return t.kind === "audio";
|
|
3186
|
+
}).length) {
|
|
3187
|
+
var audioSource = self2.audioContext.createMediaStreamSource(stream);
|
|
3188
|
+
self2.audioDestination = self2.audioContext.createMediaStreamDestination();
|
|
3189
|
+
audioSource.connect(self2.audioDestination);
|
|
3190
|
+
newStream.addTrack(self2.audioDestination.stream.getTracks().filter(function(t) {
|
|
3191
|
+
return t.kind === "audio";
|
|
3192
|
+
})[0]);
|
|
3193
|
+
}
|
|
3194
|
+
arrayOfMediaStreams.push(newStream);
|
|
3195
|
+
});
|
|
3196
|
+
};
|
|
3197
|
+
this.releaseStreams = function() {
|
|
3198
|
+
videos = [];
|
|
3199
|
+
isStopDrawingFrames = true;
|
|
3200
|
+
if (self2.gainNode) {
|
|
3201
|
+
self2.gainNode.disconnect();
|
|
3202
|
+
self2.gainNode = null;
|
|
3203
|
+
}
|
|
3204
|
+
if (self2.audioSources.length) {
|
|
3205
|
+
self2.audioSources.forEach(function(source) {
|
|
3206
|
+
source.disconnect();
|
|
3207
|
+
});
|
|
3208
|
+
self2.audioSources = [];
|
|
3209
|
+
}
|
|
3210
|
+
if (self2.audioDestination) {
|
|
3211
|
+
self2.audioDestination.disconnect();
|
|
3212
|
+
self2.audioDestination = null;
|
|
3213
|
+
}
|
|
3214
|
+
if (self2.audioContext) {
|
|
3215
|
+
self2.audioContext.close();
|
|
3216
|
+
}
|
|
3217
|
+
self2.audioContext = null;
|
|
3218
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
3219
|
+
if (canvas.stream) {
|
|
3220
|
+
canvas.stream.stop();
|
|
3221
|
+
canvas.stream = null;
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
this.resetVideoStreams = function(streams) {
|
|
3225
|
+
if (streams && !(streams instanceof Array)) {
|
|
3226
|
+
streams = [streams];
|
|
3227
|
+
}
|
|
3228
|
+
resetVideoStreams(streams);
|
|
3229
|
+
};
|
|
3230
|
+
function resetVideoStreams(streams) {
|
|
3231
|
+
videos = [];
|
|
3232
|
+
streams = streams || arrayOfMediaStreams;
|
|
3233
|
+
streams.forEach(function(stream) {
|
|
3234
|
+
if (!stream.getTracks().filter(function(t) {
|
|
3235
|
+
return t.kind === "video";
|
|
3236
|
+
}).length) {
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
var video = getVideo(stream);
|
|
3240
|
+
video.stream = stream;
|
|
3241
|
+
videos.push(video);
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3244
|
+
this.name = "MultiStreamsMixer";
|
|
3245
|
+
this.toString = function() {
|
|
3246
|
+
return this.name;
|
|
3247
|
+
};
|
|
3248
|
+
this.getMixedStream = getMixedStream;
|
|
3249
|
+
}
|
|
3250
|
+
if (typeof RecordRTC === "undefined") {
|
|
3251
|
+
if (typeof module !== "undefined") {
|
|
3252
|
+
module.exports = MultiStreamsMixer;
|
|
3253
|
+
}
|
|
3254
|
+
if (typeof define === "function" && define.amd) {
|
|
3255
|
+
define("MultiStreamsMixer", [], function() {
|
|
3256
|
+
return MultiStreamsMixer;
|
|
3257
|
+
});
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
function MultiStreamRecorder(arrayOfMediaStreams, options) {
|
|
3261
|
+
arrayOfMediaStreams = arrayOfMediaStreams || [];
|
|
3262
|
+
var self2 = this;
|
|
3263
|
+
var mixer;
|
|
3264
|
+
var mediaRecorder;
|
|
3265
|
+
options = options || {
|
|
3266
|
+
elementClass: "multi-streams-mixer",
|
|
3267
|
+
mimeType: "video/webm",
|
|
3268
|
+
video: {
|
|
3269
|
+
width: 360,
|
|
3270
|
+
height: 240
|
|
3271
|
+
}
|
|
3272
|
+
};
|
|
3273
|
+
if (!options.frameInterval) {
|
|
3274
|
+
options.frameInterval = 10;
|
|
3275
|
+
}
|
|
3276
|
+
if (!options.video) {
|
|
3277
|
+
options.video = {};
|
|
3278
|
+
}
|
|
3279
|
+
if (!options.video.width) {
|
|
3280
|
+
options.video.width = 360;
|
|
3281
|
+
}
|
|
3282
|
+
if (!options.video.height) {
|
|
3283
|
+
options.video.height = 240;
|
|
3284
|
+
}
|
|
3285
|
+
this.record = function() {
|
|
3286
|
+
mixer = new MultiStreamsMixer(arrayOfMediaStreams, options.elementClass || "multi-streams-mixer");
|
|
3287
|
+
if (getAllVideoTracks().length) {
|
|
3288
|
+
mixer.frameInterval = options.frameInterval || 10;
|
|
3289
|
+
mixer.width = options.video.width || 360;
|
|
3290
|
+
mixer.height = options.video.height || 240;
|
|
3291
|
+
mixer.startDrawingFrames();
|
|
3292
|
+
}
|
|
3293
|
+
if (options.previewStream && typeof options.previewStream === "function") {
|
|
3294
|
+
options.previewStream(mixer.getMixedStream());
|
|
3295
|
+
}
|
|
3296
|
+
mediaRecorder = new MediaStreamRecorder(mixer.getMixedStream(), options);
|
|
3297
|
+
mediaRecorder.record();
|
|
3298
|
+
};
|
|
3299
|
+
function getAllVideoTracks() {
|
|
3300
|
+
var tracks = [];
|
|
3301
|
+
arrayOfMediaStreams.forEach(function(stream) {
|
|
3302
|
+
getTracks(stream, "video").forEach(function(track) {
|
|
3303
|
+
tracks.push(track);
|
|
3304
|
+
});
|
|
3305
|
+
});
|
|
3306
|
+
return tracks;
|
|
3307
|
+
}
|
|
3308
|
+
this.stop = function(callback) {
|
|
3309
|
+
if (!mediaRecorder) {
|
|
3310
|
+
return;
|
|
3311
|
+
}
|
|
3312
|
+
mediaRecorder.stop(function(blob) {
|
|
3313
|
+
self2.blob = blob;
|
|
3314
|
+
callback(blob);
|
|
3315
|
+
self2.clearRecordedData();
|
|
3316
|
+
});
|
|
3317
|
+
};
|
|
3318
|
+
this.pause = function() {
|
|
3319
|
+
if (mediaRecorder) {
|
|
3320
|
+
mediaRecorder.pause();
|
|
3321
|
+
}
|
|
3322
|
+
};
|
|
3323
|
+
this.resume = function() {
|
|
3324
|
+
if (mediaRecorder) {
|
|
3325
|
+
mediaRecorder.resume();
|
|
3326
|
+
}
|
|
3327
|
+
};
|
|
3328
|
+
this.clearRecordedData = function() {
|
|
3329
|
+
if (mediaRecorder) {
|
|
3330
|
+
mediaRecorder.clearRecordedData();
|
|
3331
|
+
mediaRecorder = null;
|
|
3332
|
+
}
|
|
3333
|
+
if (mixer) {
|
|
3334
|
+
mixer.releaseStreams();
|
|
3335
|
+
mixer = null;
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
this.addStreams = function(streams) {
|
|
3339
|
+
if (!streams) {
|
|
3340
|
+
throw "First parameter is required.";
|
|
3341
|
+
}
|
|
3342
|
+
if (!(streams instanceof Array)) {
|
|
3343
|
+
streams = [streams];
|
|
3344
|
+
}
|
|
3345
|
+
arrayOfMediaStreams.concat(streams);
|
|
3346
|
+
if (!mediaRecorder || !mixer) {
|
|
3347
|
+
return;
|
|
3348
|
+
}
|
|
3349
|
+
mixer.appendStreams(streams);
|
|
3350
|
+
if (options.previewStream && typeof options.previewStream === "function") {
|
|
3351
|
+
options.previewStream(mixer.getMixedStream());
|
|
3352
|
+
}
|
|
3353
|
+
};
|
|
3354
|
+
this.resetVideoStreams = function(streams) {
|
|
3355
|
+
if (!mixer) {
|
|
3356
|
+
return;
|
|
3357
|
+
}
|
|
3358
|
+
if (streams && !(streams instanceof Array)) {
|
|
3359
|
+
streams = [streams];
|
|
3360
|
+
}
|
|
3361
|
+
mixer.resetVideoStreams(streams);
|
|
3362
|
+
};
|
|
3363
|
+
this.getMixer = function() {
|
|
3364
|
+
return mixer;
|
|
3365
|
+
};
|
|
3366
|
+
this.name = "MultiStreamRecorder";
|
|
3367
|
+
this.toString = function() {
|
|
3368
|
+
return this.name;
|
|
3369
|
+
};
|
|
3370
|
+
}
|
|
3371
|
+
if (typeof RecordRTC !== "undefined") {
|
|
3372
|
+
RecordRTC.MultiStreamRecorder = MultiStreamRecorder;
|
|
3373
|
+
}
|
|
3374
|
+
function RecordRTCPromisesHandler3(mediaStream, options) {
|
|
3375
|
+
if (!this) {
|
|
3376
|
+
throw 'Use "new RecordRTCPromisesHandler()"';
|
|
3377
|
+
}
|
|
3378
|
+
if (typeof mediaStream === "undefined") {
|
|
3379
|
+
throw 'First argument "MediaStream" is required.';
|
|
3380
|
+
}
|
|
3381
|
+
var self2 = this;
|
|
3382
|
+
self2.recordRTC = new RecordRTC(mediaStream, options);
|
|
3383
|
+
this.startRecording = function() {
|
|
3384
|
+
return new Promise(function(resolve, reject) {
|
|
3385
|
+
try {
|
|
3386
|
+
self2.recordRTC.startRecording();
|
|
3387
|
+
resolve();
|
|
3388
|
+
} catch (e) {
|
|
3389
|
+
reject(e);
|
|
3390
|
+
}
|
|
3391
|
+
});
|
|
3392
|
+
};
|
|
3393
|
+
this.stopRecording = function() {
|
|
3394
|
+
return new Promise(function(resolve, reject) {
|
|
3395
|
+
try {
|
|
3396
|
+
self2.recordRTC.stopRecording(function(url) {
|
|
3397
|
+
self2.blob = self2.recordRTC.getBlob();
|
|
3398
|
+
if (!self2.blob || !self2.blob.size) {
|
|
3399
|
+
reject("Empty blob.", self2.blob);
|
|
3400
|
+
return;
|
|
3401
|
+
}
|
|
3402
|
+
resolve(url);
|
|
3403
|
+
});
|
|
3404
|
+
} catch (e) {
|
|
3405
|
+
reject(e);
|
|
3406
|
+
}
|
|
3407
|
+
});
|
|
3408
|
+
};
|
|
3409
|
+
this.pauseRecording = function() {
|
|
3410
|
+
return new Promise(function(resolve, reject) {
|
|
3411
|
+
try {
|
|
3412
|
+
self2.recordRTC.pauseRecording();
|
|
3413
|
+
resolve();
|
|
3414
|
+
} catch (e) {
|
|
3415
|
+
reject(e);
|
|
3416
|
+
}
|
|
3417
|
+
});
|
|
3418
|
+
};
|
|
3419
|
+
this.resumeRecording = function() {
|
|
3420
|
+
return new Promise(function(resolve, reject) {
|
|
3421
|
+
try {
|
|
3422
|
+
self2.recordRTC.resumeRecording();
|
|
3423
|
+
resolve();
|
|
3424
|
+
} catch (e) {
|
|
3425
|
+
reject(e);
|
|
3426
|
+
}
|
|
3427
|
+
});
|
|
3428
|
+
};
|
|
3429
|
+
this.getDataURL = function(callback) {
|
|
3430
|
+
return new Promise(function(resolve, reject) {
|
|
3431
|
+
try {
|
|
3432
|
+
self2.recordRTC.getDataURL(function(dataURL) {
|
|
3433
|
+
resolve(dataURL);
|
|
3434
|
+
});
|
|
3435
|
+
} catch (e) {
|
|
3436
|
+
reject(e);
|
|
3437
|
+
}
|
|
3438
|
+
});
|
|
3439
|
+
};
|
|
3440
|
+
this.getBlob = function() {
|
|
3441
|
+
return new Promise(function(resolve, reject) {
|
|
3442
|
+
try {
|
|
3443
|
+
resolve(self2.recordRTC.getBlob());
|
|
3444
|
+
} catch (e) {
|
|
3445
|
+
reject(e);
|
|
3446
|
+
}
|
|
3447
|
+
});
|
|
3448
|
+
};
|
|
3449
|
+
this.getInternalRecorder = function() {
|
|
3450
|
+
return new Promise(function(resolve, reject) {
|
|
3451
|
+
try {
|
|
3452
|
+
resolve(self2.recordRTC.getInternalRecorder());
|
|
3453
|
+
} catch (e) {
|
|
3454
|
+
reject(e);
|
|
3455
|
+
}
|
|
3456
|
+
});
|
|
3457
|
+
};
|
|
3458
|
+
this.reset = function() {
|
|
3459
|
+
return new Promise(function(resolve, reject) {
|
|
3460
|
+
try {
|
|
3461
|
+
resolve(self2.recordRTC.reset());
|
|
3462
|
+
} catch (e) {
|
|
3463
|
+
reject(e);
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3466
|
+
};
|
|
3467
|
+
this.destroy = function() {
|
|
3468
|
+
return new Promise(function(resolve, reject) {
|
|
3469
|
+
try {
|
|
3470
|
+
resolve(self2.recordRTC.destroy());
|
|
3471
|
+
} catch (e) {
|
|
3472
|
+
reject(e);
|
|
3473
|
+
}
|
|
3474
|
+
});
|
|
3475
|
+
};
|
|
3476
|
+
this.getState = function() {
|
|
3477
|
+
return new Promise(function(resolve, reject) {
|
|
3478
|
+
try {
|
|
3479
|
+
resolve(self2.recordRTC.getState());
|
|
3480
|
+
} catch (e) {
|
|
3481
|
+
reject(e);
|
|
3482
|
+
}
|
|
3483
|
+
});
|
|
3484
|
+
};
|
|
3485
|
+
this.blob = null;
|
|
3486
|
+
this.version = "5.6.2";
|
|
3487
|
+
}
|
|
3488
|
+
if (typeof RecordRTC !== "undefined") {
|
|
3489
|
+
RecordRTC.RecordRTCPromisesHandler = RecordRTCPromisesHandler3;
|
|
3490
|
+
}
|
|
3491
|
+
function WebAssemblyRecorder(stream, config2) {
|
|
3492
|
+
if (typeof ReadableStream === "undefined" || typeof WritableStream === "undefined") {
|
|
3493
|
+
console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js");
|
|
3494
|
+
}
|
|
3495
|
+
config2 = config2 || {};
|
|
3496
|
+
config2.width = config2.width || 640;
|
|
3497
|
+
config2.height = config2.height || 480;
|
|
3498
|
+
config2.frameRate = config2.frameRate || 30;
|
|
3499
|
+
config2.bitrate = config2.bitrate || 1200;
|
|
3500
|
+
config2.realtime = config2.realtime || true;
|
|
3501
|
+
function createBufferURL(buffer, type) {
|
|
3502
|
+
return URL2.createObjectURL(new Blob([buffer], {
|
|
3503
|
+
type: type || ""
|
|
3504
|
+
}));
|
|
3505
|
+
}
|
|
3506
|
+
var finished;
|
|
3507
|
+
function cameraStream() {
|
|
3508
|
+
return new ReadableStream({
|
|
3509
|
+
start: function(controller) {
|
|
3510
|
+
var cvs = document.createElement("canvas");
|
|
3511
|
+
var video = document.createElement("video");
|
|
3512
|
+
var first = true;
|
|
3513
|
+
video.srcObject = stream;
|
|
3514
|
+
video.muted = true;
|
|
3515
|
+
video.height = config2.height;
|
|
3516
|
+
video.width = config2.width;
|
|
3517
|
+
video.volume = 0;
|
|
3518
|
+
video.onplaying = function() {
|
|
3519
|
+
cvs.width = config2.width;
|
|
3520
|
+
cvs.height = config2.height;
|
|
3521
|
+
var ctx = cvs.getContext("2d");
|
|
3522
|
+
var frameTimeout = 1e3 / config2.frameRate;
|
|
3523
|
+
var cameraTimer = setInterval(function f() {
|
|
3524
|
+
if (finished) {
|
|
3525
|
+
clearInterval(cameraTimer);
|
|
3526
|
+
controller.close();
|
|
3527
|
+
}
|
|
3528
|
+
if (first) {
|
|
3529
|
+
first = false;
|
|
3530
|
+
if (config2.onVideoProcessStarted) {
|
|
3531
|
+
config2.onVideoProcessStarted();
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
ctx.drawImage(video, 0, 0);
|
|
3535
|
+
if (controller._controlledReadableStream.state !== "closed") {
|
|
3536
|
+
try {
|
|
3537
|
+
controller.enqueue(ctx.getImageData(0, 0, config2.width, config2.height));
|
|
3538
|
+
} catch (e) {
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
}, frameTimeout);
|
|
3542
|
+
};
|
|
3543
|
+
video.play();
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
var worker;
|
|
3548
|
+
function startRecording(stream2, buffer) {
|
|
3549
|
+
if (!config2.workerPath && !buffer) {
|
|
3550
|
+
finished = false;
|
|
3551
|
+
fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then(function(r) {
|
|
3552
|
+
r.arrayBuffer().then(function(buffer2) {
|
|
3553
|
+
startRecording(stream2, buffer2);
|
|
3554
|
+
});
|
|
3555
|
+
});
|
|
3556
|
+
return;
|
|
3557
|
+
}
|
|
3558
|
+
if (!config2.workerPath && buffer instanceof ArrayBuffer) {
|
|
3559
|
+
var blob = new Blob([buffer], {
|
|
3560
|
+
type: "text/javascript"
|
|
3561
|
+
});
|
|
3562
|
+
config2.workerPath = URL2.createObjectURL(blob);
|
|
3563
|
+
}
|
|
3564
|
+
if (!config2.workerPath) {
|
|
3565
|
+
console.error("workerPath parameter is missing.");
|
|
3566
|
+
}
|
|
3567
|
+
worker = new Worker(config2.workerPath);
|
|
3568
|
+
worker.postMessage(config2.webAssemblyPath || "https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm");
|
|
3569
|
+
worker.addEventListener("message", function(event) {
|
|
3570
|
+
if (event.data === "READY") {
|
|
3571
|
+
worker.postMessage({
|
|
3572
|
+
width: config2.width,
|
|
3573
|
+
height: config2.height,
|
|
3574
|
+
bitrate: config2.bitrate || 1200,
|
|
3575
|
+
timebaseDen: config2.frameRate || 30,
|
|
3576
|
+
realtime: config2.realtime
|
|
3577
|
+
});
|
|
3578
|
+
cameraStream().pipeTo(new WritableStream({
|
|
3579
|
+
write: function(image) {
|
|
3580
|
+
if (finished) {
|
|
3581
|
+
console.error("Got image, but recorder is finished!");
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
worker.postMessage(image.data.buffer, [image.data.buffer]);
|
|
3585
|
+
}
|
|
3586
|
+
}));
|
|
3587
|
+
} else if (!!event.data) {
|
|
3588
|
+
if (!isPaused) {
|
|
3589
|
+
arrayOfBuffers.push(event.data);
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
}
|
|
3594
|
+
this.record = function() {
|
|
3595
|
+
arrayOfBuffers = [];
|
|
3596
|
+
isPaused = false;
|
|
3597
|
+
this.blob = null;
|
|
3598
|
+
startRecording(stream);
|
|
3599
|
+
if (typeof config2.initCallback === "function") {
|
|
3600
|
+
config2.initCallback();
|
|
3601
|
+
}
|
|
3602
|
+
};
|
|
3603
|
+
var isPaused;
|
|
3604
|
+
this.pause = function() {
|
|
3605
|
+
isPaused = true;
|
|
3606
|
+
};
|
|
3607
|
+
this.resume = function() {
|
|
3608
|
+
isPaused = false;
|
|
3609
|
+
};
|
|
3610
|
+
function terminate(callback) {
|
|
3611
|
+
if (!worker) {
|
|
3612
|
+
if (callback) {
|
|
3613
|
+
callback();
|
|
3614
|
+
}
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
worker.addEventListener("message", function(event) {
|
|
3618
|
+
if (event.data === null) {
|
|
3619
|
+
worker.terminate();
|
|
3620
|
+
worker = null;
|
|
3621
|
+
if (callback) {
|
|
3622
|
+
callback();
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
});
|
|
3626
|
+
worker.postMessage(null);
|
|
3627
|
+
}
|
|
3628
|
+
var arrayOfBuffers = [];
|
|
3629
|
+
this.stop = function(callback) {
|
|
3630
|
+
finished = true;
|
|
3631
|
+
var recorder = this;
|
|
3632
|
+
terminate(function() {
|
|
3633
|
+
recorder.blob = new Blob(arrayOfBuffers, {
|
|
3634
|
+
type: "video/webm"
|
|
3635
|
+
});
|
|
3636
|
+
callback(recorder.blob);
|
|
3637
|
+
});
|
|
3638
|
+
};
|
|
3639
|
+
this.name = "WebAssemblyRecorder";
|
|
3640
|
+
this.toString = function() {
|
|
3641
|
+
return this.name;
|
|
3642
|
+
};
|
|
3643
|
+
this.clearRecordedData = function() {
|
|
3644
|
+
arrayOfBuffers = [];
|
|
3645
|
+
isPaused = false;
|
|
3646
|
+
this.blob = null;
|
|
3647
|
+
};
|
|
3648
|
+
this.blob = null;
|
|
3649
|
+
}
|
|
3650
|
+
if (typeof RecordRTC !== "undefined") {
|
|
3651
|
+
RecordRTC.WebAssemblyRecorder = WebAssemblyRecorder;
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
});
|
|
3655
|
+
|
|
28
3656
|
// src/plugins/mp3.js
|
|
29
3657
|
var require_mp3 = __commonJS({
|
|
30
3658
|
"src/plugins/mp3.js"(exports, module) {
|
|
@@ -33576,479 +37204,448 @@ var require_tslib35 = __commonJS({
|
|
|
33576
37204
|
}
|
|
33577
37205
|
});
|
|
33578
37206
|
|
|
33579
|
-
// node_modules/@aws-sdk/util-defaults-mode-browser/node_modules/tslib/tslib.js
|
|
33580
|
-
var require_tslib36 = __commonJS({
|
|
33581
|
-
"node_modules/@aws-sdk/util-defaults-mode-browser/node_modules/tslib/tslib.js"(exports, module) {
|
|
33582
|
-
var __extends37;
|
|
33583
|
-
var __assign37;
|
|
33584
|
-
var __rest36;
|
|
33585
|
-
var __decorate36;
|
|
33586
|
-
var __param36;
|
|
33587
|
-
var __metadata36;
|
|
33588
|
-
var __awaiter36;
|
|
33589
|
-
var __generator36;
|
|
33590
|
-
var __exportStar36;
|
|
33591
|
-
var __values36;
|
|
33592
|
-
var __read36;
|
|
33593
|
-
var __spread36;
|
|
33594
|
-
var __spreadArrays36;
|
|
33595
|
-
var __spreadArray36;
|
|
33596
|
-
var __await36;
|
|
33597
|
-
var __asyncGenerator36;
|
|
33598
|
-
var __asyncDelegator36;
|
|
33599
|
-
var __asyncValues36;
|
|
33600
|
-
var __makeTemplateObject36;
|
|
33601
|
-
var __importStar36;
|
|
33602
|
-
var __importDefault36;
|
|
33603
|
-
var __classPrivateFieldGet36;
|
|
33604
|
-
var __classPrivateFieldSet36;
|
|
33605
|
-
var __classPrivateFieldIn36;
|
|
33606
|
-
var __createBinding37;
|
|
33607
|
-
(function(factory) {
|
|
33608
|
-
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
33609
|
-
if (typeof define === "function" && define.amd) {
|
|
33610
|
-
define("tslib", ["exports"], function(exports2) {
|
|
33611
|
-
factory(createExporter(root, createExporter(exports2)));
|
|
33612
|
-
});
|
|
33613
|
-
} else if (typeof module === "object" && typeof module.exports === "object") {
|
|
33614
|
-
factory(createExporter(root, createExporter(module.exports)));
|
|
33615
|
-
} else {
|
|
33616
|
-
factory(createExporter(root));
|
|
33617
|
-
}
|
|
33618
|
-
function createExporter(exports2, previous) {
|
|
33619
|
-
if (exports2 !== root) {
|
|
33620
|
-
if (typeof Object.create === "function") {
|
|
33621
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
33622
|
-
} else {
|
|
33623
|
-
exports2.__esModule = true;
|
|
33624
|
-
}
|
|
33625
|
-
}
|
|
33626
|
-
return function(id, v) {
|
|
33627
|
-
return exports2[id] = previous ? previous(id, v) : v;
|
|
33628
|
-
};
|
|
33629
|
-
}
|
|
33630
|
-
})(function(exporter) {
|
|
33631
|
-
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
33632
|
-
d.__proto__ = b;
|
|
33633
|
-
} || function(d, b) {
|
|
33634
|
-
for (var p in b)
|
|
33635
|
-
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
33636
|
-
d[p] = b[p];
|
|
33637
|
-
};
|
|
33638
|
-
__extends37 = function(d, b) {
|
|
33639
|
-
if (typeof b !== "function" && b !== null)
|
|
33640
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
33641
|
-
extendStatics(d, b);
|
|
33642
|
-
function __() {
|
|
33643
|
-
this.constructor = d;
|
|
33644
|
-
}
|
|
33645
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33646
|
-
};
|
|
33647
|
-
__assign37 = Object.assign || function(t) {
|
|
33648
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
33649
|
-
s = arguments[i];
|
|
33650
|
-
for (var p in s)
|
|
33651
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
33652
|
-
t[p] = s[p];
|
|
33653
|
-
}
|
|
33654
|
-
return t;
|
|
33655
|
-
};
|
|
33656
|
-
__rest36 = function(s, e) {
|
|
33657
|
-
var t = {};
|
|
33658
|
-
for (var p in s)
|
|
33659
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
33660
|
-
t[p] = s[p];
|
|
33661
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
33662
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
33663
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
33664
|
-
t[p[i]] = s[p[i]];
|
|
33665
|
-
}
|
|
33666
|
-
return t;
|
|
33667
|
-
};
|
|
33668
|
-
__decorate36 = function(decorators, target, key, desc) {
|
|
33669
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
33670
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
33671
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
33672
|
-
else
|
|
33673
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
33674
|
-
if (d = decorators[i])
|
|
33675
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
33676
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
33677
|
-
};
|
|
33678
|
-
__param36 = function(paramIndex, decorator) {
|
|
33679
|
-
return function(target, key) {
|
|
33680
|
-
decorator(target, key, paramIndex);
|
|
33681
|
-
};
|
|
33682
|
-
};
|
|
33683
|
-
__metadata36 = function(metadataKey, metadataValue) {
|
|
33684
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
33685
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
33686
|
-
};
|
|
33687
|
-
__awaiter36 = function(thisArg, _arguments, P, generator) {
|
|
33688
|
-
function adopt(value) {
|
|
33689
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
33690
|
-
resolve(value);
|
|
33691
|
-
});
|
|
33692
|
-
}
|
|
33693
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
33694
|
-
function fulfilled(value) {
|
|
33695
|
-
try {
|
|
33696
|
-
step(generator.next(value));
|
|
33697
|
-
} catch (e) {
|
|
33698
|
-
reject(e);
|
|
33699
|
-
}
|
|
33700
|
-
}
|
|
33701
|
-
function rejected(value) {
|
|
33702
|
-
try {
|
|
33703
|
-
step(generator["throw"](value));
|
|
33704
|
-
} catch (e) {
|
|
33705
|
-
reject(e);
|
|
33706
|
-
}
|
|
33707
|
-
}
|
|
33708
|
-
function step(result) {
|
|
33709
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
33710
|
-
}
|
|
33711
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33712
|
-
});
|
|
33713
|
-
};
|
|
33714
|
-
__generator36 = function(thisArg, body) {
|
|
33715
|
-
var _ = { label: 0, sent: function() {
|
|
33716
|
-
if (t[0] & 1)
|
|
33717
|
-
throw t[1];
|
|
33718
|
-
return t[1];
|
|
33719
|
-
}, trys: [], ops: [] }, f, y, t, g;
|
|
33720
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
33721
|
-
return this;
|
|
33722
|
-
}), g;
|
|
33723
|
-
function verb(n) {
|
|
33724
|
-
return function(v) {
|
|
33725
|
-
return step([n, v]);
|
|
33726
|
-
};
|
|
33727
|
-
}
|
|
33728
|
-
function step(op) {
|
|
33729
|
-
if (f)
|
|
33730
|
-
throw new TypeError("Generator is already executing.");
|
|
33731
|
-
while (_)
|
|
33732
|
-
try {
|
|
33733
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
33734
|
-
return t;
|
|
33735
|
-
if (y = 0, t)
|
|
33736
|
-
op = [op[0] & 2, t.value];
|
|
33737
|
-
switch (op[0]) {
|
|
33738
|
-
case 0:
|
|
33739
|
-
case 1:
|
|
33740
|
-
t = op;
|
|
33741
|
-
break;
|
|
33742
|
-
case 4:
|
|
33743
|
-
_.label++;
|
|
33744
|
-
return { value: op[1], done: false };
|
|
33745
|
-
case 5:
|
|
33746
|
-
_.label++;
|
|
33747
|
-
y = op[1];
|
|
33748
|
-
op = [0];
|
|
33749
|
-
continue;
|
|
33750
|
-
case 7:
|
|
33751
|
-
op = _.ops.pop();
|
|
33752
|
-
_.trys.pop();
|
|
33753
|
-
continue;
|
|
33754
|
-
default:
|
|
33755
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
33756
|
-
_ = 0;
|
|
33757
|
-
continue;
|
|
33758
|
-
}
|
|
33759
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
33760
|
-
_.label = op[1];
|
|
33761
|
-
break;
|
|
33762
|
-
}
|
|
33763
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
33764
|
-
_.label = t[1];
|
|
33765
|
-
t = op;
|
|
33766
|
-
break;
|
|
33767
|
-
}
|
|
33768
|
-
if (t && _.label < t[2]) {
|
|
33769
|
-
_.label = t[2];
|
|
33770
|
-
_.ops.push(op);
|
|
33771
|
-
break;
|
|
33772
|
-
}
|
|
33773
|
-
if (t[2])
|
|
33774
|
-
_.ops.pop();
|
|
33775
|
-
_.trys.pop();
|
|
33776
|
-
continue;
|
|
33777
|
-
}
|
|
33778
|
-
op = body.call(thisArg, _);
|
|
33779
|
-
} catch (e) {
|
|
33780
|
-
op = [6, e];
|
|
33781
|
-
y = 0;
|
|
33782
|
-
} finally {
|
|
33783
|
-
f = t = 0;
|
|
33784
|
-
}
|
|
33785
|
-
if (op[0] & 5)
|
|
33786
|
-
throw op[1];
|
|
33787
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
33788
|
-
}
|
|
33789
|
-
};
|
|
33790
|
-
__exportStar36 = function(m, o) {
|
|
33791
|
-
for (var p in m)
|
|
33792
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
33793
|
-
__createBinding37(o, m, p);
|
|
33794
|
-
};
|
|
33795
|
-
__createBinding37 = Object.create ? function(o, m, k, k2) {
|
|
33796
|
-
if (k2 === void 0)
|
|
33797
|
-
k2 = k;
|
|
33798
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
33799
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33800
|
-
desc = { enumerable: true, get: function() {
|
|
33801
|
-
return m[k];
|
|
33802
|
-
} };
|
|
33803
|
-
}
|
|
33804
|
-
Object.defineProperty(o, k2, desc);
|
|
33805
|
-
} : function(o, m, k, k2) {
|
|
33806
|
-
if (k2 === void 0)
|
|
33807
|
-
k2 = k;
|
|
33808
|
-
o[k2] = m[k];
|
|
33809
|
-
};
|
|
33810
|
-
__values36 = function(o) {
|
|
33811
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
33812
|
-
if (m)
|
|
33813
|
-
return m.call(o);
|
|
33814
|
-
if (o && typeof o.length === "number")
|
|
33815
|
-
return {
|
|
33816
|
-
next: function() {
|
|
33817
|
-
if (o && i >= o.length)
|
|
33818
|
-
o = void 0;
|
|
33819
|
-
return { value: o && o[i++], done: !o };
|
|
33820
|
-
}
|
|
33821
|
-
};
|
|
33822
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
33823
|
-
};
|
|
33824
|
-
__read36 = function(o, n) {
|
|
33825
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
33826
|
-
if (!m)
|
|
33827
|
-
return o;
|
|
33828
|
-
var i = m.call(o), r, ar = [], e;
|
|
33829
|
-
try {
|
|
33830
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
33831
|
-
ar.push(r.value);
|
|
33832
|
-
} catch (error) {
|
|
33833
|
-
e = { error };
|
|
33834
|
-
} finally {
|
|
33835
|
-
try {
|
|
33836
|
-
if (r && !r.done && (m = i["return"]))
|
|
33837
|
-
m.call(i);
|
|
33838
|
-
} finally {
|
|
33839
|
-
if (e)
|
|
33840
|
-
throw e.error;
|
|
33841
|
-
}
|
|
33842
|
-
}
|
|
33843
|
-
return ar;
|
|
33844
|
-
};
|
|
33845
|
-
__spread36 = function() {
|
|
33846
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
33847
|
-
ar = ar.concat(__read36(arguments[i]));
|
|
33848
|
-
return ar;
|
|
33849
|
-
};
|
|
33850
|
-
__spreadArrays36 = function() {
|
|
33851
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
33852
|
-
s += arguments[i].length;
|
|
33853
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
33854
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
33855
|
-
r[k] = a[j];
|
|
33856
|
-
return r;
|
|
33857
|
-
};
|
|
33858
|
-
__spreadArray36 = function(to, from, pack) {
|
|
33859
|
-
if (pack || arguments.length === 2)
|
|
33860
|
-
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
33861
|
-
if (ar || !(i in from)) {
|
|
33862
|
-
if (!ar)
|
|
33863
|
-
ar = Array.prototype.slice.call(from, 0, i);
|
|
33864
|
-
ar[i] = from[i];
|
|
33865
|
-
}
|
|
33866
|
-
}
|
|
33867
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33868
|
-
};
|
|
33869
|
-
__await36 = function(v) {
|
|
33870
|
-
return this instanceof __await36 ? (this.v = v, this) : new __await36(v);
|
|
33871
|
-
};
|
|
33872
|
-
__asyncGenerator36 = function(thisArg, _arguments, generator) {
|
|
33873
|
-
if (!Symbol.asyncIterator)
|
|
33874
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
33875
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
33876
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
33877
|
-
return this;
|
|
33878
|
-
}, i;
|
|
33879
|
-
function verb(n) {
|
|
33880
|
-
if (g[n])
|
|
33881
|
-
i[n] = function(v) {
|
|
33882
|
-
return new Promise(function(a, b) {
|
|
33883
|
-
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
33884
|
-
});
|
|
33885
|
-
};
|
|
33886
|
-
}
|
|
33887
|
-
function resume(n, v) {
|
|
33888
|
-
try {
|
|
33889
|
-
step(g[n](v));
|
|
33890
|
-
} catch (e) {
|
|
33891
|
-
settle(q[0][3], e);
|
|
33892
|
-
}
|
|
33893
|
-
}
|
|
33894
|
-
function step(r) {
|
|
33895
|
-
r.value instanceof __await36 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
33896
|
-
}
|
|
33897
|
-
function fulfill(value) {
|
|
33898
|
-
resume("next", value);
|
|
33899
|
-
}
|
|
33900
|
-
function reject(value) {
|
|
33901
|
-
resume("throw", value);
|
|
33902
|
-
}
|
|
33903
|
-
function settle(f, v) {
|
|
33904
|
-
if (f(v), q.shift(), q.length)
|
|
33905
|
-
resume(q[0][0], q[0][1]);
|
|
33906
|
-
}
|
|
33907
|
-
};
|
|
33908
|
-
__asyncDelegator36 = function(o) {
|
|
33909
|
-
var i, p;
|
|
33910
|
-
return i = {}, verb("next"), verb("throw", function(e) {
|
|
33911
|
-
throw e;
|
|
33912
|
-
}), verb("return"), i[Symbol.iterator] = function() {
|
|
33913
|
-
return this;
|
|
33914
|
-
}, i;
|
|
33915
|
-
function verb(n, f) {
|
|
33916
|
-
i[n] = o[n] ? function(v) {
|
|
33917
|
-
return (p = !p) ? { value: __await36(o[n](v)), done: n === "return" } : f ? f(v) : v;
|
|
33918
|
-
} : f;
|
|
33919
|
-
}
|
|
33920
|
-
};
|
|
33921
|
-
__asyncValues36 = function(o) {
|
|
33922
|
-
if (!Symbol.asyncIterator)
|
|
33923
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
33924
|
-
var m = o[Symbol.asyncIterator], i;
|
|
33925
|
-
return m ? m.call(o) : (o = typeof __values36 === "function" ? __values36(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
33926
|
-
return this;
|
|
33927
|
-
}, i);
|
|
33928
|
-
function verb(n) {
|
|
33929
|
-
i[n] = o[n] && function(v) {
|
|
33930
|
-
return new Promise(function(resolve, reject) {
|
|
33931
|
-
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
33932
|
-
});
|
|
33933
|
-
};
|
|
33934
|
-
}
|
|
33935
|
-
function settle(resolve, reject, d, v) {
|
|
33936
|
-
Promise.resolve(v).then(function(v2) {
|
|
33937
|
-
resolve({ value: v2, done: d });
|
|
33938
|
-
}, reject);
|
|
33939
|
-
}
|
|
33940
|
-
};
|
|
33941
|
-
__makeTemplateObject36 = function(cooked, raw) {
|
|
33942
|
-
if (Object.defineProperty) {
|
|
33943
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
33944
|
-
} else {
|
|
33945
|
-
cooked.raw = raw;
|
|
33946
|
-
}
|
|
33947
|
-
return cooked;
|
|
33948
|
-
};
|
|
33949
|
-
var __setModuleDefault = Object.create ? function(o, v) {
|
|
33950
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33951
|
-
} : function(o, v) {
|
|
33952
|
-
o["default"] = v;
|
|
33953
|
-
};
|
|
33954
|
-
__importStar36 = function(mod) {
|
|
33955
|
-
if (mod && mod.__esModule)
|
|
33956
|
-
return mod;
|
|
33957
|
-
var result = {};
|
|
33958
|
-
if (mod != null) {
|
|
33959
|
-
for (var k in mod)
|
|
33960
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
33961
|
-
__createBinding37(result, mod, k);
|
|
33962
|
-
}
|
|
33963
|
-
__setModuleDefault(result, mod);
|
|
33964
|
-
return result;
|
|
33965
|
-
};
|
|
33966
|
-
__importDefault36 = function(mod) {
|
|
33967
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
33968
|
-
};
|
|
33969
|
-
__classPrivateFieldGet36 = function(receiver, state, kind, f) {
|
|
33970
|
-
if (kind === "a" && !f)
|
|
33971
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
33972
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
33973
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
33974
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
33975
|
-
};
|
|
33976
|
-
__classPrivateFieldSet36 = function(receiver, state, value, kind, f) {
|
|
33977
|
-
if (kind === "m")
|
|
33978
|
-
throw new TypeError("Private method is not writable");
|
|
33979
|
-
if (kind === "a" && !f)
|
|
33980
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
33981
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
33982
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
33983
|
-
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
33984
|
-
};
|
|
33985
|
-
__classPrivateFieldIn36 = function(state, receiver) {
|
|
33986
|
-
if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function")
|
|
33987
|
-
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
33988
|
-
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
33989
|
-
};
|
|
33990
|
-
exporter("__extends", __extends37);
|
|
33991
|
-
exporter("__assign", __assign37);
|
|
33992
|
-
exporter("__rest", __rest36);
|
|
33993
|
-
exporter("__decorate", __decorate36);
|
|
33994
|
-
exporter("__param", __param36);
|
|
33995
|
-
exporter("__metadata", __metadata36);
|
|
33996
|
-
exporter("__awaiter", __awaiter36);
|
|
33997
|
-
exporter("__generator", __generator36);
|
|
33998
|
-
exporter("__exportStar", __exportStar36);
|
|
33999
|
-
exporter("__createBinding", __createBinding37);
|
|
34000
|
-
exporter("__values", __values36);
|
|
34001
|
-
exporter("__read", __read36);
|
|
34002
|
-
exporter("__spread", __spread36);
|
|
34003
|
-
exporter("__spreadArrays", __spreadArrays36);
|
|
34004
|
-
exporter("__spreadArray", __spreadArray36);
|
|
34005
|
-
exporter("__await", __await36);
|
|
34006
|
-
exporter("__asyncGenerator", __asyncGenerator36);
|
|
34007
|
-
exporter("__asyncDelegator", __asyncDelegator36);
|
|
34008
|
-
exporter("__asyncValues", __asyncValues36);
|
|
34009
|
-
exporter("__makeTemplateObject", __makeTemplateObject36);
|
|
34010
|
-
exporter("__importStar", __importStar36);
|
|
34011
|
-
exporter("__importDefault", __importDefault36);
|
|
34012
|
-
exporter("__classPrivateFieldGet", __classPrivateFieldGet36);
|
|
34013
|
-
exporter("__classPrivateFieldSet", __classPrivateFieldSet36);
|
|
34014
|
-
exporter("__classPrivateFieldIn", __classPrivateFieldIn36);
|
|
34015
|
-
});
|
|
34016
|
-
}
|
|
34017
|
-
});
|
|
34018
|
-
|
|
34019
|
-
// src/modules/recorder.ts
|
|
34020
|
-
function recorder(stream, buffer) {
|
|
34021
|
-
let resolvePromise;
|
|
34022
|
-
const options = {
|
|
34023
|
-
mimeType: "video/webm;codecs=vp9",
|
|
34024
|
-
videoBitsPerSecond: 128e3,
|
|
34025
|
-
audioBitsPerSecond: 64 * 1e3
|
|
34026
|
-
};
|
|
34027
|
-
const mediaRecorder = new MediaRecorder(stream, options);
|
|
34028
|
-
mediaRecorder.ondataavailable = (e) => {
|
|
34029
|
-
if (e.data.size > 0) {
|
|
34030
|
-
buffer.push(e.data);
|
|
34031
|
-
}
|
|
34032
|
-
resolvePromise && resolvePromise();
|
|
34033
|
-
};
|
|
34034
|
-
mediaRecorder.start();
|
|
34035
|
-
function stopRecording() {
|
|
34036
|
-
return new Promise((resolve) => {
|
|
34037
|
-
if (mediaRecorder.state == "recording") {
|
|
34038
|
-
resolvePromise = resolve;
|
|
34039
|
-
mediaRecorder.stop();
|
|
34040
|
-
stream.getTracks().forEach((el) => {
|
|
34041
|
-
el.stop();
|
|
37207
|
+
// node_modules/@aws-sdk/util-defaults-mode-browser/node_modules/tslib/tslib.js
|
|
37208
|
+
var require_tslib36 = __commonJS({
|
|
37209
|
+
"node_modules/@aws-sdk/util-defaults-mode-browser/node_modules/tslib/tslib.js"(exports, module) {
|
|
37210
|
+
var __extends37;
|
|
37211
|
+
var __assign37;
|
|
37212
|
+
var __rest36;
|
|
37213
|
+
var __decorate36;
|
|
37214
|
+
var __param36;
|
|
37215
|
+
var __metadata36;
|
|
37216
|
+
var __awaiter36;
|
|
37217
|
+
var __generator36;
|
|
37218
|
+
var __exportStar36;
|
|
37219
|
+
var __values36;
|
|
37220
|
+
var __read36;
|
|
37221
|
+
var __spread36;
|
|
37222
|
+
var __spreadArrays36;
|
|
37223
|
+
var __spreadArray36;
|
|
37224
|
+
var __await36;
|
|
37225
|
+
var __asyncGenerator36;
|
|
37226
|
+
var __asyncDelegator36;
|
|
37227
|
+
var __asyncValues36;
|
|
37228
|
+
var __makeTemplateObject36;
|
|
37229
|
+
var __importStar36;
|
|
37230
|
+
var __importDefault36;
|
|
37231
|
+
var __classPrivateFieldGet36;
|
|
37232
|
+
var __classPrivateFieldSet36;
|
|
37233
|
+
var __classPrivateFieldIn36;
|
|
37234
|
+
var __createBinding37;
|
|
37235
|
+
(function(factory) {
|
|
37236
|
+
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
37237
|
+
if (typeof define === "function" && define.amd) {
|
|
37238
|
+
define("tslib", ["exports"], function(exports2) {
|
|
37239
|
+
factory(createExporter(root, createExporter(exports2)));
|
|
34042
37240
|
});
|
|
37241
|
+
} else if (typeof module === "object" && typeof module.exports === "object") {
|
|
37242
|
+
factory(createExporter(root, createExporter(module.exports)));
|
|
34043
37243
|
} else {
|
|
34044
|
-
|
|
37244
|
+
factory(createExporter(root));
|
|
34045
37245
|
}
|
|
37246
|
+
function createExporter(exports2, previous) {
|
|
37247
|
+
if (exports2 !== root) {
|
|
37248
|
+
if (typeof Object.create === "function") {
|
|
37249
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
37250
|
+
} else {
|
|
37251
|
+
exports2.__esModule = true;
|
|
37252
|
+
}
|
|
37253
|
+
}
|
|
37254
|
+
return function(id, v) {
|
|
37255
|
+
return exports2[id] = previous ? previous(id, v) : v;
|
|
37256
|
+
};
|
|
37257
|
+
}
|
|
37258
|
+
})(function(exporter) {
|
|
37259
|
+
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
37260
|
+
d.__proto__ = b;
|
|
37261
|
+
} || function(d, b) {
|
|
37262
|
+
for (var p in b)
|
|
37263
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
37264
|
+
d[p] = b[p];
|
|
37265
|
+
};
|
|
37266
|
+
__extends37 = function(d, b) {
|
|
37267
|
+
if (typeof b !== "function" && b !== null)
|
|
37268
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
37269
|
+
extendStatics(d, b);
|
|
37270
|
+
function __() {
|
|
37271
|
+
this.constructor = d;
|
|
37272
|
+
}
|
|
37273
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
37274
|
+
};
|
|
37275
|
+
__assign37 = Object.assign || function(t) {
|
|
37276
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
37277
|
+
s = arguments[i];
|
|
37278
|
+
for (var p in s)
|
|
37279
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37280
|
+
t[p] = s[p];
|
|
37281
|
+
}
|
|
37282
|
+
return t;
|
|
37283
|
+
};
|
|
37284
|
+
__rest36 = function(s, e) {
|
|
37285
|
+
var t = {};
|
|
37286
|
+
for (var p in s)
|
|
37287
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
37288
|
+
t[p] = s[p];
|
|
37289
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
37290
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
37291
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
37292
|
+
t[p[i]] = s[p[i]];
|
|
37293
|
+
}
|
|
37294
|
+
return t;
|
|
37295
|
+
};
|
|
37296
|
+
__decorate36 = function(decorators, target, key, desc) {
|
|
37297
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
37298
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
37299
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
37300
|
+
else
|
|
37301
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
37302
|
+
if (d = decorators[i])
|
|
37303
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
37304
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
37305
|
+
};
|
|
37306
|
+
__param36 = function(paramIndex, decorator) {
|
|
37307
|
+
return function(target, key) {
|
|
37308
|
+
decorator(target, key, paramIndex);
|
|
37309
|
+
};
|
|
37310
|
+
};
|
|
37311
|
+
__metadata36 = function(metadataKey, metadataValue) {
|
|
37312
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
37313
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
37314
|
+
};
|
|
37315
|
+
__awaiter36 = function(thisArg, _arguments, P, generator) {
|
|
37316
|
+
function adopt(value) {
|
|
37317
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
37318
|
+
resolve(value);
|
|
37319
|
+
});
|
|
37320
|
+
}
|
|
37321
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
37322
|
+
function fulfilled(value) {
|
|
37323
|
+
try {
|
|
37324
|
+
step(generator.next(value));
|
|
37325
|
+
} catch (e) {
|
|
37326
|
+
reject(e);
|
|
37327
|
+
}
|
|
37328
|
+
}
|
|
37329
|
+
function rejected(value) {
|
|
37330
|
+
try {
|
|
37331
|
+
step(generator["throw"](value));
|
|
37332
|
+
} catch (e) {
|
|
37333
|
+
reject(e);
|
|
37334
|
+
}
|
|
37335
|
+
}
|
|
37336
|
+
function step(result) {
|
|
37337
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
37338
|
+
}
|
|
37339
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37340
|
+
});
|
|
37341
|
+
};
|
|
37342
|
+
__generator36 = function(thisArg, body) {
|
|
37343
|
+
var _ = { label: 0, sent: function() {
|
|
37344
|
+
if (t[0] & 1)
|
|
37345
|
+
throw t[1];
|
|
37346
|
+
return t[1];
|
|
37347
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
37348
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
37349
|
+
return this;
|
|
37350
|
+
}), g;
|
|
37351
|
+
function verb(n) {
|
|
37352
|
+
return function(v) {
|
|
37353
|
+
return step([n, v]);
|
|
37354
|
+
};
|
|
37355
|
+
}
|
|
37356
|
+
function step(op) {
|
|
37357
|
+
if (f)
|
|
37358
|
+
throw new TypeError("Generator is already executing.");
|
|
37359
|
+
while (_)
|
|
37360
|
+
try {
|
|
37361
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
37362
|
+
return t;
|
|
37363
|
+
if (y = 0, t)
|
|
37364
|
+
op = [op[0] & 2, t.value];
|
|
37365
|
+
switch (op[0]) {
|
|
37366
|
+
case 0:
|
|
37367
|
+
case 1:
|
|
37368
|
+
t = op;
|
|
37369
|
+
break;
|
|
37370
|
+
case 4:
|
|
37371
|
+
_.label++;
|
|
37372
|
+
return { value: op[1], done: false };
|
|
37373
|
+
case 5:
|
|
37374
|
+
_.label++;
|
|
37375
|
+
y = op[1];
|
|
37376
|
+
op = [0];
|
|
37377
|
+
continue;
|
|
37378
|
+
case 7:
|
|
37379
|
+
op = _.ops.pop();
|
|
37380
|
+
_.trys.pop();
|
|
37381
|
+
continue;
|
|
37382
|
+
default:
|
|
37383
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
37384
|
+
_ = 0;
|
|
37385
|
+
continue;
|
|
37386
|
+
}
|
|
37387
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
37388
|
+
_.label = op[1];
|
|
37389
|
+
break;
|
|
37390
|
+
}
|
|
37391
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
37392
|
+
_.label = t[1];
|
|
37393
|
+
t = op;
|
|
37394
|
+
break;
|
|
37395
|
+
}
|
|
37396
|
+
if (t && _.label < t[2]) {
|
|
37397
|
+
_.label = t[2];
|
|
37398
|
+
_.ops.push(op);
|
|
37399
|
+
break;
|
|
37400
|
+
}
|
|
37401
|
+
if (t[2])
|
|
37402
|
+
_.ops.pop();
|
|
37403
|
+
_.trys.pop();
|
|
37404
|
+
continue;
|
|
37405
|
+
}
|
|
37406
|
+
op = body.call(thisArg, _);
|
|
37407
|
+
} catch (e) {
|
|
37408
|
+
op = [6, e];
|
|
37409
|
+
y = 0;
|
|
37410
|
+
} finally {
|
|
37411
|
+
f = t = 0;
|
|
37412
|
+
}
|
|
37413
|
+
if (op[0] & 5)
|
|
37414
|
+
throw op[1];
|
|
37415
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
37416
|
+
}
|
|
37417
|
+
};
|
|
37418
|
+
__exportStar36 = function(m, o) {
|
|
37419
|
+
for (var p in m)
|
|
37420
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
37421
|
+
__createBinding37(o, m, p);
|
|
37422
|
+
};
|
|
37423
|
+
__createBinding37 = Object.create ? function(o, m, k, k2) {
|
|
37424
|
+
if (k2 === void 0)
|
|
37425
|
+
k2 = k;
|
|
37426
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
37427
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
37428
|
+
desc = { enumerable: true, get: function() {
|
|
37429
|
+
return m[k];
|
|
37430
|
+
} };
|
|
37431
|
+
}
|
|
37432
|
+
Object.defineProperty(o, k2, desc);
|
|
37433
|
+
} : function(o, m, k, k2) {
|
|
37434
|
+
if (k2 === void 0)
|
|
37435
|
+
k2 = k;
|
|
37436
|
+
o[k2] = m[k];
|
|
37437
|
+
};
|
|
37438
|
+
__values36 = function(o) {
|
|
37439
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
37440
|
+
if (m)
|
|
37441
|
+
return m.call(o);
|
|
37442
|
+
if (o && typeof o.length === "number")
|
|
37443
|
+
return {
|
|
37444
|
+
next: function() {
|
|
37445
|
+
if (o && i >= o.length)
|
|
37446
|
+
o = void 0;
|
|
37447
|
+
return { value: o && o[i++], done: !o };
|
|
37448
|
+
}
|
|
37449
|
+
};
|
|
37450
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37451
|
+
};
|
|
37452
|
+
__read36 = function(o, n) {
|
|
37453
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
37454
|
+
if (!m)
|
|
37455
|
+
return o;
|
|
37456
|
+
var i = m.call(o), r, ar = [], e;
|
|
37457
|
+
try {
|
|
37458
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
37459
|
+
ar.push(r.value);
|
|
37460
|
+
} catch (error) {
|
|
37461
|
+
e = { error };
|
|
37462
|
+
} finally {
|
|
37463
|
+
try {
|
|
37464
|
+
if (r && !r.done && (m = i["return"]))
|
|
37465
|
+
m.call(i);
|
|
37466
|
+
} finally {
|
|
37467
|
+
if (e)
|
|
37468
|
+
throw e.error;
|
|
37469
|
+
}
|
|
37470
|
+
}
|
|
37471
|
+
return ar;
|
|
37472
|
+
};
|
|
37473
|
+
__spread36 = function() {
|
|
37474
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
37475
|
+
ar = ar.concat(__read36(arguments[i]));
|
|
37476
|
+
return ar;
|
|
37477
|
+
};
|
|
37478
|
+
__spreadArrays36 = function() {
|
|
37479
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
37480
|
+
s += arguments[i].length;
|
|
37481
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
37482
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
37483
|
+
r[k] = a[j];
|
|
37484
|
+
return r;
|
|
37485
|
+
};
|
|
37486
|
+
__spreadArray36 = function(to, from, pack) {
|
|
37487
|
+
if (pack || arguments.length === 2)
|
|
37488
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
37489
|
+
if (ar || !(i in from)) {
|
|
37490
|
+
if (!ar)
|
|
37491
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
37492
|
+
ar[i] = from[i];
|
|
37493
|
+
}
|
|
37494
|
+
}
|
|
37495
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37496
|
+
};
|
|
37497
|
+
__await36 = function(v) {
|
|
37498
|
+
return this instanceof __await36 ? (this.v = v, this) : new __await36(v);
|
|
37499
|
+
};
|
|
37500
|
+
__asyncGenerator36 = function(thisArg, _arguments, generator) {
|
|
37501
|
+
if (!Symbol.asyncIterator)
|
|
37502
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
37503
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
37504
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
37505
|
+
return this;
|
|
37506
|
+
}, i;
|
|
37507
|
+
function verb(n) {
|
|
37508
|
+
if (g[n])
|
|
37509
|
+
i[n] = function(v) {
|
|
37510
|
+
return new Promise(function(a, b) {
|
|
37511
|
+
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
37512
|
+
});
|
|
37513
|
+
};
|
|
37514
|
+
}
|
|
37515
|
+
function resume(n, v) {
|
|
37516
|
+
try {
|
|
37517
|
+
step(g[n](v));
|
|
37518
|
+
} catch (e) {
|
|
37519
|
+
settle(q[0][3], e);
|
|
37520
|
+
}
|
|
37521
|
+
}
|
|
37522
|
+
function step(r) {
|
|
37523
|
+
r.value instanceof __await36 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
37524
|
+
}
|
|
37525
|
+
function fulfill(value) {
|
|
37526
|
+
resume("next", value);
|
|
37527
|
+
}
|
|
37528
|
+
function reject(value) {
|
|
37529
|
+
resume("throw", value);
|
|
37530
|
+
}
|
|
37531
|
+
function settle(f, v) {
|
|
37532
|
+
if (f(v), q.shift(), q.length)
|
|
37533
|
+
resume(q[0][0], q[0][1]);
|
|
37534
|
+
}
|
|
37535
|
+
};
|
|
37536
|
+
__asyncDelegator36 = function(o) {
|
|
37537
|
+
var i, p;
|
|
37538
|
+
return i = {}, verb("next"), verb("throw", function(e) {
|
|
37539
|
+
throw e;
|
|
37540
|
+
}), verb("return"), i[Symbol.iterator] = function() {
|
|
37541
|
+
return this;
|
|
37542
|
+
}, i;
|
|
37543
|
+
function verb(n, f) {
|
|
37544
|
+
i[n] = o[n] ? function(v) {
|
|
37545
|
+
return (p = !p) ? { value: __await36(o[n](v)), done: n === "return" } : f ? f(v) : v;
|
|
37546
|
+
} : f;
|
|
37547
|
+
}
|
|
37548
|
+
};
|
|
37549
|
+
__asyncValues36 = function(o) {
|
|
37550
|
+
if (!Symbol.asyncIterator)
|
|
37551
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
37552
|
+
var m = o[Symbol.asyncIterator], i;
|
|
37553
|
+
return m ? m.call(o) : (o = typeof __values36 === "function" ? __values36(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
37554
|
+
return this;
|
|
37555
|
+
}, i);
|
|
37556
|
+
function verb(n) {
|
|
37557
|
+
i[n] = o[n] && function(v) {
|
|
37558
|
+
return new Promise(function(resolve, reject) {
|
|
37559
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
37560
|
+
});
|
|
37561
|
+
};
|
|
37562
|
+
}
|
|
37563
|
+
function settle(resolve, reject, d, v) {
|
|
37564
|
+
Promise.resolve(v).then(function(v2) {
|
|
37565
|
+
resolve({ value: v2, done: d });
|
|
37566
|
+
}, reject);
|
|
37567
|
+
}
|
|
37568
|
+
};
|
|
37569
|
+
__makeTemplateObject36 = function(cooked, raw) {
|
|
37570
|
+
if (Object.defineProperty) {
|
|
37571
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
37572
|
+
} else {
|
|
37573
|
+
cooked.raw = raw;
|
|
37574
|
+
}
|
|
37575
|
+
return cooked;
|
|
37576
|
+
};
|
|
37577
|
+
var __setModuleDefault = Object.create ? function(o, v) {
|
|
37578
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37579
|
+
} : function(o, v) {
|
|
37580
|
+
o["default"] = v;
|
|
37581
|
+
};
|
|
37582
|
+
__importStar36 = function(mod) {
|
|
37583
|
+
if (mod && mod.__esModule)
|
|
37584
|
+
return mod;
|
|
37585
|
+
var result = {};
|
|
37586
|
+
if (mod != null) {
|
|
37587
|
+
for (var k in mod)
|
|
37588
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
37589
|
+
__createBinding37(result, mod, k);
|
|
37590
|
+
}
|
|
37591
|
+
__setModuleDefault(result, mod);
|
|
37592
|
+
return result;
|
|
37593
|
+
};
|
|
37594
|
+
__importDefault36 = function(mod) {
|
|
37595
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
37596
|
+
};
|
|
37597
|
+
__classPrivateFieldGet36 = function(receiver, state, kind, f) {
|
|
37598
|
+
if (kind === "a" && !f)
|
|
37599
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
37600
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
37601
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
37602
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
37603
|
+
};
|
|
37604
|
+
__classPrivateFieldSet36 = function(receiver, state, value, kind, f) {
|
|
37605
|
+
if (kind === "m")
|
|
37606
|
+
throw new TypeError("Private method is not writable");
|
|
37607
|
+
if (kind === "a" && !f)
|
|
37608
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
37609
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
37610
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
37611
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
37612
|
+
};
|
|
37613
|
+
__classPrivateFieldIn36 = function(state, receiver) {
|
|
37614
|
+
if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function")
|
|
37615
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
37616
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
37617
|
+
};
|
|
37618
|
+
exporter("__extends", __extends37);
|
|
37619
|
+
exporter("__assign", __assign37);
|
|
37620
|
+
exporter("__rest", __rest36);
|
|
37621
|
+
exporter("__decorate", __decorate36);
|
|
37622
|
+
exporter("__param", __param36);
|
|
37623
|
+
exporter("__metadata", __metadata36);
|
|
37624
|
+
exporter("__awaiter", __awaiter36);
|
|
37625
|
+
exporter("__generator", __generator36);
|
|
37626
|
+
exporter("__exportStar", __exportStar36);
|
|
37627
|
+
exporter("__createBinding", __createBinding37);
|
|
37628
|
+
exporter("__values", __values36);
|
|
37629
|
+
exporter("__read", __read36);
|
|
37630
|
+
exporter("__spread", __spread36);
|
|
37631
|
+
exporter("__spreadArrays", __spreadArrays36);
|
|
37632
|
+
exporter("__spreadArray", __spreadArray36);
|
|
37633
|
+
exporter("__await", __await36);
|
|
37634
|
+
exporter("__asyncGenerator", __asyncGenerator36);
|
|
37635
|
+
exporter("__asyncDelegator", __asyncDelegator36);
|
|
37636
|
+
exporter("__asyncValues", __asyncValues36);
|
|
37637
|
+
exporter("__makeTemplateObject", __makeTemplateObject36);
|
|
37638
|
+
exporter("__importStar", __importStar36);
|
|
37639
|
+
exporter("__importDefault", __importDefault36);
|
|
37640
|
+
exporter("__classPrivateFieldGet", __classPrivateFieldGet36);
|
|
37641
|
+
exporter("__classPrivateFieldSet", __classPrivateFieldSet36);
|
|
37642
|
+
exporter("__classPrivateFieldIn", __classPrivateFieldIn36);
|
|
34046
37643
|
});
|
|
34047
37644
|
}
|
|
34048
|
-
|
|
34049
|
-
}
|
|
37645
|
+
});
|
|
34050
37646
|
|
|
34051
37647
|
// src/modules/startCameraCapture.ts
|
|
37648
|
+
var import_recordrtc = __toESM(require_RecordRTC());
|
|
34052
37649
|
async function startCameraCapture(buffer, options = { cameraId: void 0, microphoneId: void 0 }, videoOptions = { width: 640, height: 480 }) {
|
|
34053
37650
|
const { cameraId, microphoneId } = options;
|
|
34054
37651
|
const constraints = {
|
|
@@ -34061,7 +37658,23 @@ async function startCameraCapture(buffer, options = { cameraId: void 0, micropho
|
|
|
34061
37658
|
}
|
|
34062
37659
|
};
|
|
34063
37660
|
const cameraStream = await navigator.mediaDevices.getUserMedia(constraints);
|
|
34064
|
-
const
|
|
37661
|
+
const recorder = new import_recordrtc.RecordRTCPromisesHandler(cameraStream, {
|
|
37662
|
+
type: "video"
|
|
37663
|
+
});
|
|
37664
|
+
recorder.startRecording();
|
|
37665
|
+
const stopCameraRecording = async () => {
|
|
37666
|
+
await recorder.stopRecording();
|
|
37667
|
+
const blob = await recorder.getBlob();
|
|
37668
|
+
(0, import_recordrtc.getSeekableBlob)(blob, function(seekableBlob) {
|
|
37669
|
+
recorder.destroy();
|
|
37670
|
+
buffer.push(seekableBlob);
|
|
37671
|
+
console.log(buffer);
|
|
37672
|
+
console.log(seekableBlob);
|
|
37673
|
+
cameraStream.getTracks().forEach((el) => {
|
|
37674
|
+
el.stop();
|
|
37675
|
+
});
|
|
37676
|
+
});
|
|
37677
|
+
};
|
|
34065
37678
|
return { cameraStream, stopCameraRecording };
|
|
34066
37679
|
}
|
|
34067
37680
|
|
|
@@ -34069,17 +37682,17 @@ async function startCameraCapture(buffer, options = { cameraId: void 0, micropho
|
|
|
34069
37682
|
var import_mp3 = __toESM(require_mp3());
|
|
34070
37683
|
var stopRecord;
|
|
34071
37684
|
function startAudioCapture() {
|
|
34072
|
-
const
|
|
37685
|
+
const recorder = new import_mp3.default({
|
|
34073
37686
|
bitRate: 128
|
|
34074
37687
|
});
|
|
34075
37688
|
function start() {
|
|
34076
|
-
|
|
37689
|
+
recorder.start().then(() => {
|
|
34077
37690
|
}).catch((e) => {
|
|
34078
37691
|
console.error(e);
|
|
34079
37692
|
});
|
|
34080
37693
|
}
|
|
34081
37694
|
async function stop() {
|
|
34082
|
-
const response = await
|
|
37695
|
+
const response = await recorder.stop().getMp3().then(async ([buffer, blob]) => {
|
|
34083
37696
|
return { buffer, blob };
|
|
34084
37697
|
}).catch((e) => {
|
|
34085
37698
|
alert("We could not retrieve your message");
|
|
@@ -34091,6 +37704,9 @@ function startAudioCapture() {
|
|
|
34091
37704
|
return { start, stop };
|
|
34092
37705
|
}
|
|
34093
37706
|
|
|
37707
|
+
// src/modules/startScreenCapture.ts
|
|
37708
|
+
var import_recordrtc2 = __toESM(require_RecordRTC());
|
|
37709
|
+
|
|
34094
37710
|
// src/errors/errors.ts
|
|
34095
37711
|
var SCRIPT_NOT_CALLED_INSIDE_BODY = "script_not_called_inside_body";
|
|
34096
37712
|
var INCOMPATIBLE_NAVIGATOR = "incompatible_navigator";
|
|
@@ -34130,7 +37746,21 @@ async function startScreenCapture(buffer, options) {
|
|
|
34130
37746
|
});
|
|
34131
37747
|
throw NOT_SHARED_FIRST_SCREEN;
|
|
34132
37748
|
}
|
|
34133
|
-
const
|
|
37749
|
+
const recorder = new import_recordrtc2.RecordRTCPromisesHandler(screenStream, {
|
|
37750
|
+
type: "video"
|
|
37751
|
+
});
|
|
37752
|
+
recorder.startRecording();
|
|
37753
|
+
const stopScreenRecorder = async () => {
|
|
37754
|
+
await recorder.stopRecording();
|
|
37755
|
+
const blob = await recorder.getBlob();
|
|
37756
|
+
(0, import_recordrtc2.getSeekableBlob)(blob, function(seekableBlob) {
|
|
37757
|
+
recorder.destroy();
|
|
37758
|
+
buffer.push(seekableBlob);
|
|
37759
|
+
screenStream.getTracks().forEach((el) => {
|
|
37760
|
+
el.stop();
|
|
37761
|
+
});
|
|
37762
|
+
});
|
|
37763
|
+
};
|
|
34134
37764
|
return { screenStream, stopScreenRecorder };
|
|
34135
37765
|
}
|
|
34136
37766
|
|
|
@@ -50179,3 +53809,283 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
50179
53809
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50180
53810
|
PERFORMANCE OF THIS SOFTWARE.
|
|
50181
53811
|
***************************************************************************** */
|
|
53812
|
+
/**
|
|
53813
|
+
* CanvasRecorder is a standalone class used by {@link RecordRTC} to bring HTML5-Canvas recording into video WebM. It uses HTML2Canvas library and runs top over {@link Whammy}.
|
|
53814
|
+
* @summary HTML2Canvas recording into video WebM.
|
|
53815
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53816
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53817
|
+
* @typedef CanvasRecorder
|
|
53818
|
+
* @class
|
|
53819
|
+
* @example
|
|
53820
|
+
* var recorder = new CanvasRecorder(htmlElement, { disableLogs: true, useWhammyRecorder: true });
|
|
53821
|
+
* recorder.record();
|
|
53822
|
+
* recorder.stop(function(blob) {
|
|
53823
|
+
* video.src = URL.createObjectURL(blob);
|
|
53824
|
+
* });
|
|
53825
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53826
|
+
* @param {HTMLElement} htmlElement - querySelector/getElementById/getElementsByTagName[0]/etc.
|
|
53827
|
+
* @param {object} config - {disableLogs:true, initCallback: function}
|
|
53828
|
+
*/
|
|
53829
|
+
/**
|
|
53830
|
+
* DiskStorage is a standalone object used by {@link RecordRTC} to store recorded blobs in IndexedDB storage.
|
|
53831
|
+
* @summary Writing blobs into IndexedDB.
|
|
53832
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53833
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53834
|
+
* @example
|
|
53835
|
+
* DiskStorage.Store({
|
|
53836
|
+
* audioBlob: yourAudioBlob,
|
|
53837
|
+
* videoBlob: yourVideoBlob,
|
|
53838
|
+
* gifBlob : yourGifBlob
|
|
53839
|
+
* });
|
|
53840
|
+
* DiskStorage.Fetch(function(dataURL, type) {
|
|
53841
|
+
* if(type === 'audioBlob') { }
|
|
53842
|
+
* if(type === 'videoBlob') { }
|
|
53843
|
+
* if(type === 'gifBlob') { }
|
|
53844
|
+
* });
|
|
53845
|
+
* // DiskStorage.dataStoreName = 'recordRTC';
|
|
53846
|
+
* // DiskStorage.onError = function(error) { };
|
|
53847
|
+
* @property {function} init - This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.
|
|
53848
|
+
* @property {function} Fetch - This method fetches stored blobs from IndexedDB.
|
|
53849
|
+
* @property {function} Store - This method stores blobs in IndexedDB.
|
|
53850
|
+
* @property {function} onError - This function is invoked for any known/unknown error.
|
|
53851
|
+
* @property {string} dataStoreName - Name of the ObjectStore created in IndexedDB storage.
|
|
53852
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53853
|
+
*/
|
|
53854
|
+
/**
|
|
53855
|
+
* GifRecorder is standalone calss used by {@link RecordRTC} to record video or canvas into animated gif.
|
|
53856
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53857
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53858
|
+
* @typedef GifRecorder
|
|
53859
|
+
* @class
|
|
53860
|
+
* @example
|
|
53861
|
+
* var recorder = new GifRecorder(mediaStream || canvas || context, { onGifPreview: function, onGifRecordingStarted: function, width: 1280, height: 720, frameRate: 200, quality: 10 });
|
|
53862
|
+
* recorder.record();
|
|
53863
|
+
* recorder.stop(function(blob) {
|
|
53864
|
+
* img.src = URL.createObjectURL(blob);
|
|
53865
|
+
* });
|
|
53866
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53867
|
+
* @param {MediaStream} mediaStream - MediaStream object or HTMLCanvasElement or CanvasRenderingContext2D.
|
|
53868
|
+
* @param {object} config - {disableLogs:true, initCallback: function, width: 320, height: 240, frameRate: 200, quality: 10}
|
|
53869
|
+
*/
|
|
53870
|
+
/**
|
|
53871
|
+
* MRecordRTC runs on top of {@link RecordRTC} to bring multiple recordings in a single place, by providing simple API.
|
|
53872
|
+
* @summary MRecordRTC stands for "Multiple-RecordRTC".
|
|
53873
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53874
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53875
|
+
* @typedef MRecordRTC
|
|
53876
|
+
* @class
|
|
53877
|
+
* @example
|
|
53878
|
+
* var recorder = new MRecordRTC();
|
|
53879
|
+
* recorder.addStream(MediaStream);
|
|
53880
|
+
* recorder.mediaType = {
|
|
53881
|
+
* audio: true, // or StereoAudioRecorder or MediaStreamRecorder
|
|
53882
|
+
* video: true, // or WhammyRecorder or MediaStreamRecorder or WebAssemblyRecorder or CanvasRecorder
|
|
53883
|
+
* gif: true // or GifRecorder
|
|
53884
|
+
* };
|
|
53885
|
+
* // mimeType is optional and should be set only in advance cases.
|
|
53886
|
+
* recorder.mimeType = {
|
|
53887
|
+
* audio: 'audio/wav',
|
|
53888
|
+
* video: 'video/webm',
|
|
53889
|
+
* gif: 'image/gif'
|
|
53890
|
+
* };
|
|
53891
|
+
* recorder.startRecording();
|
|
53892
|
+
* @see For further information:
|
|
53893
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC/tree/master/MRecordRTC|MRecordRTC Source Code}
|
|
53894
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
53895
|
+
* @requires {@link RecordRTC}
|
|
53896
|
+
*/
|
|
53897
|
+
/**
|
|
53898
|
+
* MediaStreamRecorder is an abstraction layer for {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}. It is used by {@link RecordRTC} to record MediaStream(s) in both Chrome and Firefox.
|
|
53899
|
+
* @summary Runs top over {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}.
|
|
53900
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53901
|
+
* @author {@link https://github.com/muaz-khan|Muaz Khan}
|
|
53902
|
+
* @typedef MediaStreamRecorder
|
|
53903
|
+
* @class
|
|
53904
|
+
* @example
|
|
53905
|
+
* var config = {
|
|
53906
|
+
* mimeType: 'video/webm', // vp8, vp9, h264, mkv, opus/vorbis
|
|
53907
|
+
* audioBitsPerSecond : 256 * 8 * 1024,
|
|
53908
|
+
* videoBitsPerSecond : 256 * 8 * 1024,
|
|
53909
|
+
* bitsPerSecond: 256 * 8 * 1024, // if this is provided, skip above two
|
|
53910
|
+
* checkForInactiveTracks: true,
|
|
53911
|
+
* timeSlice: 1000, // concatenate intervals based blobs
|
|
53912
|
+
* ondataavailable: function() {} // get intervals based blobs
|
|
53913
|
+
* }
|
|
53914
|
+
* var recorder = new MediaStreamRecorder(mediaStream, config);
|
|
53915
|
+
* recorder.record();
|
|
53916
|
+
* recorder.stop(function(blob) {
|
|
53917
|
+
* video.src = URL.createObjectURL(blob);
|
|
53918
|
+
*
|
|
53919
|
+
* // or
|
|
53920
|
+
* var blob = recorder.blob;
|
|
53921
|
+
* });
|
|
53922
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53923
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
53924
|
+
* @param {object} config - {disableLogs:true, initCallback: function, mimeType: "video/webm", timeSlice: 1000}
|
|
53925
|
+
* @throws Will throw an error if first argument "MediaStream" is missing. Also throws error if "MediaRecorder API" are not supported by the browser.
|
|
53926
|
+
*/
|
|
53927
|
+
/**
|
|
53928
|
+
* MultiStreamRecorder can record multiple videos in single container.
|
|
53929
|
+
* @summary Multi-videos recorder.
|
|
53930
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53931
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53932
|
+
* @typedef MultiStreamRecorder
|
|
53933
|
+
* @class
|
|
53934
|
+
* @example
|
|
53935
|
+
* var options = {
|
|
53936
|
+
* mimeType: 'video/webm'
|
|
53937
|
+
* }
|
|
53938
|
+
* var recorder = new MultiStreamRecorder(ArrayOfMediaStreams, options);
|
|
53939
|
+
* recorder.record();
|
|
53940
|
+
* recorder.stop(function(blob) {
|
|
53941
|
+
* video.src = URL.createObjectURL(blob);
|
|
53942
|
+
*
|
|
53943
|
+
* // or
|
|
53944
|
+
* var blob = recorder.blob;
|
|
53945
|
+
* });
|
|
53946
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53947
|
+
* @param {MediaStreams} mediaStreams - Array of MediaStreams.
|
|
53948
|
+
* @param {object} config - {disableLogs:true, frameInterval: 1, mimeType: "video/webm"}
|
|
53949
|
+
*/
|
|
53950
|
+
/**
|
|
53951
|
+
* RecordRTCPromisesHandler adds promises support in {@link RecordRTC}. Try a {@link https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/RecordRTCPromisesHandler.html|demo here}
|
|
53952
|
+
* @summary Promises for {@link RecordRTC}
|
|
53953
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53954
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53955
|
+
* @typedef RecordRTCPromisesHandler
|
|
53956
|
+
* @class
|
|
53957
|
+
* @example
|
|
53958
|
+
* var recorder = new RecordRTCPromisesHandler(mediaStream, options);
|
|
53959
|
+
* recorder.startRecording()
|
|
53960
|
+
* .then(successCB)
|
|
53961
|
+
* .catch(errorCB);
|
|
53962
|
+
* // Note: You can access all RecordRTC API using "recorder.recordRTC" e.g.
|
|
53963
|
+
* recorder.recordRTC.onStateChanged = function(state) {};
|
|
53964
|
+
* recorder.recordRTC.setRecordingDuration(5000);
|
|
53965
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53966
|
+
* @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.
|
|
53967
|
+
* @param {object} config - {type:"video", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
|
|
53968
|
+
* @throws Will throw an error if "new" keyword is not used to initiate "RecordRTCPromisesHandler". Also throws error if first argument "MediaStream" is missing.
|
|
53969
|
+
* @requires {@link RecordRTC}
|
|
53970
|
+
*/
|
|
53971
|
+
/**
|
|
53972
|
+
* StereoAudioRecorder is a standalone class used by {@link RecordRTC} to bring "stereo" audio-recording in chrome.
|
|
53973
|
+
* @summary JavaScript standalone object for stereo audio recording.
|
|
53974
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53975
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53976
|
+
* @typedef StereoAudioRecorder
|
|
53977
|
+
* @class
|
|
53978
|
+
* @example
|
|
53979
|
+
* var recorder = new StereoAudioRecorder(MediaStream, {
|
|
53980
|
+
* sampleRate: 44100,
|
|
53981
|
+
* bufferSize: 4096
|
|
53982
|
+
* });
|
|
53983
|
+
* recorder.record();
|
|
53984
|
+
* recorder.stop(function(blob) {
|
|
53985
|
+
* video.src = URL.createObjectURL(blob);
|
|
53986
|
+
* });
|
|
53987
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53988
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
53989
|
+
* @param {object} config - {sampleRate: 44100, bufferSize: 4096, numberOfAudioChannels: 1, etc.}
|
|
53990
|
+
*/
|
|
53991
|
+
/**
|
|
53992
|
+
* Storage is a standalone object used by {@link RecordRTC} to store reusable objects e.g. "new AudioContext".
|
|
53993
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
53994
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
53995
|
+
* @example
|
|
53996
|
+
* Storage.AudioContext === webkitAudioContext
|
|
53997
|
+
* @property {webkitAudioContext} AudioContext - Keeps a reference to AudioContext object.
|
|
53998
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
53999
|
+
*/
|
|
54000
|
+
/**
|
|
54001
|
+
* WebAssemblyRecorder lets you create webm videos in JavaScript via WebAssembly. The library consumes raw RGBA32 buffers (4 bytes per pixel) and turns them into a webm video with the given framerate and quality. This makes it compatible out-of-the-box with ImageData from a CANVAS. With realtime mode you can also use webm-wasm for streaming webm videos.
|
|
54002
|
+
* @summary Video recording feature in Chrome, Firefox and maybe Edge.
|
|
54003
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
54004
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
54005
|
+
* @typedef WebAssemblyRecorder
|
|
54006
|
+
* @class
|
|
54007
|
+
* @example
|
|
54008
|
+
* var recorder = new WebAssemblyRecorder(mediaStream);
|
|
54009
|
+
* recorder.record();
|
|
54010
|
+
* recorder.stop(function(blob) {
|
|
54011
|
+
* video.src = URL.createObjectURL(blob);
|
|
54012
|
+
* });
|
|
54013
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
54014
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
54015
|
+
* @param {object} config - {webAssemblyPath:'webm-wasm.wasm',workerPath: 'webm-worker.js', frameRate: 30, width: 1920, height: 1080, bitrate: 1024, realtime: true}
|
|
54016
|
+
*/
|
|
54017
|
+
/**
|
|
54018
|
+
* Whammy is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It is written by {@link https://github.com/antimatter15|antimatter15}
|
|
54019
|
+
* @summary A real time javascript webm encoder based on a canvas hack.
|
|
54020
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
54021
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
54022
|
+
* @typedef Whammy
|
|
54023
|
+
* @class
|
|
54024
|
+
* @example
|
|
54025
|
+
* var recorder = new Whammy().Video(15);
|
|
54026
|
+
* recorder.add(context || canvas || dataURL);
|
|
54027
|
+
* var output = recorder.compile();
|
|
54028
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
54029
|
+
*/
|
|
54030
|
+
/**
|
|
54031
|
+
* WhammyRecorder is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It runs top over {@link Whammy}.
|
|
54032
|
+
* @summary Video recording feature in Chrome.
|
|
54033
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
54034
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
54035
|
+
* @typedef WhammyRecorder
|
|
54036
|
+
* @class
|
|
54037
|
+
* @example
|
|
54038
|
+
* var recorder = new WhammyRecorder(mediaStream);
|
|
54039
|
+
* recorder.record();
|
|
54040
|
+
* recorder.stop(function(blob) {
|
|
54041
|
+
* video.src = URL.createObjectURL(blob);
|
|
54042
|
+
* });
|
|
54043
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
54044
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
54045
|
+
* @param {object} config - {disableLogs: true, initCallback: function, video: HTMLVideoElement, etc.}
|
|
54046
|
+
*/
|
|
54047
|
+
/**
|
|
54048
|
+
* {@link GetRecorderType} is an inner/private helper for {@link RecordRTC}.
|
|
54049
|
+
* @summary It returns best recorder-type available for your browser.
|
|
54050
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
54051
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
54052
|
+
* @typedef GetRecorderType
|
|
54053
|
+
* @class
|
|
54054
|
+
* @example
|
|
54055
|
+
* var RecorderType = GetRecorderType(options);
|
|
54056
|
+
* var recorder = new RecorderType(options);
|
|
54057
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
54058
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
54059
|
+
* @param {object} config - {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
|
|
54060
|
+
*/
|
|
54061
|
+
/**
|
|
54062
|
+
* {@link RecordRTCConfiguration} is an inner/private helper for {@link RecordRTC}.
|
|
54063
|
+
* @summary It configures the 2nd parameter passed over {@link RecordRTC} and returns a valid "config" object.
|
|
54064
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
54065
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
54066
|
+
* @typedef RecordRTCConfiguration
|
|
54067
|
+
* @class
|
|
54068
|
+
* @example
|
|
54069
|
+
* var options = RecordRTCConfiguration(mediaStream, options);
|
|
54070
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
54071
|
+
* @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
|
|
54072
|
+
* @param {object} config - {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, getNativeBlob:true, etc.}
|
|
54073
|
+
*/
|
|
54074
|
+
/**
|
|
54075
|
+
* {@link https://github.com/muaz-khan/RecordRTC|RecordRTC} is a WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
|
|
54076
|
+
* @summary Record audio, video or screen inside the browser.
|
|
54077
|
+
* @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
|
|
54078
|
+
* @author {@link https://MuazKhan.com|Muaz Khan}
|
|
54079
|
+
* @typedef RecordRTC
|
|
54080
|
+
* @class
|
|
54081
|
+
* @example
|
|
54082
|
+
* var recorder = RecordRTC(mediaStream or [arrayOfMediaStream], {
|
|
54083
|
+
* type: 'video', // audio or video or gif or canvas
|
|
54084
|
+
* recorderType: MediaStreamRecorder || CanvasRecorder || StereoAudioRecorder || Etc
|
|
54085
|
+
* });
|
|
54086
|
+
* recorder.startRecording();
|
|
54087
|
+
* @see For further information:
|
|
54088
|
+
* @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
|
|
54089
|
+
* @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.
|
|
54090
|
+
* @param {object} config - {type:"video", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, desiredSampRate: 16000, video: HTMLVideoElement, etc.}
|
|
54091
|
+
*/
|