]> git.parisson.com Git - teleforma.git/commitdiff
add source monitor models and views
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 10 Jan 2014 17:44:16 +0000 (18:44 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 10 Jan 2014 17:44:16 +0000 (18:44 +0100)
teleforma/models/core.py
teleforma/views/core.py

index 4a403c9f47b7568e3095ec486bf508c3e5c9a9b4..077c45763a90c428f6aac8090bf127bc338ae124 100644 (file)
@@ -625,6 +625,44 @@ class Media(MediaBase):
         ordering = ['-date_modified']
 
 
+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])
+
+
+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=self.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 NamePaginator(object):
     """Pagination for string-based objects"""
 
index 8d7e06cb34036fc44db6914b84ac0569cd7001d1..f05c5129070cdd485e4b50720cb1128bf30217e2 100644 (file)
@@ -693,3 +693,33 @@ class HelpView(TemplateView):
     def dispatch(self, *args, **kwargs):
         return super(HelpView, self).dispatch(*args, **kwargs)
 
+
+class SourcesStatusView(ListView):
+
+    model = Source
+    template_name='teleforma/source_monitors.html'
+
+    @jsonrpc_method('telecaster.get_source_status')
+    def get_source_status(request, public_id):
+        source = Source.objects.get(public_id=public_id)
+        url = 'http://' + source.ip + '/json/'
+        service = ServiceProxy(url)
+        status = s.teleforma.get_server_status()
+        return status
+
+    @jsonrpc_method('telecaster.get_source_station_status')
+    def get_source_station_status(request, public_id):
+        source = Source.objects.get(public_id=public_id)
+        url = 'http://' + source.ip + '/json/'
+        service = ServiceProxy(url)
+        station = s.teleforma.get_station_status()
+        return station
+
+    @jsonrpc_method('telecaster.source_station_start')
+    def start(request, station_dict):
+        pass
+
+    @jsonrpc_method('telecaster.source_station_stop')
+    def stop(request):
+        pass
+