recordrtc.23a12127.js 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import{c as A}from"./@vueup/vue-quill.21cd2cdd.js";var Oe={exports:{}};(function(Te){/**
  2. * {@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.
  3. * @summary Record audio, video or screen inside the browser.
  4. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  5. * @author {@link https://MuazKhan.com|Muaz Khan}
  6. * @typedef RecordRTC
  7. * @class
  8. * @example
  9. * var recorder = RecordRTC(mediaStream or [arrayOfMediaStream], {
  10. * type: 'video', // audio or video or gif or canvas
  11. * recorderType: MediaStreamRecorder || CanvasRecorder || StereoAudioRecorder || Etc
  12. * });
  13. * recorder.startRecording();
  14. * @see For further information:
  15. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  16. * @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.
  17. * @param {object} config - {type:"video", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, desiredSampRate: 16000, video: HTMLVideoElement, etc.}
  18. */function S(i,e){if(!i)throw"First parameter is required.";e=e||{type:"video"},e=new ke(i,e);var t=this;function a(o){return e.disableLogs||console.log("RecordRTC version: ",t.version),o&&(e=new ke(i,o)),e.disableLogs||console.log("started recording "+e.type+" stream."),c?(c.clearRecordedData(),c.record(),g("recording"),t.recordingDuration&&l(),t):(s(function(){t.recordingDuration&&l()}),t)}function s(o){o&&(e.initCallback=function(){o(),o=e.initCallback=null});var m=new Ee(i,e);c=new m(i,e),c.record(),g("recording"),e.disableLogs||console.log("Initialized recorderType:",c.constructor.name,"for output-type:",e.type)}function d(o){if(o=o||function(){},!c){v();return}if(t.state==="paused"){t.resumeRecording(),setTimeout(function(){d(o)},1);return}t.state!=="recording"&&!e.disableLogs&&console.warn('Recording state should be: "recording", however current state is: ',t.state),e.disableLogs||console.log("Stopped recording "+e.type+" stream."),e.type!=="gif"?c.stop(m):(c.stop(),m()),g("stopped");function m(C){if(!c){typeof o.call=="function"?o.call(t,""):o("");return}Object.keys(c).forEach(function(w){typeof c[w]!="function"&&(t[w]=c[w])});var n=c.blob;if(!n)if(C)c.blob=n=C;else throw"Recording failed.";if(n&&!e.disableLogs&&console.log(n.type,"->",ge(n.size)),o){var u;try{u=U.createObjectURL(n)}catch(w){}typeof o.call=="function"?o.call(t,u):o(u)}!e.autoWriteToDisk||b(function(w){var y={};y[e.type+"Blob"]=w,G.Store(y)})}}function f(){if(!c){v();return}if(t.state!=="recording"){e.disableLogs||console.warn("Unable to pause the recording. Recording state: ",t.state);return}g("paused"),c.pause(),e.disableLogs||console.log("Paused recording.")}function r(){if(!c){v();return}if(t.state!=="paused"){e.disableLogs||console.warn("Unable to resume the recording. Recording state: ",t.state);return}g("recording"),c.resume(),e.disableLogs||console.log("Resumed recording.")}function h(o){postMessage(new FileReaderSync().readAsDataURL(o))}function b(o,m){if(!o)throw"Pass a callback function over getDataURL.";var C=m?m.blob:(c||{}).blob;if(!C){e.disableLogs||console.warn("Blob encoder did not finish its job yet."),setTimeout(function(){b(o,m)},1e3);return}if(typeof Worker!="undefined"&&!navigator.mozGetUserMedia){var n=w(h);n.onmessage=function(y){o(y.data)},n.postMessage(C)}else{var u=new FileReader;u.readAsDataURL(C),u.onload=function(y){o(y.target.result)}}function w(y){try{var L=U.createObjectURL(new Blob([y.toString(),"this.onmessage = function (eee) {"+y.name+"(eee.data);}"],{type:"application/javascript"})),k=new Worker(L);return U.revokeObjectURL(L),k}catch(I){}}}function l(o){if(o=o||0,t.state==="paused"){setTimeout(function(){l(o)},1e3);return}if(t.state!=="stopped"){if(o>=t.recordingDuration){d(t.onRecordingStopped);return}o+=1e3,setTimeout(function(){l(o)},1e3)}}function g(o){!t||(t.state=o,typeof t.onStateChanged.call=="function"?t.onStateChanged.call(t,o):t.onStateChanged(o))}var p='It seems that recorder is destroyed or "startRecording" is not invoked for '+e.type+" recorder.";function v(){e.disableLogs!==!0&&console.warn(p)}var c,R={startRecording:a,stopRecording:d,pauseRecording:f,resumeRecording:r,initRecorder:s,setRecordingDuration:function(o,m){if(typeof o=="undefined")throw"recordingDuration is required.";if(typeof o!="number")throw"recordingDuration must be a number.";return t.recordingDuration=o,t.onRecordingStopped=m||function(){},{onRecordingStopped:function(C){t.onRecordingStopped=C}}},clearRecordedData:function(){if(!c){v();return}c.clearRecordedData(),e.disableLogs||console.log("Cleared old recorded data.")},getBlob:function(){if(!c){v();return}return c.blob},getDataURL:b,toURL:function(){if(!c){v();return}return U.createObjectURL(c.blob)},getInternalRecorder:function(){return c},save:function(o){if(!c){v();return}xe(c.blob,o)},getFromDisk:function(o){if(!c){v();return}S.getFromDisk(e.type,o)},setAdvertisementArray:function(o){e.advertisement=[];for(var m=o.length,C=0;C<m;C++)e.advertisement.push({duration:C,image:o[C]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){t.state==="recording"&&!e.disableLogs&&console.warn("Stop an active recorder."),c&&typeof c.clearRecordedData=="function"&&c.clearRecordedData(),c=null,g("inactive"),t.blob=null},onStateChanged:function(o){e.disableLogs||console.log("Recorder state changed:",o)},state:"inactive",getState:function(){return t.state},destroy:function(){var o=e.disableLogs;e={disableLogs:!0},t.reset(),g("destroyed"),R=t=null,ie.AudioContextConstructor&&(ie.AudioContextConstructor.close(),ie.AudioContextConstructor=null),e.disableLogs=o,e.disableLogs||console.log("RecordRTC is destroyed.")},version:"5.6.2"};if(!this)return t=R,R;for(var T in R)this[T]=R[T];return t=this,R}S.version="5.6.2",Te.exports=S,S.getFromDisk=function(i,e){if(!e)throw"callback is mandatory.";console.log("Getting recorded "+(i==="all"?"blobs":i+" blob ")+" from disk!"),G.Fetch(function(t,a){i!=="all"&&a===i+"Blob"&&e&&e(t),i==="all"&&e&&e(t,a.replace("Blob",""))})},S.writeToDisk=function(i){console.log("Writing recorded blob(s) to disk!"),i=i||{},i.audio&&i.video&&i.gif?i.audio.getDataURL(function(e){i.video.getDataURL(function(t){i.gif.getDataURL(function(a){G.Store({audioBlob:e,videoBlob:t,gifBlob:a})})})}):i.audio&&i.video?i.audio.getDataURL(function(e){i.video.getDataURL(function(t){G.Store({audioBlob:e,videoBlob:t})})}):i.audio&&i.gif?i.audio.getDataURL(function(e){i.gif.getDataURL(function(t){G.Store({audioBlob:e,gifBlob:t})})}):i.video&&i.gif?i.video.getDataURL(function(e){i.gif.getDataURL(function(t){G.Store({videoBlob:e,gifBlob:t})})}):i.audio?i.audio.getDataURL(function(e){G.Store({audioBlob:e})}):i.video?i.video.getDataURL(function(e){G.Store({videoBlob:e})}):i.gif&&i.gif.getDataURL(function(e){G.Store({gifBlob:e})})};/**
  19. * {@link RecordRTCConfiguration} is an inner/private helper for {@link RecordRTC}.
  20. * @summary It configures the 2nd parameter passed over {@link RecordRTC} and returns a valid "config" object.
  21. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  22. * @author {@link https://MuazKhan.com|Muaz Khan}
  23. * @typedef RecordRTCConfiguration
  24. * @class
  25. * @example
  26. * var options = RecordRTCConfiguration(mediaStream, options);
  27. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  28. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  29. * @param {object} config - {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, getNativeBlob:true, etc.}
  30. */function ke(i,e){return!e.recorderType&&!e.type&&(!!e.audio&&!!e.video?e.type="video":!!e.audio&&!e.video&&(e.type="audio")),e.recorderType&&!e.type&&(e.recorderType===fe||e.recorderType===ue||typeof oe!="undefined"&&e.recorderType===oe?e.type="video":e.recorderType===ce?e.type="gif":e.recorderType===se?e.type="audio":e.recorderType===j&&(x(i,"audio").length&&x(i,"video").length||!x(i,"audio").length&&x(i,"video").length?e.type="video":x(i,"audio").length&&!x(i,"video").length&&(e.type="audio"))),typeof j!="undefined"&&typeof MediaRecorder!="undefined"&&"requestData"in MediaRecorder.prototype&&(e.mimeType||(e.mimeType="video/webm"),e.type||(e.type=e.mimeType.split("/")[0]),e.bitsPerSecond),e.type||(e.mimeType&&(e.type=e.mimeType.split("/")[0]),e.type||(e.type="audio")),e}/**
  31. * {@link GetRecorderType} is an inner/private helper for {@link RecordRTC}.
  32. * @summary It returns best recorder-type available for your browser.
  33. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  34. * @author {@link https://MuazKhan.com|Muaz Khan}
  35. * @typedef GetRecorderType
  36. * @class
  37. * @example
  38. * var RecorderType = GetRecorderType(options);
  39. * var recorder = new RecorderType(options);
  40. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  41. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  42. * @param {object} config - {type:"video", disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
  43. */function Ee(i,e){var t;return(Q||ve||ae)&&(t=se),typeof MediaRecorder!="undefined"&&"requestData"in MediaRecorder.prototype&&!Q&&(t=j),e.type==="video"&&(Q||ae)&&(t=fe,typeof oe!="undefined"&&typeof ReadableStream!="undefined"&&(t=oe)),e.type==="gif"&&(t=ce),e.type==="canvas"&&(t=ue),_()&&t!==ue&&t!==ce&&typeof MediaRecorder!="undefined"&&"requestData"in MediaRecorder.prototype&&(x(i,"video").length||x(i,"audio").length)&&(e.type==="audio"?typeof MediaRecorder.isTypeSupported=="function"&&MediaRecorder.isTypeSupported("audio/webm")&&(t=j):typeof MediaRecorder.isTypeSupported=="function"&&MediaRecorder.isTypeSupported("video/webm")&&(t=j)),i instanceof Array&&i.length&&(t=Ue),e.recorderType&&(t=e.recorderType),!e.disableLogs&&!!t&&!!t.name&&console.log("Using recorderType:",t.name||t.constructor.name),!t&&de&&(t=j),t}/**
  44. * MRecordRTC runs on top of {@link RecordRTC} to bring multiple recordings in a single place, by providing simple API.
  45. * @summary MRecordRTC stands for "Multiple-RecordRTC".
  46. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  47. * @author {@link https://MuazKhan.com|Muaz Khan}
  48. * @typedef MRecordRTC
  49. * @class
  50. * @example
  51. * var recorder = new MRecordRTC();
  52. * recorder.addStream(MediaStream);
  53. * recorder.mediaType = {
  54. * audio: true, // or StereoAudioRecorder or MediaStreamRecorder
  55. * video: true, // or WhammyRecorder or MediaStreamRecorder or WebAssemblyRecorder or CanvasRecorder
  56. * gif: true // or GifRecorder
  57. * };
  58. * // mimeType is optional and should be set only in advance cases.
  59. * recorder.mimeType = {
  60. * audio: 'audio/wav',
  61. * video: 'video/webm',
  62. * gif: 'image/gif'
  63. * };
  64. * recorder.startRecording();
  65. * @see For further information:
  66. * @see {@link https://github.com/muaz-khan/RecordRTC/tree/master/MRecordRTC|MRecordRTC Source Code}
  67. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  68. * @requires {@link RecordRTC}
  69. */function me(i){this.addStream=function(e){e&&(i=e)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var e=this.mediaType,t,a=this.mimeType||{audio:null,video:null,gif:null};if(typeof e.audio!="function"&&_()&&!x(i,"audio").length&&(e.audio=!1),typeof e.video!="function"&&_()&&!x(i,"video").length&&(e.video=!1),typeof e.gif!="function"&&_()&&!x(i,"video").length&&(e.gif=!1),!e.audio&&!e.video&&!e.gif)throw"MediaStream must have either audio or video tracks.";if(e.audio&&(t=null,typeof e.audio=="function"&&(t=e.audio),this.audioRecorder=new S(i,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:t,mimeType:a.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),e.video||this.audioRecorder.startRecording()),e.video){t=null,typeof e.video=="function"&&(t=e.video);var s=i;if(_()&&!!e.audio&&typeof e.audio=="function"){var d=x(i,"video")[0];Ae?(s=new N,s.addTrack(d),t&&t===fe&&(t=j)):(s=new N,s.addTrack(d))}this.videoRecorder=new S(s,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:t,mimeType:a.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp,workerPath:this.workerPath,webAssemblyPath:this.webAssemblyPath,frameRate:this.frameRate,bitrate:this.bitrate}),e.audio||this.videoRecorder.startRecording()}if(!!e.audio&&!!e.video){var f=this,r=_()===!0;(e.audio instanceof se&&!!e.video||e.audio!==!0&&e.video!==!0&&e.audio!==e.video)&&(r=!1),r===!0?(f.audioRecorder=null,f.videoRecorder.startRecording()):f.videoRecorder.initRecorder(function(){f.audioRecorder.initRecorder(function(){f.videoRecorder.startRecording(),f.audioRecorder.startRecording()})})}e.gif&&(t=null,typeof e.gif=="function"&&(t=e.gif),this.gifRecorder=new S(i,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:t,mimeType:a.gif}),this.gifRecorder.startRecording())},this.stopRecording=function(e){e=e||function(){},this.audioRecorder&&this.audioRecorder.stopRecording(function(t){e(t,"audio")}),this.videoRecorder&&this.videoRecorder.stopRecording(function(t){e(t,"video")}),this.gifRecorder&&this.gifRecorder.stopRecording(function(t){e(t,"gif")})},this.pauseRecording=function(){this.audioRecorder&&this.audioRecorder.pauseRecording(),this.videoRecorder&&this.videoRecorder.pauseRecording(),this.gifRecorder&&this.gifRecorder.pauseRecording()},this.resumeRecording=function(){this.audioRecorder&&this.audioRecorder.resumeRecording(),this.videoRecorder&&this.videoRecorder.resumeRecording(),this.gifRecorder&&this.gifRecorder.resumeRecording()},this.getBlob=function(e){var t={};return this.audioRecorder&&(t.audio=this.audioRecorder.getBlob()),this.videoRecorder&&(t.video=this.videoRecorder.getBlob()),this.gifRecorder&&(t.gif=this.gifRecorder.getBlob()),e&&e(t),t},this.destroy=function(){this.audioRecorder&&(this.audioRecorder.destroy(),this.audioRecorder=null),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.gifRecorder&&(this.gifRecorder.destroy(),this.gifRecorder=null)},this.getDataURL=function(e){this.getBlob(function(s){s.audio&&s.video?t(s.audio,function(d){t(s.video,function(f){e({audio:d,video:f})})}):s.audio?t(s.audio,function(d){e({audio:d})}):s.video&&t(s.video,function(d){e({video:d})})});function t(s,d){if(typeof Worker!="undefined"){var f=a(function(b){postMessage(new FileReaderSync().readAsDataURL(b))});f.onmessage=function(h){d(h.data)},f.postMessage(s)}else{var r=new FileReader;r.readAsDataURL(s),r.onload=function(h){d(h.target.result)}}}function a(s){var d=U.createObjectURL(new Blob([s.toString(),"this.onmessage = function (eee) {"+s.name+"(eee.data);}"],{type:"application/javascript"})),f=new Worker(d),r;if(typeof U!="undefined")r=U;else if(typeof webkitURL!="undefined")r=webkitURL;else throw"Neither URL nor webkitURL detected.";return r.revokeObjectURL(d),f}},this.writeToDisk=function(){S.writeToDisk({audio:this.audioRecorder,video:this.videoRecorder,gif:this.gifRecorder})},this.save=function(e){e=e||{audio:!0,video:!0,gif:!0},!!e.audio&&this.audioRecorder&&this.audioRecorder.save(typeof e.audio=="string"?e.audio:""),!!e.video&&this.videoRecorder&&this.videoRecorder.save(typeof e.video=="string"?e.video:""),!!e.gif&&this.gifRecorder&&this.gifRecorder.save(typeof e.gif=="string"?e.gif:"")}}me.getFromDisk=S.getFromDisk,me.writeToDisk=S.writeToDisk,typeof S!="undefined"&&(S.MRecordRTC=me);var Pe="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(i){!i||typeof window=="undefined"&&typeof A!="undefined"&&(A.navigator={userAgent:Pe,getUserMedia:function(){}},A.console||(A.console={}),(typeof A.console.log=="undefined"||typeof A.console.error=="undefined")&&(A.console.error=A.console.log=A.console.log||function(){console.log(arguments)}),typeof document=="undefined"&&(i.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return e},i.HTMLVideoElement=function(){}),typeof location=="undefined"&&(i.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(i.screen={width:0,height:0}),typeof U=="undefined"&&(i.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),i.window=A)})(typeof A!="undefined"?A:null);var Y=window.requestAnimationFrame;if(typeof Y=="undefined"){if(typeof webkitRequestAnimationFrame!="undefined")Y=webkitRequestAnimationFrame;else if(typeof mozRequestAnimationFrame!="undefined")Y=mozRequestAnimationFrame;else if(typeof msRequestAnimationFrame!="undefined")Y=msRequestAnimationFrame;else if(typeof Y=="undefined"){var Le=0;Y=function(i,e){var t=new Date().getTime(),a=Math.max(0,16-(t-Le)),s=setTimeout(function(){i(t+a)},a);return Le=t+a,s}}}var Z=window.cancelAnimationFrame;typeof Z=="undefined"&&(typeof webkitCancelAnimationFrame!="undefined"?Z=webkitCancelAnimationFrame:typeof mozCancelAnimationFrame!="undefined"?Z=mozCancelAnimationFrame:typeof msCancelAnimationFrame!="undefined"?Z=msCancelAnimationFrame:typeof Z=="undefined"&&(Z=function(i){clearTimeout(i)}));var ne=window.AudioContext;typeof ne=="undefined"&&(typeof webkitAudioContext!="undefined"&&(ne=webkitAudioContext),typeof mozAudioContext!="undefined"&&(ne=mozAudioContext));var U=window.URL;typeof U=="undefined"&&typeof webkitURL!="undefined"&&(U=webkitURL),typeof navigator!="undefined"&&typeof navigator.getUserMedia=="undefined"&&(typeof navigator.webkitGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.webkitGetUserMedia),typeof navigator.mozGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.mozGetUserMedia));var ve=navigator.userAgent.indexOf("Edge")!==-1&&(!!navigator.msSaveBlob||!!navigator.msSaveOrOpenBlob),ae=!!window.opera||navigator.userAgent.indexOf("OPR/")!==-1,Ae=navigator.userAgent.toLowerCase().indexOf("firefox")>-1&&"netscape"in window&&/ rv:/.test(navigator.userAgent),Q=!ae&&!ve&&!!navigator.webkitGetUserMedia||Me()||navigator.userAgent.toLowerCase().indexOf("chrome/")!==-1,de=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);de&&!Q&&navigator.userAgent.indexOf("CriOS")!==-1&&(de=!1,Q=!0);var N=window.MediaStream;typeof N=="undefined"&&typeof webkitMediaStream!="undefined"&&(N=webkitMediaStream),typeof N!="undefined"&&typeof N.prototype.stop=="undefined"&&(N.prototype.stop=function(){this.getTracks().forEach(function(i){i.stop()})});function ge(i){var e=1e3,t=["Bytes","KB","MB","GB","TB"];if(i===0)return"0 Bytes";var a=parseInt(Math.floor(Math.log(i)/Math.log(e)),10);return(i/Math.pow(e,a)).toPrecision(3)+" "+t[a]}function xe(i,e){if(!i)throw"Blob object is required.";if(!i.type)try{i.type="video/webm"}catch(f){}var t=(i.type||"video/webm").split("/")[1];if(t.indexOf(";")!==-1&&(t=t.split(";")[0]),e&&e.indexOf(".")!==-1){var a=e.split(".");e=a[0],t=a[1]}var s=(e||Math.round(Math.random()*9999999999)+888888888)+"."+t;if(typeof navigator.msSaveOrOpenBlob!="undefined")return navigator.msSaveOrOpenBlob(i,s);if(typeof navigator.msSaveBlob!="undefined")return navigator.msSaveBlob(i,s);var d=document.createElement("a");d.href=U.createObjectURL(i),d.download=s,d.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(d),typeof d.click=="function"?d.click():(d.target="_blank",d.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),U.revokeObjectURL(d.href)}function Me(){return typeof window!="undefined"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process!="undefined"&&typeof process.versions=="object"&&!!process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0}function x(i,e){return!i||!i.getTracks?[]:i.getTracks().filter(function(t){return t.kind===(e||"audio")})}function De(i,e){"srcObject"in e?e.srcObject=i:"mozSrcObject"in e?e.mozSrcObject=i:e.srcObject=i}function je(i,e){if(typeof EBML=="undefined")throw new Error("Please link: https://www.webrtc-experiment.com/EBML.js");var t=new EBML.Reader,a=new EBML.Decoder,s=EBML.tools,d=new FileReader;d.onload=function(f){var r=a.decode(this.result);r.forEach(function(g){t.read(g)}),t.stop();var h=s.makeMetadataSeekable(t.metadatas,t.duration,t.cues),b=this.result.slice(t.metadataSize),l=new Blob([h,b],{type:"video/webm"});e(l)},d.readAsArrayBuffer(i)}typeof S!="undefined"&&(S.invokeSaveAsDialog=xe,S.getTracks=x,S.getSeekableBlob=je,S.bytesToSize=ge,S.isElectron=Me);/**
  70. * Storage is a standalone object used by {@link RecordRTC} to store reusable objects e.g. "new AudioContext".
  71. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  72. * @author {@link https://MuazKhan.com|Muaz Khan}
  73. * @example
  74. * Storage.AudioContext === webkitAudioContext
  75. * @property {webkitAudioContext} AudioContext - Keeps a reference to AudioContext object.
  76. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  77. */var ie={};typeof ne!="undefined"?ie.AudioContext=ne:typeof webkitAudioContext!="undefined"&&(ie.AudioContext=webkitAudioContext),typeof S!="undefined"&&(S.Storage=ie);function _(){if(Ae||de||ve)return!0;var i=navigator.userAgent,e=""+parseFloat(navigator.appVersion),t=parseInt(navigator.appVersion,10),a,s;return(Q||ae)&&(a=i.indexOf("Chrome"),e=i.substring(a+7)),(s=e.indexOf(";"))!==-1&&(e=e.substring(0,s)),(s=e.indexOf(" "))!==-1&&(e=e.substring(0,s)),t=parseInt(""+e,10),isNaN(t)&&(e=""+parseFloat(navigator.appVersion),t=parseInt(navigator.appVersion,10)),t>=49}/**
  78. * 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.
  79. * @summary Runs top over {@link https://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}.
  80. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  81. * @author {@link https://github.com/muaz-khan|Muaz Khan}
  82. * @typedef MediaStreamRecorder
  83. * @class
  84. * @example
  85. * var config = {
  86. * mimeType: 'video/webm', // vp8, vp9, h264, mkv, opus/vorbis
  87. * audioBitsPerSecond : 256 * 8 * 1024,
  88. * videoBitsPerSecond : 256 * 8 * 1024,
  89. * bitsPerSecond: 256 * 8 * 1024, // if this is provided, skip above two
  90. * checkForInactiveTracks: true,
  91. * timeSlice: 1000, // concatenate intervals based blobs
  92. * ondataavailable: function() {} // get intervals based blobs
  93. * }
  94. * var recorder = new MediaStreamRecorder(mediaStream, config);
  95. * recorder.record();
  96. * recorder.stop(function(blob) {
  97. * video.src = URL.createObjectURL(blob);
  98. *
  99. * // or
  100. * var blob = recorder.blob;
  101. * });
  102. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  103. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  104. * @param {object} config - {disableLogs:true, initCallback: function, mimeType: "video/webm", timeSlice: 1000}
  105. * @throws Will throw an error if first argument "MediaStream" is missing. Also throws error if "MediaRecorder API" are not supported by the browser.
  106. */function j(i,e){var l=this;if(typeof i=="undefined")throw'First argument "MediaStream" is required.';if(typeof MediaRecorder=="undefined")throw"Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";if(e=e||{mimeType:"video/webm"},e.type==="audio"){if(x(i,"video").length&&x(i,"audio").length){var t;navigator.mozGetUserMedia?(t=new N,t.addTrack(x(i,"audio")[0])):t=new N(x(i,"audio")),i=t}(!e.mimeType||e.mimeType.toString().toLowerCase().indexOf("audio")===-1)&&(e.mimeType=Q?"audio/webm":"audio/ogg"),e.mimeType&&e.mimeType.toString().toLowerCase()!=="audio/ogg"&&!!navigator.mozGetUserMedia&&(e.mimeType="audio/ogg")}var a=[];this.getArrayOfBlobs=function(){return a},this.record=function(){l.blob=null,l.clearRecordedData(),l.timestamps=[],b=[],a=[];var g=e;e.disableLogs||console.log("Passing following config over MediaRecorder API.",g),r&&(r=null),Q&&!_()&&(g="video/vp8"),typeof MediaRecorder.isTypeSupported=="function"&&g.mimeType&&(MediaRecorder.isTypeSupported(g.mimeType)||(e.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",g.mimeType),g.mimeType=e.type==="audio"?"audio/webm":"video/webm"));try{r=new MediaRecorder(i,g),e.mimeType=g.mimeType}catch(p){r=new MediaRecorder(i)}g.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in r&&r.canRecordMimeType(g.mimeType)===!1&&(e.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",g.mimeType)),r.ondataavailable=function(p){if(p.data&&b.push("ondataavailable: "+ge(p.data.size)),typeof e.timeSlice=="number"){if(p.data&&p.data.size&&(a.push(p.data),s(),typeof e.ondataavailable=="function")){var v=e.getNativeBlob?p.data:new Blob([p.data],{type:d(g)});e.ondataavailable(v)}return}if(!p.data||!p.data.size||p.data.size<100||l.blob){l.recordingCallback&&(l.recordingCallback(new Blob([],{type:d(g)})),l.recordingCallback=null);return}l.blob=e.getNativeBlob?p.data:new Blob([p.data],{type:d(g)}),l.recordingCallback&&(l.recordingCallback(l.blob),l.recordingCallback=null)},r.onstart=function(){b.push("started")},r.onpause=function(){b.push("paused")},r.onresume=function(){b.push("resumed")},r.onstop=function(){b.push("stopped")},r.onerror=function(p){!p||(p.name||(p.name="UnknownError"),b.push("error: "+p),e.disableLogs||(p.name.toString().toLowerCase().indexOf("invalidstate")!==-1?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.",p):p.name.toString().toLowerCase().indexOf("notsupported")!==-1?console.error("MIME type (",g.mimeType,") is not supported.",p):p.name.toString().toLowerCase().indexOf("security")!==-1?console.error("MediaRecorder security error",p):p.name==="OutOfMemory"?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.",p):p.name==="IllegalStreamModification"?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.",p):p.name==="OtherRecordingError"?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.",p):p.name==="GenericError"?console.error("The UA cannot provide the codec or recording option that has been requested.",p):console.error("MediaRecorder Error",p)),function(v){if(!l.manuallyStopped&&r&&r.state==="inactive"){delete e.timeslice,r.start(10*60*1e3);return}setTimeout(v,1e3)}(),r.state!=="inactive"&&r.state!=="stopped"&&r.stop())},typeof e.timeSlice=="number"?(s(),r.start(e.timeSlice)):r.start(36e5),e.initCallback&&e.initCallback()},this.timestamps=[];function s(){l.timestamps.push(new Date().getTime()),typeof e.onTimeStamp=="function"&&e.onTimeStamp(l.timestamps[l.timestamps.length-1],l.timestamps)}function d(g){return r&&r.mimeType?r.mimeType:g.mimeType||"video/webm"}this.stop=function(g){g=g||function(){},l.manuallyStopped=!0,r&&(this.recordingCallback=g,r.state==="recording"&&r.stop(),typeof e.timeSlice=="number"&&setTimeout(function(){l.blob=new Blob(a,{type:d(e)}),l.recordingCallback(l.blob)},100))},this.pause=function(){!r||r.state==="recording"&&r.pause()},this.resume=function(){!r||r.state==="paused"&&r.resume()},this.clearRecordedData=function(){r&&r.state==="recording"&&l.stop(f),f()};function f(){a=[],r=null,l.timestamps=[]}var r;this.getInternalRecorder=function(){return r};function h(){if("active"in i){if(!i.active)return!1}else if("ended"in i&&i.ended)return!1;return!0}this.blob=null,this.getState=function(){return r&&r.state||"inactive"};var b=[];this.getAllStates=function(){return b},typeof e.checkForInactiveTracks=="undefined"&&(e.checkForInactiveTracks=!1);var l=this;(function g(){if(!(!r||e.checkForInactiveTracks===!1)){if(h()===!1){e.disableLogs||console.log("MediaStream seems stopped."),l.stop();return}setTimeout(g,1e3)}})(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}typeof S!="undefined"&&(S.MediaStreamRecorder=j);/**
  107. * StereoAudioRecorder is a standalone class used by {@link RecordRTC} to bring "stereo" audio-recording in chrome.
  108. * @summary JavaScript standalone object for stereo audio recording.
  109. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  110. * @author {@link https://MuazKhan.com|Muaz Khan}
  111. * @typedef StereoAudioRecorder
  112. * @class
  113. * @example
  114. * var recorder = new StereoAudioRecorder(MediaStream, {
  115. * sampleRate: 44100,
  116. * bufferSize: 4096
  117. * });
  118. * recorder.record();
  119. * recorder.stop(function(blob) {
  120. * video.src = URL.createObjectURL(blob);
  121. * });
  122. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  123. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  124. * @param {object} config - {sampleRate: 44100, bufferSize: 4096, numberOfAudioChannels: 1, etc.}
  125. */function se(i,e){if(!x(i,"audio").length)throw"Your stream has no audio tracks.";e=e||{};var t=this,a=[],s=[],d=!1,f=0,r,h=2,b=e.desiredSampRate;e.leftChannel===!0&&(h=1),e.numberOfAudioChannels===1&&(h=1),(!h||h<1)&&(h=2),e.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+h),typeof e.checkForInactiveTracks=="undefined"&&(e.checkForInactiveTracks=!0);function l(){if(e.checkForInactiveTracks===!1)return!0;if("active"in i){if(!i.active)return!1}else if("ended"in i&&i.ended)return!1;return!0}this.record=function(){if(l()===!1)throw"Please make sure MediaStream is active.";C(),u=m=!1,d=!0,typeof e.timeSlice!="undefined"&&L()};function g(k,I){function M(D,re){var V=D.numberOfAudioChannels,E=D.leftBuffers.slice(0),X=D.rightBuffers.slice(0),q=D.sampleRate,K=D.internalInterleavedLength,P=D.desiredSampRate;V===2&&(E=ye(E,K),X=ye(X,K),P&&(E=ee(E,P,q),X=ee(X,P,q))),V===1&&(E=ye(E,K),P&&(E=ee(E,P,q))),P&&(q=P);function ee(B,H,z){var W=Math.round(B.length*(H/z)),O=[],J=Number((B.length-1)/(W-1));O[0]=B[0];for(var te=1;te<W-1;te++){var Ce=te*J,Ie=Number(Math.floor(Ce)).toFixed(),qe=Number(Math.ceil(Ce)).toFixed(),He=Ce-Ie;O[te]=we(B[Ie],B[qe],He)}return O[W-1]=B[B.length-1],O}function we(B,H,z){return B+(H-B)*z}function ye(B,H){for(var z=new Float64Array(H),W=0,O=B.length,J=0;J<O;J++){var te=B[J];z.set(te,W),W+=te.length}return z}function We(B,H){for(var z=B.length+H.length,W=new Float64Array(z),O=0,J=0;J<z;)W[J++]=B[O],W[J++]=H[O],O++;return W}function le(B,H,z){for(var W=z.length,O=0;O<W;O++)B.setUint8(H+O,z.charCodeAt(O))}var he;V===2&&(he=We(E,X)),V===1&&(he=E);var pe=he.length,Ne=44+pe*2,Re=new ArrayBuffer(Ne),F=new DataView(Re);le(F,0,"RIFF"),F.setUint32(4,36+pe*2,!0),le(F,8,"WAVE"),le(F,12,"fmt "),F.setUint32(16,16,!0),F.setUint16(20,1,!0),F.setUint16(22,V,!0),F.setUint32(24,q,!0),F.setUint32(28,q*V*2,!0),F.setUint16(32,V*2,!0),F.setUint16(34,16,!0),le(F,36,"data"),F.setUint32(40,pe*2,!0);for(var Ge=pe,Fe=44,Ve=1,Se=0;Se<Ge;Se++)F.setInt16(Fe,he[Se]*(32767*Ve),!0),Fe+=2;if(re)return re({buffer:Re,view:F});postMessage({buffer:Re,view:F})}if(k.noWorker){M(k,function(D){I(D.buffer,D.view)});return}var $=p(M);$.onmessage=function(D){I(D.data.buffer,D.data.view),U.revokeObjectURL($.workerURL),$.terminate()},$.postMessage(k)}function p(k){var I=U.createObjectURL(new Blob([k.toString(),";this.onmessage = function (eee) {"+k.name+"(eee.data);}"],{type:"application/javascript"})),M=new Worker(I);return M.workerURL=I,M}this.stop=function(k){k=k||function(){},d=!1,g({desiredSampRate:b,sampleRate:o,numberOfAudioChannels:h,internalInterleavedLength:f,leftBuffers:a,rightBuffers:h===1?[]:s,noWorker:e.noWorker},function(I,M){t.blob=new Blob([M],{type:"audio/wav"}),t.buffer=new ArrayBuffer(M.buffer.byteLength),t.view=M,t.sampleRate=b||o,t.bufferSize=T,t.length=f,u=!1,k&&k(t.blob)})},typeof S.Storage=="undefined"&&(S.Storage={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext}),(!S.Storage.AudioContextConstructor||S.Storage.AudioContextConstructor.state==="closed")&&(S.Storage.AudioContextConstructor=new S.Storage.AudioContext);var v=S.Storage.AudioContextConstructor,c=v.createMediaStreamSource(i),R=[0,256,512,1024,2048,4096,8192,16384],T=typeof e.bufferSize=="undefined"?4096:e.bufferSize;if(R.indexOf(T)===-1&&(e.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(R,null," "))),v.createJavaScriptNode)r=v.createJavaScriptNode(T,h,h);else if(v.createScriptProcessor)r=v.createScriptProcessor(T,h,h);else throw"WebAudio API has no support on this browser.";c.connect(r),e.bufferSize||(T=r.bufferSize);var o=typeof e.sampleRate!="undefined"?e.sampleRate:v.sampleRate||44100;(o<22050||o>96e3)&&(e.disableLogs||console.log("sample-rate must be under range 22050 and 96000.")),e.disableLogs||e.desiredSampRate&&console.log("Desired sample-rate: "+e.desiredSampRate);var m=!1;this.pause=function(){m=!0},this.resume=function(){if(l()===!1)throw"Please make sure MediaStream is active.";if(!d){e.disableLogs||console.log("Seems recording has been restarted."),this.record();return}m=!1},this.clearRecordedData=function(){e.checkForInactiveTracks=!1,d&&this.stop(n),n()};function C(){a=[],s=[],f=0,u=!1,d=!1,m=!1,v=null,t.leftchannel=a,t.rightchannel=s,t.numberOfAudioChannels=h,t.desiredSampRate=b,t.sampleRate=o,t.recordingLength=f,y={left:[],right:[],recordingLength:0}}function n(){r&&(r.onaudioprocess=null,r.disconnect(),r=null),c&&(c.disconnect(),c=null),C()}this.name="StereoAudioRecorder",this.toString=function(){return this.name};var u=!1;function w(k){if(!m){if(l()===!1&&(e.disableLogs||console.log("MediaStream seems stopped."),r.disconnect(),d=!1),!d){c&&(c.disconnect(),c=null);return}u||(u=!0,e.onAudioProcessStarted&&e.onAudioProcessStarted(),e.initCallback&&e.initCallback());var I=k.inputBuffer.getChannelData(0),M=new Float32Array(I);if(a.push(M),h===2){var $=k.inputBuffer.getChannelData(1),D=new Float32Array($);s.push(D)}f+=T,t.recordingLength=f,typeof e.timeSlice!="undefined"&&(y.recordingLength+=T,y.left.push(M),h===2&&y.right.push(D))}}r.onaudioprocess=w,v.createMediaStreamDestination?r.connect(v.createMediaStreamDestination()):r.connect(v.destination),this.leftchannel=a,this.rightchannel=s,this.numberOfAudioChannels=h,this.desiredSampRate=b,this.sampleRate=o,t.recordingLength=f;var y={left:[],right:[],recordingLength:0};function L(){!d||typeof e.ondataavailable!="function"||typeof e.timeSlice=="undefined"||(y.left.length?(g({desiredSampRate:b,sampleRate:o,numberOfAudioChannels:h,internalInterleavedLength:y.recordingLength,leftBuffers:y.left,rightBuffers:h===1?[]:y.right},function(k,I){var M=new Blob([I],{type:"audio/wav"});e.ondataavailable(M),setTimeout(L,e.timeSlice)}),y={left:[],right:[],recordingLength:0}):setTimeout(L,e.timeSlice))}}typeof S!="undefined"&&(S.StereoAudioRecorder=se);/**
  126. * 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}.
  127. * @summary HTML2Canvas recording into video WebM.
  128. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  129. * @author {@link https://MuazKhan.com|Muaz Khan}
  130. * @typedef CanvasRecorder
  131. * @class
  132. * @example
  133. * var recorder = new CanvasRecorder(htmlElement, { disableLogs: true, useWhammyRecorder: true });
  134. * recorder.record();
  135. * recorder.stop(function(blob) {
  136. * video.src = URL.createObjectURL(blob);
  137. * });
  138. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  139. * @param {HTMLElement} htmlElement - querySelector/getElementById/getElementsByTagName[0]/etc.
  140. * @param {object} config - {disableLogs:true, initCallback: function}
  141. */function ue(i,e){if(typeof html2canvas=="undefined")throw"Please link: https://www.webrtc-experiment.com/screenshot.js";e=e||{},e.frameInterval||(e.frameInterval=10);var t=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach(function(R){R in document.createElement("canvas")&&(t=!0)});var a=(!!window.webkitRTCPeerConnection||!!window.webkitGetUserMedia)&&!!window.chrome,s=50,d=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);a&&d&&d[2]&&(s=parseInt(d[2],10)),a&&s<52&&(t=!1),e.useWhammyRecorder&&(t=!1);var f,r;if(t)if(e.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),i instanceof HTMLCanvasElement)f=i;else if(i instanceof CanvasRenderingContext2D)f=i.canvas;else throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";else navigator.mozGetUserMedia&&(e.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));var h;this.record=function(){if(h=!0,t&&!e.useWhammyRecorder){var R;"captureStream"in f?R=f.captureStream(25):"mozCaptureStream"in f?R=f.mozCaptureStream(25):"webkitCaptureStream"in f&&(R=f.webkitCaptureStream(25));try{var T=new N;T.addTrack(x(R,"video")[0]),R=T}catch(o){}if(!R)throw"captureStream API are NOT available.";r=new j(R,{mimeType:e.mimeType||"video/webm"}),r.record()}else c.frames=[],v=new Date().getTime(),p();e.initCallback&&e.initCallback()},this.getWebPImages=function(R){if(i.nodeName.toLowerCase()!=="canvas"){R();return}var T=c.frames.length;c.frames.forEach(function(o,m){var C=T-m;e.disableLogs||console.log(C+"/"+T+" frames remaining"),e.onEncodingCallback&&e.onEncodingCallback(C,T);var n=o.image.toDataURL("image/webp",1);c.frames[m].image=n}),e.disableLogs||console.log("Generating WebM"),R()},this.stop=function(R){h=!1;var T=this;if(t&&r){r.stop(R);return}this.getWebPImages(function(){c.compile(function(o){e.disableLogs||console.log("Recording finished!"),T.blob=o,T.blob.forEach&&(T.blob=new Blob([],{type:"video/webm"})),R&&R(T.blob),c.frames=[]})})};var b=!1;this.pause=function(){if(b=!0,r instanceof j){r.pause();return}},this.resume=function(){if(b=!1,r instanceof j){r.resume();return}h||this.record()},this.clearRecordedData=function(){h&&this.stop(l),l()};function l(){c.frames=[],h=!1,b=!1}this.name="CanvasRecorder",this.toString=function(){return this.name};function g(){var R=document.createElement("canvas"),T=R.getContext("2d");return R.width=i.width,R.height=i.height,T.drawImage(i,0,0),R}function p(){if(b)return v=new Date().getTime(),setTimeout(p,500);if(i.nodeName.toLowerCase()==="canvas"){var R=new Date().getTime()-v;v=new Date().getTime(),c.frames.push({image:g(),duration:R}),h&&setTimeout(p,e.frameInterval);return}html2canvas(i,{grabMouse:typeof e.showMousePointer=="undefined"||e.showMousePointer,onrendered:function(T){var o=new Date().getTime()-v;if(!o)return setTimeout(p,e.frameInterval);v=new Date().getTime(),c.frames.push({image:T.toDataURL("image/webp",1),duration:o}),h&&setTimeout(p,e.frameInterval)}})}var v=new Date().getTime(),c=new be.Video(100)}typeof S!="undefined"&&(S.CanvasRecorder=ue);/**
  142. * WhammyRecorder is a standalone class used by {@link RecordRTC} to bring video recording in Chrome. It runs top over {@link Whammy}.
  143. * @summary Video recording feature in Chrome.
  144. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  145. * @author {@link https://MuazKhan.com|Muaz Khan}
  146. * @typedef WhammyRecorder
  147. * @class
  148. * @example
  149. * var recorder = new WhammyRecorder(mediaStream);
  150. * recorder.record();
  151. * recorder.stop(function(blob) {
  152. * video.src = URL.createObjectURL(blob);
  153. * });
  154. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  155. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  156. * @param {object} config - {disableLogs: true, initCallback: function, video: HTMLVideoElement, etc.}
  157. */function fe(i,e){e=e||{},e.frameInterval||(e.frameInterval=10),e.disableLogs||console.log("Using frames-interval:",e.frameInterval),this.record=function(){e.width||(e.width=320),e.height||(e.height=240),e.video||(e.video={width:e.width,height:e.height}),e.canvas||(e.canvas={width:e.width,height:e.height}),h.width=e.canvas.width||320,h.height=e.canvas.height||240,b=h.getContext("2d"),e.video&&e.video instanceof HTMLVideoElement?(l=e.video.cloneNode(),e.initCallback&&e.initCallback()):(l=document.createElement("video"),De(i,l),l.onloadedmetadata=function(){e.initCallback&&e.initCallback()},l.width=e.video.width,l.height=e.video.height),l.muted=!0,l.play(),g=new Date().getTime(),p=new be.Video,e.disableLogs||(console.log("canvas resolutions",h.width,"*",h.height),console.log("video width/height",l.width||h.width,"*",l.height||h.height)),t(e.frameInterval)};function t(v){v=typeof v!="undefined"?v:10;var c=new Date().getTime()-g;if(!c)return setTimeout(t,v,v);if(f)return g=new Date().getTime(),setTimeout(t,100);g=new Date().getTime(),l.paused&&l.play(),b.drawImage(l,0,0,h.width,h.height),p.frames.push({duration:c,image:h.toDataURL("image/webp")}),d||setTimeout(t,v,v)}function a(v){var c=-1,R=v.length;(function T(){if(c++,c===R){v.callback();return}setTimeout(function(){v.functionToLoop(T,c)},1)})()}function s(v,c,R,T,o){var m=document.createElement("canvas");m.width=h.width,m.height=h.height;var C=m.getContext("2d"),n=[],u=c===-1,w=c&&c>0&&c<=v.length?c:v.length,y={r:0,g:0,b:0},L=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),k=R&&R>=0&&R<=1?R:0,I=T&&T>=0&&T<=1?T:0,M=!1;a({length:w,functionToLoop:function($,D){var re,V,E,X=function(){!M&&E-re<=E*I||(u&&(M=!0),n.push(v[D])),$()};if(M)X();else{var q=new Image;q.onload=function(){C.drawImage(q,0,0,h.width,h.height);var K=C.getImageData(0,0,h.width,h.height);re=0,V=K.data.length,E=K.data.length/4;for(var P=0;P<V;P+=4){var ee={r:K.data[P],g:K.data[P+1],b:K.data[P+2]},we=Math.sqrt(Math.pow(ee.r-y.r,2)+Math.pow(ee.g-y.g,2)+Math.pow(ee.b-y.b,2));we<=L*k&&re++}X()},q.src=v[D].image}},callback:function(){n=n.concat(v.slice(w)),n.length<=0&&n.push(v[v.length-1]),o(n)}})}var d=!1;this.stop=function(v){v=v||function(){},d=!0;var c=this;setTimeout(function(){s(p.frames,-1,null,null,function(R){p.frames=R,e.advertisement&&e.advertisement.length&&(p.frames=e.advertisement.concat(p.frames)),p.compile(function(T){c.blob=T,c.blob.forEach&&(c.blob=new Blob([],{type:"video/webm"})),v&&v(c.blob)})})},10)};var f=!1;this.pause=function(){f=!0},this.resume=function(){f=!1,d&&this.record()},this.clearRecordedData=function(){d||this.stop(r),r()};function r(){p.frames=[],d=!0,f=!1}this.name="WhammyRecorder",this.toString=function(){return this.name};var h=document.createElement("canvas"),b=h.getContext("2d"),l,g,p}typeof S!="undefined"&&(S.WhammyRecorder=fe);/**
  158. * 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}
  159. * @summary A real time javascript webm encoder based on a canvas hack.
  160. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  161. * @author {@link https://MuazKhan.com|Muaz Khan}
  162. * @typedef Whammy
  163. * @class
  164. * @example
  165. * var recorder = new Whammy().Video(15);
  166. * recorder.add(context || canvas || dataURL);
  167. * var output = recorder.compile();
  168. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  169. */var be=function(){function i(a){this.frames=[],this.duration=a||1,this.quality=.8}i.prototype.add=function(a,s){if("canvas"in a&&(a=a.canvas),"toDataURL"in a&&(a=a.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/ig.test(a))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:a,duration:s||this.duration})};function e(a){var s=U.createObjectURL(new Blob([a.toString(),"this.onmessage = function (eee) {"+a.name+"(eee.data);}"],{type:"application/javascript"})),d=new Worker(s);return U.revokeObjectURL(s),d}function t(a){function s(o){var m=f(o);if(!m)return[];for(var C=3e4,n=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:R(m.duration),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:m.width,id:176},{data:m.height,id:186}]}]}]}]}],u=0,w=0;u<o.length;){var y=[],L=0;do y.push(o[u]),L+=o[u].duration,u++;while(u<o.length&&L<C);var k=0,I={id:524531317,data:d(w,k,y)};n[1].data.push(I),w+=L}return l(n)}function d(o,m,C){return[{data:o,id:231}].concat(C.map(function(n){var u=g({discardable:0,frame:n.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(m)});return m+=n.duration,{data:u,id:163}}))}function f(o){if(!o[0]){postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."});return}for(var m=o[0].width,C=o[0].height,n=o[0].duration,u=1;u<o.length;u++)n+=o[u].duration;return{duration:n,width:m,height:C}}function r(o){for(var m=[];o>0;)m.push(o&255),o=o>>8;return new Uint8Array(m.reverse())}function h(o){return new Uint8Array(o.split("").map(function(m){return m.charCodeAt(0)}))}function b(o){var m=[],C=o.length%8?new Array(9-o.length%8).join("0"):"";o=C+o;for(var n=0;n<o.length;n+=8)m.push(parseInt(o.substr(n,8),2));return new Uint8Array(m)}function l(o){for(var m=[],C=0;C<o.length;C++){var n=o[C].data;typeof n=="object"&&(n=l(n)),typeof n=="number"&&(n=b(n.toString(2))),typeof n=="string"&&(n=h(n));var u=n.size||n.byteLength||n.length,w=Math.ceil(Math.ceil(Math.log(u)/Math.log(2))/8),y=u.toString(2),L=new Array(w*7+7+1-y.length).join("0")+y,k=new Array(w).join("0")+"1"+L;m.push(r(o[C].id)),m.push(b(k)),m.push(n)}return new Blob(m,{type:"video/webm"})}function g(o){var m=0;if(o.keyframe&&(m|=128),o.invisible&&(m|=8),o.lacing&&(m|=o.lacing<<1),o.discardable&&(m|=1),o.trackNum>127)throw"TrackNumber > 127 not supported";var C=[o.trackNum|128,o.timecode>>8,o.timecode&255,m].map(function(n){return String.fromCharCode(n)}).join("")+o.frame;return C}function p(o){for(var m=o.RIFF[0].WEBP[0],C=m.indexOf("\x9D*"),n=0,u=[];n<4;n++)u[n]=m.charCodeAt(C+3+n);var w,y,L;return L=u[1]<<8|u[0],w=L&16383,L=u[3]<<8|u[2],y=L&16383,{width:w,height:y,data:m,riff:o}}function v(o,m){return parseInt(o.substr(m+4,4).split("").map(function(C){var n=C.charCodeAt(0).toString(2);return new Array(8-n.length+1).join("0")+n}).join(""),2)}function c(o){for(var m=0,C={};m<o.length;){var n=o.substr(m,4),u=v(o,m),w=o.substr(m+4+4,u);m+=4+4+u,C[n]=C[n]||[],n==="RIFF"||n==="LIST"?C[n].push(c(w)):C[n].push(w)}return C}function R(o){return[].slice.call(new Uint8Array(new Float64Array([o]).buffer),0).map(function(m){return String.fromCharCode(m)}).reverse().join("")}var T=new s(a.map(function(o){var m=p(c(atob(o.image.slice(23))));return m.duration=o.duration,m}));postMessage(T)}return i.prototype.compile=function(a){var s=e(t);s.onmessage=function(d){if(d.data.error){console.error(d.data.error);return}a(d.data)},s.postMessage(this.frames)},{Video:i}}();typeof S!="undefined"&&(S.Whammy=be);/**
  170. * DiskStorage is a standalone object used by {@link RecordRTC} to store recorded blobs in IndexedDB storage.
  171. * @summary Writing blobs into IndexedDB.
  172. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  173. * @author {@link https://MuazKhan.com|Muaz Khan}
  174. * @example
  175. * DiskStorage.Store({
  176. * audioBlob: yourAudioBlob,
  177. * videoBlob: yourVideoBlob,
  178. * gifBlob : yourGifBlob
  179. * });
  180. * DiskStorage.Fetch(function(dataURL, type) {
  181. * if(type === 'audioBlob') { }
  182. * if(type === 'videoBlob') { }
  183. * if(type === 'gifBlob') { }
  184. * });
  185. * // DiskStorage.dataStoreName = 'recordRTC';
  186. * // DiskStorage.onError = function(error) { };
  187. * @property {function} init - This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.
  188. * @property {function} Fetch - This method fetches stored blobs from IndexedDB.
  189. * @property {function} Store - This method stores blobs in IndexedDB.
  190. * @property {function} onError - This function is invoked for any known/unknown error.
  191. * @property {string} dataStoreName - Name of the ObjectStore created in IndexedDB storage.
  192. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  193. */var G={init:function(){var i=this;if(typeof indexedDB=="undefined"||typeof indexedDB.open=="undefined"){console.error("IndexedDB API are not available in this browser.");return}var e=1,t=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),a,s=indexedDB.open(t,e);function d(r){r.createObjectStore(i.dataStoreName)}function f(){var r=a.transaction([i.dataStoreName],"readwrite");i.videoBlob&&r.objectStore(i.dataStoreName).put(i.videoBlob,"videoBlob"),i.gifBlob&&r.objectStore(i.dataStoreName).put(i.gifBlob,"gifBlob"),i.audioBlob&&r.objectStore(i.dataStoreName).put(i.audioBlob,"audioBlob");function h(b){r.objectStore(i.dataStoreName).get(b).onsuccess=function(l){i.callback&&i.callback(l.target.result,b)}}h("audioBlob"),h("videoBlob"),h("gifBlob")}s.onerror=i.onError,s.onsuccess=function(){if(a=s.result,a.onerror=i.onError,a.setVersion)if(a.version!==e){var r=a.setVersion(e);r.onsuccess=function(){d(a),f()}}else f();else f()},s.onupgradeneeded=function(r){d(r.target.result)}},Fetch:function(i){return this.callback=i,this.init(),this},Store:function(i){return this.audioBlob=i.audioBlob,this.videoBlob=i.videoBlob,this.gifBlob=i.gifBlob,this.init(),this},onError:function(i){console.error(JSON.stringify(i,null," "))},dataStoreName:"recordRTC",dbName:null};typeof S!="undefined"&&(S.DiskStorage=G);/**
  194. * GifRecorder is standalone calss used by {@link RecordRTC} to record video or canvas into animated gif.
  195. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  196. * @author {@link https://MuazKhan.com|Muaz Khan}
  197. * @typedef GifRecorder
  198. * @class
  199. * @example
  200. * var recorder = new GifRecorder(mediaStream || canvas || context, { onGifPreview: function, onGifRecordingStarted: function, width: 1280, height: 720, frameRate: 200, quality: 10 });
  201. * recorder.record();
  202. * recorder.stop(function(blob) {
  203. * img.src = URL.createObjectURL(blob);
  204. * });
  205. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  206. * @param {MediaStream} mediaStream - MediaStream object or HTMLCanvasElement or CanvasRenderingContext2D.
  207. * @param {object} config - {disableLogs:true, initCallback: function, width: 320, height: 240, frameRate: 200, quality: 10}
  208. */function ce(i,e){if(typeof GIFEncoder=="undefined"){var t=document.createElement("script");t.src="https://www.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(t)}e=e||{};var a=i instanceof CanvasRenderingContext2D||i instanceof HTMLCanvasElement;this.record=function(){if(typeof GIFEncoder=="undefined"){setTimeout(v.record,1e3);return}if(!h){setTimeout(v.record,1e3);return}a||(e.width||(e.width=b.offsetWidth||320),e.height||(e.height=b.offsetHeight||240),e.video||(e.video={width:e.width,height:e.height}),e.canvas||(e.canvas={width:e.width,height:e.height}),f.width=e.canvas.width||320,f.height=e.canvas.height||240,b.width=e.video.width||320,b.height=e.video.height||240),p=new GIFEncoder,p.setRepeat(0),p.setDelay(e.frameRate||200),p.setQuality(e.quality||10),p.start(),typeof e.onGifRecordingStarted=="function"&&e.onGifRecordingStarted();function c(R){if(v.clearedRecordedData!==!0){if(s)return setTimeout(function(){c(R)},100);l=Y(c),typeof g===void 0&&(g=R),!(R-g<90)&&(!a&&b.paused&&b.play(),a||r.drawImage(b,0,0,f.width,f.height),e.onGifPreview&&e.onGifPreview(f.toDataURL("image/png")),p.addFrame(r),g=R)}}l=Y(c),e.initCallback&&e.initCallback()},this.stop=function(c){c=c||function(){},l&&Z(l),this.blob=new Blob([new Uint8Array(p.stream().bin)],{type:"image/gif"}),c(this.blob),p.stream().bin=[]};var s=!1;this.pause=function(){s=!0},this.resume=function(){s=!1},this.clearRecordedData=function(){v.clearedRecordedData=!0,d()};function d(){p&&(p.stream().bin=[])}this.name="GifRecorder",this.toString=function(){return this.name};var f=document.createElement("canvas"),r=f.getContext("2d");a&&(i instanceof CanvasRenderingContext2D?(r=i,f=r.canvas):i instanceof HTMLCanvasElement&&(r=i.getContext("2d"),f=i));var h=!0;if(!a){var b=document.createElement("video");b.muted=!0,b.autoplay=!0,b.playsInline=!0,h=!1,b.onloadedmetadata=function(){h=!0},De(i,b),b.play()}var l=null,g,p,v=this}typeof S!="undefined"&&(S.GifRecorder=ce);function Be(i,e){var t="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(n){typeof S=="undefined"&&(!n||typeof window=="undefined"&&typeof A!="undefined"&&(A.navigator={userAgent:t,getUserMedia:function(){}},A.console||(A.console={}),(typeof A.console.log=="undefined"||typeof A.console.error=="undefined")&&(A.console.error=A.console.log=A.console.log||function(){console.log(arguments)}),typeof document=="undefined"&&(n.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var u={getContext:function(){return u},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return u},n.HTMLVideoElement=function(){}),typeof location=="undefined"&&(n.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(n.screen={width:0,height:0}),typeof b=="undefined"&&(n.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),n.window=A))})(typeof A!="undefined"?A:null),e=e||"multi-streams-mixer";var a=[],s=!1,d=document.createElement("canvas"),f=d.getContext("2d");d.style.opacity=0,d.style.position="absolute",d.style.zIndex=-1,d.style.top="-1000em",d.style.left="-1000em",d.className=e,(document.body||document.documentElement).appendChild(d),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var r=this,h=window.AudioContext;typeof h=="undefined"&&(typeof webkitAudioContext!="undefined"&&(h=webkitAudioContext),typeof mozAudioContext!="undefined"&&(h=mozAudioContext));var b=window.URL;typeof b=="undefined"&&typeof webkitURL!="undefined"&&(b=webkitURL),typeof navigator!="undefined"&&typeof navigator.getUserMedia=="undefined"&&(typeof navigator.webkitGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.webkitGetUserMedia),typeof navigator.mozGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.mozGetUserMedia));var l=window.MediaStream;typeof l=="undefined"&&typeof webkitMediaStream!="undefined"&&(l=webkitMediaStream),typeof l!="undefined"&&typeof l.prototype.stop=="undefined"&&(l.prototype.stop=function(){this.getTracks().forEach(function(n){n.stop()})});var g={};typeof h!="undefined"?g.AudioContext=h:typeof webkitAudioContext!="undefined"&&(g.AudioContext=webkitAudioContext);function p(n,u){"srcObject"in u?u.srcObject=n:"mozSrcObject"in u?u.mozSrcObject=n:u.srcObject=n}this.startDrawingFrames=function(){v()};function v(){if(!s){var n=a.length,u=!1,w=[];if(a.forEach(function(L){L.stream||(L.stream={}),L.stream.fullcanvas?u=L:w.push(L)}),u)d.width=u.stream.width,d.height=u.stream.height;else if(w.length){d.width=n>1?w[0].width*2:w[0].width;var y=1;(n===3||n===4)&&(y=2),(n===5||n===6)&&(y=3),(n===7||n===8)&&(y=4),(n===9||n===10)&&(y=5),d.height=w[0].height*y}else d.width=r.width||360,d.height=r.height||240;u&&u instanceof HTMLVideoElement&&c(u),w.forEach(function(L,k){c(L,k)}),setTimeout(v,r.frameInterval)}}function c(n,u){if(!s){var w=0,y=0,L=n.width,k=n.height;u===1&&(w=n.width),u===2&&(y=n.height),u===3&&(w=n.width,y=n.height),u===4&&(y=n.height*2),u===5&&(w=n.width,y=n.height*2),u===6&&(y=n.height*3),u===7&&(w=n.width,y=n.height*3),typeof n.stream.left!="undefined"&&(w=n.stream.left),typeof n.stream.top!="undefined"&&(y=n.stream.top),typeof n.stream.width!="undefined"&&(L=n.stream.width),typeof n.stream.height!="undefined"&&(k=n.stream.height),f.drawImage(n,w,y,L,k),typeof n.stream.onRender=="function"&&n.stream.onRender(f,w,y,L,k,u)}}function R(){s=!1;var n=T(),u=o();return u&&u.getTracks().filter(function(w){return w.kind==="audio"}).forEach(function(w){n.addTrack(w)}),i.forEach(function(w){w.fullcanvas}),n}function T(){C();var n;"captureStream"in d?n=d.captureStream():"mozCaptureStream"in d?n=d.mozCaptureStream():r.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var u=new l;return n.getTracks().filter(function(w){return w.kind==="video"}).forEach(function(w){u.addTrack(w)}),d.stream=u,u}function o(){g.AudioContextConstructor||(g.AudioContextConstructor=new g.AudioContext),r.audioContext=g.AudioContextConstructor,r.audioSources=[],r.useGainNode===!0&&(r.gainNode=r.audioContext.createGain(),r.gainNode.connect(r.audioContext.destination),r.gainNode.gain.value=0);var n=0;if(i.forEach(function(u){if(!!u.getTracks().filter(function(y){return y.kind==="audio"}).length){n++;var w=r.audioContext.createMediaStreamSource(u);r.useGainNode===!0&&w.connect(r.gainNode),r.audioSources.push(w)}}),!!n)return r.audioDestination=r.audioContext.createMediaStreamDestination(),r.audioSources.forEach(function(u){u.connect(r.audioDestination)}),r.audioDestination.stream}function m(n){var u=document.createElement("video");return p(n,u),u.className=e,u.muted=!0,u.volume=0,u.width=n.width||r.width||360,u.height=n.height||r.height||240,u.play(),u}this.appendStreams=function(n){if(!n)throw"First parameter is required.";n instanceof Array||(n=[n]),n.forEach(function(u){var w=new l;if(u.getTracks().filter(function(k){return k.kind==="video"}).length){var y=m(u);y.stream=u,a.push(y),w.addTrack(u.getTracks().filter(function(k){return k.kind==="video"})[0])}if(u.getTracks().filter(function(k){return k.kind==="audio"}).length){var L=r.audioContext.createMediaStreamSource(u);r.audioDestination=r.audioContext.createMediaStreamDestination(),L.connect(r.audioDestination),w.addTrack(r.audioDestination.stream.getTracks().filter(function(k){return k.kind==="audio"})[0])}i.push(w)})},this.releaseStreams=function(){a=[],s=!0,r.gainNode&&(r.gainNode.disconnect(),r.gainNode=null),r.audioSources.length&&(r.audioSources.forEach(function(n){n.disconnect()}),r.audioSources=[]),r.audioDestination&&(r.audioDestination.disconnect(),r.audioDestination=null),r.audioContext&&r.audioContext.close(),r.audioContext=null,f.clearRect(0,0,d.width,d.height),d.stream&&(d.stream.stop(),d.stream=null)},this.resetVideoStreams=function(n){n&&!(n instanceof Array)&&(n=[n]),C(n)};function C(n){a=[],n=n||i,n.forEach(function(u){if(!!u.getTracks().filter(function(y){return y.kind==="video"}).length){var w=m(u);w.stream=u,a.push(w)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=R}typeof S=="undefined"&&(Te.exports=Be);/**
  209. * MultiStreamRecorder can record multiple videos in single container.
  210. * @summary Multi-videos recorder.
  211. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  212. * @author {@link https://MuazKhan.com|Muaz Khan}
  213. * @typedef MultiStreamRecorder
  214. * @class
  215. * @example
  216. * var options = {
  217. * mimeType: 'video/webm'
  218. * }
  219. * var recorder = new MultiStreamRecorder(ArrayOfMediaStreams, options);
  220. * recorder.record();
  221. * recorder.stop(function(blob) {
  222. * video.src = URL.createObjectURL(blob);
  223. *
  224. * // or
  225. * var blob = recorder.blob;
  226. * });
  227. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  228. * @param {MediaStreams} mediaStreams - Array of MediaStreams.
  229. * @param {object} config - {disableLogs:true, frameInterval: 1, mimeType: "video/webm"}
  230. */function Ue(i,e){i=i||[];var t=this,a,s;e=e||{elementClass:"multi-streams-mixer",mimeType:"video/webm",video:{width:360,height:240}},e.frameInterval||(e.frameInterval=10),e.video||(e.video={}),e.video.width||(e.video.width=360),e.video.height||(e.video.height=240),this.record=function(){a=new Be(i,e.elementClass||"multi-streams-mixer"),d().length&&(a.frameInterval=e.frameInterval||10,a.width=e.video.width||360,a.height=e.video.height||240,a.startDrawingFrames()),e.previewStream&&typeof e.previewStream=="function"&&e.previewStream(a.getMixedStream()),s=new j(a.getMixedStream(),e),s.record()};function d(){var f=[];return i.forEach(function(r){x(r,"video").forEach(function(h){f.push(h)})}),f}this.stop=function(f){!s||s.stop(function(r){t.blob=r,f(r),t.clearRecordedData()})},this.pause=function(){s&&s.pause()},this.resume=function(){s&&s.resume()},this.clearRecordedData=function(){s&&(s.clearRecordedData(),s=null),a&&(a.releaseStreams(),a=null)},this.addStreams=function(f){if(!f)throw"First parameter is required.";f instanceof Array||(f=[f]),i.concat(f),!(!s||!a)&&(a.appendStreams(f),e.previewStream&&typeof e.previewStream=="function"&&e.previewStream(a.getMixedStream()))},this.resetVideoStreams=function(f){!a||(f&&!(f instanceof Array)&&(f=[f]),a.resetVideoStreams(f))},this.getMixer=function(){return a},this.name="MultiStreamRecorder",this.toString=function(){return this.name}}typeof S!="undefined"&&(S.MultiStreamRecorder=Ue);/**
  231. * RecordRTCPromisesHandler adds promises support in {@link RecordRTC}. Try a {@link https://github.com/muaz-khan/RecordRTC/blob/master/simple-demos/RecordRTCPromisesHandler.html|demo here}
  232. * @summary Promises for {@link RecordRTC}
  233. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  234. * @author {@link https://MuazKhan.com|Muaz Khan}
  235. * @typedef RecordRTCPromisesHandler
  236. * @class
  237. * @example
  238. * var recorder = new RecordRTCPromisesHandler(mediaStream, options);
  239. * recorder.startRecording()
  240. * .then(successCB)
  241. * .catch(errorCB);
  242. * // Note: You can access all RecordRTC API using "recorder.recordRTC" e.g.
  243. * recorder.recordRTC.onStateChanged = function(state) {};
  244. * recorder.recordRTC.setRecordingDuration(5000);
  245. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  246. * @param {MediaStream} mediaStream - Single media-stream object, array of media-streams, html-canvas-element, etc.
  247. * @param {object} config - {type:"video", recorderType: MediaStreamRecorder, disableLogs: true, numberOfAudioChannels: 1, bufferSize: 0, sampleRate: 0, video: HTMLVideoElement, etc.}
  248. * @throws Will throw an error if "new" keyword is not used to initiate "RecordRTCPromisesHandler". Also throws error if first argument "MediaStream" is missing.
  249. * @requires {@link RecordRTC}
  250. */function ze(i,e){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(typeof i=="undefined")throw'First argument "MediaStream" is required.';var t=this;t.recordRTC=new S(i,e),this.startRecording=function(){return new Promise(function(a,s){try{t.recordRTC.startRecording(),a()}catch(d){s(d)}})},this.stopRecording=function(){return new Promise(function(a,s){try{t.recordRTC.stopRecording(function(d){if(t.blob=t.recordRTC.getBlob(),!t.blob||!t.blob.size){s("Empty blob.",t.blob);return}a(d)})}catch(d){s(d)}})},this.pauseRecording=function(){return new Promise(function(a,s){try{t.recordRTC.pauseRecording(),a()}catch(d){s(d)}})},this.resumeRecording=function(){return new Promise(function(a,s){try{t.recordRTC.resumeRecording(),a()}catch(d){s(d)}})},this.getDataURL=function(a){return new Promise(function(s,d){try{t.recordRTC.getDataURL(function(f){s(f)})}catch(f){d(f)}})},this.getBlob=function(){return new Promise(function(a,s){try{a(t.recordRTC.getBlob())}catch(d){s(d)}})},this.getInternalRecorder=function(){return new Promise(function(a,s){try{a(t.recordRTC.getInternalRecorder())}catch(d){s(d)}})},this.reset=function(){return new Promise(function(a,s){try{a(t.recordRTC.reset())}catch(d){s(d)}})},this.destroy=function(){return new Promise(function(a,s){try{a(t.recordRTC.destroy())}catch(d){s(d)}})},this.getState=function(){return new Promise(function(a,s){try{a(t.recordRTC.getState())}catch(d){s(d)}})},this.blob=null,this.version="5.6.2"}typeof S!="undefined"&&(S.RecordRTCPromisesHandler=ze);/**
  251. * 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.
  252. * @summary Video recording feature in Chrome, Firefox and maybe Edge.
  253. * @license {@link https://github.com/muaz-khan/RecordRTC/blob/master/LICENSE|MIT}
  254. * @author {@link https://MuazKhan.com|Muaz Khan}
  255. * @typedef WebAssemblyRecorder
  256. * @class
  257. * @example
  258. * var recorder = new WebAssemblyRecorder(mediaStream);
  259. * recorder.record();
  260. * recorder.stop(function(blob) {
  261. * video.src = URL.createObjectURL(blob);
  262. * });
  263. * @see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
  264. * @param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
  265. * @param {object} config - {webAssemblyPath:'webm-wasm.wasm',workerPath: 'webm-worker.js', frameRate: 30, width: 1920, height: 1080, bitrate: 1024, realtime: true}
  266. */function oe(i,e){(typeof ReadableStream=="undefined"||typeof WritableStream=="undefined")&&console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"),e=e||{},e.width=e.width||640,e.height=e.height||480,e.frameRate=e.frameRate||30,e.bitrate=e.bitrate||1200,e.realtime=e.realtime||!0;var t;function a(){return new ReadableStream({start:function(b){var l=document.createElement("canvas"),g=document.createElement("video"),p=!0;g.srcObject=i,g.muted=!0,g.height=e.height,g.width=e.width,g.volume=0,g.onplaying=function(){l.width=e.width,l.height=e.height;var v=l.getContext("2d"),c=1e3/e.frameRate,R=setInterval(function(){if(t&&(clearInterval(R),b.close()),p&&(p=!1,e.onVideoProcessStarted&&e.onVideoProcessStarted()),v.drawImage(g,0,0),b._controlledReadableStream.state!=="closed")try{b.enqueue(v.getImageData(0,0,e.width,e.height))}catch(o){}},c)},g.play()}})}var s;function d(b,l){if(!e.workerPath&&!l){t=!1,fetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then(function(p){p.arrayBuffer().then(function(v){d(b,v)})});return}if(!e.workerPath&&l instanceof ArrayBuffer){var g=new Blob([l],{type:"text/javascript"});e.workerPath=U.createObjectURL(g)}e.workerPath||console.error("workerPath parameter is missing."),s=new Worker(e.workerPath),s.postMessage(e.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),s.addEventListener("message",function(p){p.data==="READY"?(s.postMessage({width:e.width,height:e.height,bitrate:e.bitrate||1200,timebaseDen:e.frameRate||30,realtime:e.realtime}),a().pipeTo(new WritableStream({write:function(v){if(t){console.error("Got image, but recorder is finished!");return}s.postMessage(v.data.buffer,[v.data.buffer])}}))):p.data&&(f||h.push(p.data))})}this.record=function(){h=[],f=!1,this.blob=null,d(i),typeof e.initCallback=="function"&&e.initCallback()};var f;this.pause=function(){f=!0},this.resume=function(){f=!1};function r(b){if(!s){b&&b();return}s.addEventListener("message",function(l){l.data===null&&(s.terminate(),s=null,b&&b())}),s.postMessage(null)}var h=[];this.stop=function(b){t=!0;var l=this;r(function(){l.blob=new Blob(h,{type:"video/webm"}),b(l.blob)})},this.name="WebAssemblyRecorder",this.toString=function(){return this.name},this.clearRecordedData=function(){h=[],f=!1,this.blob=null},this.blob=null}typeof S!="undefined"&&(S.WebAssemblyRecorder=oe)})(Oe);const Je=Oe.exports;export{Je as R};