Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine-core
Commits
b6598f4a
Commit
b6598f4a
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Test: Adapt to extracted, testable functions
parent
848d8000
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/base_config.liq
+3
-0
3 additions, 0 deletions
tests/base_config.liq
tests/test_metadata_insert_merge.liq
+21
-70
21 additions, 70 deletions
tests/test_metadata_insert_merge.liq
with
24 additions
and
70 deletions
tests/base_config.liq
+
3
−
0
View file @
b6598f4a
...
...
@@ -29,6 +29,9 @@ settings.log.level.set(1)
# settings.ffmpeg.log.level.set(5)
# Engine Defaults
engine_meta_key_show_id = "show_id"
ignore(engine_meta_key_show_id)
engine_default_track_type = "0"
ignore(engine_default_track_type)
...
...
This diff is collapsed.
Click to expand it.
tests/test_metadata_insert_merge.liq
+
21
−
70
View file @
b6598f4a
...
...
@@ -19,7 +19,7 @@
%include "base_config.liq"
%include "../src/functions.liq"
# Test insert metadata on stream
url = "https://securestream.o94.at/live.mp3"
...
...
@@ -33,87 +33,38 @@ end
last_metadata = in_stream.last_metadata
imcb = in_stream.insert_metadata
# Check for show-specific metadata
def has_show_meta(meta) =
key_show_id = "show_id"
list.assoc.mem(key_show_id, meta) ? true : false
end
# Check if the current show metadata is same as the prev one
def is_same_show(last_meta, current_meta) =
key_show_id = "show_id"
if has_show_meta(last_meta) then
if not has_show_meta(current_meta) then
# No current show meta: handle as same show
true
else
# A new show has started
false
end
else
# Last show has no show meta
if not has_show_meta(current_meta) then
# And the current one either: handle as same show
true
else
# A new show has started
false
end
end
end
# Ability to insert and merge with previous metadata
def insert_merged_meta(meta) =
lm = (last_metadata() ?? [])
merged = ref(lm)
def add_meta_entry(entry) =
print("Add entry #{entry}")
let (k, v) = entry
if list.assoc.mem(k, !merged) then
print("Remove existing entry #{entry} with key #{k}")
merged := list.assoc.remove(k, !merged)
end
merged := list.add(entry, !merged)
end
list.iter(add_meta_entry, (meta))
print("MERGED META: #{!merged}")
imcb(!merged)
end
# Handles either insert or merge & insert of metadata
def process_meta_insert(meta) =
lm = (last_metadata() ?? [])
if is_same_show(lm, meta) then
print("SAME SHOW: merge & insert")
insert_merged_meta(meta)
else
print("NEW SHOW: insert -> #{meta}")
imcb(meta)
end
end
# Handle event and stream output
in_stream = source.on_metadata(id="in_stream", in_stream, on_metadata_notification)
output.alsa(id="lineout", device="default", mksafe(in_stream))
# Test Case 1: Normal insert and merge
# Provide new metadata every 3 seconds
def case1() =
print("Running Test Case 1 ...")
meta = [("foo", "bar")]
process
_meta_insert(meta)
do
_meta_insert(
last_metadata, imcb,
meta)
end
thread.run(delay=2., every=3., { case1() })
thread.run(delay=2., { case1() })
thread.run(delay=4., { case1() })
thread.run(delay=8., { case1() })
# Test Case
1
: Insert metadata with new show
# Test Case
2
: Insert metadata with new show
# Provide new metadata after 23 seconds
def case2() =
print("Running Test Case 2 ...")
meta = [("show_id", "333"), ("fooBar", "2000")]
process_meta_insert(meta)
meta = [("show_id", "333"), ("FooBar", "2000")]
do_meta_insert(last_metadata, imcb, meta)
end
thread.run(delay=13., { case2() })
thread.run(delay=16., { case1() })
# Test Case 3: Insert metadata with new show
# Provide new show metadata after 42 seconds
def case3() =
print("Running Test Case 3 ...")
meta = [("show_id", "42"), ("Something", "...completely different")]
do_meta_insert(last_metadata, imcb, meta)
end
thread.run(delay=23., { case2() })
thread.run(delay=23., { case3() })
thread.run(delay=42., { case1() })
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment