Logo Search packages:      
Sourcecode: scenic version File versions  Download package

def scenic::application::Application::check_if_ready_to_stream (   self,
  role = "offerer" 
)
Does the flight check, checking if ready to stream.

Checks if ready to stream. 
Will pop up error dialog if there are errors.
Calls the deferred with a result that either True (ok) False (technical problems) or one of the communication.REFUSE_REASON_* constant value.
@rtype: L{Deferred}
@param role: Either "offerer" or "answerer".

Definition at line 991 of file application.py.

                                                      :
        """
        Does the flight check, checking if ready to stream.
        
        Checks if ready to stream. 
        Will pop up error dialog if there are errors.
        Calls the deferred with a result that either True (ok) False (technical problems) or one of the communication.REFUSE_REASON_* constant value.
        @rtype: L{Deferred}
        @param role: Either "offerer" or "answerer".
        """
        #TODO: poll X11 devices
        #TODO: poll xv extension
        log.debug("Check if ready to stream. - Pre-flight check.")
        self.gui.close_preview_if_running() # TODO: use its deferred
        self.save_configuration()
        self.prepare_before_rtp_stream()
        deferred = defer.Deferred()
        def _callback(unused_result):
            # callback for the deferred list created below.
            # calls the deferred's callback
            if role == "offerer":
                error_msg = _("Impossible to invite a contact to start streaming.")
            elif role == "answerer":
                error_msg = _("Impossible to accept an invitation to stream.")
            else:
                raise RuntimeError("Invalid role value : %s" % (role))
            
            x11_displays = [display["name"] for display in self.devices["x11_displays"]]
            #midi_input_devices = [device["name"] for device in self.devices["midi_input_devices"]]
            #midi_output_devices = [device["name"] for device in self.devices["midi_output_devices"]]
            #cameras = self.devices["cameras"].keys()

            #TODO: if video receive is enabled and video codec is not supported: error
                
            if self.config.video_display not in x11_displays: #TODO: do not test if not receiving video
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("The X11 display %(display)s disappeared!") % {"display": self.config.video_display}, parent=self.gui.main_window) # not very likely to happen !
                return deferred.callback(communication.REFUSE_REASON_DISPLAY_NOT_FOUND)
            
            elif self.config.video_source == "v4l2src" and self.parse_v4l2_device_name(self.config.video_device) is None: #TODO: do not test if not sending video
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("The video source %(camera)s disappeared!") % {"camera": self.config.video_source}, parent=self.gui.main_window) 
                return deferred.callback(communication.REFUSE_REASON_CAMERA_NOT_FOUND)

            elif (not self.devices["jackd_is_running"]) and (self.config.audio_send_enabled or self.config.audio_recv_enabled):
                log.debug("audio send/recv enabled: %s %s" % (self.config.audio_send_enabled, self.config.audio_recv_enabled))
                log.debug("self.devices[\'jackd_is_running\'] = %s" % (self.devices["jackd_is_running"]))
                # TODO: Actually poll jackd right now.
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("JACK is not running."), parent=self.gui.main_window)
                return deferred.callback(communication.REFUSE_REASON_PROBLEM_JACKD_NOT_RUNNING)
            
            elif self.streamer_manager.is_busy():
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("A streaming session is already in progress."), parent=self.gui.main_window)
                deferred.callback(False)
            
            elif self.config.midi_recv_enabled and self.parse_midi_device_name(self.config.midi_output_device, is_input=False) is None:
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("The MIDI output device %(device)s disappeared!") % {"device": self.config.midi_output_device}, parent=self.gui.main_window)
                deferred.callback(communication.REFUSE_REASON_MIDI_DEVICE_NOT_FOUND)
            
            elif self.config.midi_send_enabled and self.parse_midi_device_name(self.config.midi_input_device, is_input=True) is None:
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("The MIDI input device %(device)s disappeared!") % {"device": self.config.midi_input_device}, parent=self.gui.main_window)
                deferred.callback(communication.REFUSE_REASON_MIDI_DEVICE_NOT_FOUND)
            
            # "cameras": {}, # dict of dicts (only V4L2 cameras for now)
            elif not self.devices["xvideo_is_present"] and self.config.video_recv_enabled:
                dialogs.ErrorDialog.create(error_msg + "\n\n" + _("The X video extension is not present."), parent=self.gui.main_window)
                deferred.callback(communication.REFUSE_REASON_XVIDEO_NOT_FOUND)
            
            else:
                deferred.callback(True)
        
        deferred_list = defer.DeferredList([
            self.poll_x11_devices(), 
            self.poll_midi_devices(), 
            self.poll_xvideo_extension(),
            self.poll_jack_now(),
            self.poll_camera_devices()
            ])
        deferred_list.addCallback(_callback)
        return deferred


Generated by  Doxygen 1.6.0   Back to index