2020-04-15 20:29:59 +02:00
|
|
|
from django.db import models
|
2020-04-23 20:19:49 +02:00
|
|
|
from django.utils.translation import gettext as _
|
2020-04-15 20:29:59 +02:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
from . import signals
|
|
|
|
|
2020-04-20 14:51:44 +02:00
|
|
|
|
2020-04-15 20:29:59 +02:00
|
|
|
class Application(models.Model):
|
2020-04-23 21:08:39 +02:00
|
|
|
name = models.CharField(max_length=100, unique=True, help_text=_("rtmp_application_name"))
|
2020-04-15 20:29:59 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2020-04-23 21:08:39 +02:00
|
|
|
class Stream(models.Model):
|
2020-04-15 20:29:59 +02:00
|
|
|
application = models.ForeignKey(Application, on_delete=models.CASCADE)
|
2020-04-23 21:08:39 +02:00
|
|
|
stream = models.CharField(max_length=64, unique=True, default=uuid.uuid4)
|
2020-04-15 20:29:59 +02:00
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2020-04-23 21:08:39 +02:00
|
|
|
def on_publish(self, param):
|
2020-04-15 20:29:59 +02:00
|
|
|
signals.on_publish.send(sender=self.__class__,
|
|
|
|
name=self.name,
|
2020-04-23 21:08:39 +02:00
|
|
|
stream=self.stream,
|
2020-04-15 20:29:59 +02:00
|
|
|
app=str(self.application),
|
|
|
|
param=param
|
|
|
|
)
|
|
|
|
|
2020-04-23 21:08:39 +02:00
|
|
|
def on_unpublish(self, param):
|
2020-04-15 20:29:59 +02:00
|
|
|
signals.on_unpublish.send(sender=self.__class__,
|
2020-04-20 14:51:44 +02:00
|
|
|
name=self.name,
|
2020-04-23 21:08:39 +02:00
|
|
|
stream=self.stream,
|
2020-04-20 14:51:44 +02:00
|
|
|
app=str(self.application),
|
|
|
|
param=param
|
|
|
|
)
|
2020-04-15 20:29:59 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
2020-04-23 21:08:39 +02:00
|
|
|
return self.name
|