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
2c7d36a5
Commit
2c7d36a5
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Test: Cases on ID and metadata triggering
parent
709cd4a8
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!3
Liquidsoap 2 migration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_source.liq
+69
-0
69 additions, 0 deletions
tests/test_source.liq
with
69 additions
and
0 deletions
tests/test_source.liq
0 → 100755
+
69
−
0
View file @
2c7d36a5
#!/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"
url = "https://orf-live.ors-shoutcast.at/oe1-q2a"
input_stream = input.http(id="input_stream", url, start=true)
def handle_meta1(meta) =
print("Called metadata handler1 and got: #{meta}")
end
def handle_meta2(meta) =
print("Called metadata handler2 and got: #{meta}")
end
### SOURCE ID ###
# Test retrieving ID via getter
id = input_stream.id()
print("Source ID: #{id}")
assertEquals(id, "input_stream")
# Test retrieving ID via `source.id`
id = source.id(input_stream)
print("Source ID: #{id}")
assertEquals(id, "input_stream")
### ON_METADATA ###
# Two variants of metadata event handling
# See https://github.com/savonet/liquidsoap/discussions/2509
# Variant A.) Attach `on_metadata` handler directly: handlers registered
# directly using the source method will be called whenever the source is being consumed
input_stream.on_metadata(handle_meta1)
print("Source ID: #{input_stream.id()}")
assertEquals(id, "input_stream")
# Variant B.) Source returned by `on_metadata`: Handlers are only called
# when the returned source is being used
input_stream = source.on_metadata(id="input_stream", input_stream, handle_meta2)
print("Source ID: #{input_stream.id()}")
assertEquals(id, "input_stream")
# IMPORTANT: If this is commented out, only "handle_meta1" will be called
output.alsa(device="default", mksafe(mixer), bufferize=true)
# The same is true for a mixer i.e. when the source is not selected/not audible:
# mixer = mix(id="mixer", [input_stream])
# output.alsa(device="default", mksafe(mixer), bufferize=true)
\ 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