-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
64 lines (48 loc) · 2.33 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from vidstream import * #used to stream video over a network
import tkinter as tk #used to construct basic graphical user interface (GUI) application
import socket # used to send and receive data, and they can be used to create both client-server and peer-to-peer applications
import threading #allows you to have different parts of your process run concurrently (for audio and video simultaneously)
import requests
local_ip_addr = socket.gethostbyname(socket.gethostname())
public_ip_addr = requests.get("https://api.ipify.org").text
print(local_ip_addr)
print(public_ip_addr)
server = StreamingServer(local_ip_addr, 9999) # send
receiver = AudioReceiver(local_ip_addr, 8888) # receive
#adding function for connecting two servers
def start_listening():
t1 = threading.Thread(target = server.start_server)
t2 = threading.Thread(target = receiver.start_server)
t1.start()
t2.start()
#adding function for video
def start_camera_stream():
camera_client = CameraClient(text_target_ip.get(1.0,'end-1c'), 7777) # send
t3 = threading.Thread(target = camera_client.start_stream)
t3.start()
#adding function for screen sharing
def start_screen_sharing():
screen_client = ScreenShareClient(text_target_ip.get(1.0,'end-1c'), 7777) # send
t4 = threading.Thread(target = screen_client.start_stream)
t4.start()
#adding function for audio streaming
def start_audio_stream():
audio_sender = AudioSender(text_target_ip.get(1.0,'end-1c'), 6666) # receive
t5 = threading.Thread(target = audio_sender.start_stream)
t5.start()
window = tk.Tk()
window.title("My zoom app - streamer")
window.geometry("350x250")
label_target_ip = tk.Label(window, text="Target IP:")
label_target_ip.pack()
text_target_ip = tk.Text(window, height=1)
text_target_ip.pack()
btn_listen = tk.Button(window, text="Start Listening", width=50, command=start_listening)
btn_listen.pack(anchor=tk.CENTER, expand=True)
btn_camera = tk.Button(window, text="Start Camera Stream", width=50, command=start_camera_stream)
btn_camera.pack(anchor=tk.CENTER, expand=True)
btn_screen = tk.Button(window, text="Start Screen Sharing", width=50, command=start_screen_sharing)
btn_screen.pack(anchor=tk.CENTER, expand=True)
btn_audio = tk.Button(window, text="Start Audio Stream", width=50, command=start_audio_stream)
btn_audio.pack(anchor=tk.CENTER, expand=True)
window.mainloop()