(mediaStream)
| 16 | // MediaStreamRecorder.js |
| 17 | |
| 18 | function MediaStreamRecorder(mediaStream) { |
| 19 | if (!mediaStream) { |
| 20 | throw 'MediaStream is mandatory.'; |
| 21 | } |
| 22 | |
| 23 | // void start(optional long timeSlice) |
| 24 | // timestamp to fire "ondataavailable" |
| 25 | this.start = function(timeSlice) { |
| 26 | var Recorder; |
| 27 | |
| 28 | if (typeof MediaRecorder !== 'undefined') { |
| 29 | Recorder = MediaRecorderWrapper; |
| 30 | } else if (IsChrome || IsOpera || IsEdge) { |
| 31 | if (this.mimeType.indexOf('video') !== -1) { |
| 32 | Recorder = WhammyRecorder; |
| 33 | } else if (this.mimeType.indexOf('audio') !== -1) { |
| 34 | Recorder = StereoAudioRecorder; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // video recorder (in GIF format) |
| 39 | if (this.mimeType === 'image/gif') { |
| 40 | Recorder = GifRecorder; |
| 41 | } |
| 42 | |
| 43 | // audio/wav is supported only via StereoAudioRecorder |
| 44 | // audio/pcm (int16) is supported only via StereoAudioRecorder |
| 45 | if (this.mimeType === 'audio/wav' || this.mimeType === 'audio/pcm') { |
| 46 | Recorder = StereoAudioRecorder; |
| 47 | } |
| 48 | |
| 49 | // allows forcing StereoAudioRecorder.js on Edge/Firefox |
| 50 | if (this.recorderType) { |
| 51 | Recorder = this.recorderType; |
| 52 | } |
| 53 | |
| 54 | mediaRecorder = new Recorder(mediaStream); |
| 55 | mediaRecorder.blobs = []; |
| 56 | |
| 57 | var self = this; |
| 58 | mediaRecorder.ondataavailable = function(data) { |
| 59 | mediaRecorder.blobs.push(data); |
| 60 | self.ondataavailable(data); |
| 61 | }; |
| 62 | mediaRecorder.onstop = this.onstop; |
| 63 | mediaRecorder.onStartedDrawingNonBlankFrames = this.onStartedDrawingNonBlankFrames; |
| 64 | |
| 65 | // Merge all data-types except "function" |
| 66 | mediaRecorder = mergeProps(mediaRecorder, this); |
| 67 | |
| 68 | mediaRecorder.start(timeSlice); |
| 69 | }; |
| 70 | |
| 71 | this.onStartedDrawingNonBlankFrames = function() {}; |
| 72 | this.clearOldRecordedFrames = function() { |
| 73 | if (!mediaRecorder) { |
| 74 | return; |
| 75 | } |
nothing calls this directly
no test coverage detected