-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
52 lines (39 loc) · 1.06 KB
/
main.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
51
52
(function() {
window.piCamStream = {
streamSocket: null,
sessionStart: Date.now(),
connected: false,
init: function() {
this.connected = this.connectStreamSocket();
if (!this.connected) {
alert('Could not connect to stream. Sorry :-(');
return;
}
this.streamSocket.send('ready', { start: this.sessionStart });
},
connectStreamSocket: function() {
if (!SocketServer) return false;
this.streamSocket = new SocketServer({
connectCallback: this.connectHandler,
disconnectCallback: this.disconnectHandler,
drawHandler: this.drawHandler
});
return !!this.streamSocket.connection;
},
connectCallback: function(socket) {
// show opening frames
},
disconnectCallback: function(socket) {
},
drawHandler: function(method, data) {
if (method === 'newFrame') {
this.streamJPEGDataToCanvas(data);
}
},
streamJPEGDataToCanvas: function(rawJPEG) {
}
};
})();
$(document).ready(function() {
piCamStream.init();
});