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
5278901e
Commit
5278901e
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Test: Detection of track type
parent
2ac40fa7
No related branches found
No related tags found
1 merge request
!3
Liquidsoap 2 migration
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_eval_track_type.liq
+87
-0
87 additions, 0 deletions
tests/test_eval_track_type.liq
with
87 additions
and
0 deletions
tests/test_eval_track_type.liq
0 → 100755
+
87
−
0
View file @
5278901e
#!/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"
# Init defaults
engine_default_track_type = "0"
engine_current_track_type = ref("-1")
# Evaluates the track type based on the given:
# a.) "meta.track_type" passed as annotation, and if not available on
# b.) "engine_current_track_type" passed via server function
# c.) "meta.source" and if not available on
# d.) configured default track type setting
#
# Returns:
# 0=QUEUE/FILE, 1=STREAM, 2=LIVE ANALOG, 3=PLAYLIST
#
def eval_track_type(meta_track_type, meta_source) =
# let source = meta["source"]
type_mapping = [
("fallback_folder", "0"),
("fallback_playlist", "3"),
("in_filesystem_0", "0"),
("in_filesystem_0", "0"),
("in_http_0", "1"),
("in_http_1", "1"),
("linein_0", "2"),
("linein_1", "2"),
("linein_2", "2"),
("linein_3", "2"),
("linein_4", "2")
]
if meta_track_type != "" then
engine_current_track_type := meta_track_type
else
if !engine_current_track_type == "" then
let source_type = list.assoc(
default=engine_default_track_type,
meta_source,
type_mapping
)
engine_current_track_type := source_type
end
end
!engine_current_track_type
end
# Case 1: Passed meta track type => 33
engine_current_track_type := "55"
type = eval_track_type("33", "fallback_playlist")
print("Got Type: #{type}")
# Case 2: Passed track type via server function => 55
engine_current_track_type := "55"
type = eval_track_type("", "fallback_playlist")
print("Got Type: #{type}")
# Case 3: Detect track type via source => 3
engine_current_track_type := ""
type = eval_track_type("", "fallback_playlist")
print("Got Type: #{type}")
# Case 4: Default track type => 0
engine_current_track_type := ""
type = eval_track_type("", "fallback_playlistx")
print("Got Type: #{type}")
\ 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