-
Notifications
You must be signed in to change notification settings - Fork 3
/
awbwnd_cli.lua
144 lines (115 loc) · 3.37 KB
/
awbwnd_cli.lua
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
local animtexco_vshader = [[
uniform mat4 modelview;
uniform mat4 projection;
uniform int timestamp;
uniform vec2 speedfact;
attribute vec4 vertex;
attribute vec2 texcoord;
varying vec2 texco;
void main(void)
{
texco.s = texcoord.s + fract(float(timestamp) / speedfact.x);
texco.t = texcoord.t + fract(float(timestamp) / speedfact.y);
gl_Position = (projection * modelview) * vertex;
}
]];
function awbwnd_breakdisplay(wnd)
switch_default_texmode( TEX_REPEAT, TEX_REPEAT );
wnd:update_canvas(random_surface(128, 128));
switch_default_texmode( TEX_CLAMP, TEX_CLAMP );
wnd.broken = true;
if (wnd.dir.tt) then
wnd.dir.tt:destroy();
end
wnd.rebuild_chain = function() end
wnd.shid = build_shader(animtexco_vshader, nil, "vid_" .. wnd.wndid);
if (wnd.shid ~= nil) then
shader_uniform(wnd.shid, "speedfact", "ff", PERSIST, 12.0, 12.0);
image_shader(wnd.canvas.vid, wnd.shid);
end
wnd:resize(wnd.canvasw, wnd.canvash, true);
end
local function datashare(wnd)
local res = awbwman_setup_cursortag(sysicons.floppy);
res.kind = "media";
res.source = wnd;
res.audio = wnd.recv;
res.name = wnd.name;
return res;
end
local function cli_handler(pwin, source, status)
if (pwin.alive == false) then
return;
end
if (pwin.controlid == nil) then
pwin:update_canvas(source);
end
if (status.kind == "resized") then
print("resized to", status.width, status.height);
-- pwin:resize(status.width, status.height, true, true);
elseif (status.kind == "preroll") then
target_fonthint(source, deffont, deffont_sz, 0, 0);
local cw = image_surface_resolve(pwin.canvas.vid);
target_displayhint(source, cw.width, cw.height, 0, {
ppcm = VPPCM, subpixel_layout = "rgb"
});
elseif (status.kind == "terminated") then
pwin:break_display();
elseif (status.kind == "streamstatus") then
awbmedia_update_streamstats(pwin, status);
end
end
function awbwnd_cli(pwin, source, options)
local kind = pwin.kind;
pwin.filters = {};
pwin.hoverlut = {};
pwin.rebuild_chain = awbwmedia_filterchain;
pwin.break_display = awbwnd_breakdisplay;
pwin:add_handler("on_destroy",
function(self)
if (pwin.filtertmp ~= nil) then
for i, v in ipairs(pwin.filtertmp) do
if (valid_vid(v)) then delete_image(v); end
end
end
if (valid_vid(pwin.controlid)) then
delete_image(pwin.controlid);
pwin.controlid = nil;
end
end
);
pwin.canvas.resize =
function(canvas, winw, winh, cnvw, cnvh)
resize_image(pwin.canvas.vid, pwin.canvasw, pwin.canvash);
if (valid_vid(pwin.controlid, TYPE_FRAMESERVER)) then
target_displayhint(pwin.controlid, pwin.canvasw, pwin.canvash);
end
end;
local canvash = {
name = kind .. "_canvash",
own = function(self, vid)
return vid == pwin.canvas.vid;
end,
click = function()
pwin:focus();
end
}
pwin.input = function(self, iotbl)
if (valid_vid(pwin.controlid, TYPE_FRAMESERVER)) then
target_input(pwin.controlid, iotbl);
end
end
mouse_addlistener(canvash, {"click"});
table.insert(pwin.handlers, canvash);
local bar = pwin:add_bar("tt", pwin.ttbar_bg, pwin.ttbar_bg,
pwin.dir.t.rsize, pwin.dir.t.bsize);
bar.name = "vmedia_ttbarh";
local cfg = awbwman_cfg();
bar.hoverlut[
(bar:add_icon("clone", "r", cfg.bordericns["clone"],
function() datashare(pwin); end)).vid] =
MESSAGE["HOVER_CLONE"];
return function(source, status)
cli_handler(pwin, source, status);
end
end