def getImagesMjpegInterlace(self, camera, url, control, prefix):
        """ Update camera position with interlaced mjpeg frames """

        try:
            stream = requests.get(url, stream=True, timeout=TIMEOUT).raw

        except requests.RequestException as e:
            utils.log(3, e)
            control[0].setImage(_error, useCache=False)
            return

        x = 0
        while not monitor.abortRequested() and self.isRunning:

            filename = os.path.join(_datapath, "%s_%s.%d.jpg") % (prefix, camera.number, x)
            filename_exists = utils.get_mjpeg_frame(stream, filename)

            if filename_exists:
                if x % 2 == 0:  # Interlacing for flicker reduction/elimination
                    control[0].setImage(filename, useCache=False)
                else:
                    control[1].setImage(filename, useCache=False)
                xbmcvfs.delete(os.path.join(_datapath, "%s_%s.%d.jpg") % (prefix, camera.number, x - 2))
                x += 1

            else:
                utils.log(3, "Camera %s - Error on MJPEG" % camera.number)
                control[0].setImage(_error, useCache=False)
                return
    def getImagesMjpegInterlace(self, url, *args, **kwargs):
        """ Update camera position with interlaced mjpeg frames """
        
        try:
            stream = requests.get(url, stream = True, timeout = TIMEOUT).raw
            
        except requests.RequestException as e:
            utils.log(3, e)
            self.img1.setImage(_error, useCache = False)
            return
            
        x = 0
        while not self.monitor.abortRequested() and not self.monitor.stopped() and self.monitor.previewOpened(self.camera.number):
            
            filename = os.path.join(_datapath, '%s_%s.%d.jpg') %(self.prefix, self.camera.number, x)
            filename_exists = utils.get_mjpeg_frame(stream, filename)

            if filename_exists:
                if x % 2 == 0:  #Interlacing for flicker reduction/elimination
                    self.img1.setImage(filename, useCache = False)
                else:
                    self.img2.setImage(filename, useCache = False)
                xbmcvfs.delete(os.path.join(_datapath, '%s_%s.%d.jpg') %(self.prefix, self.camera.number, x - 2))
                x += 1
                
            else:
                utils.log(3, 'Camera %s :: Error updating preview image on MJPEG' %self.camera.number)
                self.img1.setImage(_error, useCache = False)
                break

        if not not self.monitor.abortRequested() and not self.monitor.stopped():
            utils.remove_leftover_images('%s_%s.' %(self.prefix, self.camera.number))
Exemplo n.º 3
0
    def getImagesMjpegInterlace(self, camera, url, control, prefix):
        """ Update camera position with interlaced mjpeg frames """

        try:
            stream = requests.get(url, stream = True, timeout = TIMEOUT).raw
            
        except requests.RequestException as e:
            utils.log(3, e)
            control[0].setImage(_error, useCache = False)
            return
            
        x = 0
        while not monitor.abortRequested() and self.isRunning:
            
            filename = os.path.join(_datapath, '%s_%s.%d.jpg') %(prefix, camera.number, x)
            filename_exists = utils.get_mjpeg_frame(stream, filename)

            if filename_exists:
                if x % 2 == 0:  #Interlacing for flicker reduction/elimination
                    control[0].setImage(filename, useCache = False)
                else:
                    control[1].setImage(filename, useCache = False)
                xbmcvfs.delete(os.path.join(_datapath, '%s_%s.%d.jpg') %(prefix, camera.number, x - 2))
                x += 1
                
            else:
                utils.log(3, 'Camera %s - Error on MJPEG' %camera.number)
                control[0].setImage(_error, useCache = False)
                return
Exemplo n.º 4
0
    def getImagesMjpegInterlace(self, url, *args, **kwargs):
        """ Update camera position with interlaced mjpeg frames """

        try:
            stream = requests.get(url, stream=True, timeout=TIMEOUT).raw

        except requests.RequestException as e:
            utils.log(3, e)
            self.img1.setImage(_error, useCache=False)
            return

        x = 0
        while not self.monitor.abortRequested() and not self.monitor.stopped(
        ) and self.monitor.previewOpened(self.camera.number):

            filename = os.path.join(_datapath, '%s_%s.%d.jpg') % (
                self.prefix, self.camera.number, x)
            filename_exists = utils.get_mjpeg_frame(stream, filename)

            if filename_exists:
                if x % 2 == 0:  #Interlacing for flicker reduction/elimination
                    self.img1.setImage(filename, useCache=False)
                else:
                    self.img2.setImage(filename, useCache=False)
                xbmcvfs.delete(
                    os.path.join(_datapath, '%s_%s.%d.jpg') %
                    (self.prefix, self.camera.number, x - 2))
                x += 1

            else:
                utils.log(
                    3, 'Camera %s :: Error updating preview image on MJPEG' %
                    self.camera.number)
                self.img1.setImage(_error, useCache=False)
                break

        if not not self.monitor.abortRequested() and not self.monitor.stopped(
        ):
            utils.remove_leftover_images('%s_%s.' %
                                         (self.prefix, self.camera.number))
    def getImagesMjpeg(self, url):
        """ Update camera position with mjpeg frames """

        try:
            #            stream = requests.get(url, stream = True, timeout = TIMEOUT, auth=HTTPDigestAuth('USERNAME', 'PASSWORD')).raw #uncomment if you need digest support for mjpeg
            stream = requests.get(url, stream=True, timeout=TIMEOUT).raw
        except requests.RequestException as e:
            utils.log(3, e)
            self.img1.setImage(_error, useCache=False)
            return

        x = 0
        while not self.monitor.abortRequested() and not self.monitor.stopped(
        ) and self.monitor.previewOpened(self.camera.number):
            filename = os.path.join(_datapath, '%s_%s.%d.jpg') % (
                self.prefix, self.camera.number, x)
            filename_exists = utils.get_mjpeg_frame(stream, filename)

            if filename_exists:
                self.img1.setImage(filename, useCache=False)
                self.img2.setImage(filename, useCache=False)
                xbmcvfs.delete(
                    os.path.join(_datapath, '%s_%s.%d.jpg') %
                    (self.prefix, self.camera.number, x - 1))
                x += 1

            else:
                utils.log(
                    3, 'Camera %s :: Error updating preview image on MJPEG' %
                    self.camera.number)
                self.img1.setImage(_error, useCache=False)
                break

        if not not self.monitor.abortRequested() and not self.monitor.stopped(
        ):
            utils.remove_leftover_images('%s_%s.' %
                                         (self.prefix, self.camera.number))