Skip to content

Commit

Permalink
更新--V1.0.9
Browse files Browse the repository at this point in the history
易控第一个正式版本

请注意正式版本与测试版本之间不保证兼容性,请卸载重装使用。

- 提高音频码率,优化音频质量
- 支持关闭音频
- 优化界面排布
- 支持隐藏全屏页面导航栏
- 优化视频传输局部马赛克状况
- 增加心跳包,避免因网络断开导致未及时恢复分辨率,以及遗留程序
  • Loading branch information
mingzhixian committed Oct 30, 2023
1 parent 0c25bae commit 2283303
Show file tree
Hide file tree
Showing 32 changed files with 334 additions and 293 deletions.
Binary file modified easycontrol/.gradle/8.0/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified easycontrol/.gradle/8.0/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified easycontrol/.gradle/8.0/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified easycontrol/.gradle/8.0/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified easycontrol/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified easycontrol/.gradle/file-system.probe
Binary file not shown.
4 changes: 2 additions & 2 deletions easycontrol/.idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions easycontrol/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions easycontrol/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "top.saymzx.easycontrol.app"
minSdk 23
targetSdk 33
versionCode 10007
versionName "1.0.7_dev"
versionCode 10008
versionName "1.0.8_dev"
resConfigs "zh"
resConfigs "xhdpi"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void startDefault() {
// 添加设备监听
private void setAddDeviceListener() {
mainActivity.masterAdd.setOnClickListener(v -> {
Dialog dialog = AppData.publicTools.createAddDeviceView(this, new Device(null, "", "", AppData.setting.getDefaultMaxSize(), AppData.setting.getDefaultMaxFps(), AppData.setting.getDefaultVideoBit(), AppData.setting.getDefaultSetResolution()), deviceListAdapter);
Dialog dialog = AppData.publicTools.createAddDeviceView(this, new Device(null, "", "",AppData.setting.getDefaultIsAudio(), AppData.setting.getDefaultMaxSize(), AppData.setting.getDefaultMaxFps(), AppData.setting.getDefaultVideoBit(), AppData.setting.getDefaultSetResolution()), deviceListAdapter);
dialog.show();
});
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public void onReceive(Context context, Intent intent) {
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
mainActivity.linkedDevice.setVisibility(View.VISIBLE);
// 有线设备参数为默认参数
Device device = new Device(null, "", "", AppData.setting.getDefaultMaxSize(), AppData.setting.getDefaultMaxFps(), AppData.setting.getDefaultVideoBit(), AppData.setting.getDefaultSetResolution());
Device device = new Device(null, "", "",AppData.setting.getDefaultIsAudio(), AppData.setting.getDefaultMaxSize(), AppData.setting.getDefaultMaxFps(), AppData.setting.getDefaultVideoBit(), AppData.setting.getDefaultSetResolution());
// 设置监听
mainActivity.linkedDevice.setOnClickListener(view -> new Client(device, usbDevice));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,116 +34,36 @@ private void drawUi() {
ArrayAdapter<String> maxFpsAdapter = new ArrayAdapter<>(this, R.layout.item_spinner_item, AppData.publicTools.maxFpsList);
ArrayAdapter<String> videoBitAdapter = new ArrayAdapter<>(this, R.layout.item_spinner_item, AppData.publicTools.videoBitList);
// 默认配置
setActivity.setDefault.addView(
AppData.publicTools.createSpinnerCard(
this,
"最大大小",
maxSizeAdapter,
String.valueOf(AppData.setting.getDefaultMaxSize()),
str -> AppData.setting.setDefaultMaxSize(Integer.parseInt(str))
).getRoot()
);
setActivity.setDefault.addView(
AppData.publicTools.createSpinnerCard(
this,
"最大帧率",
maxFpsAdapter,
String.valueOf(AppData.setting.getDefaultMaxFps()),
str -> AppData.setting.setDefaultMaxFps(Integer.parseInt(str))
).getRoot()
);
setActivity.setDefault.addView(
AppData.publicTools.createSpinnerCard(
this,
"最大码率",
videoBitAdapter,
String.valueOf(AppData.setting.getDefaultVideoBit()),
str -> AppData.setting.setDefaultVideoBit(Integer.parseInt(str))
).getRoot()
);
setActivity.setDefault.addView(
AppData.publicTools.createSwitchCard(
this,
"修改分辨率",
AppData.setting.getDefaultSetResolution(),
isChecked -> AppData.setting.setDefaultSetResolution(isChecked)
).getRoot()
);
setActivity.setDefault.addView(AppData.publicTools.createSwitchCard(this, "使能音频", AppData.setting.getDefaultIsAudio(), isChecked -> AppData.setting.setDefaultIsAudio(isChecked)).getRoot());
setActivity.setDefault.addView(AppData.publicTools.createSpinnerCard(this, "最大大小", maxSizeAdapter, String.valueOf(AppData.setting.getDefaultMaxSize()), str -> AppData.setting.setDefaultMaxSize(Integer.parseInt(str))).getRoot());
setActivity.setDefault.addView(AppData.publicTools.createSpinnerCard(this, "最大帧率", maxFpsAdapter, String.valueOf(AppData.setting.getDefaultMaxFps()), str -> AppData.setting.setDefaultMaxFps(Integer.parseInt(str))).getRoot());
setActivity.setDefault.addView(AppData.publicTools.createSpinnerCard(this, "最大码率", videoBitAdapter, String.valueOf(AppData.setting.getDefaultVideoBit()), str -> AppData.setting.setDefaultVideoBit(Integer.parseInt(str))).getRoot());
setActivity.setDefault.addView(AppData.publicTools.createSwitchCard(this, "修改分辨率", AppData.setting.getDefaultSetResolution(), isChecked -> AppData.setting.setDefaultSetResolution(isChecked)).getRoot());
// 显示
setActivity.setDisplay.addView(
AppData.publicTools.createSwitchCard(
this,
"被控端熄屏",
AppData.setting.getSlaveTurnOffScreen(),
isChecked -> AppData.setting.setSlaveTurnOffScreen(isChecked)
).getRoot()
);
setActivity.setDisplay.addView(
AppData.publicTools.createSwitchCard(
this,
"默认全屏启动",
AppData.setting.getDefaultFull(),
isChecked -> AppData.setting.setDefaultFull(isChecked)
).getRoot()
);
setActivity.setDisplay.addView(AppData.publicTools.createSwitchCard(this, "被控端熄屏", AppData.setting.getSlaveTurnOffScreen(), isChecked -> AppData.setting.setSlaveTurnOffScreen(isChecked)).getRoot());
setActivity.setDisplay.addView(AppData.publicTools.createSwitchCard(this, "默认全屏启动", AppData.setting.getDefaultFull(), isChecked -> AppData.setting.setDefaultFull(isChecked)).getRoot());
// 其他
setActivity.setOther.addView(
AppData.publicTools.createTextCard(
this,
"清除默认设备",
() -> {
AppData.setting.setDefaultDevice(-1);
Toast.makeText(this, "已清除", Toast.LENGTH_SHORT).show();
}
).getRoot()
);
setActivity.setOther.addView(
AppData.publicTools.createTextCard(
this,
"重新生成密钥(需重新授权)",
() -> {
try {
// 读取密钥文件
File privateKey = new File(this.getApplicationContext().getFilesDir(), "private.key");
File publicKey = new File(this.getApplicationContext().getFilesDir(), "public.key");
AdbKeyPair.generate(privateKey, publicKey);
AppData.keyPair = AdbKeyPair.read(privateKey, publicKey);
Toast.makeText(this, "已刷新", Toast.LENGTH_SHORT).show();
} catch (Exception ignored) {
}
setActivity.setOther.addView(AppData.publicTools.createTextCard(this, "清除默认设备", () -> {
AppData.setting.setDefaultDevice(-1);
Toast.makeText(this, "已清除", Toast.LENGTH_SHORT).show();
}).getRoot());
setActivity.setOther.addView(AppData.publicTools.createTextCard(this, "重新生成密钥(需重新授权)", () -> {
try {
// 读取密钥文件
File privateKey = new File(this.getApplicationContext().getFilesDir(), "private.key");
File publicKey = new File(this.getApplicationContext().getFilesDir(), "public.key");
AdbKeyPair.generate(privateKey, publicKey);
AppData.keyPair = AdbKeyPair.read(privateKey, publicKey);
Toast.makeText(this, "已刷新", Toast.LENGTH_SHORT).show();
} catch (Exception ignored) {
}

}
).getRoot()
);
}).getRoot());
// 关于
setActivity.setAbout.addView(
AppData.publicTools.createTextCard(
this,
"查看本机IP",
() -> startActivity(new Intent(this, IpActivity.class))
).getRoot()
);
setActivity.setAbout.addView(
AppData.publicTools.createTextCard(
this,
"使用说明",
() -> startUrl("https://github.com/mingzhixian/Easycontrol/blob/master/HOW_TO_USE.md")
).getRoot()
);
setActivity.setAbout.addView(
AppData.publicTools.createTextCard(
this,
"隐私政策",
() -> startUrl("https://github.com/mingzhixian/Easycontrol/blob/master/PRIVACY.md")
).getRoot()
);
setActivity.setAbout.addView(
AppData.publicTools.createTextCard(
this,
"版本: " + BuildConfig.VERSION_NAME,
() -> startUrl("https://github.com/mingzhixian/Easycontrol/releases")
).getRoot()
);
setActivity.setAbout.addView(AppData.publicTools.createTextCard(this, "查看本机IP", () -> startActivity(new Intent(this, IpActivity.class))).getRoot());
setActivity.setAbout.addView(AppData.publicTools.createTextCard(this, "使用说明", () -> startUrl("https://github.com/mingzhixian/Easycontrol/blob/master/HOW_TO_USE.md")).getRoot());
setActivity.setAbout.addView(AppData.publicTools.createTextCard(this, "隐私政策", () -> startUrl("https://github.com/mingzhixian/Easycontrol/blob/master/PRIVACY.md")).getRoot());
setActivity.setAbout.addView(AppData.publicTools.createTextCard(this, "版本: " + BuildConfig.VERSION_NAME, () -> startUrl("https://github.com/mingzhixian/Easycontrol/releases")).getRoot());
}

// 浏览器打开
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public synchronized void decodeIn(ByteBuffer data) {
int inIndex = audioDecodec.dequeueInputBuffer(0);
// 缓冲区已满丢帧
if (inIndex < 0) return;
int size = data.remaining();
audioDecodec.getInputBuffer(inIndex).put(data);
// 提交解码器解码
audioDecodec.queueInputBuffer(inIndex, 0, size, 0, 0);
audioDecodec.queueInputBuffer(inIndex, 0, data.capacity(), 0, 0);
} catch (IllegalStateException ignored) {
}
}
Expand All @@ -69,7 +68,7 @@ private void setAudioDecodec(ByteBuffer csd0) throws IOException {
// 音频参数
int sampleRate = 48000;
int channelCount = 2;
int bitRate = 64000;
int bitRate = 96000;
MediaFormat mediaFormat = MediaFormat.createAudioFormat(codecMime, sampleRate, channelCount);
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
// 获取音频标识头
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public class Client {
public Client(Device device, UsbDevice usbDevice) {
// 显示加载框
dialog.show();
// 设置剪切板的其余服务的检查时间
videoOutLoopNum = videoOutLoopNumLimit = device.maxFps;
// 索取高性能wifi锁(非wifi情况会忽略本设置)
wifiLock = ((WifiManager) AppData.main.getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ? WifiManager.WIFI_MODE_FULL_LOW_LATENCY : WifiManager.WIFI_MODE_FULL_HIGH_PERF, "easycontrol");
wifiLock.acquire();
Expand Down Expand Up @@ -129,6 +127,7 @@ private void startServer(Device device) throws Exception {
setHeight = tmpDeviceSize.second;
}
adb.runAdbCmd("CLASSPATH=/data/local/tmp/easycontrol_server_" + AppData.versionCode + ".jar app_process / top.saymzx.easycontrol.server.Server" +
" is_audio=" + (device.isAudio ? 1 : 0) +
" max_size=" + device.maxSize +
" max_fps=" + device.maxFps +
" video_bit_rate=" + device.maxVideoBit +
Expand Down Expand Up @@ -180,11 +179,12 @@ private void createSubService() throws Exception {
}
}

// 启动子服务
public void startSubService() {
// 启动子服务
executor.execute(this::executeVideoDecodeOut);
if (audioDecode != null) executor.execute(this::executeAudioDecodeOut);
executor.execute(this::executeStreamIn);
executor.execute(this::executeOtherService);
}

// 创建UI
Expand Down Expand Up @@ -225,16 +225,8 @@ private void executeStreamIn() {
}
}

private int videoOutLoopNum;
private final int videoOutLoopNumLimit;

private void executeVideoDecodeOut() {
videoDecode.decodeOut(isNormalPlay);
videoOutLoopNum++;
if (videoOutLoopNum > videoOutLoopNumLimit) {
controller.checkClipBoard();
videoOutLoopNum = 0;
}
executor.execute(this::executeVideoDecodeOut);
}

Expand All @@ -243,6 +235,17 @@ private void executeAudioDecodeOut() {
executor.execute(this::executeAudioDecodeOut);
}

private void executeOtherService() {
controller.checkClipBoard();
controller.sendKeepAlive();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
clientView.hide(true);
}
executor.execute(this::executeOtherService);
}

private ByteBuffer readFrame() throws InterruptedException, IOException {
return stream.readByteArray(stream.readInt());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN;

import android.content.ClipData;
import android.view.MotionEvent;

import java.io.IOException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -49,7 +50,14 @@ public void handleRotationNotification() {

// 发送触摸事件
public void sendTouchEvent(int action, int p, float x, float y) {
if (x < 0 || x > 1 || y < 0 || y > 1) return;
if (x < 0 || x > 1 || y < 0 || y > 1) {
// 超出范围则改为抬起事件
if (x < 0) x = 0;
if (x > 1) x = 1;
if (y < 0) y = 0;
if (y > 1) y = 1;
action = MotionEvent.ACTION_UP;
}
ByteBuffer byteBuffer = ByteBuffer.allocate(11);
// 触摸事件
byteBuffer.put((byte) 1);
Expand Down Expand Up @@ -87,6 +95,11 @@ private void sendClipboardEvent() {
writeStream(byteBuffer);
}

// 发送心跳包
public void sendKeepAlive() {
writeStream(ByteBuffer.wrap(new byte[]{4}));
}

private void writeStream(ByteBuffer byteBuffer) {
try {
stream.write(byteBuffer);
Expand Down
Loading

0 comments on commit 2283303

Please sign in to comment.