forked from omerjerk/RemoteDroid_web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw.h264.js
50 lines (43 loc) · 1.09 KB
/
raw.h264.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
var toUint8Array = function(data){
// var raw = window.atob(parStr);
var rawLength = data.length;
// var array = new Uint8Array(new ArrayBuffer(rawLength));
var array = new Uint8Array(data);
var i;
for(i = 0; i < rawLength; i++) {
array[i] = data.charCodeAt(i);
}
return array;
};
var RawRenderer = function(_useWorker) {
// this.url = url;
this.player = new Player({
useWorker : _useWorker,
workerFile : "Decoder.js"
});
/*
this.player = new Decoder({
"rgb" : "false"
});*/
/*
this.onPictureDecoded = function(buffer, width, height) {
console.log("on picture decoded");
};*/
this.fileReader = new FileReader();
var that = this;
this.fileReader.onload = function() {
that.onDecodeMessage(that.fileReader.result);
};
};
RawRenderer.prototype.getCanvas = function() {
return this.player.canvas;
};
RawRenderer.prototype.render = function(data) {
this.fileReader.readAsArrayBuffer(data);
};
RawRenderer.prototype.onDecodeMessage = function(data) {
var array = new Uint8Array(data);
console.log(array);
this.player.decode(array);
};