Esempio n. 1
0
	def setup_video(self, video_mapping, with_extras=None, video_callback=None):
		logging.debug("setting up video #%d (%s)" % (video_mapping.index, video_mapping.src))
		
		# load video into omxplayer on fifo. this will block.
		start_daemon(video_mapping.d_files)
		
		setup_cmd = self.OMX_CMD['setup']
		if with_extras is not None:
			setup_cmd = setup_cmd.replace("-I", "-I %s " % " ".join(\
				["--%s %s" % (e, with_extras[e]) for e in with_extras.keys()]))

		logging.debug("setup command: %s" % setup_cmd)

		p = Popen(setup_cmd % (video_mapping.src, video_mapping.fifo), \
			shell=True, stdout=PIPE, stderr=STDOUT)

		while True:
			duration_line = re.findall(r'Duration\:\s+(.*),.*', p.stdout.readline())
			if len(duration_line) == 1:
				duration_str = duration_line[0].split(",")[0]
				duration = {
					'millis' : time_str_to_millis(duration_str),
					'str' : duration_str
				}

				if video_callback is not None:
					video_callback({'index' : video_mapping.index, \
						'info' : {'duration' : duration}})

				break

		stop_daemon(video_mapping.d_files)
Esempio n. 2
0
	def on_hang_up(self):
		logging.info("hanging up")
		self.send_command({ 'stop_audio' : True })
		stop_daemon(self.conf['d_files']['module'])
		self.db.set('IS_HUNG_UP', True)

		try:
			current_record_pid = self.db.get("CURRENT_RECORD_PID")
			if current_record_pid is not None:
				logging.debug("current_record_pid: %s" % current_record_pid)
				os.kill(int(current_record_pid), signal.SIGKILL)
				self.db.delete("CURRENT_RECORD_PID")
			else:
				logging.debug("not currently recording")

		except Exception as e:
			logging.warning("NO CURRENT RECORD TO KILL")
			print e, type(e)

		return { 'ok' : str_to_bool(self.db.get('IS_HUNG_UP')) }
Esempio n. 3
0
 def stop_audio_pad(self):
     stop_daemon(self.conf["d_files"]["audio"])
Esempio n. 4
0
	def stop_api(self):
		"""Stops the API.
		"""

		# don't forget to save the redis db
		stop_daemon(self.conf['d_files']['api'])