Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
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
Container Registry
Model registry
Operate
Environments
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
Commits
64028c40
Commit
64028c40
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Feat: Update playout config on boot
parent
50a31bb4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client/playerclient.py
+10
-5
10 additions, 5 deletions
src/client/playerclient.py
src/engine.py
+27
-24
27 additions, 24 deletions
src/engine.py
with
37 additions
and
29 deletions
src/client/playerclient.py
+
10
−
5
View file @
64028c40
...
...
@@ -76,7 +76,6 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
# self.command(input_id, "status")
# return self.message
def
mixer_volume
(
self
,
mixer_id
,
pos
,
volume
):
"""
Sets some mixer channel to the given volume
...
...
@@ -265,10 +264,9 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
"""
if
command
==
"
state
"
:
return
self
.
engine_state
()
return
(
"
LiquidSoapPlayerClient does not understand engine.
"
+
command
+
str
(
args
)
)
if
command
==
"
update_config
"
:
return
self
.
engine_update_config
(
str
(
args
[
0
]))
return
"
LiquidSoapPlayerClient does not understand engine.
"
+
command
+
str
(
args
)
def
engine_state
(
self
):
"""
...
...
@@ -277,6 +275,13 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
self
.
command
(
"
aura_engine
"
,
"
status
"
)
return
self
.
message
def
engine_update_config
(
self
,
json_config
):
"""
Updates the config
"""
self
.
command
(
"
aura_engine
"
,
"
update_config
"
,
json_config
)
return
self
.
message
# def skip(self, namespace="playlist", pos=""):
# """
# Source skippen
...
...
This diff is collapsed.
Click to expand it.
src/engine.py
+
27
−
24
View file @
64028c40
...
...
@@ -19,6 +19,7 @@
import
logging
import
time
import
json
from
collections
import
namedtuple
from
contextlib
import
suppress
from
threading
import
Thread
...
...
@@ -95,6 +96,11 @@ class Engine:
self
.
logger
.
info
(
SU
.
yellow
(
"
Waiting for Liquidsoap to be running ...
"
))
time
.
sleep
(
2
)
self
.
logger
.
info
(
SU
.
green
(
"
Engine Core ------[ connected ]-------- Liquidsoap
"
))
result
=
self
.
engine_update_config
()
if
result
==
"
OK
"
:
self
.
logger
.
info
(
SU
.
green
(
"
Playout config successfully updated
"
))
else
:
self
.
logger
.
info
(
SU
.
red
(
"
Error while updating playout config
"
))
self
.
player
=
Player
(
self
.
connector
,
self
.
event_dispatcher
)
self
.
event_dispatcher
.
on_boot
()
...
...
@@ -116,9 +122,7 @@ class Engine:
except
LQConnectionError
:
self
.
logger
.
info
(
"
Liquidsoap is not running so far
"
)
except
Exception
as
e
:
self
.
logger
.
error
(
"
Cannot check if Liquidsoap is running. Reason:
"
+
str
(
e
)
)
self
.
logger
.
error
(
"
Cannot check if Liquidsoap is running. Reason:
"
+
str
(
e
))
return
has_connection
...
...
@@ -129,6 +133,18 @@ class Engine:
state
=
self
.
connector
.
send_lqc_command
(
"
engine
"
,
"
state
"
)
return
state
def
engine_update_config
(
self
):
"""
Update the config of playout with the current values
"""
playout_config
=
{
"
engine_id
"
:
str
(
self
.
config
.
get
(
"
api_engine_number
"
)),
"
engine_api_playlog
"
:
self
.
config
.
get
(
"
api_engine_store_playlog
"
),
}
json_config
=
json
.
dumps
(
playout_config
,
ensure_ascii
=
False
)
res
=
self
.
connector
.
send_lqc_command
(
"
engine
"
,
"
update_config
"
,
json_config
)
return
res
def
version
(
self
):
"""
Get the version of Liquidsoap.
...
...
@@ -233,18 +249,12 @@ class Player:
if
entry
.
get_content_type
()
in
ResourceClass
.
LIVE
.
types
:
entry
.
channel
=
ChannelResolver
.
live_channel_for_resource
(
entry
.
source
)
if
entry
.
channel
is
None
:
self
.
logger
.
critical
(
SU
.
red
(
"
Invalid live channel
'
{entry.source}
'
requested!
"
)
)
self
.
logger
.
critical
(
SU
.
red
(
"
Invalid live channel
'
{entry.source}
'
requested!
"
))
entry
.
previous_channel
=
None
is_ready
=
True
else
:
channel_type
=
self
.
channel_router
.
type_for_resource
(
entry
.
get_content_type
()
)
entry
.
previous_channel
,
entry
.
channel
=
self
.
channel_router
.
channel_swap
(
channel_type
)
channel_type
=
self
.
channel_router
.
type_for_resource
(
entry
.
get_content_type
())
entry
.
previous_channel
,
entry
.
channel
=
self
.
channel_router
.
channel_swap
(
channel_type
)
# QUEUE
if
entry
.
get_content_type
()
in
ResourceClass
.
FILE
.
types
:
...
...
@@ -306,7 +316,7 @@ class Player:
This method expects that the entry is pre-loaded using `preload(..)` or
`preload_group(self, entries)` before being played.
In case the pre-
roll
has happened for a group of entries, only the first entry of the group
In case the pre-
loading
has happened for a group of entries, only the first entry of the group
needs to be passed.
Args:
...
...
@@ -460,8 +470,7 @@ class Player:
lqs_url
=
result
.
split
(
"
"
)[
1
]
if
not
url
==
lqs_url
:
self
.
logger
.
error
(
"
Wrong URL
'
%s
'
set for channel
'
%s
'
, expected:
'
%s
'
.
"
%
(
lqs_url
,
channel
,
url
)
"
Wrong URL
'
%s
'
set for channel
'
%s
'
, expected:
'
%s
'
.
"
%
(
lqs_url
,
channel
,
url
)
)
return
False
...
...
@@ -536,9 +545,7 @@ class Player:
raise
InvalidChannelException
self
.
connector
.
enable_transaction
()
result
=
self
.
connector
.
send_lqc_command
(
channel
,
"
queue_seek
"
,
str
(
seconds_to_seek
)
)
result
=
self
.
connector
.
send_lqc_command
(
channel
,
"
queue_seek
"
,
str
(
seconds_to_seek
))
self
.
logger
.
info
(
"
%s.seek result: %s
"
%
(
channel
,
result
))
self
.
connector
.
disable_transaction
()
...
...
@@ -602,14 +609,10 @@ class Player:
Returns:
(String): Liquidsoap response
"""
self
.
logger
.
info
(
SU
.
pink
(
"
Setting URI of playlist
'
%s
'
to
'
%s
'"
%
(
channel
,
playlist_uri
))
)
self
.
logger
.
info
(
SU
.
pink
(
"
Setting URI of playlist
'
%s
'
to
'
%s
'"
%
(
channel
,
playlist_uri
)))
self
.
connector
.
enable_transaction
()
result
=
self
.
connector
.
send_lqc_command
(
channel
,
"
playlist_uri_set
"
,
playlist_uri
)
result
=
self
.
connector
.
send_lqc_command
(
channel
,
"
playlist_uri_set
"
,
playlist_uri
)
self
.
logger
.
info
(
"
%s.playlist_uri result: %s
"
%
(
channel
,
result
))
self
.
connector
.
disable_transaction
()
...
...
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