minicap二次开发之minicap over WebSockets

minicap二次开发之TCP直连模式(不需adb forward)
修改 minicap源码,实现局域网内与设备直连,获取设备实时屏幕数据
GitHub地址: https://github.com/guowee/minicap-AF_INET

Example: minicap over WebSockets

A quick and dirty example to show how minicap might be used as part of an application. Also useful for testing.

Requirements

  • Node.js >= 0.12 (for this example only)
  • ADB
  • An Android device with USB debugging enabled.

Running

  1. Check that your device is connected and ADB is running with adb devices. The following steps may not work properly if you don’t.
adb devices
  1. Get information about your display. Unfortunately the easy API methods we could use for automatic detection segfault on some Samsung devices, presumably due to maker customizations. You’ll need to know the display width and height in pixels. Here are some ways to do it:
adb shell wm size
adb shell dumpsys display

To run manually, you have to first figure out which ABI your device supports:

ABI=$(adb shell getprop ro.product.cpu.abi | tr -d '\r')

Note that as Android shell always ends lines with CRLF, you’ll have to remove the CR like above or the rest of the commands will not work properly.

Also note that if you’ve got multiple devices connected, setting ANDROID_SERIAL will make things quite a bit easier as you won’t have to specify the -s option every time.

Now, push the appropriate binary to the device:

adb push libs/$ABI/minicap /data/local/tmp/

Note that for SDK <16, you will have to use the minicap-nopie executable which comes without PIE support. Check run.sh for a scripting example.

The binary enough is not enough. We’ll also need to select and push the correct shared library to the device. This can be done as follows.

SDK=$(adb shell getprop ro.build.version.sdk | tr -d '\r')
adb push jni/minicap-shared/aosp/libs/android-$SDK/$ABI/minicap.so /data/local/tmp/
  1. Start the minicap server. The most convenient way is to use the helper script at the root of this repo.
# -R means port. You can customize port. The default port number is 6666.
adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -R 10010 -P 1080x1920@1080x1920/0 -Q 100

The first set is the true size of your display, and the second set is the size of the desired projection. Larger projections require more processing power and bandwidth. The final argument is the rotation of the display. Note that this is not the rotation you want it to have, it simply specifies the display’s current rotation, which is used to normalize the output frames between Android versions. If the rotation changes you have to restart the server.
4. Start the example app.

node install

PORT=9002 node app.js
  1. Open http://localhost:9002 in your browser.(Ensure that PC and mobile phone are in the same network.)

你可能感兴趣的:(minicap二次开发之minicap over WebSockets)