from Source import Source
from Components.Element import cached
try:
	from Plugins.Extensions.MerlinRemuxer.emerlinremux import eMerlinRemux, eMerlinRemuxEvent
	remuxerInstalled = True
except:
	remuxerInstalled = False

class MerlinRemuxState(Source):
	def __init__(self):
		Source.__init__(self)
		self.remuxing = None
		if remuxerInstalled:
			self.remux_conn = eMerlinRemux.getInstance().remuxEvent.connect(self.gotRemuxEvent)		

	def gotRemuxEvent(self, event):
		self.remuxing = event
		self.changed((self.CHANGED_ALL,))

	@cached
	def getBoolean(self):
		return (remuxerInstalled and self.remuxing == eMerlinRemuxEvent.evStart) or False
	boolean = property(getBoolean)

	@cached
	def getValue(self):
		return self.remuxing
	value = property(getValue)
