developer-guide.md 7.06 KB
Newer Older
1
# Aura Engine Development Guide
David Trattnig's avatar
David Trattnig committed
2
3
4

This page gives insights on extending Aura Engine internals or through the API.

David Trattnig's avatar
David Trattnig committed
5
<!-- TOC -->
David Trattnig's avatar
David Trattnig committed
6

7
- [Aura Engine Development Guide](#aura-engine-development-guide)
David Trattnig's avatar
David Trattnig committed
8
    - [AURA Componentes](#aura-componentes)
David Trattnig's avatar
David Trattnig committed
9
    - [Engine Components](#engine-components)
David Trattnig's avatar
David Trattnig committed
10
    - [Running Engine for Development](#running-engine-for-development)
11
    - [API](#api)
12
13
    - [Scheduler](#scheduler)
    - [Docker](#docker)
14
    - [Read more](#read-more)
David Trattnig's avatar
David Trattnig committed
15
16
17

<!-- /TOC -->

David Trattnig's avatar
David Trattnig committed
18
## AURA Componentes
David Trattnig's avatar
David Trattnig committed
19

20
AURA Engine as part of the AURA Radio Suite uses an modulear architecture based on a REST API. All external information is retrieved using JSON data-structures.
David Trattnig's avatar
David Trattnig committed
21
22
23

To get the basic architectural overview, visit the [Aura Meta](https://gitlab.servus.at/autoradio/meta) repository.

David Trattnig's avatar
David Trattnig committed
24
25
26
27
Starting development of engine can be quite tedious, as it requires all most all other AURA components to be up and running.

For example:

David Trattnig's avatar
David Trattnig committed
28
29
30
31
- Steering, to get the main incredient of an play-out engine: schedules (or "timeslots" in Steering terms),
    which hold the actual information on playlists and their entries.
- Dashboard, to have a neat interface, being able to programm the timeslots
- Tank, to get the references to audio files and other audio sources. Plus the actual files.
David Trattnig's avatar
David Trattnig committed
32
33
34

If you need to test and develop against the Engine's API you'll also need to get the `engine-api` project running.

35
For a start it's recommended to create a general `aura` project folder. In there you start cloning all the sub-projects. After having all the sub-projects configured, and verified that they are working, take a look at the AURA `meta` project.
David Trattnig's avatar
David Trattnig committed
36
37
38
39
40
41
42

There's a convenience script to start all of the three main dependencies (Steering, Dashboard, Tank) all at once:

```bash
    ~/code/aura/meta$ ./run.sh aura local
```

David Trattnig's avatar
David Trattnig committed
43
## Engine Components
44
45


46
*...TBD...*
47

David Trattnig's avatar
David Trattnig committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

## Running Engine for Development

Ensure you have following other projects up and running:

- steering
- tank
- dashboard
- engine-api
- engine-clock (optional)

Then you can start the engine. The following command includes the activation of your virtual environment, which you have created during the installation step (`source python/bin/activate`):

```shell
~/code/aura/engine$ ./run.sh dev
```

Now start Liquidsoap which is part of Engine Core:

```shell
~/code/aura/engine-core$ ./run.sh
```

David Trattnig's avatar
David Trattnig committed
71
72
If your IDE of choice is *Visual Studio Code*, then there are launch settings provided in `.vscode/launch.json`.

73
74
## API

David Trattnig's avatar
David Trattnig committed
75
You can find the AURA API definition here: https://gitlab.servus.at/autoradio/meta/blob/master/api-definition.md
David Trattnig's avatar
David Trattnig committed
76

David Trattnig's avatar
David Trattnig committed
77
OpenAPI definition for Engine API: https://app.swaggerhub.com/apis/AURA-Engine/engine-api/
David Trattnig's avatar
David Trattnig committed
78

79
## Scheduler
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

Scheduling is split into multiple phases. Below you see a timeline with one timeslot planned at a certain
point in time and the involved phase before:

```ascii
========================================= [                  Scheduling Window               ] ===========
=======================================================  [        Timeslot Play-out                 ] ====

== (FILESYSTEM A) ========================== [ Preload ] [  Play 4  ] ====================================
== (STREAM A) ========================================== [ Preload ] [ Play 1 ] ==========================
== (LIVE 1) ====================================================== [ Preload ] [ Play 1 ] ================
== (FILESYSTEM B) ========================================================== [ Preload ] [  Play 4  ] ====
```

- **Scheduling Window**: Within the scheduling window any commands for controlling
    the mixer of the soundsystem are prepared and queued.

    Only until the start of the window, timeslots can be updated or removed via external API Endpoints
    (e.g. using Steering or Dashboard). Until here any changes on the timeslot itself will be reflected
    in the actual play-out. This only affects the start and end time of the "timeslot" itself.
    It does not involve related playlists and their entries. Those can still be modified after the
    scheduling window has started.

    The start and the end of the window is defined by the start of the timeslot minus
    a configured amount of seconds (see `scheduling_window_start` and `scheduling_window_end`
    in `engine.ini`). The actual start of the window is calcuated by (timeslot start - window start)
    and the end by (timeslot end - window end)

    During the scheduling window, the external API Endpoints are pulled continiously, to
    check for updated timeslots and related playlists. Also, any changes to playlists and
    its entries are respected within that window (see `fetching_frequency` in `engine.ini`).

    > Important: It's vital that the the scheduling window is wider than the fetching frequency.
    Otherwise one fetch might never hit a scheduling window, hence not being able to schedule stuff.

    > Note: If you delete any existing timeslot in Dashboard/Steering this is only reflected in Engine until the start
    of the scheduling window. The scheduling window is defined by the start of the timeslot minus a configured offset
    in seconds. This is limitation is required to avoid corrupted playout in case audio content has been
    preloaded or started playing already.

- **Queuing and Pre-Loading**: Before any playlist entries of the timeslot can be turned into
    sound, they need to be queued and pre-loaded. Ideally the pre-loading happens somewhat before
    the scheduled play-out time to avoid any delays in timing. Set the maximum time reserved for
    pre-loading in your configuration (compare `preload_offset`in `engine.ini`).

    If there is not enough time to reserve the given amount of time for preloading (i.e. some entry
    should have started in the past already) the offset is ignored and the entry is played as soon as possible.

    > Important: To ensure proper timings, the offset should not exceed the time between the start of
    the scheduling-window and the start of the actual timeslot playout. Practically, of course there
    are scenario where playout start later than planned e.g. during startup of the engine during a timeslot
    or due to some severe connectivity issues to some external stream.

- **Play-out**: Finally the actual play-out is happening. The faders of the virtual mixers are pushed
    all the way up, as soon it's "time to play" for one of the pre-loaded entries.
    Transitions between playlist entries with different types of sources (file, stream and analog
    inputs) are performed automatically. At the end of each timeslot the channel is faded-out,
    no matter if the total length of the playlist entries would require a longer timeslot.

    If for some reason the playout is corrupted, stopped or too silent to make any sense, then
    this <u>triggers a fallback using the silence detector</u>.


143
## Docker
144

145
Build your own, local Docker image
146

147
148
```shell
./run.sh docker:build
David Trattnig's avatar
David Trattnig committed
149
150
```

151
Releasing a new version to DockerHub
David Trattnig's avatar
David Trattnig committed
152

153
154
```shell
./run.sh docker:push
David Trattnig's avatar
David Trattnig committed
155
156
```

157
158
## Read more

159
160
161
- [Bare Metal Installation](docs/bare-metal-installation.md)
- [Developer Guide](docs/developer-guide.md)
- [Setting up the Audio Store [meta]](https://gitlab.servus.at/aura/meta/-/blob/master/docs/setup-audio-store.md)