Wrote new ControlerGUI
This commit is contained in:
parent
b71788cdea
commit
c2ce62f72d
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/env python2
|
||||||
|
import pygst
|
||||||
|
pygst.require('0.10')
|
||||||
|
import gst
|
||||||
|
|
||||||
|
MIXER_IP = 'localhost'
|
||||||
|
MIXER_PORT = 9999
|
||||||
|
|
||||||
|
class CameraFeed(object):
|
||||||
|
|
||||||
|
def __init__(self, pipe, cam_ip):
|
||||||
|
self.pipe = pipe
|
||||||
|
self.cam_ip = cam_ip
|
||||||
|
|
||||||
|
def _run(self):
|
||||||
|
snowmix_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
snowmix_socket.connect((ip, 9999))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class ClockController(object):
|
||||||
|
|
||||||
|
TEXT_ID = 0
|
||||||
|
|
||||||
|
def __init__(self, socket):
|
||||||
|
self.snowmix_socket = socket
|
||||||
|
|
||||||
|
self.update_thread = threading.Thread(target=self.update_clock)
|
||||||
|
self.stopped = False
|
||||||
|
self.update_thread.start()
|
||||||
|
|
||||||
|
def update_clock(self):
|
||||||
|
print "Starting update thread !"
|
||||||
|
while not self.stopped:
|
||||||
|
now = datetime.now()
|
||||||
|
self.update_text(now.strftime("%H:%M:%S"))
|
||||||
|
time.sleep(1.0)
|
||||||
|
|
||||||
|
print "Stopping update thread !"
|
||||||
|
|
||||||
|
|
||||||
|
def update_text(self, text):
|
||||||
|
cmd = "text string %d %s\n" % (self.TEXT_ID,text)
|
||||||
|
self.snowmix_socket.send(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.stopped = True
|
||||||
|
self.update_thread.join(5.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
class SceneChanger(object):
|
class SceneChanger(object):
|
||||||
|
|
||||||
def __init__(self, socket):
|
def __init__(self, socket):
|
||||||
self.cur_scene = 1
|
self.cur_scene = 'Full'
|
||||||
self.snowmix_socket = socket
|
self.snowmix_socket = socket
|
||||||
|
|
||||||
|
|
||||||
def switch_to(self, next_scene):
|
def switch_to(self, next_scene):
|
||||||
if self.cur_scene != next_scene:
|
if self.cur_scene != next_scene:
|
||||||
cmd = "Swap%d%d\n" % (self.cur_scene, next_scene)
|
cmd = "overlay finish Show%s\n" % (next_scene)
|
||||||
self.snowmix_socket.send(cmd)
|
self.snowmix_socket.send(cmd)
|
||||||
self.cur_scene = next_scene
|
self.cur_scene = next_scene
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
#!/bin/env python2
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
class TextChanger(object):
|
|
||||||
|
|
||||||
TEXT_ID = 1
|
|
||||||
UMLAUTS = {
|
|
||||||
'ä' : 'ae',
|
|
||||||
'ü' : 'ue',
|
|
||||||
'ö' : 'oe',
|
|
||||||
'ß' : 'ss'
|
|
||||||
}
|
|
||||||
|
|
||||||
def __init__(self, socket):
|
|
||||||
self.snowmix_socket = socket
|
|
||||||
|
|
||||||
|
|
||||||
def set_text(self, text):
|
|
||||||
for umlaut, replacement in self.UMLAUTS.items():
|
|
||||||
text = text.replace(umlaut, replacement)
|
|
||||||
|
|
||||||
cmd = "text string %d %s\n" % (self.TEXT_ID,text)
|
|
||||||
self.snowmix_socket.send(cmd)
|
|
||||||
|
|
||||||
def hide_text(self):
|
|
||||||
cmd = "text string %d\n" % self.TEXT_ID
|
|
||||||
self.snowmix_socket.send(cmd)
|
|
||||||
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
class TimerController(object):
|
|
||||||
|
|
||||||
TEXT_ID = 2
|
|
||||||
UMLAUTS = {
|
|
||||||
'ä' : 'ae',
|
|
||||||
'ü' : 'ue',
|
|
||||||
'ö' : 'oe',
|
|
||||||
'ß' : 'ss'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, socket):
|
|
||||||
self.snowmix_socket = socket
|
|
||||||
|
|
||||||
self.active_timer = None
|
|
||||||
self.timers = {}
|
|
||||||
|
|
||||||
self.update_thread = threading.Thread(target=self.update_timer)
|
|
||||||
self.stopped = False
|
|
||||||
self.update_thread.start()
|
|
||||||
|
|
||||||
def start_timer(self, name):
|
|
||||||
if not name in self.timers.keys():
|
|
||||||
self.timers[name] = datetime.now()
|
|
||||||
|
|
||||||
def get_timers(self):
|
|
||||||
return self.timers.keys()
|
|
||||||
|
|
||||||
|
|
||||||
def hide_timer(self):
|
|
||||||
self.active_timer = None
|
|
||||||
self.hide_text()
|
|
||||||
|
|
||||||
|
|
||||||
def set_active_timer(self, name):
|
|
||||||
if name in self.timers.keys():
|
|
||||||
self.active_timer = name
|
|
||||||
|
|
||||||
|
|
||||||
def update_timer(self):
|
|
||||||
print "Starting update thread !"
|
|
||||||
while not self.stopped:
|
|
||||||
if self.active_timer != None:
|
|
||||||
delta = datetime.now() - self.timers[self.active_timer]
|
|
||||||
hours, remainder = divmod(delta.total_seconds(), 3600)
|
|
||||||
minutes, seconds = divmod(remainder, 60)
|
|
||||||
self.update_text('%s: %d:%d:%d' % (self.active_timer, hours, minutes, seconds))
|
|
||||||
pass
|
|
||||||
time.sleep(1.0)
|
|
||||||
|
|
||||||
print "Stopping update thread !"
|
|
||||||
|
|
||||||
|
|
||||||
def update_text(self, text):
|
|
||||||
for umlaut, replacement in self.UMLAUTS.items():
|
|
||||||
text = text.replace(umlaut, replacement)
|
|
||||||
|
|
||||||
cmd = "text string %d %s\n" % (self.TEXT_ID,text)
|
|
||||||
self.snowmix_socket.send(cmd)
|
|
||||||
|
|
||||||
|
|
||||||
def hide_text(self):
|
|
||||||
cmd = "text string %d\n" % self.TEXT_ID
|
|
||||||
self.snowmix_socket.send(cmd)
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
self.stopped = True
|
|
||||||
self.update_thread.join(5.0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,20 +6,18 @@ import socket
|
||||||
from gi.repository import Gtk, GObject
|
from gi.repository import Gtk, GObject
|
||||||
|
|
||||||
from scenechanger import SceneChanger
|
from scenechanger import SceneChanger
|
||||||
from textchanger import TextChanger
|
from clockcontroller import ClockController
|
||||||
from timercontroller import TimerController
|
|
||||||
|
|
||||||
class VideoController(object):
|
class VideoController(object):
|
||||||
def __init__(self, ip):
|
def __init__(self, ip):
|
||||||
|
|
||||||
self.snowmix_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.snowmix_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
self.snowmix_socket.connect((ip, 9999))
|
self.snowmix_socket.connect((ip, 9999))
|
||||||
|
|
||||||
self.scenechanger = SceneChanger(self.snowmix_socket)
|
self.scenechanger = SceneChanger(self.snowmix_socket)
|
||||||
self.textchanger = TextChanger(self.snowmix_socket)
|
self.clockcontroller = ClockController(self.snowmix_socket)
|
||||||
self.timercontroller = TimerController(self.snowmix_socket)
|
|
||||||
|
|
||||||
self.gladefile = "videocontroller.ui"
|
self.gladefile = "videocontroller.ui"
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_file(self.gladefile)
|
self.builder.add_from_file(self.gladefile)
|
||||||
|
|
||||||
|
@ -27,9 +25,7 @@ class VideoController(object):
|
||||||
self.max_cam1_button = self.builder.get_object("MaxCam1Button")
|
self.max_cam1_button = self.builder.get_object("MaxCam1Button")
|
||||||
self.max_cam2_button = self.builder.get_object("MaxCam2Button")
|
self.max_cam2_button = self.builder.get_object("MaxCam2Button")
|
||||||
self.max_cam3_button = self.builder.get_object("MaxCam3Button")
|
self.max_cam3_button = self.builder.get_object("MaxCam3Button")
|
||||||
self.set_text_entry = self.builder.get_object("SetTextEntry")
|
self.show_all_button = self.builder.get_object("ShowAllButton")
|
||||||
self.start_timer_entry = self.builder.get_object("StartTimerEntry")
|
|
||||||
self.change_timer_combobox = self.builder.get_object("ChangeTimerComboBox")
|
|
||||||
|
|
||||||
self.messagebox = Gtk.MessageDialog(self.main_window, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, "I'm afaraid I can't let you do that dave.")
|
self.messagebox = Gtk.MessageDialog(self.main_window, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, "I'm afaraid I can't let you do that dave.")
|
||||||
|
|
||||||
|
@ -37,24 +33,24 @@ class VideoController(object):
|
||||||
self.main_window.show_all()
|
self.main_window.show_all()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def MaxCam1ButtonToggled(self, widget):
|
def MaxCam1ButtonToggled(self, widget):
|
||||||
if self.max_cam1_button.get_active():
|
if self.max_cam1_button.get_active():
|
||||||
self.max_cam2_button.set_active(False)
|
self.max_cam2_button.set_active(False)
|
||||||
self.max_cam3_button.set_active(False)
|
self.max_cam3_button.set_active(False)
|
||||||
self.scenechanger.switch_to(1)
|
self.show_all_button.set_active(False)
|
||||||
|
self.scenechanger.switch_to('Full1')
|
||||||
else:
|
else:
|
||||||
if not self.max_cam2_button.get_active() and not self.max_cam3_button.get_active():
|
if not self.max_cam2_button.get_active() and not self.max_cam3_button.get_active() and not self.show_all_button.get_active():
|
||||||
self.max_cam1_button.set_active(True)
|
self.max_cam1_button.set_active(True)
|
||||||
|
|
||||||
|
|
||||||
def MaxCam2ButtonToggled(self, widget):
|
def MaxCam2ButtonToggled(self, widget):
|
||||||
if self.max_cam2_button.get_active():
|
if self.max_cam2_button.get_active():
|
||||||
self.max_cam1_button.set_active(False)
|
self.max_cam1_button.set_active(False)
|
||||||
self.max_cam3_button.set_active(False)
|
self.max_cam3_button.set_active(False)
|
||||||
self.scenechanger.switch_to(2)
|
self.show_all_button.set_active(False)
|
||||||
|
self.scenechanger.switch_to('Full2')
|
||||||
else:
|
else:
|
||||||
if not self.max_cam1_button.get_active() and not self.max_cam3_button.get_active():
|
if not self.max_cam1_button.get_active() and not self.max_cam3_button.get_active() and not self.show_all_button.get_active():
|
||||||
self.max_cam2_button.set_active(True)
|
self.max_cam2_button.set_active(True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,40 +58,28 @@ class VideoController(object):
|
||||||
if self.max_cam3_button.get_active():
|
if self.max_cam3_button.get_active():
|
||||||
self.max_cam1_button.set_active(False)
|
self.max_cam1_button.set_active(False)
|
||||||
self.max_cam2_button.set_active(False)
|
self.max_cam2_button.set_active(False)
|
||||||
self.scenechanger.switch_to(3)
|
self.show_all_button.set_active(False)
|
||||||
|
self.scenechanger.switch_to('Full3')
|
||||||
else:
|
else:
|
||||||
if not self.max_cam1_button.get_active() and not self.max_cam2_button.get_active():
|
if not self.max_cam1_button.get_active() and not self.max_cam2_button.get_active() and not self.show_all_button.get_active():
|
||||||
self.max_cam3_button.set_active(True)
|
self.max_cam3_button.set_active(True)
|
||||||
|
|
||||||
|
def ShowAllButtonToggled(self, widget):
|
||||||
def SetTextButtonClicked(self, widget):
|
if self.show_all_button.get_active():
|
||||||
self.textchanger.set_text(self.set_text_entry.get_text())
|
self.max_cam1_button.set_active(False)
|
||||||
|
self.max_cam2_button.set_active(False)
|
||||||
|
self.max_cam3_button.set_active(False)
|
||||||
def HideTextButtonClicked(self, widget):
|
self.scenechanger.switch_to('All')
|
||||||
self.textchanger.hide_text()
|
else:
|
||||||
|
if not self.max_cam1_button.get_active() and not self.max_cam2_button.get_active() and not self.max_cam3_button.get_active():
|
||||||
|
self.show_all_button.set_active(True)
|
||||||
def StartTimerButtonClicked(self, widget):
|
|
||||||
self.timercontroller.start_timer(self.start_timer_entry.get_text())
|
|
||||||
self.change_timer_combobox.remove_all()
|
|
||||||
for timer in self.timercontroller.get_timers():
|
|
||||||
self.change_timer_combobox.append_text(timer)
|
|
||||||
|
|
||||||
def ChangeTimerComboBoxChanged(self, widget):
|
|
||||||
self.timercontroller.set_active_timer(self.change_timer_combobox.get_active_text())
|
|
||||||
|
|
||||||
|
|
||||||
def HideTimerButtonClicked(self, widget):
|
|
||||||
self.timercontroller.hide_timer()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def MainWindowDelete(self, widget, event):
|
def MainWindowDelete(self, widget, event):
|
||||||
if self.messagebox.run() == Gtk.ResponseType.OK:
|
if self.messagebox.run() == Gtk.ResponseType.OK:
|
||||||
self.timercontroller.stop()
|
self.clockcontroller.stop()
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
self.messagebox.hide()
|
self.messagebox.hide()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -68,140 +68,21 @@ Cam 2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="SetTextLabel">
|
<object class="GtkToggleButton" id="ShowAllButton">
|
||||||
<property name="width_request">130</property>
|
<property name="label" translatable="yes">Show alll
|
||||||
<property name="height_request">30</property>
|
Cameras</property>
|
||||||
<property name="visible">True</property>
|
<property name="width_request">470</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="height_request">150</property>
|
||||||
<property name="margin_top">3</property>
|
|
||||||
<property name="label" translatable="yes">Set text</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">10</property>
|
|
||||||
<property name="y">170</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="SetTextButton">
|
|
||||||
<property name="label" translatable="yes">Set Text</property>
|
|
||||||
<property name="width_request">120</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<signal name="clicked" handler="SetTextButtonClicked" swapped="no"/>
|
<property name="relief">half</property>
|
||||||
</object>
|
<property name="yalign">0.4699999988079071</property>
|
||||||
<packing>
|
<signal name="toggled" handler="ShowAllButtonToggled" swapped="no"/>
|
||||||
<property name="x">340</property>
|
|
||||||
<property name="y">174</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="StartTimerLabel">
|
|
||||||
<property name="width_request">130</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">Start a new timer</property>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">10</property>
|
<property name="x">10</property>
|
||||||
<property name="y">220</property>
|
<property name="y">200</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="StartTimerEntry">
|
|
||||||
<property name="width_request">180</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">150</property>
|
|
||||||
<property name="y">220</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="SetTextEntry">
|
|
||||||
<property name="width_request">180</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">150</property>
|
|
||||||
<property name="y">174</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="StartTimerButton">
|
|
||||||
<property name="label" translatable="yes">Start Timer</property>
|
|
||||||
<property name="width_request">120</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="StartTimerButtonClicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">340</property>
|
|
||||||
<property name="y">220</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="ChangeTimerLabel">
|
|
||||||
<property name="width_request">150</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="label" translatable="yes">Change timer dispaly</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">10</property>
|
|
||||||
<property name="y">270</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="HideTextButton">
|
|
||||||
<property name="label" translatable="yes">Hide text</property>
|
|
||||||
<property name="width_request">200</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="HideTextButtonClicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">10</property>
|
|
||||||
<property name="y">320</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="HideTimer">
|
|
||||||
<property name="label" translatable="yes">Hide Timer</property>
|
|
||||||
<property name="width_request">200</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="HideTimerButtonClicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">230</property>
|
|
||||||
<property name="y">320</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBoxText" id="ChangeTimerComboBox">
|
|
||||||
<property name="width_request">285</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<signal name="changed" handler="ChangeTimerComboBoxChanged" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">174</property>
|
|
||||||
<property name="y">270</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue