-
Notifications
You must be signed in to change notification settings - Fork 0
/
VideoLive.py
42 lines (29 loc) · 1004 Bytes
/
VideoLive.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
# -*- coding: utf-8 -*-
from network.UDPSocket import Client, Server
from service.Video import VideoSender
from PyQt5.QtCore import QThread, pyqtSignal
class LiveClient(Client, VideoSender): # 广播发送方
def __init__(self, broadcast_ip: str, key: str, video_type: str):
Client.__init__(self, broadcast_ip)
self.set_handler(key)
VideoSender.__init__(self, video_type)
self.set_quality(20)
def sendall(self, data: bytes):
self.sendto(data)
class LiveServer(Server, QThread): # 广播接收方
# 定义信号
_log = pyqtSignal(str)
_video = pyqtSignal(bytes)
def __init__(self, key: str):
self.key = key
Server.__init__(self)
QThread.__init__(self)
def emit(self, data: bytes):
self._video.emit(data)
def _print(self, text: str):
self._log.emit(text)
def quit(self):
self.close_connect()
def run(self):
self.set_handler(self.key)
self.bind()