|
@@ -16,6 +16,7 @@ HEIGHT = 720
|
|
|
SCREEN_WIDTH = 800
|
|
SCREEN_WIDTH = 800
|
|
|
SCREEN_HEIGHT = 600
|
|
SCREEN_HEIGHT = 600
|
|
|
zoom = 1
|
|
zoom = 1
|
|
|
|
|
+not_exited = True
|
|
|
|
|
|
|
|
|
|
|
|
|
# def bus_call(bus, msg, *args):
|
|
# def bus_call(bus, msg, *args):
|
|
@@ -70,12 +71,16 @@ def on_connect(client, userdata, flags, rc):
|
|
|
|
|
|
|
|
# The callback for when a PUBLISH message is received from the server.
|
|
# The callback for when a PUBLISH message is received from the server.
|
|
|
def on_message(client, userdata, msg):
|
|
def on_message(client, userdata, msg):
|
|
|
|
|
+ global not_exited
|
|
|
print(msg.topic+" "+str(msg.payload))
|
|
print(msg.topic+" "+str(msg.payload))
|
|
|
|
|
|
|
|
if msg.topic == "video/cam1/preview":
|
|
if msg.topic == "video/cam1/preview":
|
|
|
set_preview(int(msg.payload))
|
|
set_preview(int(msg.payload))
|
|
|
elif msg.topic == "video/cam1/zoom":
|
|
elif msg.topic == "video/cam1/zoom":
|
|
|
set_zoom(float(msg.payload))
|
|
set_zoom(float(msg.payload))
|
|
|
|
|
+ elif msg.topic == "video/cam1/restart":
|
|
|
|
|
+ print("Restarting!")
|
|
|
|
|
+ not_exited = False
|
|
|
|
|
|
|
|
|
|
|
|
|
client = mqtt.Client()
|
|
client = mqtt.Client()
|
|
@@ -123,8 +128,12 @@ if __name__ == "__main__":
|
|
|
pipeline.set_state(Gst.State.PLAYING)
|
|
pipeline.set_state(Gst.State.PLAYING)
|
|
|
t = threading.Thread(target=client.loop_forever, daemon=True)
|
|
t = threading.Thread(target=client.loop_forever, daemon=True)
|
|
|
t.start()
|
|
t.start()
|
|
|
- while True:
|
|
|
|
|
- client.publish("video/heartbeat", "cam1")
|
|
|
|
|
- time.sleep(10)
|
|
|
|
|
|
|
+ counter = 0
|
|
|
|
|
+ while not_exited:
|
|
|
|
|
+ time.sleep(1)
|
|
|
|
|
+ counter += 1
|
|
|
|
|
+ if counter >= 10:
|
|
|
|
|
+ client.publish("video/heartbeat", "cam1")
|
|
|
|
|
|
|
|
pipeline.set_state(Gst.State.NULL)
|
|
pipeline.set_state(Gst.State.NULL)
|
|
|
|
|
+ print("Pipeline dead. Bye")
|