mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 14:18:45 +00:00
add:增加是否直接使用forward的选项
This commit is contained in:
parent
c713c292cc
commit
f5a9a399f0
7 changed files with 71 additions and 88 deletions
|
@ -169,6 +169,7 @@ void Device::startServer()
|
||||||
params.crop = "-";
|
params.crop = "-";
|
||||||
params.sendFrameMeta = m_recorder ? true : false;
|
params.sendFrameMeta = m_recorder ? true : false;
|
||||||
params.control = true;
|
params.control = true;
|
||||||
|
params.useReverse = m_params.useReverse;
|
||||||
m_server->start(params);
|
m_server->start(params);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
quint16 maxSize = 0;
|
quint16 maxSize = 0;
|
||||||
quint32 bitRate = 8000000;
|
quint32 bitRate = 8000000;
|
||||||
bool closeScreen = false;
|
bool closeScreen = false;
|
||||||
|
bool useReverse = true;
|
||||||
};
|
};
|
||||||
explicit Device(DeviceParams params, QObject *parent = nullptr);
|
explicit Device(DeviceParams params, QObject *parent = nullptr);
|
||||||
virtual ~Device();
|
virtual ~Device();
|
||||||
|
|
|
@ -182,6 +182,17 @@ bool Server::connectTo()
|
||||||
emit connectToResult(false, "", QSize());
|
emit connectToResult(false, "", QSize());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// control socket
|
||||||
|
m_controlSocket = new QTcpSocket();
|
||||||
|
m_controlSocket->connectToHost(QHostAddress::LocalHost, m_params.localPort);
|
||||||
|
if (!m_controlSocket->waitForConnected(1000)) {
|
||||||
|
stop();
|
||||||
|
qWarning("control socket connect to server failed");
|
||||||
|
emit connectToResult(false, "", QSize());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (QTcpSocket::ConnectedState == m_videoSocket->state()) {
|
if (QTcpSocket::ConnectedState == m_videoSocket->state()) {
|
||||||
// connect will success even if devices offline, recv data is real connect success
|
// connect will success even if devices offline, recv data is real connect success
|
||||||
// because connect is to pc adb server
|
// because connect is to pc adb server
|
||||||
|
@ -200,16 +211,6 @@ bool Server::connectTo()
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// control socket
|
|
||||||
m_controlSocket = new QTcpSocket();
|
|
||||||
m_controlSocket->connectToHost(QHostAddress::LocalHost, m_params.localPort);
|
|
||||||
if (!m_controlSocket->waitForConnected(1000)) {
|
|
||||||
stop();
|
|
||||||
qWarning("control socket connect to server failed");
|
|
||||||
emit connectToResult(false, "", QSize());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
// we don't need the adb tunnel anymore
|
// we don't need the adb tunnel anymore
|
||||||
disableTunnelForward();
|
disableTunnelForward();
|
||||||
|
@ -358,13 +359,12 @@ void Server::onWorkProcessResult(AdbProcess::ADB_EXEC_RESULT processResult)
|
||||||
switch (m_serverStartStep) {
|
switch (m_serverStartStep) {
|
||||||
case SSS_PUSH:
|
case SSS_PUSH:
|
||||||
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
||||||
#if 1
|
if (m_params.useReverse) {
|
||||||
m_serverStartStep = SSS_ENABLE_TUNNEL_REVERSE;
|
m_serverStartStep = SSS_ENABLE_TUNNEL_REVERSE;
|
||||||
#else
|
} else {
|
||||||
// test tunnelForward
|
|
||||||
m_tunnelForward = true;
|
m_tunnelForward = true;
|
||||||
m_serverStartStep = SSS_ENABLE_TUNNEL_FORWARD;
|
m_serverStartStep = SSS_ENABLE_TUNNEL_FORWARD;
|
||||||
#endif
|
}
|
||||||
startServerByStep();
|
startServerByStep();
|
||||||
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
||||||
qCritical("adb push failed");
|
qCritical("adb push failed");
|
||||||
|
|
|
@ -25,11 +25,12 @@ public:
|
||||||
struct ServerParams {
|
struct ServerParams {
|
||||||
QString serial = "";
|
QString serial = "";
|
||||||
quint16 localPort = 27183;
|
quint16 localPort = 27183;
|
||||||
quint16 maxSize = 0;
|
quint16 maxSize = 750;
|
||||||
quint32 bitRate = 8000000;
|
quint32 bitRate = 8000000;
|
||||||
QString crop = "-";
|
QString crop = "-";
|
||||||
bool sendFrameMeta = false;
|
bool sendFrameMeta = false;
|
||||||
bool control = true;
|
bool control = true;
|
||||||
|
bool useReverse = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Server(QObject *parent = nullptr);
|
explicit Server(QObject *parent = nullptr);
|
||||||
|
|
|
@ -123,6 +123,7 @@ void Dialog::on_startServerBtn_clicked()
|
||||||
params.bitRate = bitRate;
|
params.bitRate = bitRate;
|
||||||
params.recordFileName = absFilePath;
|
params.recordFileName = absFilePath;
|
||||||
params.closeScreen = ui->closeScreenCheck->isChecked();
|
params.closeScreen = ui->closeScreenCheck->isChecked();
|
||||||
|
params.useReverse = ui->useReverseCheck->isChecked();
|
||||||
m_device = new Device(params, this);
|
m_device = new Device(params, this);
|
||||||
if (ui->alwaysTopCheck->isChecked() && m_device->getVideoForm()) {
|
if (ui->alwaysTopCheck->isChecked() && m_device->getVideoForm()) {
|
||||||
m_device->getVideoForm()->staysOnTop();
|
m_device->getVideoForm()->staysOnTop();
|
||||||
|
@ -243,32 +244,6 @@ void Dialog::on_recordPathEdt_textChanged(const QString &arg1)
|
||||||
ui->recordPathEdt->setToolTip(arg1);
|
ui->recordPathEdt->setToolTip(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::on_alwaysTopCheck_stateChanged(int arg1)
|
|
||||||
{
|
|
||||||
if (!m_device || m_device->getVideoForm()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Qt::Checked == arg1) {
|
|
||||||
m_device->getVideoForm()->staysOnTop(true);
|
|
||||||
} else {
|
|
||||||
m_device->getVideoForm()->staysOnTop(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog::on_closeScreenCheck_stateChanged(int arg1)
|
|
||||||
{
|
|
||||||
Q_UNUSED(arg1);
|
|
||||||
if (!m_device || m_device->getVideoForm()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ui->closeScreenCheck->isChecked()) {
|
|
||||||
m_device->getController()->setScreenPowerMode(ControlMsg::SPM_OFF);
|
|
||||||
} else {
|
|
||||||
m_device->getController()->setScreenPowerMode(ControlMsg::SPM_NORMAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Dialog::on_adbCommandBtn_clicked()
|
void Dialog::on_adbCommandBtn_clicked()
|
||||||
{
|
{
|
||||||
execAdbCmd();
|
execAdbCmd();
|
||||||
|
|
|
@ -41,10 +41,6 @@ private slots:
|
||||||
|
|
||||||
void on_recordPathEdt_textChanged(const QString &arg1);
|
void on_recordPathEdt_textChanged(const QString &arg1);
|
||||||
|
|
||||||
void on_alwaysTopCheck_stateChanged(int arg1);
|
|
||||||
|
|
||||||
void on_closeScreenCheck_stateChanged(int arg1);
|
|
||||||
|
|
||||||
void on_adbCommandBtn_clicked();
|
void on_adbCommandBtn_clicked();
|
||||||
|
|
||||||
void on_stopAdbBtn_clicked();
|
void on_stopAdbBtn_clicked();
|
||||||
|
|
|
@ -116,36 +116,16 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGroupBox" name="configGroupBox">
|
<widget class="QGroupBox" name="configGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Config</string>
|
<string>Start Config</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="5">
|
<item row="0" column="4">
|
||||||
<widget class="QComboBox" name="formatBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>video size:</string>
|
<string>video size:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QComboBox" name="videoSizeBox">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="bitRateBox">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="currentText">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -153,6 +133,19 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="7">
|
||||||
|
<widget class="QComboBox" name="formatBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QComboBox" name="bitRateBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="currentText">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -163,14 +156,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="3">
|
<item row="1" column="6" colspan="2">
|
||||||
<widget class="QLineEdit" name="recordPathEdt">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="4" colspan="2">
|
|
||||||
<widget class="QPushButton" name="selectRecordPathBtn">
|
<widget class="QPushButton" name="selectRecordPathBtn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>select path</string>
|
<string>select path</string>
|
||||||
|
@ -180,13 +166,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
|
||||||
<widget class="QLabel" name="label_6">
|
|
||||||
<property name="text">
|
|
||||||
<string>record format:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="alwaysTopCheck">
|
<widget class="QCheckBox" name="alwaysTopCheck">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -197,7 +176,38 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="0" column="6">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>record format:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3" colspan="3">
|
||||||
|
<widget class="QLineEdit" name="recordPathEdt">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="5">
|
||||||
|
<widget class="QComboBox" name="videoSizeBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="5">
|
||||||
|
<widget class="QCheckBox" name="useReverseCheck">
|
||||||
|
<property name="text">
|
||||||
|
<string>use reverse</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3" colspan="2">
|
||||||
<widget class="QCheckBox" name="closeScreenCheck">
|
<widget class="QCheckBox" name="closeScreenCheck">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>close screen</string>
|
<string>close screen</string>
|
||||||
|
@ -342,7 +352,6 @@
|
||||||
<tabstop>recordPathEdt</tabstop>
|
<tabstop>recordPathEdt</tabstop>
|
||||||
<tabstop>selectRecordPathBtn</tabstop>
|
<tabstop>selectRecordPathBtn</tabstop>
|
||||||
<tabstop>alwaysTopCheck</tabstop>
|
<tabstop>alwaysTopCheck</tabstop>
|
||||||
<tabstop>closeScreenCheck</tabstop>
|
|
||||||
<tabstop>serialBox</tabstop>
|
<tabstop>serialBox</tabstop>
|
||||||
<tabstop>startServerBtn</tabstop>
|
<tabstop>startServerBtn</tabstop>
|
||||||
<tabstop>stopServerBtn</tabstop>
|
<tabstop>stopServerBtn</tabstop>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue