mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 06:08:39 +00:00
refactor: change device params
This commit is contained in:
parent
ea0d55b175
commit
4b9a8cfe86
3 changed files with 15 additions and 20 deletions
|
@ -17,7 +17,7 @@ namespace qsc {
|
||||||
|
|
||||||
Device::Device(DeviceParams params, QObject *parent) : IDevice(parent), m_params(params)
|
Device::Device(DeviceParams params, QObject *parent) : IDevice(parent), m_params(params)
|
||||||
{
|
{
|
||||||
if (!params.display && m_params.recordFileName.trimmed().isEmpty()) {
|
if (!params.display && !m_params.recordFile) {
|
||||||
qCritical("not display must be recorded");
|
qCritical("not display must be recorded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,17 @@ Device::Device(DeviceParams params, QObject *parent) : IDevice(parent), m_params
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
m_server = new Server(this);
|
m_server = new Server(this);
|
||||||
if (!m_params.recordFileName.trimmed().isEmpty()) {
|
if (m_params.recordFile && !m_params.recordPath.trimmed().isEmpty()) {
|
||||||
m_recorder = new Recorder(m_params.recordFileName, this);
|
QString absFilePath;
|
||||||
|
QString fileDir(m_params.recordPath);
|
||||||
|
if (!fileDir.isEmpty()) {
|
||||||
|
QDateTime dateTime = QDateTime::currentDateTime();
|
||||||
|
QString fileName = dateTime.toString("_yyyyMMdd_hhmmss_zzz");
|
||||||
|
fileName = m_params.serial + fileName + "." + m_params.recordFileFormat;
|
||||||
|
QDir dir(fileDir);
|
||||||
|
absFilePath = dir.absoluteFilePath(fileName);
|
||||||
|
}
|
||||||
|
m_recorder = new Recorder(absFilePath, this);
|
||||||
}
|
}
|
||||||
initSignals();
|
initSignals();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,14 @@ namespace qsc {
|
||||||
struct DeviceParams {
|
struct DeviceParams {
|
||||||
QString serverLocalPath = ""; // 本地安卓server路径
|
QString serverLocalPath = ""; // 本地安卓server路径
|
||||||
QString serverRemotePath = ""; // 要推送到远端设备的server路径
|
QString serverRemotePath = ""; // 要推送到远端设备的server路径
|
||||||
QString recordFileName = ""; // 视频录制文件名
|
|
||||||
QString recordPath = ""; // 视频保存路径
|
QString recordPath = ""; // 视频保存路径
|
||||||
|
QString recordFileFormat = "mp4"; // 视频保存格式 mp4/mkv
|
||||||
QString serial = ""; // 设备序列号
|
QString serial = ""; // 设备序列号
|
||||||
quint16 localPort = 27183; // reverse时本地监听端口
|
quint16 localPort = 27183; // reverse时本地监听端口
|
||||||
quint16 maxSize = 720; // 视频分辨率
|
quint16 maxSize = 720; // 视频分辨率
|
||||||
quint32 bitRate = 2000000; // 视频比特率
|
quint32 bitRate = 2000000; // 视频比特率
|
||||||
quint32 maxFps = 60; // 视频最大帧率
|
quint32 maxFps = 60; // 视频最大帧率
|
||||||
|
bool recordFile = false; // 录制到文件
|
||||||
bool closeScreen = false; // 启动时自动息屏
|
bool closeScreen = false; // 启动时自动息屏
|
||||||
bool useReverse = true; // true:先使用adb reverse,失败后自动使用adb forward;false:直接使用adb forward
|
bool useReverse = true; // true:先使用adb reverse,失败后自动使用adb forward;false:直接使用adb forward
|
||||||
bool display = true; // 是否显示画面(或者仅仅后台录制)
|
bool display = true; // 是否显示画面(或者仅仅后台录制)
|
||||||
|
@ -20,7 +21,6 @@ struct DeviceParams {
|
||||||
bool renderExpiredFrames = false; // 是否渲染延迟视频帧
|
bool renderExpiredFrames = false; // 是否渲染延迟视频帧
|
||||||
int lockVideoOrientation = -1; // 是否锁定视频方向
|
int lockVideoOrientation = -1; // 是否锁定视频方向
|
||||||
bool stayAwake = false; // 是否保持唤醒
|
bool stayAwake = false; // 是否保持唤醒
|
||||||
bool framelessWindow = false; // 是否无边框窗口
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,19 +265,6 @@ void Dialog::on_startServerBtn_clicked()
|
||||||
{
|
{
|
||||||
outLog("start server...", false);
|
outLog("start server...", false);
|
||||||
|
|
||||||
QString absFilePath;
|
|
||||||
if (ui->recordScreenCheck->isChecked()) {
|
|
||||||
QString fileDir(ui->recordPathEdt->text().trimmed());
|
|
||||||
if (!fileDir.isEmpty()) {
|
|
||||||
QDateTime dateTime = QDateTime::currentDateTime();
|
|
||||||
QString fileName = dateTime.toString("_yyyyMMdd_hhmmss_zzz");
|
|
||||||
QString ext = ui->formatBox->currentText().trimmed();
|
|
||||||
fileName = windowTitle() + fileName + "." + ext;
|
|
||||||
QDir dir(fileDir);
|
|
||||||
absFilePath = dir.absoluteFilePath(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is ok that "native" toUshort is 0
|
// this is ok that "native" toUshort is 0
|
||||||
quint16 videoSize = ui->maxSizeBox->currentText().trimmed().toUShort();
|
quint16 videoSize = ui->maxSizeBox->currentText().trimmed().toUShort();
|
||||||
qsc::DeviceParams params;
|
qsc::DeviceParams params;
|
||||||
|
@ -286,15 +273,14 @@ void Dialog::on_startServerBtn_clicked()
|
||||||
params.bitRate = getBitRate();
|
params.bitRate = getBitRate();
|
||||||
// on devices with Android >= 10, the capture frame rate can be limited
|
// on devices with Android >= 10, the capture frame rate can be limited
|
||||||
params.maxFps = static_cast<quint32>(Config::getInstance().getMaxFps());
|
params.maxFps = static_cast<quint32>(Config::getInstance().getMaxFps());
|
||||||
params.recordFileName = absFilePath;
|
|
||||||
params.closeScreen = ui->closeScreenCheck->isChecked();
|
params.closeScreen = ui->closeScreenCheck->isChecked();
|
||||||
params.useReverse = ui->useReverseCheck->isChecked();
|
params.useReverse = ui->useReverseCheck->isChecked();
|
||||||
params.display = !ui->notDisplayCheck->isChecked();
|
params.display = !ui->notDisplayCheck->isChecked();
|
||||||
params.renderExpiredFrames = Config::getInstance().getRenderExpiredFrames();
|
params.renderExpiredFrames = Config::getInstance().getRenderExpiredFrames();
|
||||||
params.lockVideoOrientation = ui->lockOrientationBox->currentIndex() - 1;
|
params.lockVideoOrientation = ui->lockOrientationBox->currentIndex() - 1;
|
||||||
params.stayAwake = ui->stayAwakeCheck->isChecked();
|
params.stayAwake = ui->stayAwakeCheck->isChecked();
|
||||||
params.framelessWindow = ui->framelessCheck->isChecked();
|
|
||||||
params.recordPath = ui->recordPathEdt->text().trimmed();
|
params.recordPath = ui->recordPathEdt->text().trimmed();
|
||||||
|
params.recordFileFormat = ui->formatBox->currentText().trimmed();
|
||||||
params.serverLocalPath = getServerPath();
|
params.serverLocalPath = getServerPath();
|
||||||
params.serverRemotePath = Config::getInstance().getServerPath();
|
params.serverRemotePath = Config::getInstance().getServerPath();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue