recieve
This commit is contained in:
parent
e7e14b48ca
commit
fc6181a12b
|
@ -1,6 +1,7 @@
|
|||
from PySide6 import QtCore, QtWidgets
|
||||
from generated.mainwindow import Ui_ScreenStreamer
|
||||
from streamer import Streamer
|
||||
from reciever import Reciever
|
||||
from Xlib import display
|
||||
from Xlib.ext import randr
|
||||
|
||||
|
@ -53,13 +54,22 @@ class ScreenStreamerGUI(QtWidgets.QMainWindow):
|
|||
@QtCore.Slot()
|
||||
def stream_pressed(self):
|
||||
displaydata = self.ui.displaySelect.currentData()
|
||||
self.streamer = Streamer(self.format_display(displaydata), self.format_screensize(displaydata), self.ui.sendto.text())
|
||||
self.streamer = Streamer(
|
||||
self.format_display(displaydata),
|
||||
self.format_screensize(displaydata),
|
||||
self.ui.protocolSelect.currentText().lower(),
|
||||
self.ui.sendto.text()
|
||||
)
|
||||
self.streamer.start()
|
||||
# TODO: add button to stop and feedback on error
|
||||
print('stream started')
|
||||
self.ui.statusbar.showMessage('stream started')
|
||||
|
||||
@QtCore.Slot()
|
||||
def recieve_pressed(self):
|
||||
# TODO
|
||||
print('recieve')
|
||||
self.receiver = Reciever(
|
||||
self.ui.protocolSelect.currentText().lower(),
|
||||
self.ui.listenAddr.text()
|
||||
)
|
||||
self.receiver.start()
|
||||
# TODO: add button to stop and feedback on error
|
||||
self.ui.statusbar.showMessage('stream started')
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import subprocess
|
||||
|
||||
class Reciever:
|
||||
|
||||
def __init__(self, protocol: str, target: str) -> None:
|
||||
self.protocol = protocol # should be 'tcp' or 'udp'
|
||||
self.target = target
|
||||
|
||||
def start(self):
|
||||
# currently there is no direct ffplay support in the ffmpeg package
|
||||
|
||||
addr = self.protocol+ '://' + self.target + '?listen'
|
||||
self.proc = subprocess.Popen(['ffplay', '-fflags', 'nobuffer', '-flags', 'low_delay', '-f', 'mpegts', addr])
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
from platform import python_branch
|
||||
import ffmpeg
|
||||
|
||||
class Streamer:
|
||||
|
||||
def __init__(self, screendef: str, screensize: str, target: str) -> None:
|
||||
def __init__(self, screendef: str, screensize: str, protocol: str, target: str) -> None:
|
||||
self.screendef = screendef
|
||||
self.screensize = screensize
|
||||
self.protocol = protocol # should be 'tcp' or 'udp'
|
||||
self.target = target
|
||||
|
||||
def start(self):
|
||||
self.input = ffmpeg.input(self.screendef, f='x11grab', r=60, s=self.screensize)
|
||||
self.output = ffmpeg.output(self.input, 'tcp://' + self.target, f='mpegts', vcodec='nvenc_hevc', tune='zerolatency')
|
||||
self.output = ffmpeg.output(self.input, self.protocol + '://' + self.target, f='mpegts', vcodec='nvenc_hevc', tune='zerolatency')
|
||||
self.proc = ffmpeg.run_async(self.output)
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>231</height>
|
||||
<width>587</width>
|
||||
<height>296</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -19,15 +19,36 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>456</width>
|
||||
<height>153</height>
|
||||
<width>571</width>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="protocolSelect">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>TCP</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>UDP</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="protocolLabel">
|
||||
<property name="text">
|
||||
<string>Protocol</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="streamBox">
|
||||
<property name="title">
|
||||
<string>Stream</string>
|
||||
|
@ -67,27 +88,27 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="recieveBox">
|
||||
<property name="title">
|
||||
<string>Recieve</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>ListenAddress</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="listenAddr">
|
||||
<property name="placeholderText">
|
||||
<string>0.0.0.0:1234</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="recieveBtn">
|
||||
<property name="text">
|
||||
<string>Recieve</string>
|
||||
|
@ -105,7 +126,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<width>587</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -121,12 +142,12 @@
|
|||
<slot>stream_pressed()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>96</x>
|
||||
<y>134</y>
|
||||
<x>130</x>
|
||||
<y>181</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>119</x>
|
||||
<y>197</y>
|
||||
<x>141</x>
|
||||
<y>269</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -137,12 +158,12 @@
|
|||
<slot>recieve_pressed()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>275</x>
|
||||
<y>137</y>
|
||||
<x>392</x>
|
||||
<y>152</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>300</x>
|
||||
<y>201</y>
|
||||
<x>441</x>
|
||||
<y>270</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
|
Loading…
Reference in New Issue