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
2d8237d5
Commit
2d8237d5
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Test: Split cases for simple stream and insert
parent
dddadf1c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Liquidsoap 2 migration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_metadata_insert_merge.liq
+61
-0
61 additions, 0 deletions
tests/test_metadata_insert_merge.liq
tests/test_metadata_stream.liq
+0
-28
0 additions, 28 deletions
tests/test_metadata_stream.liq
with
61 additions
and
28 deletions
tests/test_metadata_insert_merge.liq
0 → 100755
+
61
−
0
View file @
2d8237d5
#!/usr/bin/env liquidsoap
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-now() - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
%include "base_config.liq"
# Test insert metadata on stream
url = "https://securestream.o94.at/live.mp3"
in_stream = input.http(id="in_stream", start=true, url)
in_stream = insert_metadata(id="in_stream", in_stream)
def on_metadata_notification(metadata) =
print("METADATA: \n#{metadata}")
end
# Save the callback
last_metadata = in_stream.last_metadata
imcb = in_stream.insert_metadata
# 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
in_stream = source.on_metadata(id="in_stream", in_stream, on_metadata_notification)
output.alsa(id="lineout", device="default", mksafe(in_stream))
# Later:
meta = [("foo", "bar")]
thread.run(every=3., { insert_merged_meta(meta) })
This diff is collapsed.
Click to expand it.
tests/test_metadata_stream.liq
+
0
−
28
View file @
2d8237d5
...
...
@@ -29,33 +29,5 @@ def on_metadata_notification(metadata) =
print("METADATA: \n#{metadata}")
end
# Save the callback
last_metadata = in_stream.last_metadata
imcb = in_stream.insert_metadata
# 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
in_stream = source.on_metadata(id="in_stream", in_stream, on_metadata_notification)
output.alsa(id="lineout", device="default", mksafe(in_stream))
# Later:
meta = [("foo", "bar")]
thread.run(every=3., { insert_merged_meta(meta) })
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