Skip to content

Instantly share code, notes, and snippets.

View jefBinomed's full-sized avatar

Jean-François Garreau - Binomed jefBinomed

View GitHub Profile
@jefBinomed
jefBinomed / test.java
Created August 22, 2012 11:15
A simple gist test
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
}
@jefBinomed
jefBinomed / gist:ebcd92cd595efe19ff33
Created June 17, 2015 14:47
Programmez-07/08_2015-PortalWebrtc-01
var sendChannel;
var sendButton = document.getElementById("sendButton");
var sendTextarea = document.getElementById("dataChannelSend");
var receiveTextarea = document.getElementById("dataChannelReceive");
sendButton.onclick = sendData;
@jefBinomed
jefBinomed / gist:f9d021477fbc8e313501
Created June 17, 2015 14:47
Programmez-07/08_2015-PortalWebrtc-02
varpc_constraints = {
'optional': [
{'DtlsSrtpKeyAgreement': true},
{'RtpDataChannels': true}
]};
est à remplacer par :
varpc_constraints = {
'optional': [
{'DtlsSrtpKeyAgreement': true}
]};
@jefBinomed
jefBinomed / gist:f0f9697b022627b73579
Created June 17, 2015 14:48
Programmez-07/08_2015-PortalWebrtc-03
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');
@jefBinomed
jefBinomed / gist:f524a35662675351eb2f
Created June 17, 2015 14:49
Programmez-07/08_2015-PortalWebrtc-04
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);
@jefBinomed
jefBinomed / gist:1d548336d9e66db196ba
Created June 17, 2015 14:50
Programmez-07/08_2015-PortalWebrtc-05
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);
}
@jefBinomed
jefBinomed / gist:d8352bfeb0dbb09c69e0
Created June 17, 2015 14:50
Programmez-07/08_2015-PortalWebrtc-06
this.refresh = function(){
update();
}
// main render loop
varupdate = function()
{
smooth();
draw();
frames++;
//requestAnimFrame(function() {update(); });
@jefBinomed
jefBinomed / gist:10c927e157e4ff531cf7
Created June 17, 2015 14:51
Programmez-07/08_2015-PortalWebrtc-07
//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);
@jefBinomed
jefBinomed / gist:2df5ea08063138042cea
Created June 17, 2015 14:52
Programmez-07/08_2015-PortalWebrtc-08
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{
@jefBinomed
jefBinomed / gist:2a401edfc41f48252f51
Created June 17, 2015 14:53
Programmez-07/08_2015-PortalWebrtc-09
// 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{