This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sendChannel; | |
var sendButton = document.getElementById("sendButton"); | |
var sendTextarea = document.getElementById("dataChannelSend"); | |
var receiveTextarea = document.getElementById("dataChannelReceive"); | |
sendButton.onclick = sendData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varpc_constraints = { | |
'optional': [ | |
{'DtlsSrtpKeyAgreement': true}, | |
{'RtpDataChannels': true} | |
]}; | |
est à remplacer par : | |
varpc_constraints = { | |
'optional': [ | |
{'DtlsSrtpKeyAgreement': true} | |
]}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isInitiator) { | |
try{ | |
//Reliable DataChannelsnotyet supportedinChrome | |
sendChannel = pc.createDataChannel("sendDataChannel", | |
{reliable: false}); | |
sendChannel.onmessage = handleMessage; | |
trace('Createdsenddatachannel'); | |
} catch (e) { | |
alert('Failedtocreatedatachannel. ' + | |
'You needChrome M25or later with RtpDataChannelenabled'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvasRemoteElement = document.querySelector('#canvasRemoteVideo'); | |
var ctxRemote = canvasRemoteElement.getContext('2d'); | |
function snapshot(){ | |
var canvasToUse = canvasRemoteElement; | |
var contextToUse = ctxRemote; | |
varvideoToUse = remoteVideo; | |
canvasRemoteElement.width = remoteVideo.videoWidth; | |
canvasRemoteElement.height = remoteVideo.videoHeight; | |
if (remoteStream){ | |
ctxRemote.drawImage(remoteVideo,0,0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var init = false; | |
function snapshot(){ | |
var canvasToUse = canvasRemoteElement; | |
var contextToUse = ctxRemote; | |
varvideoToUse = remoteVideo; | |
canvasRemoteElement.width = remoteVideo.videoWidth; | |
canvasRemoteElement.height = remoteVideo.videoHeight; | |
if (remoteStream){ | |
ctxRemote.drawImage(remoteVideo,0,0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.refresh = function(){ | |
update(); | |
} | |
// main render loop | |
varupdate = function() | |
{ | |
smooth(); | |
draw(); | |
frames++; | |
//requestAnimFrame(function() {update(); }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//draw colormap->palettevalues toscreen | |
vardraw = function() | |
{ | |
// render theimagedatatotheoffscreen buffer... | |
bufferContext.putImageData(imageData,0,0); | |
// ...then draw it toscaletotheonscreen canvas | |
// Imagedebaseen bas ! | |
drawAngle(0); | |
drawAngle(90); | |
drawAngle(180); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vardims = {}; | |
this.canvas = undefined; | |
this.init = function(dim) | |
{ | |
context = this.canvas.getContext('2d'); | |
width = Math.round(this.canvas.width / scale); | |
height = Math.round(this.canvas.height / scale); | |
if (dim){ | |
dims = dim; | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setpixels in imageData | |
vardrawPixel = function(x,y, color) | |
{ | |
varoffset = (x + y*imageData.width)*4; | |
imageData.data[offset] = color[0]; | |
imageData.data[offset + 1] = color[1]; | |
imageData.data[offset + 2] = color[2]; | |
if (color[0] <= 100 && color[1] === 0 && color[2] <= 100){ | |
imageData.data[offset + 3] = 0; | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawEllipse(ctx, x,y, w, h) { | |
varkappa = .5522848, | |
ox = (w /2)*kappa, // controlpointoffset horizontal | |
oy = (h /2)*kappa, // controlpointoffsetvertical | |
xe = x + w, // x-end | |
ye = y + h, //y-end | |
xm = x + w /2, // x-middle | |
ym = y + h /2; //y-middle | |
ctx.beginPath(); | |
ctx.moveTo(x,ym); |
OlderNewer