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