-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcommon.js
More file actions
82 lines (69 loc) · 1.9 KB
/
Copy pathcommon.js
File metadata and controls
82 lines (69 loc) · 1.9 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Player request.
const kPlayVideoReq = 0;
const kPauseVideoReq = 1;
const kStopVideoReq = 2;
// Player response.
const kPlayVideoRsp = 0;
const kAudioInfo = 1;
const kVideoInfo = 2;
const kAudioData = 3;
const kVideoData = 4;
// Downloader request.
const kGetFileInfoReq = 0;
const kDownloadFileReq = 1;
const kCloseDownloaderReq = 2;
// Downloader response.
const kGetFileInfoRsp = 0;
const kFileData = 1;
// Downloader Protocol.
const kProtoHttp = 0;
const kProtoWebsocket = 1;
// Decoder request.
const kInitDecoderReq = 0;
const kUninitDecoderReq = 1;
const kOpenDecoderReq = 2;
const kCloseDecoderReq = 3;
const kFeedDataReq = 4;
const kStartDecodingReq = 5;
const kPauseDecodingReq = 6;
const kSeekToReq = 7;
// Decoder response.
const kInitDecoderRsp = 0;
const kUninitDecoderRsp = 1;
const kOpenDecoderRsp = 2;
const kCloseDecoderRsp = 3;
const kVideoFrame = 4;
const kAudioFrame = 5;
const kStartDecodingRsp = 6;
const kPauseDecodingRsp = 7;
const kDecodeFinishedEvt = 8;
const kRequestDataEvt = 9;
const kSeekToRsp = 10;
class Logger {
constructor(module) {
this.module = module;
}
log(line) {
console.log(`[${this.currentTimeStr()}][${this.module}] ${line}`);
}
logError(line) {
console.error(`[${this.currentTimeStr()}][${this.module}][ER] ${line}`);
}
logInfo(line) {
console.log(`[${this.currentTimeStr()}][${this.module}][IF] ${line}`);
}
logDebug(line) {
console.debug(`[${this.currentTimeStr()}][${this.module}][DT] ${line}`);
}
currentTimeStr() {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
const day = now.getDate();
const hour = now.getHours();
const min = now.getMinutes();
const sec = now.getSeconds();
const ms = now.getMilliseconds();
return `${year}-${month}-${day} ${hour}:${min}:${sec}:${ms}`;
}
}