-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
94 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let config = {} | ||
|
||
%include "streamcast/index.liq" | ||
%include "server.liq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
let config.server = {} | ||
|
||
let config.server.host = | ||
utils.env.get(default="0.0.0.0", "FUSION__SERVER__HOST") | ||
let config.server.port = | ||
int_of_string(utils.env.get(default="9000", "FUSION__SERVER__PORT")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let config.streamcast.icy = {} | ||
|
||
let config.streamcast.icy.host = | ||
utils.env.get(default="localhost", "FUSION__STREAMCAST__ICY__HOST") | ||
let config.streamcast.icy.port = | ||
int_of_string(utils.env.get(default="8000", "FUSION__STREAMCAST__ICY__PORT")) | ||
let config.streamcast.icy.user = | ||
utils.env.get(default="source", "FUSION__STREAMCAST__ICY__USER") | ||
let config.streamcast.icy.password = | ||
utils.env.get(default="password", "FUSION__STREAMCAST__ICY__PASSWORD") | ||
let config.streamcast.icy.mount = | ||
utils.env.get(default="radio.mp3", "FUSION__STREAMCAST__ICY__MOUNT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let config.streamcast = {} | ||
|
||
%include "icy.liq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let constants = {} | ||
|
||
%include "metadata.liq" | ||
%include "paths.liq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
let constants.metadata = {} | ||
|
||
let constants.metadata.keys = ["title", "artist"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let constants.paths = {} | ||
|
||
let constants.paths.source = "src/" | ||
let constants.paths.resources = "#{constants.paths.source}resources/" | ||
let constants.paths.fallback = "#{constants.paths.resources}audio/fallback.mp3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let inputs = {} | ||
|
||
let inputs.music = single(constants.paths.fallback) | ||
|
||
let inputs.live = | ||
buffer( | ||
input.srt( | ||
bind_address=config.server.host, | ||
port=config.server.port, | ||
read_timeout=null(), | ||
write_timeout=null() | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,6 @@ | ||
### Constants | ||
|
||
SOURCE_PATH = "src/" | ||
RESOURCES_PATH = "#{SOURCE_PATH}/resources/" | ||
FALLBACK_PATH = "#{RESOURCES_PATH}/audio/fallback.mp3" | ||
|
||
ALLOWED_METADATA_KEYS = ["title", "artist"] | ||
|
||
### Utils | ||
|
||
def get_env(~default="", key) = | ||
list.assoc(default=default, key, environment()) | ||
end | ||
|
||
def filter_metadata(keys, source) = | ||
predicate = fun (md) -> list.mem(fst(md), keys) | ||
|
||
metadata.map( | ||
update=false, strip=true, fun (md) -> list.filter(predicate, md), source | ||
) | ||
end | ||
|
||
### Variables | ||
|
||
server_host = get_env(default="0.0.0.0", "FUSION__SERVER__HOST") | ||
server_port = int_of_string(get_env(default="9000", "FUSION__SERVER__PORT")) | ||
streamcast_icy_host = | ||
get_env(default="localhost", "FUSION__STREAMCAST__ICY__HOST") | ||
streamcast_icy_port = | ||
int_of_string(get_env(default="8000", "FUSION__STREAMCAST__ICY__PORT")) | ||
streamcast_icy_user = get_env(default="source", "FUSION__STREAMCAST__ICY__USER") | ||
streamcast_icy_password = | ||
get_env(default="password", "FUSION__STREAMCAST__ICY__PASSWORD") | ||
streamcast_icy_mount = | ||
get_env(default="radio.mp3", "FUSION__STREAMCAST__ICY__MOUNT") | ||
|
||
### Inputs | ||
|
||
music = single(FALLBACK_PATH) | ||
|
||
live = | ||
input.srt( | ||
bind_address=server_host, | ||
port=server_port, | ||
read_timeout=null(), | ||
write_timeout=null() | ||
) | ||
live = buffer(live) | ||
|
||
### Stream | ||
|
||
radio = fallback(track_sensitive=false, [live, music]) | ||
radio = filter_metadata(ALLOWED_METADATA_KEYS, radio) | ||
radio = mksafe(radio) | ||
|
||
### Outputs | ||
|
||
output.icecast( | ||
%mp3, | ||
host=streamcast_icy_host, | ||
port=streamcast_icy_port, | ||
user=streamcast_icy_user, | ||
password=streamcast_icy_password, | ||
mount=streamcast_icy_mount, | ||
icy_metadata=ALLOWED_METADATA_KEYS, | ||
icy_song=fun (_) -> null(), | ||
radio | ||
) | ||
%include "constants/index.liq" | ||
%include "utils/index.liq" | ||
%include "config/index.liq" | ||
%include "inputs.liq" | ||
%include "streams.liq" | ||
%include "outputs.liq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output.icecast( | ||
%mp3, | ||
host=config.streamcast.icy.host, | ||
port=config.streamcast.icy.port, | ||
user=config.streamcast.icy.user, | ||
password=config.streamcast.icy.password, | ||
mount=config.streamcast.icy.mount, | ||
icy_metadata=constants.metadata.keys, | ||
icy_song=fun (_) -> null(), | ||
streams.radio | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let streams = {} | ||
|
||
let streams.radio = | ||
mksafe( | ||
utils.metadata.filter( | ||
constants.metadata.keys, | ||
fallback(track_sensitive=false, [inputs.live, inputs.music]) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let utils.env = {} | ||
|
||
def utils.env.get(~default="", key) = | ||
list.assoc(default=default, key, environment()) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let utils = {} | ||
|
||
%include "env.liq" | ||
%include "metadata.liq" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let utils.metadata = {} | ||
|
||
def utils.metadata.filter(keys, source) = | ||
predicate = fun (md) -> list.mem(fst(md), keys) | ||
|
||
metadata.map( | ||
update=false, strip=true, fun (md) -> list.filter(predicate, md), source | ||
) | ||
end |