]> git.parisson.com Git - teleforma.git/commitdiff
update conference rpc methods
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 22 Nov 2023 07:11:16 +0000 (08:11 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 22 Nov 2023 07:11:16 +0000 (08:11 +0100)
teleforma/views/core.py

index 64f47b3f5aea96c8f6d6f9197b1aafa0728d5df1..ed37cb61ae6232d3e2ec2405c7f8491ac762f70c 100644 (file)
@@ -713,10 +713,8 @@ class ConferenceView(CourseAccessMixin, DetailView):
             app_label="teleforma", model="course")
 
         room_name = conference.course.code
-
-        context['room'] = get_room(name=room_name, period=context['period'].name,
-                                   content_type=content_type,
-                                   id=conference.course.id)
+        # if conference.web_class_group:
+        #     room_name += '_' + conference.public_id
 
         context['livestreams'] = conference.livestream.all()
         context['host'] = get_host(self.request)
@@ -728,22 +726,68 @@ class ConferenceView(CourseAccessMixin, DetailView):
 
     @jsonrpc_method('teleforma.stop_conference')
     def stop(request, public_id):
-        conference = Conference.objects.get(public_id=public_id)
-        conference.date_end = datetime.datetime.now()
-        conference.save()
-        for stream in conference.livestream.all():
-            stream.delete()
-        for station in conference.station.all():
-            station.started = False
-            station.save()
-            station.stop()
-        if 'telecaster' in settings.INSTALLED_APPS:
-            try:
-                url = 'http://' + conference.department.domain + '/json/'
-                s = ServiceProxy(url)
-                s.teleforma.stop_conference(conference.public_id)
-            except:
-                pass
+            conference = Conference.objects.get(public_id=public_id)
+            conference.date_end = datetime.datetime.now()
+            conference.save()
+            for stream in conference.livestream.all():
+                stream.delete()
+            if 'telecaster' in settings.INSTALLED_APPS:
+                for station in conference.station.all():
+                    station.started = False
+                    station.save()
+                    station.stop()
+                    try:
+                        url = 'https://' + conference.department.domain + '/json/'
+                        s = ServiceProxy(url)
+                        s.teleforma.stop_conference(conference.public_id)
+                    except:
+                        pass
+
+    @jsonrpc_method('teleforma.create_conference')
+    def create(request, conf_dict):
+        if isinstance(conf_dict, dict):
+            conferences = Conference.objects.filter(public_id=conf_dict['id'])
+            if not conferences:
+                conference = Conference()
+                conference.from_json_dict(conf_dict)
+                conference.save()
+                if conference.streaming:
+                    for stream in conf_dict['streams']:
+                        host = getattr(
+                            settings, "TELECASTER_LIVE_STREAMING_SERVER", stream['host'])
+                        protocol = getattr(
+                            settings, "TELECASTER_LIVE_STREAMING_PROTOCOL", 'http')
+                        server_type = stream['server_type']
+                        stream_type = stream['stream_type']
+                        if server_type == 'icecast':
+                            port = getattr(
+                                settings, "TELECASTER_LIVE_ICECAST_STREAMING_PORT", '8000')
+                            path = getattr(
+                                settings, "TELECASTER_LIVE_ICECAST_STREAMING_PATH", '/')
+                        elif server_type == 'stream-m':
+                            port = getattr(
+                                settings, "TELECASTER_LIVE_STREAM_M_STREAMING_PORT", '8080')
+                            path = getattr(
+                                settings, "TELECASTER_LIVE_STREAM_M_STREAMING_PATH", '/')
+                        #site = Site.objects.all()[0]
+                        server, c = StreamingServer.objects.get_or_create(
+                            protocol=protocol,
+                            host=host,
+                            port=port,
+                            path=path,
+                            type=server_type)
+                        stream = LiveStream(conference=conference, server=server,
+                                            stream_type=stream_type, streaming=True)
+                        stream.save()
+
+                    if not conference.web_class_group and settings.TELECASTER_LIVE_TWEETER:
+                        try:
+                            site = get_current_site(request)
+                            live_message(site, conference)
+                        except:
+                            pass
+        else:
+            raise 'Error : input must be a conference dictionnary'
 
     @method_decorator(access_required)
     def dispatch(self, *args, **kwargs):