Ejemplo n.º 1
0
 def on_changed(self, collection, id, fields, cleared):
     self.set_audio(fields)
     me = self.client.find_one('rooms')
     if self.paused != me['paused']:
         self.set_paused(me['paused'])
     if context.get_state().is_recording != me['recording']:
         self.set_recording(me)
Ejemplo n.º 2
0
    def check_net(self, origin, status=None):
        """Update the value of the network status"""
        attr1 = pango.AttrList()
        attr2 = pango.AttrList()
        attr3 = pango.AttrList()
        attr4 = pango.AttrList()
        gray = pango.AttrForeground(20000, 20000, 20000, 0, -1)
        red = pango.AttrForeground(65535, 0, 0, 0, -1)
        green = pango.AttrForeground(0, 65535, 0, 0, -1)
        black = pango.AttrForeground(5000, 5000, 5000, 0, -1)
        attr1.insert(gray)
        attr2.insert(green)
        attr3.insert(red)
        attr4.insert(black)

        s3 = self.gui.get_object("status3")
        if not self.net_activity:
            s3.set_text("Disabled")
            s3.set_attributes(attr1)
        else:
            net = status or context.get_state().net
            try:
                if net:
                    s3.set_text("Up")
                    s3.set_attributes(attr2)
                else:
                    s3.set_text("Down")
                    s3.set_attributes(attr3)
            except KeyError:
                s3.set_text("Connecting")
                s3.set_attributes(attr4)
Ejemplo n.º 3
0
    def on_scheduled_start(self, source, identifier):
        """Starts a scheduled recording, replacing the mediapackage in use"""
        logger.info("Scheduled Start")
        self.conf.reload()
        self.current_mediapackage = identifier
        context.get_state().mp = identifier
        self.scheduled_recording = True

        if self.status == GC_PREVIEW: # Record directly
            self.mediapackage = self.repo.get(self.current_mediapackage)
            self.on_rec() 
        
        elif self.status in [ GC_RECORDING, GC_PAUSED ] :

            if self.allow_overlap:
                pass
                # TODO: dont stop and extend recording until the end of the new interval
                # In case of stop, restart with the overlapped job

            else: # Stop current recording, wait until prewiew restarted and record
                self.start_recording = True
                self.close_recording()                
                      
        elif self.status == GC_INIT:  # Start Preview and Record
            self.on_start_button()
            while self.recorder.get_status() != gst.STATE_PLAYING:
                time.sleep(0.2)
            self.mediapackage = self.repo.get(self.current_mediapackage)
            self.on_rec()

        title = self.repo.get(identifier).title
        self.dispatcher.emit("update-video", title)
Ejemplo n.º 4
0
    def close_recording(self):
        """Set the final data on the mediapackage, stop the record and restart the preview"""
        paused = self.paused_time.total_seconds() * 1000000000  # pass to ns
        close_duration = int(
            (self.recorder.get_time() - self.initial_time - paused) * 1000 /
            gst.SECOND)
        # To avoid error messages on stopping pipelines
        if self.error_dialog:
            if self.error_id:
                self.dispatcher.disconnect(self.error_id)
                self.error_id = None
            self.error_dialog.dialog_destroy()
            self.error_dialog = None
            self.error_text = None
        self.recorder.stop_record_and_restart_preview()
        self.change_state(GC_STOP)

        self.mediapackage.status = mediapackage.RECORDED
        self.mediapackage.properties['origin'] = self.conf.hostname
        self.repo.add_after_rec(self.mediapackage, self.recorder.bins_desc,
                                close_duration, self.mediapackage.manual)

        code = 'manual' if self.mediapackage.manual else 'scheduled'
        if self.conf.get_lower('ingest', code) == 'immediately':
            self.worker.ingest(self.mediapackage)
        elif self.conf.get_lower('ingest', code) == 'nightly':
            self.worker.ingest_nightly(self.mediapackage)

        context.get_state().is_recording = False
        self.timer_thread_id = None
Ejemplo n.º 5
0
    def close_recording(self):
        """Set the final data on the mediapackage, stop the record and restart the preview"""
        paused = self.paused_time.total_seconds()*1000000000 # pass to ns
        close_duration = int((self.recorder.get_time()-self.initial_time-paused)*1000/gst.SECOND)
        # To avoid error messages on stopping pipelines
        if self.error_dialog:
            if self.error_id:
                self.dispatcher.disconnect(self.error_id)
                self.error_id = None
            self.error_dialog.dialog_destroy()
            self.error_dialog = None
            self.error_text = None
        self.recorder.stop_record_and_restart_preview()
        self.change_state(GC_STOP)

        self.mediapackage.status = mediapackage.RECORDED
        self.mediapackage.properties['origin'] = self.conf.hostname
        self.repo.add_after_rec(self.mediapackage, self.recorder.bins_desc, 
                                close_duration, self.mediapackage.manual)
        
        code = 'manual' if self.mediapackage.manual else 'scheduled'
        if self.conf.get_lower('ingest', code) == 'immediately':
            self.worker.ingest(self.mediapackage)
        elif self.conf.get_lower('ingest', code) == 'nightly':
            self.worker.ingest_nightly(self.mediapackage)

        context.get_state().is_recording = False
        self.timer_thread_id = None
Ejemplo n.º 6
0
 def _update_images(self, delay):
     time.sleep(delay)
     files = {}
     audio_devices = ['audiotest', 'autoaudio', 'pulse']
     for track in context.get_state().profile.tracks:
         if track.device not in audio_devices:
             file = os.path.join('/tmp', track.file + '.jpg')
             try:
                 if(os.path.getctime(file) > time.time() - 3):
                     files[track.flavor] = (track.flavor + '.jpg',
                                            open(file, 'rb'),
                                            'image/jpeg')
             except Exception:
                 logger.warn("Unable to check date of or open file (%s)"
                             % file)
     im = ImageGrab.grab(bbox=(10, 10, 1280, 720), backend='imagemagick')
     im.thumbnail((640, 360))
     output = cStringIO.StringIO()
     if im.mode != "RGB":
         im = im.convert("RGB")
     im.save(output, format="JPEG")
     files['galicaster'] = ('galicaster.jpg', output.getvalue(),
                            'image/jpeg')
     try:
         # add verify=False for testing self signed certs
         requests.post(
             "%s/image/%s" %
             (self._http_host, self.id), files=files, auth=(
                 self._user, self._password))
     except Exception:
         logger.warn('Unable to post images')
Ejemplo n.º 7
0
 def on_changed(self, collection, id, fields, cleared):
     self.set_audio(fields)
     me = self.client.find_one('rooms')
     if self.paused != me['paused']:
         self.set_paused(me['paused'])
     if context.get_state().is_recording != me['recording']:
         self.set_recording(me)
Ejemplo n.º 8
0
 def _update_images(self, delay):
     time.sleep(delay)
     files = {}
     audio_devices = ['audiotest', 'autoaudio', 'pulse']
     for track in context.get_state().profile.tracks:
         if track.device not in audio_devices:
             file = os.path.join('/tmp', track.file + '.jpg')
             try:
                 if (os.path.getctime(file) > time.time() - 3):
                     files[track.flavor] = (track.flavor + '.jpg',
                                            open(file, 'rb'), 'image/jpeg')
             except Exception:
                 logger.warn("Unable to check date of or open file (%s)" %
                             file)
     im = ImageGrab.grab(bbox=(10, 10, 1280, 720), backend='imagemagick')
     im.thumbnail((640, 360))
     output = cStringIO.StringIO()
     if im.mode != "RGB":
         im = im.convert("RGB")
     im.save(output, format="JPEG")
     files['galicaster'] = ('galicaster.jpg', output.getvalue(),
                            'image/jpeg')
     try:
         # add verify=False for testing self signed certs
         requests.post("%s/image/%s" % (self._http_host, self.id),
                       files=files,
                       auth=(self._user, self._password))
     except Exception:
         logger.warn('Unable to post images')
Ejemplo n.º 9
0
    def select_devices(self):
        """Loads the bins and creates the preview areas for the active profile, creating a new mediapacakge."""
        self.configure_profile()
        logger.info("Setting Devices the new way")
        now = datetime.datetime.now().replace(microsecond=0)
        self.mediapackage = mediapackage.Mediapackage(
            title="Recording started at " + now.isoformat())

        context.get_state().mp = self.mediapackage.identifier

        current_profile = self.conf.get_current_profile()
        bins = current_profile.tracks

        for objectbin in bins:
            objectbin['path'] = self.repo.get_rectemp_path()
        devices = current_profile.get_video_areas()
        areas = self.create_drawing_areas(devices)

        self.bins = bins
        self.areas = areas

        if self.error_dialog:
            if self.error_id:
                self.dispatcher.disconnect(self.error_id)
                self.error_id = None
            self.error_dialog.dialog_destroy()
            self.error_dialog = None
            self.error_text = None

        self.error_id = self.dispatcher.connect("recorder-error",
                                                self.handle_pipeline_error)
        self.audiobar.ClearVumeter()
        if self.ok_to_show:
            self.init_recorder()
        return True
Ejemplo n.º 10
0
def quit():
    if not context.get_state().is_recording:
        # Emit quit signal and exit
        gtk.gdk.threads_enter()
        context.get_dispatcher().emit('galicaster-notify-quit')
        gtk.main_quit()
        gtk.gdk.threads_leave()
Ejemplo n.º 11
0
    def select_devices(self):
        """Loads the bins and creates the preview areas for the active profile, creating a new mediapacakge."""
        self.configure_profile()
        logger.info("Setting Devices the new way")
        now = datetime.datetime.now().replace(microsecond=0)
        self.mediapackage = mediapackage.Mediapackage(title="Recording started at " + now.isoformat())

        context.get_state().mp = self.mediapackage.identifier

        current_profile = self.conf.get_current_profile()
        bins = current_profile.tracks

        for objectbin in bins:
            objectbin["path"] = self.repo.get_rectemp_path()
        devices = current_profile.get_video_areas()
        areas = self.create_drawing_areas(devices)

        self.bins = bins
        self.areas = areas

        if self.error_dialog:
            if self.error_id:
                self.dispatcher.disconnect(self.error_id)
                self.error_id = None
            self.error_dialog.dialog_destroy()
            self.error_dialog = None
            self.error_text = None

        self.error_id = self.dispatcher.connect("recorder-error", self.handle_pipeline_error)
        self.audiobar.ClearVumeter()
        if self.ok_to_show:
            self.init_recorder()
        return True
Ejemplo n.º 12
0
    def check_net(self, origin, status=None):
        """Update the value of the network status"""
        attr1 = pango.AttrList()
        attr2 = pango.AttrList()
        attr3 = pango.AttrList()
        attr4 = pango.AttrList()
        gray = pango.AttrForeground(20000, 20000, 20000, 0, -1)
        red = pango.AttrForeground(65535, 0, 0, 0, -1)
        green = pango.AttrForeground(0, 65535, 0, 0, -1)
        black = pango.AttrForeground(5000, 5000, 5000, 0, -1)
        attr1.insert(gray)
        attr2.insert(green)
        attr3.insert(red)
        attr4.insert(black)

        s3 = self.gui.get_object("status3")
        if not self.net_activity:
            s3.set_text("Disabled")
            s3.set_attributes(attr1)
        else:
            net = status or context.get_state().net
            try:
                if net:
                    s3.set_text("Up")
                    s3.set_attributes(attr2)
                else:
                    s3.set_text("Down")
                    s3.set_attributes(attr3)
            except KeyError:
                s3.set_text("Connecting")
                s3.set_attributes(attr4)
Ejemplo n.º 13
0
 def configure_profile(self):
     profile = self.conf.get_current_profile()
     context.get_state().profile = profile
     if profile.execute:
         out = os.system(profile.execute)
         logger.info("Executing {0} with out {1}".format(profile.execute, out))
         if out:
             self.dispatcher.emit("recorder-error", "Error executing command configuring profile")
Ejemplo n.º 14
0
 def configure_profile(self):
     profile = self.conf.get_current_profile()
     context.get_state().profile = profile
     if profile.execute:
         out = os.system(profile.execute)
         logger.info("Executing {0} with out {1}".format(profile.execute, out))
         if out:
             self.dispatcher.emit("recorder-error", "Error executing command configuring profile")
Ejemplo n.º 15
0
 def on_start_before(self, origin, key):
     """ Start a recording before its schedule or via rest """
     if key:
         logger.info("Start recording before schedule")
         self.mediapackage = self.repo.get(key)
         context.get_state().mp=self.mediapackage.identifier
     else:
         logger.info("Rest triggered recording")
     self.on_rec()
     return True            
Ejemplo n.º 16
0
 def on_start_before(self, origin, key):
     """ Start a recording before its schedule or via rest """
     if key:
         logger.info("Start recording before schedule")
         self.mediapackage = self.repo.get(key)
         context.get_state().mp = self.mediapackage.identifier
     else:
         logger.info("Rest triggered recording")
     self.on_rec()
     return True
Ejemplo n.º 17
0
    def handle_pipeline_error(self, origin, error_message):
        """ Captures a pipeline error.
        If the recording are is active, shows it
        """
        self.change_state(GC_ERROR)
        self.timer_thread_id = None
        context.get_state().is_error = True
        self.recorder.stop_elements()
        context.get_state().is_recording = False
        self.error_count += 1

        if (self.error_count > 5):
            logger.error("Error. Show message ({})".format(self.error_count))
            self.show_pipeline_error(origin, error_message)
        elif(self.status not in [ GC_RECORDING, GC_PAUSED ]):
            if self.error_count == 1:
                self.repo.save_crash_recordings()
            logger.error("Error, retry intent {}".format(self.error_count))
            self.error_handle_id = gobject.timeout_add_seconds(13, self.select_devices)
Ejemplo n.º 18
0
 def on_start_recording(self, sender, id):
     self.recording = True
     self.currentMediaPackage = self.media_package_metadata(id)
     self.currentProfile = context.get_state().profile.name
     self.update('rooms', {'_id': self.id}, {
         '$set': {
             'currentMediaPackage': self.currentMediaPackage,
             'currentProfile': self.currentProfile,
             'recording': self.recording
         }
     })
Ejemplo n.º 19
0
def stop():
    response.content_type = 'text/html'
    state = context.get_state()

    if state.is_recording:
        #Emit the signal to begin the recording
        gtk.gdk.threads_enter()
        context.get_dispatcher().emit('stop-record', 0)
        gtk.gdk.threads_leave()
        return "Signal to stop recording sent"
    else:
        abort(500, "failed to stop the capture, or no current active capture")
Ejemplo n.º 20
0
    def start_thread(self,identifier):
        """Thread handling a scheduled recording"""
        self.start_thread_id = 1        
        if self.status == GC_PREVIEW: # Record directly
            self.mediapackage = self.repo.get(self.current_mediapackage)
            context.get_state().mp = self.mediapackage.identifier
            self.on_rec() 
        
        elif self.status in [ GC_RECORDING, GC_PAUSED ] :

            if self.allow_overlap:
                pass
                # TODO: dont stop and extend recording until the end of the new interval
                # In case of stop, restart with the overlapped job

            else: # Stop current recording, wait until prewiew restarted and record
                self.restarting = True
                self.close_recording()                
                while self.restarting:
                    time.sleep(0.1) 
                    if self.start_thread_id == None:
                        return
                self.mediapackage = self.repo.get(self.current_mediapackage)   
                self.on_rec()       
                      
        elif self.status == GC_INIT:  # Start Preview and Record
            self.on_start_button()
            while self.recorder.get_status() != gst.STATE_PLAYING:
                time.sleep(0.2)
                if self.start_thread_id == None:
                    return
            self.mediapackage = self.repo.get(self.current_mediapackage)
            self.on_rec()

        elif self.status == GC_ERROR:
            if self.error_dialog:
                if self.error_id:
                    self.dispatcher.disconnect(self.error_id)
                    self.error_id = None
                self.error_dialog.dialog_destroy()
                self.error_dialog = None
                self.error_text = None
            self.on_start_button()
            while self.recorder.get_status() != gst.STATE_PLAYING:
                time.sleep(0.2)
                if self.start_thread_id == None:
                    return
            self.mediapackage = self.repo.get(self.current_mediapackage)
            self.on_rec()              

        title = self.repo.get(identifier).title
        self.dispatcher.emit("update-video", title)        
        return None
Ejemplo n.º 21
0
def check_pipeline_amp(self, valor):
    if context.get_state().is_recording:
        rms = valor
        rms_list.append(rms)
        if os.path.exists(temp_amp):
            f = open(temp_amp, 'a')
        else:
            f = open(temp_amp, 'w')
        if len(rms_list) > 100:
            f.write(str(max(rms_list)) + '\n')
            f.close()
            del rms_list[:]
Ejemplo n.º 22
0
    def close_recording(self):
        """Set the final data on the mediapackage, stop the record and restart the preview"""
        # To avoid error messages on stopping pipelines
        if self.error_dialog:
            self.error_dialog.dialog_destroy()
            self.error_dialog = None
            self.error_text = None
        self.recorder.stop_record_and_restart_preview()
        self.change_state(GC_STOP)

        context.get_state().is_recording = False
        self.timer_thread_id = None
Ejemplo n.º 23
0
def check_pipeline_amp(self, valor):
    if context.get_state().is_recording:
        rms = valor
        rms_list.append(rms)
        if os.path.exists(temp_amp):
            f = open(temp_amp, 'a')
        else:
            f = open(temp_amp, 'w')
        if len(rms_list) > 100:
            f.write(str(max(rms_list)) + '\n')
            f.close()
            del rms_list[:]
Ejemplo n.º 24
0
    def start_thread(self, identifier):
        """Thread handling a scheduled recording"""
        self.start_thread_id = 1
        if self.status == GC_PREVIEW:  # Record directly
            self.mediapackage = self.repo.get(self.current_mediapackage)
            context.get_state().mp = self.mediapackage.identifier
            self.on_rec()

        elif self.status in [GC_RECORDING, GC_PAUSED]:

            if self.allow_overlap:
                pass
                # TODO: dont stop and extend recording until the end of the new interval
                # In case of stop, restart with the overlapped job

            else:  # Stop current recording, wait until prewiew restarted and record
                self.restarting = True
                self.close_recording()
                while self.restarting:
                    time.sleep(0.1)
                    if self.start_thread_id == None:
                        return
                self.mediapackage = self.repo.get(self.current_mediapackage)
                self.on_rec()

        elif self.status == GC_INIT:  # Start Preview and Record
            self.on_start_button()
            while self.recorder.get_status() != gst.STATE_PLAYING:
                time.sleep(0.2)
                if self.start_thread_id == None:
                    return
            self.mediapackage = self.repo.get(self.current_mediapackage)
            self.on_rec()

        elif self.status == GC_ERROR:
            if self.error_dialog:
                if self.error_id:
                    self.dispatcher.disconnect(self.error_id)
                    self.error_id = None
                self.error_dialog.dialog_destroy()
                self.error_dialog = None
                self.error_text = None
            self.on_start_button()
            while self.recorder.get_status() != gst.STATE_PLAYING:
                time.sleep(0.2)
                if self.start_thread_id == None:
                    return
            self.mediapackage = self.repo.get(self.current_mediapackage)
            self.on_rec()

        title = self.repo.get(identifier).title
        self.dispatcher.emit("update-video", title)
        return None
Ejemplo n.º 25
0
def start():
    response.content_type = 'text/html'
    state = context.get_state()

    # Already Recording
    if state.is_recording:
        abort(500, "couldn't start capture")
    else:
        gtk.gdk.threads_enter()
        context.get_dispatcher().emit('start-before', None)
        gtk.gdk.threads_leave()
        return "Signal to start recording sent"    
Ejemplo n.º 26
0
    def __init__(self):
        DBusService(self)

        logger.info('galicaster.__version__: %r', __version__)
        logger.info('galicaster.__file__: %r', __file__)

        self.conf = context.get_conf()
        self.state = context.get_state()
        self.dispatcher = context.get_dispatcher()
        self.modules = self.conf.get_modules()
        self.load_modules()
        self.dispatcher.connect('net-up', self.check_net, True)
        self.dispatcher.connect('net-down', self.check_net, False)
Ejemplo n.º 27
0
    def __init__(self):
        DBusService(self)

        logger.info("galicaster.__version__: %r", __version__)
        logger.info("galicaster.__file__: %r", __file__)

        self.conf = context.get_conf()
        self.state = context.get_state()
        self.dispatcher = context.get_dispatcher()
        self.modules = self.conf.get_modules()
        self.load_modules()
        self.dispatcher.connect("net-up", self.check_net, True)
        self.dispatcher.connect("net-down", self.check_net, False)
Ejemplo n.º 28
0
    def select_devices(self):
        """Loads the bins and creates the preview areas for the active profile, creating a new mediapacakge."""
        self.configure_profile()
        logger.info("Setting Devices the new way")
        now = datetime.datetime.now().replace(microsecond=0)
        self.mediapackage = mediapackage.Mediapackage(title=_("Recording started at {0}").format(now.isoformat()))

        context.get_state().mp = self.mediapackage.identifier

        if self.ok_to_show:
            self.init_recorder()
        self.error_handle_id = None
        return False
Ejemplo n.º 29
0
    def init_recorder(self):
        if self.error_dialog:
            self.error_dialog.dialog_destroy()
            self.error_dialog = None
            self.error_text = None
        self.audiobar.ClearVumeter()
        context.get_state().is_error = False

        current_profile = self.conf.get_current_profile()
        bins = current_profile.tracks
        for objectbin in bins:
            objectbin['path'] = self.repo.get_rectemp_path()

        self.recorder = Recorder(bins) 
        self.recorder.mute_preview(not self.focus_is_active)   
        info = self.recorder.get_display_areas_info()
        if self.swap: 
            info.reverse()
        areas = self.create_drawing_areas(info)
        self.recorder.set_drawing_areas(areas)

        if self.start_recording:
            self.start_recording = False
            ok = self.recorder.preview_and_record()
            self.mediapackage = self.repo.get(self.current_mediapackage)
            # NOTE only call on_rec to update UI. Recorder is already recording.
            self.on_rec()
        else:
            ok = self.recorder.preview()
        if ok :
            if self.mediapackage.manual:
                self.change_state(GC_PREVIEW)
        else:
            logger.error("Restarting Preview Failed")
            context.get_state().is_error = True
            self.change_state(GC_ERROR)
            if self.scheduled_recording:
                self.on_failed_scheduled(self.current_mediapackage)    
Ejemplo n.º 30
0
 def on_start_recording(self, sender, id):
     self.recording = True
     self.currentMediaPackage = self.media_package_metadata(id)
     self.currentProfile = context.get_state().profile.name
     self.update(
         'rooms', {
             '_id': self.id
         }, {
             '$set': {
                 'currentMediaPackage': self.currentMediaPackage,
                 'currentProfile': self.currentProfile,
                 'recording': self.recording
             }
         })
Ejemplo n.º 31
0
 def on_rec(self, button=None):
     """Manual Recording """
     logger.info("Recording")
     self.dispatcher.emit("starting-record")
     self.recorder.record()
     self.mediapackage.status = mediapackage.RECORDING
     now = datetime.datetime.utcnow().replace(microsecond=0)
     self.mediapackage.setDate(now)
     self.timer_thread_id = 1
     self.timer_thread = thread(target=self.timer_launch_thread)
     self.timer_thread.daemon = True
     self.timer_thread.start()
     self.change_state(GC_RECORDING)
     context.get_state().is_recording = True
     return True
Ejemplo n.º 32
0
    def handle_pipeline_error(self, origin, error_message):
        """ Captures a pipeline error.
        If the recording are is active, shows it
        """
        self.change_state(GC_ERROR)
        self.recorder.stop_elements()
        context.get_state().is_recording = False
        if self.error_id:
            self.dispatcher.disconnect(self.error_id)
            self.error_id = None
            #TODO kill previous error if needed

        self.error_text = error_message
        if self.focus_is_active:
            self.launch_error_message(error_message)
Ejemplo n.º 33
0
    def __init__(self):
        DBusService(self)

        logger.info('galicaster.__version__: %r', __version__)
        logger.info('galicaster.__file__: %r', __file__)

        self.conf = context.get_conf()
        self.state = context.get_state()
        self.dispatcher = context.get_dispatcher()
        self.modules = self.conf.get_modules()
        self.load_modules()
        self.dispatcher.connect('net-up', self.check_net, True)
        self.dispatcher.connect('net-down', self.check_net, False)
        self.dispatcher.connect("reload-profile", self.reload_profile)
        self.reload_profile(None) # To exec the execute to start
Ejemplo n.º 34
0
 def on_rec(self,button=None): 
     """Manual Recording """
     logger.info("Recording")
     self.dispatcher.emit("starting-record")
     self.recorder.record()
     self.mediapackage.status=mediapackage.RECORDING
     now = datetime.datetime.utcnow().replace(microsecond=0)
     self.mediapackage.setDate(now)
     self.timer_thread_id = 1
     self.timer_thread = thread(target=self.timer_launch_thread) 
     self.timer_thread.daemon = True
     self.timer_thread.start()
     self.change_state(GC_RECORDING)
     context.get_state().is_recording = True
     return True  
Ejemplo n.º 35
0
 def handle_pipeline_error(self, origin, error_message):
     """ Captures a pipeline error.
     If the recording are is active, shows it
     """
     self.change_state(GC_ERROR)
     self.recorder.stop_elements()
     context.get_state().is_recording = False
     if self.error_id:
         self.dispatcher.disconnect(self.error_id)
         self.error_id = None
         #TODO kill previous error if needed
     
     self.error_text = error_message
     if self.focus_is_active:
         self.launch_error_message(error_message)
Ejemplo n.º 36
0
    def check_status_area(self, origin, signal=None, other=None): 
        """Updates the values on the recording tab"""
        s1 = self.gui.get_object("status1")
        s2 = self.gui.get_object("status2")
        # s3 = self.gui.get_object("status3")
        s4 = self.gui.get_object("status4")
 
        freespace,text_space=status_bar.GetFreeSpace(self.repo.get_rectemp_path())
        s1.set_text(text_space)
        four_gb = 4000000000.0
        hours = int(freespace/four_gb)
        s2.set_text(_("{0} hours left").format(str(hours)))
        agent = context.get_state().hostname # TODO just consult it once
        if s4.get_text() != agent:
            s4.set_text(agent)
Ejemplo n.º 37
0
    def event_change_mode(self, orig, old_state, new_state):
        """Handles the focus or the Rercording Area, launching messages when focus is recoverde"""
        if new_state == 0: 
            self.focus_is_active = True
            if self.recorder:
                self.recorder.mute_preview(False)
            if self.error_text:            
                if self.status != GC_ERROR:
                    self.change_state(GC_ERROR)
                    context.get_state().is_error = True
                self.launch_error_message(self.error_text)            

        if old_state == 0:
            self.focus_is_active = False
            if self.recorder:
                self.recorder.mute_preview(True)
Ejemplo n.º 38
0
    def check_status_area(self, origin, signal=None, other=None):
        """Updates the values on the recording tab"""
        s1 = self.gui.get_object("status1")
        s2 = self.gui.get_object("status2")
        # s3 = self.gui.get_object("status3")
        s4 = self.gui.get_object("status4")

        freespace, text_space = status_bar.GetFreeSpace(
            self.repo.get_attach_path())
        s1.set_text(text_space)
        four_gb = 4000000000.0
        hours = int(freespace / four_gb)
        s2.set_text(str(hours) + " hours left")
        agent = context.get_state().hostname  # TODO just consult it once
        if s4.get_text() != agent:
            s4.set_text(agent)
Ejemplo n.º 39
0
def index():
    response.content_type = 'application/json'
    state = context.get_state()
    text="Galicaster REST endpoint plugin\n\n"
    endpoints = {
            "/state" : "show some state values",
            "/repository" : "list mp keys" ,
            "/repository/:id" : "get mp manifest (XML)",
            "/metadata/:id" : "get mp metadata (JSON)",
            "/start" : "starts a manual recording",
            "/stop" :  "stops current recording",
            "/operation/ingest/:id" : "Ingest MP",
            "/operation/sidebyside/:id"  : "Export MP to side-by-side",
            "/operation/exporttozip/:id" : "Export MP to zip",
            "/screen" : "get a screenshoot of the active"
        }    
    return json.dumps(endpoints)
Ejemplo n.º 40
0
    def check_status_area(self, origin, signal=None, other=None): 
        """Updates the values on the recording tab"""
        s1 = self.gui.get_object("status1")
        s2 = self.gui.get_object("status2")
        # s3 = self.gui.get_object("status3")
        s4 = self.gui.get_object("status4")
 
        freespace = self.repo.get_free_space()
        text_space = readable.size(freespace)
        
        s1.set_text(text_space)
        four_gb = 4000000000.0
        hours = int(freespace/four_gb)
        s2.set_text(_("{0} hours left").format(str(hours)))
        agent = context.get_state().hostname # TODO just consult it once
        if s4.get_text() != agent:
            s4.set_text(agent)
Ejemplo n.º 41
0
    def on_rec(self,button=None, pre_filled=False): 
        """Manual Recording """
        logger.info("Recording")
        self.dispatcher.emit("starting-record")
        self.recorder.record()
        self.mediapackage.status=mediapackage.RECORDING
        now = datetime.datetime.utcnow().replace(microsecond=0)
        self.mediapackage.setDate(now)

        if self.mediapackage.manual and not pre_filled:
            self.mediapackage.setTitle(_("Recording started at {0}").format(now.isoformat()))

        self.timer_thread_id = 1
        self.timer_thread = thread(target=self.timer_launch_thread) 
        self.timer_thread.daemon = True
        self.timer_thread.start()
        self.change_state(GC_RECORDING)
        context.get_state().is_recording = True
        return True  
Ejemplo n.º 42
0
def check_key(source, event):
    """
    Filter Ctrl combinations for quit,restart and configuration 
    """
    dispatcher = context.get_dispatcher()
    window = context.get_mainwindow()
    state = context.get_state()
    if ((event.state & gtk.gdk.SHIFT_MASK and event.state & gtk.gdk.CONTROL_MASK) 
        and event.state & gtk.gdk.MOD2_MASK and
        (event.keyval in [gtk.gdk.keyval_from_name('q'), gtk.gdk.keyval_from_name('Q')])):
        
        if not state.is_recording:
            dispatcher.emit('galicaster-quit')

    if ((event.state & gtk.gdk.CONTROL_MASK)  and
        event.keyval == gtk.gdk.keyval_from_name('Return') ):
        window.toggle_fullscreen(None)
                
    return True  
Ejemplo n.º 43
0
    def __init__(self):
        service = DBusService(self)
        self.conf = context.get_conf()
        self.state = context.get_state()
        self.dispatcher = context.get_dispatcher()

        self.modules = []
        self.modules.append('recorder')

        if self.conf.get_boolean('basic', 'admin'):
            self.modules.append('media_manager')
            self.modules.append('player')

        if self.conf.get_boolean('ingest', 'active'):
            self.modules.append('scheduler')

        if self.conf.get_boolean('basic', 'pin'):
            self.modules.append('pin')

        self.load_modules()
        self.dispatcher.connect('net-up', self.check_net, True)
        self.dispatcher.connect('net-down', self.check_net, False)
Ejemplo n.º 44
0
def check_key(source, event):
    """
    Filter Ctrl combinations for quit,restart and configuration 
    """
    dispatcher = context.get_dispatcher()
    window = context.get_mainwindow()
    state = context.get_state()
    if ((event.state & gtk.gdk.SHIFT_MASK
         and event.state & gtk.gdk.CONTROL_MASK)
            and event.state & gtk.gdk.MOD2_MASK and
        (event.keyval
         in [gtk.gdk.keyval_from_name('q'),
             gtk.gdk.keyval_from_name('Q')])):

        if not state.is_recording:
            dispatcher.emit('galicaster-quit')

    if ((event.state & gtk.gdk.CONTROL_MASK)
            and event.keyval == gtk.gdk.keyval_from_name('Return')):
        window.toggle_fullscreen(None)

    return True
Ejemplo n.º 45
0
    def __init__(self):
        service = DBusService(self)
        self.conf = context.get_conf()
        self.state = context.get_state()
        self.dispatcher = context.get_dispatcher()

        self.modules = []
        self.modules.append('recorder')
             
        if self.conf.get_boolean('basic', 'admin'):
            self.modules.append('media_manager')
            self.modules.append('player')

        if self.conf.get_boolean('ingest', 'active'):
            self.modules.append('scheduler')

        if self.conf.get_boolean('basic', 'pin'):
            self.modules.append('pin')

        self.load_modules()
        self.dispatcher.connect('net-up', self.check_net, True)
        self.dispatcher.connect('net-down', self.check_net, False)
Ejemplo n.º 46
0
 def check_net(self, origin, data):
     context.get_state().net = data
Ejemplo n.º 47
0
    def change_state(self, state):
        """Activates or deactivates the buttons depending on the new state"""
        record = self.gui.get_object("recbutton")
        pause = self.gui.get_object("pausebutton")
        stop = self.gui.get_object("stopbutton")
        helpb = self.gui.get_object("helpbutton")
        editb = self.gui.get_object("editbutton")
        prevb = self.gui.get_object("previousbutton")
        swapb = self.gui.get_object("swapbutton")
        if not self.swap_active:
            swapb.hide()

        if state != self.status:
            self.previous, self.status = self.status, state

        if state == GC_INIT:
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)
            swapb.set_sensitive(False)
            self.dispatcher.emit("update-rec-status", "Initialization")

        elif state == GC_PREVIEW:
            record.set_sensitive((self.allow_start or self.allow_manual))
            pause.set_sensitive(False)
            pause.set_active(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)
            swapb.set_sensitive(True)
            if self.next == None:
                self.dispatcher.emit("update-rec-status", "Idle")
            else:
                self.dispatcher.emit("update-rec-status", "Waiting")

        elif state == GC_RECORDING:
            record.set_sensitive(False)
            pause.set_sensitive(self.allow_pause
                                and self.recorder.is_pausable())
            stop.set_sensitive((self.allow_stop or self.allow_manual))
            helpb.set_sensitive(True)
            prevb.set_sensitive(False)
            swapb.set_sensitive(False)
            editb.set_sensitive(True and not self.scheduled_recording)
            self.dispatcher.emit("update-rec-status", "  Recording  ")

        elif state == GC_PAUSED:
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            prevb.set_sensitive(False)
            helpb.set_sensitive(False)
            editb.set_sensitive(False)

            self.dispatcher.emit("update-rec-status", "Paused")

        elif state == GC_STOP:
            if self.previous == GC_PAUSED:
                self.pause_dialog.destroy()
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)

        elif state == GC_BLOCKED:
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(False)
            prevb.set_sensitive(False)
            editb.set_sensitive(False)

        elif state == GC_ERROR:
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)

        context.get_state().status = STATUS[state][0]

        if self.next == None and state == GC_PREVIEW:
            self.view.set_displayed_row(GC_PRE2)
        else:
            self.view.set_displayed_row(state)
Ejemplo n.º 48
0
 def check_net(self, origin, data):
     context.get_state().net = data
Ejemplo n.º 49
0
def state():
    response.content_type = 'application/json'
    state = context.get_state()
    return json.dumps(state.get_all())
Ejemplo n.º 50
0
    def change_state(self, state):
        """Activates or deactivates the buttons depending on the new state"""
        record = self.gui.get_object("recbutton")
        pause = self.gui.get_object("pausebutton")
        stop = self.gui.get_object("stopbutton")
        helpb = self.gui.get_object("helpbutton")
        editb = self.gui.get_object("editbutton")
        prevb = self.gui.get_object("previousbutton")
        swapb = self.gui.get_object("swapbutton")
        if not self.swap_active:
            swapb.hide()

        if state != self.status:
            self.previous,self.status = self.status,state

        if state == GC_INIT:
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)
            swapb.set_sensitive(False)
            self.dispatcher.emit("update-rec-status", "Initialization")            

        elif state == GC_PREVIEW:    
            record.set_sensitive( (self.allow_start or self.allow_manual) )
            pause.set_sensitive(False)
            pause.set_active(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)
            swapb.set_sensitive(True)
            if self.next == None:
                self.dispatcher.emit("update-rec-status", "Idle")            
            else:
                self.dispatcher.emit("update-rec-status", "Waiting")     

        elif state == GC_RECORDING:
            record.set_sensitive(False)
            pause.set_sensitive(self.allow_pause and self.recorder.is_pausable()) 
            stop.set_sensitive( (self.allow_stop or self.allow_manual) )
            helpb.set_sensitive(True)
            prevb.set_sensitive(False)
            swapb.set_sensitive(False)
            editb.set_sensitive(True and not self.scheduled_recording)    
            self.dispatcher.emit("update-rec-status", "  Recording  ")
       
        elif state == GC_PAUSED:
            record.set_sensitive(False)
            pause.set_sensitive(False) 
            stop.set_sensitive(False)
            prevb.set_sensitive(False)
            helpb.set_sensitive(False)
            editb.set_sensitive(False)
  
            self.dispatcher.emit("update-rec-status", "Paused")
            
        elif state == GC_STOP:
            if self.previous == GC_PAUSED:
                self.pause_dialog.destroy()
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True)
            prevb.set_sensitive(True)
            editb.set_sensitive(False)

        elif state == GC_BLOCKED: 
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(False)   
            prevb.set_sensitive(False)
            editb.set_sensitive(False)

        elif state == GC_ERROR:             
            record.set_sensitive(False)
            pause.set_sensitive(False)
            stop.set_sensitive(False)
            helpb.set_sensitive(True) 
            prevb.set_sensitive(True )
            editb.set_sensitive(False)


        context.get_state().status = STATUS[state][0]

        if self.next == None and state == GC_PREVIEW:
            self.view.set_displayed_row(GC_PRE2)
        else:
            self.view.set_displayed_row(state)