(mediaStream)
| 2064 | // GifRecorder.js |
| 2065 | |
| 2066 | function GifRecorder(mediaStream) { |
| 2067 | if (typeof GIFEncoder === 'undefined') { |
| 2068 | throw 'Please link: https://cdn.webrtc-experiment.com/gif-recorder.js'; |
| 2069 | } |
| 2070 | |
| 2071 | // void start(optional long timeSlice) |
| 2072 | // timestamp to fire "ondataavailable" |
| 2073 | this.start = function(timeSlice) { |
| 2074 | timeSlice = timeSlice || 1000; |
| 2075 | |
| 2076 | var imageWidth = this.videoWidth || 320; |
| 2077 | var imageHeight = this.videoHeight || 240; |
| 2078 | |
| 2079 | canvas.width = video.width = imageWidth; |
| 2080 | canvas.height = video.height = imageHeight; |
| 2081 | |
| 2082 | // external library to record as GIF images |
| 2083 | gifEncoder = new GIFEncoder(); |
| 2084 | |
| 2085 | // void setRepeat(int iter) |
| 2086 | // Sets the number of times the set of GIF frames should be played. |
| 2087 | // Default is 1; 0 means play indefinitely. |
| 2088 | gifEncoder.setRepeat(0); |
| 2089 | |
| 2090 | // void setFrameRate(Number fps) |
| 2091 | // Sets frame rate in frames per second. |
| 2092 | // Equivalent to setDelay(1000/fps). |
| 2093 | // Using "setDelay" instead of "setFrameRate" |
| 2094 | gifEncoder.setDelay(this.frameRate || this.speed || 200); |
| 2095 | |
| 2096 | // void setQuality(int quality) |
| 2097 | // Sets quality of color quantization (conversion of images to the |
| 2098 | // maximum 256 colors allowed by the GIF specification). |
| 2099 | // Lower values (minimum = 1) produce better colors, |
| 2100 | // but slow processing significantly. 10 is the default, |
| 2101 | // and produces good color mapping at reasonable speeds. |
| 2102 | // Values greater than 20 do not yield significant improvements in speed. |
| 2103 | gifEncoder.setQuality(this.quality || 1); |
| 2104 | |
| 2105 | // Boolean start() |
| 2106 | // This writes the GIF Header and returns false if it fails. |
| 2107 | gifEncoder.start(); |
| 2108 | |
| 2109 | startTime = Date.now(); |
| 2110 | |
| 2111 | function drawVideoFrame(time) { |
| 2112 | if (isPaused) { |
| 2113 | setTimeout(drawVideoFrame, 500, time); |
| 2114 | return; |
| 2115 | } |
| 2116 | |
| 2117 | lastAnimationFrame = requestAnimationFrame(drawVideoFrame); |
| 2118 | |
| 2119 | if (typeof lastFrameTime === undefined) { |
| 2120 | lastFrameTime = time; |
| 2121 | } |
| 2122 | |
| 2123 | // ~10 fps |
nothing calls this directly
no test coverage detected