Compare commits
1 Commits
encoder_na
...
legacy_pas
Author | SHA1 | Date | |
---|---|---|---|
206abdb2c5 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,4 +6,3 @@ build/
|
|||||||
.idea/
|
.idea/
|
||||||
.gradle/
|
.gradle/
|
||||||
/x/
|
/x/
|
||||||
local.properties
|
|
||||||
|
31
README.md
31
README.md
@ -203,22 +203,6 @@ scrcpy --lock-video-orientation 3 # 90° clockwise
|
|||||||
This affects recording orientation.
|
This affects recording orientation.
|
||||||
|
|
||||||
|
|
||||||
#### Encoder
|
|
||||||
|
|
||||||
Some devices have more than one encoder, and some of them may cause issues or
|
|
||||||
crash. It is possible to select a different encoder:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --encoder OMX.qcom.video.encoder.avc
|
|
||||||
```
|
|
||||||
|
|
||||||
To list the available encoders, you could pass an invalid encoder name, the
|
|
||||||
error will give the available encoders:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --encoder _
|
|
||||||
```
|
|
||||||
|
|
||||||
### Recording
|
### Recording
|
||||||
|
|
||||||
It is possible to record the screen while mirroring:
|
It is possible to record the screen while mirroring:
|
||||||
@ -566,9 +550,8 @@ way.
|
|||||||
|
|
||||||
Some devices do not behave as expected when setting the device clipboard
|
Some devices do not behave as expected when setting the device clipboard
|
||||||
programmatically. An option `--legacy-paste` is provided to change the behavior
|
programmatically. An option `--legacy-paste` is provided to change the behavior
|
||||||
of <kbd>Ctrl</kbd>+<kbd>v</kbd> and <kbd>MOD</kbd>+<kbd>v</kbd> so that they
|
of <kbd>Ctrl</kbd>+<kbd>v</kbd> and <kbd>MOD</kbd>+<kbd>v</kbd> to also inject
|
||||||
also inject the computer clipboard text as a sequence of key events (the same
|
the computer clipboard text as a sequence of key events.
|
||||||
way as <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>).
|
|
||||||
|
|
||||||
#### Pinch-to-zoom
|
#### Pinch-to-zoom
|
||||||
|
|
||||||
@ -616,16 +599,6 @@ scrcpy --no-key-repeat
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Right-click and middle-click
|
|
||||||
|
|
||||||
By default, right-click triggers BACK (or POWER on) and middle-click triggers
|
|
||||||
HOME. To disable these shortcuts and forward the clicks to the device instead:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
scrcpy --forward-all-clicks
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### File drop
|
### File drop
|
||||||
|
|
||||||
#### Install APK
|
#### Install APK
|
||||||
|
@ -56,18 +56,10 @@ The list of possible display ids can be listed by "adb shell dumpsys display"
|
|||||||
|
|
||||||
Default is 0.
|
Default is 0.
|
||||||
|
|
||||||
.TP
|
|
||||||
.BI "\-\-encoder " name
|
|
||||||
Use a specific MediaCodec encoder (must be a H.264 encoder).
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-\-force\-adb\-forward
|
.B \-\-force\-adb\-forward
|
||||||
Do not attempt to use "adb reverse" to connect to the device.
|
Do not attempt to use "adb reverse" to connect to the device.
|
||||||
|
|
||||||
.TP
|
|
||||||
.B \-\-forward\-all\-clicks
|
|
||||||
By default, right-click triggers BACK (or POWER on) and middle-click triggers HOME. This option disables these shortcuts and forward the clicks to the device instead.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-f, \-\-fullscreen
|
.B \-f, \-\-fullscreen
|
||||||
Start in fullscreen.
|
Start in fullscreen.
|
||||||
|
@ -53,18 +53,10 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
" Default is 0.\n"
|
" Default is 0.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --encoder name\n"
|
|
||||||
" Use a specific MediaCodec encoder (must be a H.264 encoder).\n"
|
|
||||||
"\n"
|
|
||||||
" --force-adb-forward\n"
|
" --force-adb-forward\n"
|
||||||
" Do not attempt to use \"adb reverse\" to connect to the\n"
|
" Do not attempt to use \"adb reverse\" to connect to the\n"
|
||||||
" the device.\n"
|
" the device.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" --forward-all-clicks\n"
|
|
||||||
" By default, right-click triggers BACK (or POWER on) and\n"
|
|
||||||
" middle-click triggers HOME. This option disables these\n"
|
|
||||||
" shortcuts and forward the clicks to the device instead.\n"
|
|
||||||
"\n"
|
|
||||||
" -f, --fullscreen\n"
|
" -f, --fullscreen\n"
|
||||||
" Start in fullscreen.\n"
|
" Start in fullscreen.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -665,9 +657,7 @@ guess_record_format(const char *filename) {
|
|||||||
#define OPT_DISABLE_SCREENSAVER 1020
|
#define OPT_DISABLE_SCREENSAVER 1020
|
||||||
#define OPT_SHORTCUT_MOD 1021
|
#define OPT_SHORTCUT_MOD 1021
|
||||||
#define OPT_NO_KEY_REPEAT 1022
|
#define OPT_NO_KEY_REPEAT 1022
|
||||||
#define OPT_FORWARD_ALL_CLICKS 1023
|
#define OPT_LEGACY_PASTE 1023
|
||||||
#define OPT_LEGACY_PASTE 1024
|
|
||||||
#define OPT_ENCODER_NAME 1025
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
@ -679,11 +669,8 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||||||
{"disable-screensaver", no_argument, NULL,
|
{"disable-screensaver", no_argument, NULL,
|
||||||
OPT_DISABLE_SCREENSAVER},
|
OPT_DISABLE_SCREENSAVER},
|
||||||
{"display", required_argument, NULL, OPT_DISPLAY_ID},
|
{"display", required_argument, NULL, OPT_DISPLAY_ID},
|
||||||
{"encoder", required_argument, NULL, OPT_ENCODER_NAME},
|
|
||||||
{"force-adb-forward", no_argument, NULL,
|
{"force-adb-forward", no_argument, NULL,
|
||||||
OPT_FORCE_ADB_FORWARD},
|
OPT_FORCE_ADB_FORWARD},
|
||||||
{"forward-all-clicks", no_argument, NULL,
|
|
||||||
OPT_FORWARD_ALL_CLICKS},
|
|
||||||
{"fullscreen", no_argument, NULL, 'f'},
|
{"fullscreen", no_argument, NULL, 'f'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"legacy-paste", no_argument, NULL, OPT_LEGACY_PASTE},
|
{"legacy-paste", no_argument, NULL, OPT_LEGACY_PASTE},
|
||||||
@ -866,9 +853,6 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||||||
case OPT_CODEC_OPTIONS:
|
case OPT_CODEC_OPTIONS:
|
||||||
opts->codec_options = optarg;
|
opts->codec_options = optarg;
|
||||||
break;
|
break;
|
||||||
case OPT_ENCODER_NAME:
|
|
||||||
opts->encoder_name = optarg;
|
|
||||||
break;
|
|
||||||
case OPT_FORCE_ADB_FORWARD:
|
case OPT_FORCE_ADB_FORWARD:
|
||||||
opts->force_adb_forward = true;
|
opts->force_adb_forward = true;
|
||||||
break;
|
break;
|
||||||
@ -880,9 +864,6 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPT_FORWARD_ALL_CLICKS:
|
|
||||||
opts->forward_all_clicks = true;
|
|
||||||
break;
|
|
||||||
case OPT_LEGACY_PASTE:
|
case OPT_LEGACY_PASTE:
|
||||||
opts->legacy_paste = true;
|
opts->legacy_paste = true;
|
||||||
break;
|
break;
|
||||||
|
@ -60,7 +60,6 @@ input_manager_init(struct input_manager *im,
|
|||||||
im->control = options->control;
|
im->control = options->control;
|
||||||
im->forward_key_repeat = options->forward_key_repeat;
|
im->forward_key_repeat = options->forward_key_repeat;
|
||||||
im->prefer_text = options->prefer_text;
|
im->prefer_text = options->prefer_text;
|
||||||
im->forward_all_clicks = options->forward_all_clicks;
|
|
||||||
im->legacy_paste = options->legacy_paste;
|
im->legacy_paste = options->legacy_paste;
|
||||||
|
|
||||||
const struct sc_shortcut_mods *shortcut_mods = &options->shortcut_mods;
|
const struct sc_shortcut_mods *shortcut_mods = &options->shortcut_mods;
|
||||||
@ -636,7 +635,7 @@ input_manager_process_mouse_button(struct input_manager *im,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool down = event->type == SDL_MOUSEBUTTONDOWN;
|
bool down = event->type == SDL_MOUSEBUTTONDOWN;
|
||||||
if (!im->forward_all_clicks && down) {
|
if (down) {
|
||||||
if (control && event->button == SDL_BUTTON_RIGHT) {
|
if (control && event->button == SDL_BUTTON_RIGHT) {
|
||||||
press_back_or_turn_screen_on(im->controller);
|
press_back_or_turn_screen_on(im->controller);
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,6 @@ struct input_manager {
|
|||||||
bool control;
|
bool control;
|
||||||
bool forward_key_repeat;
|
bool forward_key_repeat;
|
||||||
bool prefer_text;
|
bool prefer_text;
|
||||||
bool forward_all_clicks;
|
|
||||||
bool legacy_paste;
|
bool legacy_paste;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -318,7 +318,6 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
.show_touches = options->show_touches,
|
.show_touches = options->show_touches,
|
||||||
.stay_awake = options->stay_awake,
|
.stay_awake = options->stay_awake,
|
||||||
.codec_options = options->codec_options,
|
.codec_options = options->codec_options,
|
||||||
.encoder_name = options->encoder_name,
|
|
||||||
.force_adb_forward = options->force_adb_forward,
|
.force_adb_forward = options->force_adb_forward,
|
||||||
};
|
};
|
||||||
if (!server_start(&server, options->serial, ¶ms)) {
|
if (!server_start(&server, options->serial, ¶ms)) {
|
||||||
@ -423,7 +422,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
options->window_y, options->window_width,
|
options->window_y, options->window_width,
|
||||||
options->window_height,
|
options->window_height,
|
||||||
options->window_borderless,
|
options->window_borderless,
|
||||||
options->rotation, options->mipmaps)) {
|
options->rotation, options-> mipmaps)) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@ struct scrcpy_options {
|
|||||||
const char *push_target;
|
const char *push_target;
|
||||||
const char *render_driver;
|
const char *render_driver;
|
||||||
const char *codec_options;
|
const char *codec_options;
|
||||||
const char *encoder_name;
|
|
||||||
enum sc_log_level log_level;
|
enum sc_log_level log_level;
|
||||||
enum sc_record_format record_format;
|
enum sc_record_format record_format;
|
||||||
struct sc_port_range port_range;
|
struct sc_port_range port_range;
|
||||||
@ -80,7 +79,6 @@ struct scrcpy_options {
|
|||||||
bool force_adb_forward;
|
bool force_adb_forward;
|
||||||
bool disable_screensaver;
|
bool disable_screensaver;
|
||||||
bool forward_key_repeat;
|
bool forward_key_repeat;
|
||||||
bool forward_all_clicks;
|
|
||||||
bool legacy_paste;
|
bool legacy_paste;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,7 +90,6 @@ struct scrcpy_options {
|
|||||||
.push_target = NULL, \
|
.push_target = NULL, \
|
||||||
.render_driver = NULL, \
|
.render_driver = NULL, \
|
||||||
.codec_options = NULL, \
|
.codec_options = NULL, \
|
||||||
.encoder_name = NULL, \
|
|
||||||
.log_level = SC_LOG_LEVEL_INFO, \
|
.log_level = SC_LOG_LEVEL_INFO, \
|
||||||
.record_format = SC_RECORD_FORMAT_AUTO, \
|
.record_format = SC_RECORD_FORMAT_AUTO, \
|
||||||
.port_range = { \
|
.port_range = { \
|
||||||
@ -127,7 +124,6 @@ struct scrcpy_options {
|
|||||||
.force_adb_forward = false, \
|
.force_adb_forward = false, \
|
||||||
.disable_screensaver = false, \
|
.disable_screensaver = false, \
|
||||||
.forward_key_repeat = true, \
|
.forward_key_repeat = true, \
|
||||||
.forward_all_clicks = false, \
|
|
||||||
.legacy_paste = false, \
|
.legacy_paste = false, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,6 @@ execute_server(struct server *server, const struct server_params *params) {
|
|||||||
params->show_touches ? "true" : "false",
|
params->show_touches ? "true" : "false",
|
||||||
params->stay_awake ? "true" : "false",
|
params->stay_awake ? "true" : "false",
|
||||||
params->codec_options ? params->codec_options : "-",
|
params->codec_options ? params->codec_options : "-",
|
||||||
params->encoder_name ? params->encoder_name : "-",
|
|
||||||
};
|
};
|
||||||
#ifdef SERVER_DEBUGGER
|
#ifdef SERVER_DEBUGGER
|
||||||
LOGI("Server debugger waiting for a client on device port "
|
LOGI("Server debugger waiting for a client on device port "
|
||||||
|
@ -48,7 +48,6 @@ struct server_params {
|
|||||||
enum sc_log_level log_level;
|
enum sc_log_level log_level;
|
||||||
const char *crop;
|
const char *crop;
|
||||||
const char *codec_options;
|
const char *codec_options;
|
||||||
const char *encoder_name;
|
|
||||||
struct sc_port_range port_range;
|
struct sc_port_range port_range;
|
||||||
uint16_t max_size;
|
uint16_t max_size;
|
||||||
uint32_t bit_rate;
|
uint32_t bit_rate;
|
||||||
|
@ -205,13 +205,9 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right-click and middle-click only work if the source is a mouse
|
|
||||||
boolean nonPrimaryButtonPressed = (buttons & ~MotionEvent.BUTTON_PRIMARY) != 0;
|
|
||||||
int source = nonPrimaryButtonPressed ? InputDevice.SOURCE_MOUSE : InputDevice.SOURCE_TOUCHSCREEN;
|
|
||||||
|
|
||||||
MotionEvent event = MotionEvent
|
MotionEvent event = MotionEvent
|
||||||
.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEVICE_ID_VIRTUAL, 0, source,
|
.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEVICE_ID_VIRTUAL, 0,
|
||||||
0);
|
InputDevice.SOURCE_TOUCHSCREEN, 0);
|
||||||
return device.injectEvent(event);
|
return device.injectEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package com.genymobile.scrcpy;
|
|
||||||
|
|
||||||
import android.media.MediaCodecInfo;
|
|
||||||
|
|
||||||
public class InvalidEncoderException extends RuntimeException {
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final MediaCodecInfo[] availableEncoders;
|
|
||||||
|
|
||||||
public InvalidEncoderException(String name, MediaCodecInfo[] availableEncoders) {
|
|
||||||
super("There is no encoder having name '" + name + '"');
|
|
||||||
this.name = name;
|
|
||||||
this.availableEncoders = availableEncoders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MediaCodecInfo[] getAvailableEncoders() {
|
|
||||||
return availableEncoders;
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,6 @@ public class Options {
|
|||||||
private boolean showTouches;
|
private boolean showTouches;
|
||||||
private boolean stayAwake;
|
private boolean stayAwake;
|
||||||
private String codecOptions;
|
private String codecOptions;
|
||||||
private String encoderName;
|
|
||||||
|
|
||||||
public Ln.Level getLogLevel() {
|
public Ln.Level getLogLevel() {
|
||||||
return logLevel;
|
return logLevel;
|
||||||
@ -121,12 +120,4 @@ public class Options {
|
|||||||
public void setCodecOptions(String codecOptions) {
|
public void setCodecOptions(String codecOptions) {
|
||||||
this.codecOptions = codecOptions;
|
this.codecOptions = codecOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncoderName() {
|
|
||||||
return encoderName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEncoderName(String encoderName) {
|
|
||||||
this.encoderName = encoderName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.media.MediaCodecList;
|
|
||||||
import android.media.MediaFormat;
|
import android.media.MediaFormat;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
@ -13,8 +12,6 @@ import android.view.Surface;
|
|||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
@ -29,19 +26,17 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||||||
private final AtomicBoolean rotationChanged = new AtomicBoolean();
|
private final AtomicBoolean rotationChanged = new AtomicBoolean();
|
||||||
private final ByteBuffer headerBuffer = ByteBuffer.allocate(12);
|
private final ByteBuffer headerBuffer = ByteBuffer.allocate(12);
|
||||||
|
|
||||||
private String encoderName;
|
|
||||||
private List<CodecOption> codecOptions;
|
private List<CodecOption> codecOptions;
|
||||||
private int bitRate;
|
private int bitRate;
|
||||||
private int maxFps;
|
private int maxFps;
|
||||||
private boolean sendFrameMeta;
|
private boolean sendFrameMeta;
|
||||||
private long ptsOrigin;
|
private long ptsOrigin;
|
||||||
|
|
||||||
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps, List<CodecOption> codecOptions, String encoderName) {
|
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps, List<CodecOption> codecOptions) {
|
||||||
this.sendFrameMeta = sendFrameMeta;
|
this.sendFrameMeta = sendFrameMeta;
|
||||||
this.bitRate = bitRate;
|
this.bitRate = bitRate;
|
||||||
this.maxFps = maxFps;
|
this.maxFps = maxFps;
|
||||||
this.codecOptions = codecOptions;
|
this.codecOptions = codecOptions;
|
||||||
this.encoderName = encoderName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,7 +69,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||||||
boolean alive;
|
boolean alive;
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
MediaCodec codec = createCodec(encoderName);
|
MediaCodec codec = createCodec();
|
||||||
IBinder display = createDisplay();
|
IBinder display = createDisplay();
|
||||||
ScreenInfo screenInfo = device.getScreenInfo();
|
ScreenInfo screenInfo = device.getScreenInfo();
|
||||||
Rect contentRect = screenInfo.getContentRect();
|
Rect contentRect = screenInfo.getContentRect();
|
||||||
@ -155,30 +150,8 @@ public class ScreenEncoder implements Device.RotationListener {
|
|||||||
IO.writeFully(fd, headerBuffer);
|
IO.writeFully(fd, headerBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MediaCodecInfo[] listEncoders() {
|
private static MediaCodec createCodec() throws IOException {
|
||||||
List<MediaCodecInfo> result = new ArrayList<>();
|
return MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_VIDEO_AVC);
|
||||||
MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
|
|
||||||
for (MediaCodecInfo codecInfo : list.getCodecInfos()) {
|
|
||||||
if (codecInfo.isEncoder() && Arrays.asList(codecInfo.getSupportedTypes()).contains(MediaFormat.MIMETYPE_VIDEO_AVC)) {
|
|
||||||
result.add(codecInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toArray(new MediaCodecInfo[result.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MediaCodec createCodec(String encoderName) throws IOException {
|
|
||||||
if (encoderName != null) {
|
|
||||||
Ln.d("Creating encoder by name: '" + encoderName + "'");
|
|
||||||
try {
|
|
||||||
return MediaCodec.createByCodecName(encoderName);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
MediaCodecInfo[] encoders = listEncoders();
|
|
||||||
throw new InvalidEncoderException(encoderName, encoders);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MediaCodec codec = MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_VIDEO_AVC);
|
|
||||||
Ln.d("Using encoder: '" + codec.getName() + "'");
|
|
||||||
return codec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCodecOption(MediaFormat format, CodecOption codecOption) {
|
private static void setCodecOption(MediaFormat format, CodecOption codecOption) {
|
||||||
|
@ -4,7 +4,6 @@ import com.genymobile.scrcpy.wrappers.ContentProvider;
|
|||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
import android.media.MediaCodecInfo;
|
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
@ -55,8 +54,7 @@ public final class Server {
|
|||||||
boolean tunnelForward = options.isTunnelForward();
|
boolean tunnelForward = options.isTunnelForward();
|
||||||
|
|
||||||
try (DesktopConnection connection = DesktopConnection.open(device, tunnelForward)) {
|
try (DesktopConnection connection = DesktopConnection.open(device, tunnelForward)) {
|
||||||
ScreenEncoder screenEncoder = new ScreenEncoder(options.getSendFrameMeta(), options.getBitRate(), options.getMaxFps(), codecOptions,
|
ScreenEncoder screenEncoder = new ScreenEncoder(options.getSendFrameMeta(), options.getBitRate(), options.getMaxFps(), codecOptions);
|
||||||
options.getEncoderName());
|
|
||||||
|
|
||||||
if (options.getControl()) {
|
if (options.getControl()) {
|
||||||
final Controller controller = new Controller(device, connection);
|
final Controller controller = new Controller(device, connection);
|
||||||
@ -122,7 +120,7 @@ public final class Server {
|
|||||||
"The server version (" + BuildConfig.VERSION_NAME + ") does not match the client " + "(" + clientVersion + ")");
|
"The server version (" + BuildConfig.VERSION_NAME + ") does not match the client " + "(" + clientVersion + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
final int expectedParameters = 15;
|
final int expectedParameters = 14;
|
||||||
if (args.length != expectedParameters) {
|
if (args.length != expectedParameters) {
|
||||||
throw new IllegalArgumentException("Expecting " + expectedParameters + " parameters");
|
throw new IllegalArgumentException("Expecting " + expectedParameters + " parameters");
|
||||||
}
|
}
|
||||||
@ -169,9 +167,6 @@ public final class Server {
|
|||||||
String codecOptions = args[13];
|
String codecOptions = args[13];
|
||||||
options.setCodecOptions(codecOptions);
|
options.setCodecOptions(codecOptions);
|
||||||
|
|
||||||
String encoderName = "-".equals(args[14]) ? null : args[14];
|
|
||||||
options.setEncoderName(encoderName);
|
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,15 +206,6 @@ public final class Server {
|
|||||||
Ln.e(" scrcpy --display " + id);
|
Ln.e(" scrcpy --display " + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e instanceof InvalidEncoderException) {
|
|
||||||
InvalidEncoderException iee = (InvalidEncoderException) e;
|
|
||||||
MediaCodecInfo[] encoders = iee.getAvailableEncoders();
|
|
||||||
if (encoders != null && encoders.length > 0) {
|
|
||||||
Ln.e("Try to use one of the available encoders:");
|
|
||||||
for (MediaCodecInfo encoder : encoders) {
|
|
||||||
Ln.e(" scrcpy --encoder-name '" + encoder.getName() + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user