2022-07-18 05:30:07 +00:00
|
|
|
|
|
|
|
# importing vlc module
|
|
|
|
from time import sleep
|
|
|
|
import paho.mqtt.client as mqtt
|
|
|
|
from video import Video
|
|
|
|
import multiprocessing
|
2022-07-18 06:47:01 +00:00
|
|
|
import sys
|
2022-07-18 05:30:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
class App:
|
2022-07-18 06:47:01 +00:00
|
|
|
def __init__(self, client, x, y):
|
2022-07-18 05:30:07 +00:00
|
|
|
self.client = client
|
2022-07-18 06:47:01 +00:00
|
|
|
self.video = Video(x, y)
|
2022-07-18 05:30:07 +00:00
|
|
|
|
|
|
|
def on_connect(self, client, userdata, flags, rc):
|
|
|
|
print("Connected with result code "+str(rc))
|
|
|
|
self.client.subscribe("video")
|
|
|
|
|
|
|
|
|
|
|
|
def on_message(self, client, userdata, msg):
|
|
|
|
print(msg.topic+" "+str(msg.payload))
|
|
|
|
if msg.payload == b'start':
|
|
|
|
print("Start")
|
2022-07-18 06:47:01 +00:00
|
|
|
self.x = multiprocessing.Process(target = self.video.start, args=("slave/sample-mp4-file.mp4",))
|
2022-07-18 05:30:07 +00:00
|
|
|
self.x.start()
|
|
|
|
|
|
|
|
elif msg.payload == b'stop':
|
|
|
|
print("Stop")
|
|
|
|
self.x.terminate()
|
|
|
|
|
2022-07-18 06:47:01 +00:00
|
|
|
def main():
|
2022-07-18 05:30:07 +00:00
|
|
|
|
2022-07-18 06:47:01 +00:00
|
|
|
client = mqtt.Client()
|
|
|
|
app = App(client, int(sys.argv[1]), int(sys.argv[2]))
|
|
|
|
client.on_connect = app.on_connect
|
|
|
|
client.on_message = app.on_message
|
2022-07-18 05:30:07 +00:00
|
|
|
|
2022-07-18 06:47:01 +00:00
|
|
|
client.connect("10.173.54.35", 1883, 60)
|
|
|
|
|
|
|
|
client.loop_forever()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|