channels.py 2.65 KB
Newer Older
1
#
David Trattnig's avatar
David Trattnig committed
2
# Aura Engine (https://gitlab.servus.at/aura/engine)
3
#
David Trattnig's avatar
David Trattnig committed
4
# Copyright (C) 2017-2020 - The Aura Engine Team.
5
#
David Trattnig's avatar
David Trattnig committed
6
7
8
9
# 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.
10
#
David Trattnig's avatar
David Trattnig committed
11
12
13
14
# 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.
15
#
David Trattnig's avatar
David Trattnig committed
16
17
18
# 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/>.

19
20
21
22
23

from enum import Enum



David Trattnig's avatar
David Trattnig committed
24
25
26
27
28
29
class TransitionType(Enum):
    """
    Types of fade-in and fade-out transition.
    """
    INSTANT = "instant"
    FADE = "fade"
30

David Trattnig's avatar
David Trattnig committed
31
    
32
33
34
35
36
37
class Channel(Enum):
    """
    Channel name mappings to the Liqidsoap channel IDs
    """
    FILESYSTEM_A = "in_filesystem_0"
    FILESYSTEM_B = "in_filesystem_1"
38
    SCHEDULED_FALLBACK = "playlist_fallback_scheduled"
David Trattnig's avatar
David Trattnig committed
39
40
    HTTP_A  = "in_http_0"
    HTTP_B  = "in_http_1"
David Trattnig's avatar
David Trattnig committed
41
42
    HTTPS_A  = "in_https_0"
    HTTPS_B  = "in_https_1"
43
44
45
46
47
    LIVE_0 = "linein_0"
    LIVE_1 = "linein_1"
    LIVE_2 = "linein_2"
    LIVE_3 = "linein_3"
    LIVE_4 = "linein_4"
48

49
50
51
    def __str__(self):
        return str(self.value)

52

53
54
55
56
57
58
class ChannelType(Enum):
    """
    Engine channel types mapped to `Entry` source types.
    """
    FILESYSTEM = {
        "id": "fs",
59
        "numeric": 0,
60
        "channels": [Channel.FILESYSTEM_A, Channel.FILESYSTEM_B, Channel.SCHEDULED_FALLBACK]
61
    }
David Trattnig's avatar
David Trattnig committed
62
    HTTP = {
63
        "id": "http",
64
        "numeric": 1,
David Trattnig's avatar
Fix.    
David Trattnig committed
65
        "channels": [Channel.HTTP_A, Channel.HTTP_B]
66
    }
David Trattnig's avatar
David Trattnig committed
67
68
    HTTPS = {
        "id": "https",
69
        "numeric": 2,
David Trattnig's avatar
Fix.    
David Trattnig committed
70
        "channels": [Channel.HTTPS_A, Channel.HTTPS_B]
David Trattnig's avatar
David Trattnig committed
71
    }
72
73
    LIVE = {
        "id": "live",
74
        "numeric": 3,
75
76
77
78
79
80
81
82
83
        "channels": [
            Channel.LIVE_0, 
            Channel.LIVE_1,
            Channel.LIVE_2,
            Channel.LIVE_3,
            Channel.LIVE_4
        ]
    }

84
85
86
87
    @property
    def channels(self):
        return self.value["channels"]

88
89
90
91
    @property
    def numeric(self):
        return self.value["numeric"]

92
    def __str__(self):
93
94
        return str(self.value["id"])

95

David Trattnig's avatar
David Trattnig committed
96
97
98
99
100
101
102
103
104
105
106
107
class EntryPlayState(Enum):
    UNKNOWN = "unknown"
    LOADING = "loading"
    READY = "ready_to_play"
    PLAYING = "playing"
    FINISHED = "finished"

class LiquidsoapResponse(Enum):
    SUCCESS = "Done"
    STREAM_STATUS_POLLING = "polling"
    STREAM_STATUS_STOPPED = "stopped"
    STREAM_STATUS_CONNECTED = "connected"
David Trattnig's avatar
David Trattnig committed
108