2020-04-15 20:29:59 +02:00
|
|
|
from django.dispatch import receiver
|
2020-04-26 19:46:58 +02:00
|
|
|
from rtmp.signals import stream_active
|
2020-04-15 20:29:59 +02:00
|
|
|
from .models import RestreamConfig
|
2020-04-23 21:08:39 +02:00
|
|
|
from rtmp.models import Stream
|
2020-04-26 19:46:58 +02:00
|
|
|
from concierge.models import Task
|
2020-04-26 22:25:58 +02:00
|
|
|
import json
|
2020-04-20 14:51:44 +02:00
|
|
|
|
2020-04-15 20:29:59 +02:00
|
|
|
|
2020-04-26 19:46:58 +02:00
|
|
|
@receiver(stream_active)
|
|
|
|
def create_tasks(sender, **kwargs):
|
|
|
|
stream = Stream.objects.get(stream=kwargs['stream'])
|
2020-04-26 22:25:58 +02:00
|
|
|
instances = RestreamConfig.objects.filter(active=True, stream=stream)
|
|
|
|
for inst in instances:
|
|
|
|
config = {
|
|
|
|
'name': inst.name,
|
|
|
|
'app': inst.stream.application.name,
|
|
|
|
'stream': str(inst.stream.stream),
|
|
|
|
'target': inst.target
|
|
|
|
}
|
|
|
|
|
|
|
|
json_config = json.dumps(config)
|
|
|
|
task = Task(stream=stream, type='restream', configuration=json_config)
|
2020-04-26 19:46:58 +02:00
|
|
|
task.save()
|