Skip to content

Commit 875f23d

Browse files
ntocmassiot
authored andcommitted
luajit: cleanup examples
1 parent d1bdd59 commit 875f23d

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

luajit/examples/extract_pic.lua

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require "upipe-framers"
1010
require "upipe-filters"
1111
require "upipe-swscale"
1212

13-
local UPROBE_LOG_LEVEL = UPROBE_LOG_INFO
13+
local UPROBE_LOG_LEVEL = 'UPROBE_LOG_INFO'
1414

1515
local src_path = assert(arg[1])
1616
local dst_path = assert(arg[2])
@@ -27,9 +27,7 @@ local null = upipe.null():new(pfx("null") .. probe)
2727

2828
-- file source
2929
local source = upipe.fsrc():new(pfx("src") .. probe)
30-
if not ubase_check(source:set_uri(src_path)) then
31-
os.exit(1)
32-
end
30+
source.uri = src_path
3331

3432
local split_pipe
3533

@@ -58,7 +56,7 @@ local avcdec_probe = uprobe {
5856
local sar = flow_def:pic_flow_get_sar()
5957
if not hsize or not sar then
6058
pipe:err_va("incompatible flow def")
61-
return "unhandled"
59+
return 'unhandled'
6260
end
6361

6462
local wanted_hsize = (hsize * sar.num / sar.den / 2) * 2
@@ -86,7 +84,7 @@ local avcdec_probe = uprobe {
8684
probe)
8785

8886
local fsink = upipe.fsink():new(pfx("sink") .. probe)
89-
fsink:fsink_set_path(dst_path, "UPIPE_FSINK_OVERWRITE")
87+
ubase_assert(fsink:fsink_set_path(dst_path, 'UPIPE_FSINK_OVERWRITE'))
9088

9189
pipe.output = ffmt .. jpegenc .. urefprobe .. fsink
9290
end
@@ -110,8 +108,8 @@ ts_demux_mgr.autof_mgr = upipe.autof()
110108

111109
source.output = ts_demux_mgr:new(
112110
pfx("ts demux") ..
113-
uprobe.selflow(UPROBE_SELFLOW_VOID, "auto",
114-
uprobe.selflow(UPROBE_SELFLOW_PIC, "auto",
111+
uprobe.selflow('UPROBE_SELFLOW_VOID', "auto",
112+
uprobe.selflow('UPROBE_SELFLOW_PIC', "auto",
115113
split_probe ..
116114
probe) ..
117115
probe) ..

luajit/examples/upipe_duration.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require "upipe-modules"
77
require "upipe-ts"
88
require "upipe-framers"
99

10-
local UPROBE_LOG_LEVEL = UPROBE_LOG_INFO
10+
local UPROBE_LOG_LEVEL = 'UPROBE_LOG_INFO'
1111

1212
if #arg ~= 1 then
1313
io.stderr:write("Usage: ", arg[0], " <filename>\n")
@@ -46,10 +46,7 @@ end
4646

4747
-- pipes
4848
local src = upipe.fsrc():new(pfx("src") .. probe)
49-
if not ubase_check(src:set_uri(file)) then
50-
io.stderr:write("invalid file\n")
51-
os.exit(1)
52-
end
49+
src.uri = file
5350

5451
local sink = count_mgr:new(pfx("count") .. probe)
5552

@@ -58,10 +55,10 @@ ts_demux_mgr.autof_mgr = upipe.autof()
5855

5956
src.output = ts_demux_mgr:new(
6057
pfx("ts demux") ..
61-
uprobe.selflow(UPROBE_SELFLOW_VOID, "auto",
62-
uprobe.selflow(UPROBE_SELFLOW_PIC, "auto",
58+
uprobe.selflow('UPROBE_SELFLOW_VOID', "auto",
59+
uprobe.selflow('UPROBE_SELFLOW_PIC', "auto",
6360
uprobe {
64-
new_flow_def = function (probe, pipe, flow_def)
61+
need_output = function (probe, pipe, flow_def)
6562
pipe.output = sink
6663
end } ..
6764
probe) ..

luajit/examples/upipe_http_get.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require "upump-ev"
66
require "upipe-modules"
77
require "upipe-openssl"
88

9-
local UPROBE_LOG_LEVEL = UPROBE_LOG_INFO
9+
local UPROBE_LOG_LEVEL = 'UPROBE_LOG_INFO'
1010

1111
if #arg ~= 1 then
1212
io.stderr:write("Usage: ", arg[0], " <url>\n")
@@ -25,7 +25,7 @@ end
2525

2626
-- pipes
2727
local sink = upipe.fsink():new(pfx("sink") .. probe)
28-
ubase_assert(sink:fsink_set_path("/dev/stdout", "UPIPE_FSINK_OVERWRITE"))
28+
ubase_assert(sink:fsink_set_path("/dev/stdout", 'UPIPE_FSINK_OVERWRITE'))
2929

3030
local src = upipe.http_src():new(pfx("http") .. probe_https .. probe)
3131
src.uri = url

luajit/examples/upipe_xor.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local upipe = require "upipe"
66
require "upump-ev"
77
require "upipe-modules"
88

9-
local UPROBE_LOG_LEVEL = UPROBE_LOG_INFO
9+
local UPROBE_LOG_LEVEL = 'UPROBE_LOG_INFO'
1010

1111
if #arg ~= 2 then
1212
io.stderr:write("Usage: ", arg[0], " <input> <output>\n")
@@ -50,7 +50,7 @@ local upipe_xor_mgr = upipe {
5050
control = {
5151
set_flow_def = function (pipe, flow_def)
5252
if not ubase_check(flow_def:flow_match_def("block.")) then
53-
return "invalid"
53+
return 'invalid'
5454
end
5555
pipe:helper_store_flow_def(flow_def:dup())
5656
end
@@ -70,7 +70,7 @@ local xor = upipe_xor_mgr:new(pfx "xor")
7070
local sink = upipe.fsink():new(pfx "sink")
7171

7272
src.uri = input
73-
ubase_assert(sink:fsink_set_path(output, "UPIPE_FSINK_OVERWRITE"))
73+
ubase_assert(sink:fsink_set_path(output, 'UPIPE_FSINK_OVERWRITE'))
7474
src.output = xor .. sink
7575

7676
-- main loop

0 commit comments

Comments
 (0)