forked from vladpen/python-rtsp-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
27 lines (20 loc) · 725 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import asyncio
from _config import Config
from client import Client
from storage import Storage
from shared import Shared
async def main():
# Start one listener for all clients
tasks = [asyncio.create_task(Client.listen())]
for camera_hash in Config.cameras.keys():
# All tasks will communicate through this object
Shared.data[camera_hash] = {'camera': None, 'clients': {}}
# Start streams saving, if enabled
if Config.storage_enable:
s = Storage(camera_hash)
tasks.append(asyncio.create_task(s.run()))
tasks.append(asyncio.create_task(s.watchdog()))
for t in tasks:
await t
if __name__ == '__main__':
asyncio.run(main())