mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +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.sendFrameMeta = m_recorder ? true : false;
|
||||
params.control = true;
|
||||
params.useReverse = m_params.useReverse;
|
||||
m_server->start(params);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
quint16 maxSize = 0;
|
||||
quint32 bitRate = 8000000;
|
||||
bool closeScreen = false;
|
||||
bool useReverse = true;
|
||||
};
|
||||
explicit Device(DeviceParams params, QObject *parent = nullptr);
|
||||
virtual ~Device();
|
||||
|
|
|
@ -181,7 +181,18 @@ bool Server::connectTo()
|
|||
qWarning("video socket connect to server failed");
|
||||
emit connectToResult(false, "", QSize());
|
||||
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()) {
|
||||
// connect will success even if devices offline, recv data is real connect success
|
||||
// because connect is to pc adb server
|
||||
|
@ -200,17 +211,7 @@ bool Server::connectTo()
|
|||
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
|
||||
disableTunnelForward();
|
||||
m_tunnelEnabled = false;
|
||||
|
@ -358,13 +359,12 @@ void Server::onWorkProcessResult(AdbProcess::ADB_EXEC_RESULT processResult)
|
|||
switch (m_serverStartStep) {
|
||||
case SSS_PUSH:
|
||||
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
||||
#if 1
|
||||
m_serverStartStep = SSS_ENABLE_TUNNEL_REVERSE;
|
||||
#else
|
||||
// test tunnelForward
|
||||
m_tunnelForward = true;
|
||||
m_serverStartStep = SSS_ENABLE_TUNNEL_FORWARD;
|
||||
#endif
|
||||
if (m_params.useReverse) {
|
||||
m_serverStartStep = SSS_ENABLE_TUNNEL_REVERSE;
|
||||
} else {
|
||||
m_tunnelForward = true;
|
||||
m_serverStartStep = SSS_ENABLE_TUNNEL_FORWARD;
|
||||
}
|
||||
startServerByStep();
|
||||
} else if (AdbProcess::AER_SUCCESS_START != processResult){
|
||||
qCritical("adb push failed");
|
||||
|
|
|
@ -25,11 +25,12 @@ public:
|
|||
struct ServerParams {
|
||||
QString serial = "";
|
||||
quint16 localPort = 27183;
|
||||
quint16 maxSize = 0;
|
||||
quint16 maxSize = 750;
|
||||
quint32 bitRate = 8000000;
|
||||
QString crop = "-";
|
||||
bool sendFrameMeta = false;
|
||||
bool control = true;
|
||||
bool useReverse = true;
|
||||
};
|
||||
|
||||
explicit Server(QObject *parent = nullptr);
|
||||
|
|
|
@ -123,6 +123,7 @@ void Dialog::on_startServerBtn_clicked()
|
|||
params.bitRate = bitRate;
|
||||
params.recordFileName = absFilePath;
|
||||
params.closeScreen = ui->closeScreenCheck->isChecked();
|
||||
params.useReverse = ui->useReverseCheck->isChecked();
|
||||
m_device = new Device(params, this);
|
||||
if (ui->alwaysTopCheck->isChecked() && m_device->getVideoForm()) {
|
||||
m_device->getVideoForm()->staysOnTop();
|
||||
|
@ -243,32 +244,6 @@ void Dialog::on_recordPathEdt_textChanged(const QString &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()
|
||||
{
|
||||
execAdbCmd();
|
||||
|
|
|
@ -41,10 +41,6 @@ private slots:
|
|||
|
||||
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_stopAdbBtn_clicked();
|
||||
|
|
|
@ -116,36 +116,16 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="configGroupBox">
|
||||
<property name="title">
|
||||
<string>Config</string>
|
||||
<string>Start Config</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="5">
|
||||
<widget class="QComboBox" name="formatBox"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>video size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
|
@ -153,6 +133,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
|
@ -163,14 +156,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="recordPathEdt">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4" colspan="2">
|
||||
<item row="1" column="6" colspan="2">
|
||||
<widget class="QPushButton" name="selectRecordPathBtn">
|
||||
<property name="text">
|
||||
<string>select path</string>
|
||||
|
@ -180,13 +166,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QCheckBox" name="alwaysTopCheck">
|
||||
<property name="text">
|
||||
|
@ -197,7 +176,38 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="text">
|
||||
<string>close screen</string>
|
||||
|
@ -342,7 +352,6 @@
|
|||
<tabstop>recordPathEdt</tabstop>
|
||||
<tabstop>selectRecordPathBtn</tabstop>
|
||||
<tabstop>alwaysTopCheck</tabstop>
|
||||
<tabstop>closeScreenCheck</tabstop>
|
||||
<tabstop>serialBox</tabstop>
|
||||
<tabstop>startServerBtn</tabstop>
|
||||
<tabstop>stopServerBtn</tabstop>
|
||||
|
|
Loading…
Add table
Reference in a new issue