From 700686db10b18be0a2d85c4afd4c4f4c1c4495f0 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 30 Jan 2014 11:21:35 +0100 Subject: [PATCH] add monitor and (distant) source models --- teleforma/models/sources.py | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 teleforma/models/sources.py diff --git a/teleforma/models/sources.py b/teleforma/models/sources.py new file mode 100644 index 00000000..409b6af2 --- /dev/null +++ b/teleforma/models/sources.py @@ -0,0 +1,41 @@ + +from teleforma.models.core import * + + +class Monitor(Model): + "Streaming source monitor" + + mime_types = [('audio/ogg', 'audio/ogg'), ('audio/mp3', 'audio/mp3'), + ('video/webm', 'video/webm'), ('video/mp4', 'video/mp4')] + + port = IntegerField(_('port')) + mount_point = CharField(_('public_id'), max_length=255) + mime_type = CharField(_('type'), choices=mime_types, max_length=255) + + @property + def slug(self): + return ':' + str(self.port) + '/' + self.mount_point + + class Meta: + db_table = app_label + '_' + 'monitor' + + def __unicode__(self): + return self.slug + '(' + self.type + ')' + + +class Source(Model): + "Streaming source" + + public_id = CharField(_('public_id'), max_length=255) + ip = GenericIPAddressField(_('IP')) + room = ForeignKey(Room, related_name='source', verbose_name=_('room'), + blank=True, null=True, on_delete=models.SET_NULL) + monitors = ManyToManyField(Monitor, related_name="source", + verbose_name=_('monitors'), blank=True, null=True) + class Meta: + db_table = app_label + '_' + 'source' + ordering = ['public_id'] + + def __unicode__(self): + return '-'.join([self.public_id, self.room, self.ip]) + -- 2.39.5