-
Notifications
You must be signed in to change notification settings - Fork 7
/
loadworker.cc
54 lines (51 loc) · 1.29 KB
/
loadworker.cc
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
#include "loadworker.h"
void LoadWorker::Execute() {
baton->state = DS_LOAD;
baton->filename = filename;
baton->decode_first_frame = decodeFirstFrame;
baton->colorspace = colorspace;
baton->OpenVideoFile();
}
void LoadWorker::HandleOKCallback() {
Nan::HandleScope();
if(baton->error != "") {
baton->m_Error(baton->error);
}
else {
baton->m_MetaData();
baton->state = DS_IDLE;
switch (baton->action) {
case DA_LOAD:
baton->action = DA_NONE;
if(baton->decode_first_frame) {
Nan::AsyncQueueWorker(new DemuxWorker(baton, false));
}
break;
case DA_PLAY:
baton->demux_start = uv_now(uv_default_loop());
baton->video_start = baton->current_frame * baton->frame_time * 1000.0;
baton->m_Start();
Nan::AsyncQueueWorker(new DemuxWorker(baton, true));
break;
case DA_NEXT_FRAME:
baton->demux_start = uv_now(uv_default_loop());
baton->video_start = baton->current_frame * baton->frame_time * 1000.0;
baton->m_Start();
Nan::AsyncQueueWorker(new DemuxWorker(baton, false));
break;
case DA_PAUSE:
baton->action = DA_NONE;
baton->m_Pause();
break;
case DA_SEEK:
Nan::AsyncQueueWorker(new SeekWorker(baton));
break;
case DA_END:
baton->action = DA_NONE;
baton->m_End();
break;
default:
break;
}
}
}