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