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
4466c67f
Verified
Commit
4466c67f
authored
11 months ago
by
Ole Binder
Browse files
Options
Downloads
Patches
Plain Diff
Refactor: improve stream endpoints
parent
01132add
No related branches found
No related tags found
1 merge request
!17
Yaml configuration file
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/out_stream.liq
+44
-98
44 additions, 98 deletions
src/out_stream.liq
with
44 additions
and
98 deletions
src/out_stream.liq
+
44
−
98
View file @
4466c67f
...
...
@@ -17,50 +17,36 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Output streaming settings
# What a mess...
# s0_encoding =
# get_setting("ogg", "stream_0_encoding", "AURA_ENGINE_STREAM_OUTPUT_ENCODING")
# s0_bitrate =
# int_of_string(
# get_setting("192", "stream_0_bitrate", "AURA_ENGINE_STREAM_OUTPUT_BITRATE")
# )
# s0_host = get_setting("", "stream_0_host", "AURA_ENGINE_STREAM_OUTPUT_HOST")
# s0_port =
# int_of_string(
# get_setting("0", "stream_0_port", "AURA_ENGINE_STREAM_OUTPUT_PORT")
# )
# s0_user = get_setting("", "stream_0_user", "AURA_ENGINE_STREAM_OUTPUT_USER")
# s0_pass =
# get_setting("", "stream_0_password", "AURA_ENGINE_STREAM_OUTPUT_PASSWORD")
# s0_mount =
# get_setting("", "stream_0_mountpoint", "AURA_ENGINE_STREAM_OUTPUT_MOUNTPOINT")
# s0_url = get_setting("", "stream_0_url", "AURA_ENGINE_STREAM_OUTPUT_URL")
# s0_desc =
# get_setting(
# "", "stream_0_description", "AURA_ENGINE_STREAM_OUTPUT_DESCRIPTION"
# )
# s0_genre = get_setting("", "stream_0_genre", "AURA_ENGINE_STREAM_OUTPUT_GENRE")
# s0_name = get_setting("", "stream_0_name", "AURA_ENGINE_STREAM_OUTPUT_NAME")
# s0_channels =
# get_setting("", "stream_0_channels", "AURA_ENGINE_STREAM_OUTPUT_CHANNELS")
# FIXME: this should move into the list of streams
# What is this used for anyway?
s0_connected = ref("")
# s1_connected = ref('')
# s2_connected = ref('')
# s3_connected = ref('')
# s4_connected = ref('')
# number of streams
# counter of streams
stream_count = ref(0)
# list of streams
stream_list = ref([])
# create a stream with the given stream record
def create_stream(stream) =
let url = string(stream.url)
# status of the stream
connected = ref("false")
# on error try to reconnect after 5 seconds. This goes up to 120 seconds.
retry_time = ref(5.)
def on_error(msg) =
connected := "false"
retry_time := retry_time() < 120. ? retry_time() + 5. : retry_time()
log(msg)
retry_time()
end
def on_connect() =
connected := "true"
log(
"Successfully connected to stream_#{stream_count()}"
)
end
# FIXME: make enc more flexible, read bitrate etc from settings
enc = ref(%vorbis(stereo = true))
# set icy_metadata accoring to the encoder (enc) to send
...
...
@@ -73,24 +59,6 @@ def create_stream(stream) =
snd_icy_metadata := true
end
# register a server function for every stream
# TODO: what is this used for?
server.register(
namespace="out_http_#{stream_count()}",
"connected",
fun (s) ->
begin
ignore(s)
s0_connected()
end
)
# create a list of streams to keep track of the created streams
# if
# list.assoc.mem(url, stream_list())
# then
# "Stream for url #{url} already exists!"
# else
out_stream =
output.icecast(
id="out_http_#{stream_count()}",
...
...
@@ -104,55 +72,33 @@ def create_stream(stream) =
name=stream.name,
genre=stream.genre,
user=stream.user,
on_error=on_error,
on_connect=on_connect,
send_icy_metadata=snd_icy_metadata(),
enc(),
output_source
)
stream_count := stream_count() + 1
# append the new stream to the list of streams, the key is the url
# if we could alter the unit (stream) with all its values we could
# save all of this in the stream unit itself
stream_list := [...stream_list(), (url, out_stream.shutdown)]
print(
"Stream: #{url}"
# register a server function for every stream
# this shows the status for each stream
server.register(
namespace="out_http_#{stream_count()}",
"connected",
fun (s) ->
begin
ignore(s)
connected()
end
)
end
stream_count := stream_count() + 1
# def create_stream(stream) =
# server.register(
# namespace="out_http_#{stream_count()}",
# "connected",
# fun (s) ->
# begin
# ignore(s)
# s0_connected()
# end
# )
# stream_to_icecast(
# "out_http_#{stream_count()}",
# stream.encoding,
# int_of_string(stream.bitrate),
# stream.host,
# int_of_float(stream.port),
# stream.password,
# stream.mount,
# stream.url,
# stream.desc,
# stream.genre,
# stream.user,
# output_source,
# "#{stream_count()}",
# s0_connected,
# stream.name,
# stream.channels
# )
# stream_count := stream_count() + 1
# print(
# "Registered stream #{stream.url}"
# )
# end
# append the new stream to the list of streams, the key is the url if we could
# alter the unit (stream) with all its values we could save all of this in the
# stream unit itself
stream_list := [...stream_list(), (stream.url, out_stream.shutdown)]
end
# itterate over all stream units (read from the yaml config)
# iterate over all stream units (read from the yaml config)
# here we could read the env variables and create an endpoint if the env
# variables are set. But this would be ugly and bloat the code
list.iter(create_stream, config.stream)
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