def run(self): """ This runs the main loop for the camera """ #Reset PTZ Camera on Service Start self.camera.resetLocation() # Settings check_interval = settings.getSetting_int('interval', self.camera.number) cond_service = settings.getSetting_int('cond_service', self.camera.number) self.motion_enabled, self.sound_enabled = settings.getEnabledAlarms(self.camera.number) trigger_interval = self.camera.getTriggerInterval(self.motion_enabled, self.sound_enabled) if trigger_interval < 1: # Fix for Foscam Cameras that apparently get the data messed up trigger_interval = check_interval ### MAIN LOOP ### while not self.monitor.abortRequested() and not self.monitor.stopped(): alarmActive = self.alarmStateHealthCheck() #PREVIEW WINDOW IS CURRENTLY CLOSED if self.monitor.previewAllowed(self.camera.number): #Open Condition: Alarm is Detected if alarmActive: self.monitor.openRequest(self.camera.number) utils.log(2, 'Camera %s :: Alarm is detected. Preview window is opening' %self.camera.number) #PREVIEW WINDOW IS OPEN elif self.monitor.previewOpened(self.camera.number): #Close Condition: No Alarm is Detected if cond_service == camerapreview.CONDITION_NO_ALARM and not self.monitor.openRequest_manual(self.camera.number): if not alarmActive: self.monitor.closeRequest(self.camera.number) utils.log(2, 'Camera %s :: The alarm is no longer detected. The preview window will close.' %self.camera.number) # Sleep Logic if not alarmActive: sleep = check_interval else: sleep = trigger_interval - 1 #print '%s, %s, %d, %d, %d, %s' %(self.camera.number, self.monitor.previewOpened(self.camera.number), sleep, check_interval, trigger_interval, alarmActive) self.monitor.waitForAbort(sleep) ### /MAIN LOOP ### if self.monitor.previewOpened(self.camera.number): self.monitor.closeRequest(self.camera.number) utils.log(1, 'Camera %s :: **SERVICE SHUTDOWN** :: Thread Stopped.' %self.camera.number)
def advanced_camera_menu(camera_number): """ Third Level Advanced Menu for additional IP Camera Functions """ #EXTENDED MENU IDEAS #FPS Test #Force Show preview mjpeg / snapshot #Show snapshot if settings.getSetting('enabled_preview', camera_number) == 'true': #Show Preview addDirectoryItem(name = utils.translation(32210), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'show_preview', 'camera_number': camera_number}) #Disable Preview addDirectoryItem(name = utils.translation(32212), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'disable_preview', 'camera_number': camera_number}) else: #Enable Preview addDirectoryItem(name = utils.translation(32211), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'enable_preview', 'camera_number': camera_number}) if settings.getSetting_int('fanart') == 1: #Update Fanart addDirectoryItem(name = utils.translation(32213), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'update_fanart', 'camera_number': camera_number}) camera_type = settings.getCameraType(camera_number) if camera_type < 3: #Play Stream no Controls addDirectoryItem(name = utils.translation(32214), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'single_camera_no_controls', 'camera_number': camera_number}) #Camera Settings addDirectoryItem(name = utils.translation(32215), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'camera_settings', 'camera_number': camera_number}) #Reboot Camera addDirectoryItem(name = utils.translation(32216), icon = utils.get_icon('settings'), fanart = utils.get_fanart(camera_number), parameters = {'action': 'reboot', 'camera_number': camera_number}) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def main_menu(): """ First Level Menu to access main functions """ if settings.atLeastOneCamera(): # All Camera Player addDirectoryItem(name = utils.translation(32027), icon = utils.get_icon('default'), fanart = utils.get_fanart('default'), parameters = {'action': 'all_cameras'}) for camera_number in "123456": if settings.enabled_camera(camera_number): camera = Camera(camera_number) list_label = settings.getCameraName(camera_number) # Build Context Menu li = li = xbmcgui.ListItem(list_label) context_items = [] if settings.getSetting('enabled_preview', camera_number) == 'true': #Show Preview context_items.append((utils.translation(32210), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=show_preview&camera_number=%s)' %camera_number)) #Disable Preview context_items.append((utils.translation(32212), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=disable_preview&camera_number=%s)' %camera_number)) else: #Enable Preview context_items.append((utils.translation(32211), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=enable_preview&camera_number=%s)' %camera_number)) camera_type = settings.getCameraType(camera_number) if camera_type < 3: #Play Stream no Controls context_items.append((utils.translation(32214), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=single_camera_no_controls&camera_number=%s)' %camera_number)) #Camera Settings context_items.append((utils.translation(32215), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=camera_settings&camera_number=%s)' %camera_number)) # Update Fanart if settings.getSetting_int('fanart') == 1: context_items.append((utils.translation(32213), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=update_fanart&camera_number=%s)' %camera_number)) li.addContextMenuItems(context_items, replaceItems=True) # Fanart URL new_art_url = None if camera.Connected(monitor): new_art_url = camera.getSnapShotUrl() else: if camera.Connected(monitor, False): new_art_url = camera.getSnapShotUrl() # Single Camera Player for enabled cameras addDirectoryItem(name = list_label, icon = utils.get_icon(camera_number), fanart = utils.get_fanart(camera_number, new_art_url), li = li, parameters = {'action': 'single_camera', 'camera_number': camera_number}) # Link to Second Level Advanced Menu addDirectoryItem(name = utils.translation(32029), isFolder = True, icon = utils.get_icon('advanced'), fanart = utils.get_fanart('default'), parameters={'action': 'advanced'}) else: # Add-on Settings if no cameras are configured addDirectoryItem(name = utils.translation(32028), icon = utils.get_icon('settings'), fanart = utils.get_fanart('default'), parameters = {'action': 'settings'}) xbmcplugin.endOfDirectory(handle=handle, succeeded=True) utils.cleanup_images()
else: utils.dialog_ok(utils.translation(32219)) # Camera settings elif action == 'camera_settings': window = camerasettings.CameraSettingsWindow(camera_number) window.doModal() del window utils.dialog_ok(utils.translation(32220)) # Show Preview elif action == 'show_preview': if settings.enabled_preview(camera_number): if settings.getSetting_int('cond_manual_toggle', camera_number) == 1 and monitor.previewOpened(camera_number): monitor.closeRequest(camera_number) else: monitor.openRequest_manual(camera_number) else: utils.notify(utils.translation(32228)) # Disable Preview elif action == 'disable_preview': settings.setSetting('enabled_preview', camera_number, 'false') xbmc.executebuiltin('Container.Refresh') # Enable Preview elif action == 'enable_preview':
def advanced_camera_menu(camera_number): """ Third Level Advanced Menu for additional IP Camera Functions """ #EXTENDED MENU IDEAS #FPS Test #Force Show preview mjpeg / snapshot #Show snapshot if settings.getSetting('enabled_preview', camera_number) == 'true': #Show Preview addDirectoryItem(name=utils.translation(32210), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'show_preview', 'camera_number': camera_number }) #Disable Preview addDirectoryItem(name=utils.translation(32212), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'disable_preview', 'camera_number': camera_number }) else: #Enable Preview addDirectoryItem(name=utils.translation(32211), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'enable_preview', 'camera_number': camera_number }) if settings.getSetting_int('fanart') == 1: #Update Fanart addDirectoryItem(name=utils.translation(32213), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'update_fanart', 'camera_number': camera_number }) camera_type = settings.getCameraType(camera_number) if camera_type < 3: #Play Stream no Controls addDirectoryItem(name=utils.translation(32214), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'single_camera_no_controls', 'camera_number': camera_number }) #Camera Settings addDirectoryItem(name=utils.translation(32215), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'camera_settings', 'camera_number': camera_number }) #Reboot Camera addDirectoryItem(name=utils.translation(32216), icon=utils.get_icon('settings'), fanart=utils.get_fanart(camera_number), parameters={ 'action': 'reboot', 'camera_number': camera_number }) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def main_menu(): """ First Level Menu to access main functions """ if settings.atLeastOneCamera(): # All Camera Player addDirectoryItem(name=utils.translation(32027), icon=utils.get_icon('default'), fanart=utils.get_fanart('default'), parameters={'action': 'all_cameras'}) for camera_number in "123456": if settings.enabled_camera(camera_number): camera = Camera(camera_number) list_label = settings.getCameraName(camera_number) # Build Context Menu li = li = xbmcgui.ListItem(list_label) context_items = [] if settings.getSetting('enabled_preview', camera_number) == 'true': #Show Preview context_items.append((utils.translation( 32210 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=show_preview&camera_number=%s)' % camera_number)) #Disable Preview context_items.append((utils.translation( 32212 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=disable_preview&camera_number=%s)' % camera_number)) else: #Enable Preview context_items.append((utils.translation( 32211 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=enable_preview&camera_number=%s)' % camera_number)) camera_type = settings.getCameraType(camera_number) if camera_type < 3: #Play Stream no Controls context_items.append((utils.translation( 32214 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=single_camera_no_controls&camera_number=%s)' % camera_number)) #Camera Settings context_items.append((utils.translation( 32215 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=camera_settings&camera_number=%s)' % camera_number)) # Update Fanart if settings.getSetting_int('fanart') == 1: context_items.append((utils.translation( 32213 ), 'RunPlugin(plugin://plugin.video.surveillanceroom?action=update_fanart&camera_number=%s)' % camera_number)) li.addContextMenuItems(context_items, replaceItems=True) # Fanart URL new_art_url = None if camera.Connected(monitor): new_art_url = camera.getSnapShotUrl() else: if camera.Connected(monitor, False): new_art_url = camera.getSnapShotUrl() # Single Camera Player for enabled cameras addDirectoryItem(name=list_label, icon=utils.get_icon(camera_number), fanart=utils.get_fanart( camera_number, new_art_url), li=li, parameters={ 'action': 'single_camera', 'camera_number': camera_number }) # Link to Second Level Advanced Menu addDirectoryItem(name=utils.translation(32029), isFolder=True, icon=utils.get_icon('advanced'), fanart=utils.get_fanart('default'), parameters={'action': 'advanced'}) else: # Add-on Settings if no cameras are configured addDirectoryItem(name=utils.translation(32028), icon=utils.get_icon('settings'), fanart=utils.get_fanart('default'), parameters={'action': 'settings'}) xbmcplugin.endOfDirectory(handle=handle, succeeded=True) utils.cleanup_images()
utils.dialog_ok(utils.translation(32218)) else: utils.dialog_ok(utils.translation(32219)) # Camera settings elif action == 'camera_settings': window = camerasettings.CameraSettingsWindow(camera_number) window.doModal() del window utils.dialog_ok(utils.translation(32220)) # Show Preview elif action == 'show_preview': if settings.enabled_preview(camera_number): if settings.getSetting_int( 'cond_manual_toggle', camera_number ) == 1 and monitor.previewOpened(camera_number): monitor.closeRequest(camera_number) else: monitor.openRequest_manual(camera_number) else: utils.notify(utils.translation(32228)) # Disable Preview elif action == 'disable_preview': settings.setSetting('enabled_preview', camera_number, 'false') xbmc.executebuiltin('Container.Refresh') # Enable Preview elif action == 'enable_preview': settings.setSetting('enabled_preview', camera_number, 'true')