Compare commits
9 Commits
fix_audio_
...
pr4075
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03a8a71745 | ||
|
|
a3cdf1a6b8 | ||
|
|
b16d4d1835 | ||
|
|
b8d43866d2 | ||
|
|
2d79aeb117 | ||
|
|
888a5aae7d | ||
|
|
323ea2f1d9 | ||
|
|
9ca554ca41 | ||
|
|
9d3c656414 |
@@ -19,8 +19,9 @@ _scrcpy() {
|
|||||||
-f --fullscreen
|
-f --fullscreen
|
||||||
--force-adb-forward
|
--force-adb-forward
|
||||||
--forward-all-clicks
|
--forward-all-clicks
|
||||||
-K --hid-keyboard
|
|
||||||
-h --help
|
-h --help
|
||||||
|
--kill-adb-on-close
|
||||||
|
-K --hid-keyboard
|
||||||
--legacy-paste
|
--legacy-paste
|
||||||
--list-displays
|
--list-displays
|
||||||
--list-encoders
|
--list-encoders
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ arguments=(
|
|||||||
{-f,--fullscreen}'[Start in fullscreen]'
|
{-f,--fullscreen}'[Start in fullscreen]'
|
||||||
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
|
'--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]'
|
||||||
'--forward-all-clicks[Forward clicks to device]'
|
'--forward-all-clicks[Forward clicks to device]'
|
||||||
{-K,--hid-keyboard}'[Simulate a physical keyboard by using HID over AOAv2]'
|
|
||||||
{-h,--help}'[Print the help]'
|
{-h,--help}'[Print the help]'
|
||||||
|
'--kill-adb-on-close[Kill adb when scrcpy terminates]'
|
||||||
|
{-K,--hid-keyboard}'[Simulate a physical keyboard by using HID over AOAv2]'
|
||||||
'--legacy-paste[Inject computer clipboard text as a sequence of key events on Ctrl+v]'
|
'--legacy-paste[Inject computer clipboard text as a sequence of key events on Ctrl+v]'
|
||||||
'--list-displays[List displays available on the device]'
|
'--list-displays[List displays available on the device]'
|
||||||
'--list-encoders[List video and audio encoders available on the device]'
|
'--list-encoders[List video and audio encoders available on the device]'
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ By default, right-click triggers BACK (or POWER on) and middle-click triggers HO
|
|||||||
.B \-h, \-\-help
|
.B \-h, \-\-help
|
||||||
Print this help.
|
Print this help.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-kill\-adb\-on\-close
|
||||||
|
Kill adb when scrcpy terminates.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-K, \-\-hid\-keyboard
|
.B \-K, \-\-hid\-keyboard
|
||||||
Simulate a physical keyboard by using HID over AOAv2.
|
Simulate a physical keyboard by using HID over AOAv2.
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ enum {
|
|||||||
OPT_NO_AUDIO_PLAYBACK,
|
OPT_NO_AUDIO_PLAYBACK,
|
||||||
OPT_NO_VIDEO_PLAYBACK,
|
OPT_NO_VIDEO_PLAYBACK,
|
||||||
OPT_AUDIO_SOURCE,
|
OPT_AUDIO_SOURCE,
|
||||||
|
OPT_KILL_ADB_ON_CLOSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sc_option {
|
struct sc_option {
|
||||||
@@ -275,6 +276,16 @@ static const struct sc_option options[] = {
|
|||||||
"middle-click triggers HOME. This option disables these "
|
"middle-click triggers HOME. This option disables these "
|
||||||
"shortcuts and forwards the clicks to the device instead.",
|
"shortcuts and forwards the clicks to the device instead.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.shortopt = 'h',
|
||||||
|
.longopt = "help",
|
||||||
|
.text = "Print this help.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.longopt_id = OPT_KILL_ADB_ON_CLOSE,
|
||||||
|
.longopt = "kill-adb-on-close",
|
||||||
|
.text = "Kill adb when scrcpy terminates.",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.shortopt = 'K',
|
.shortopt = 'K',
|
||||||
.longopt = "hid-keyboard",
|
.longopt = "hid-keyboard",
|
||||||
@@ -292,11 +303,6 @@ static const struct sc_option options[] = {
|
|||||||
"is enabled (or a physical keyboard is connected).\n"
|
"is enabled (or a physical keyboard is connected).\n"
|
||||||
"Also see --hid-mouse.",
|
"Also see --hid-mouse.",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.shortopt = 'h',
|
|
||||||
.longopt = "help",
|
|
||||||
.text = "Print this help.",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.longopt_id = OPT_LEGACY_PASTE,
|
.longopt_id = OPT_LEGACY_PASTE,
|
||||||
.longopt = "legacy-paste",
|
.longopt = "legacy-paste",
|
||||||
@@ -1944,6 +1950,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OPT_KILL_ADB_ON_CLOSE:
|
||||||
|
opts->kill_adb_on_close = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// getopt prints the error message on stderr
|
// getopt prints the error message on stderr
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -80,4 +80,5 @@ const struct scrcpy_options scrcpy_options_default = {
|
|||||||
.require_audio = false,
|
.require_audio = false,
|
||||||
.list_encoders = false,
|
.list_encoders = false,
|
||||||
.list_displays = false,
|
.list_displays = false,
|
||||||
|
.kill_adb_on_close = false,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ struct scrcpy_options {
|
|||||||
bool require_audio;
|
bool require_audio;
|
||||||
bool list_encoders;
|
bool list_encoders;
|
||||||
bool list_displays;
|
bool list_displays;
|
||||||
|
bool kill_adb_on_close;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct scrcpy_options scrcpy_options_default;
|
extern const struct scrcpy_options scrcpy_options_default;
|
||||||
|
|||||||
@@ -101,8 +101,9 @@ sc_recorder_write_stream(struct sc_recorder *recorder,
|
|||||||
AVStream *stream = recorder->ctx->streams[st->index];
|
AVStream *stream = recorder->ctx->streams[st->index];
|
||||||
sc_recorder_rescale_packet(stream, packet);
|
sc_recorder_rescale_packet(stream, packet);
|
||||||
if (st->last_pts != AV_NOPTS_VALUE && packet->pts <= st->last_pts) {
|
if (st->last_pts != AV_NOPTS_VALUE && packet->pts <= st->last_pts) {
|
||||||
LOGW("Fixing PTS non monotonically increasing "
|
LOGW("Fixing PTS non monotonically increasing in stream %d "
|
||||||
"(%" PRIi64 " >= %" PRIi64 ")", st->last_pts, packet->pts);
|
"(%" PRIi64 " >= %" PRIi64 ")",
|
||||||
|
st->index, st->last_pts, packet->pts);
|
||||||
packet->pts = ++st->last_pts;
|
packet->pts = ++st->last_pts;
|
||||||
packet->dts = packet->pts;
|
packet->dts = packet->pts;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -364,6 +364,7 @@ scrcpy(struct scrcpy_options *options) {
|
|||||||
.power_on = options->power_on,
|
.power_on = options->power_on,
|
||||||
.list_encoders = options->list_encoders,
|
.list_encoders = options->list_encoders,
|
||||||
.list_displays = options->list_displays,
|
.list_displays = options->list_displays,
|
||||||
|
.kill_adb_on_close = options->kill_adb_on_close,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct sc_server_callbacks cbs = {
|
static const struct sc_server_callbacks cbs = {
|
||||||
|
|||||||
@@ -794,6 +794,15 @@ sc_server_configure_tcpip_unknown_address(struct sc_server *server,
|
|||||||
return sc_server_connect_to_tcpip(server, ip_port);
|
return sc_server_connect_to_tcpip(server, ip_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sc_server_kill_adb_if_requested(struct sc_server *server) {
|
||||||
|
if (server->params.kill_adb_on_close) {
|
||||||
|
LOGI("Killing adb server...");
|
||||||
|
unsigned flags = SC_ADB_NO_STDOUT | SC_ADB_NO_STDERR | SC_ADB_NO_LOGERR;
|
||||||
|
sc_adb_kill_server(&server->intr, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
run_server(void *data) {
|
run_server(void *data) {
|
||||||
struct sc_server *server = data;
|
struct sc_server *server = data;
|
||||||
@@ -805,7 +814,7 @@ run_server(void *data) {
|
|||||||
// is parsed, so it is not output)
|
// is parsed, so it is not output)
|
||||||
bool ok = sc_adb_start_server(&server->intr, 0);
|
bool ok = sc_adb_start_server(&server->intr, 0);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Could not start adb daemon");
|
LOGE("Could not start adb server");
|
||||||
goto error_connection_failed;
|
goto error_connection_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -993,9 +1002,12 @@ run_server(void *data) {
|
|||||||
|
|
||||||
sc_process_close(pid);
|
sc_process_close(pid);
|
||||||
|
|
||||||
|
sc_server_kill_adb_if_requested(server);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_connection_failed:
|
error_connection_failed:
|
||||||
|
sc_server_kill_adb_if_requested(server);
|
||||||
server->cbs->on_connection_failed(server, server->cbs_userdata);
|
server->cbs->on_connection_failed(server, server->cbs_userdata);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ struct sc_server_params {
|
|||||||
bool power_on;
|
bool power_on;
|
||||||
bool list_encoders;
|
bool list_encoders;
|
||||||
bool list_displays;
|
bool list_displays;
|
||||||
|
bool kill_adb_on_close;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sc_server {
|
struct sc_server {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ scrcpy_otg(struct scrcpy_options *options) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// On Windows, only one process could open a USB device
|
// On Windows, only one process could open a USB device
|
||||||
// <https://github.com/Genymobile/scrcpy/issues/2773>
|
// <https://github.com/Genymobile/scrcpy/issues/2773>
|
||||||
LOGI("Killing adb daemon (if any)...");
|
LOGI("Killing adb server (if any)...");
|
||||||
unsigned flags = SC_ADB_NO_STDOUT | SC_ADB_NO_STDERR | SC_ADB_NO_LOGERR;
|
unsigned flags = SC_ADB_NO_STDOUT | SC_ADB_NO_STDERR | SC_ADB_NO_LOGERR;
|
||||||
// uninterruptible (intr == NULL), but in practice it's very quick
|
// uninterruptible (intr == NULL), but in practice it's very quick
|
||||||
sc_adb_kill_server(NULL, flags);
|
sc_adb_kill_server(NULL, flags);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ For example, to use the device as a dictaphone and record a capture directly on
|
|||||||
the computer:
|
the computer:
|
||||||
|
|
||||||
```
|
```
|
||||||
scrcpy --audio-source=mic --no-video --no-audio-playback --record=file.opus
|
scrcpy --audio-source=mic --no-video --no-playback --record=file.opus
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ To record only the audio:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
scrcpy --no-video --record=file.opus
|
scrcpy --no-video --record=file.opus
|
||||||
scrcpy --no-video --audio-codec=aac --record-file=file.aac
|
scrcpy --no-video --audio-codec=aac --record=file.aac
|
||||||
# .m4a/.mp4 and .mka/.mkv are also supported for both opus and aac
|
# .m4a/.mp4 and .mka/.mkv are also supported for both opus and aac
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ public final class InputManager {
|
|||||||
public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT = 1;
|
public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_RESULT = 1;
|
||||||
public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2;
|
public static final int INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH = 2;
|
||||||
|
|
||||||
private final android.hardware.input.InputManager manager;
|
private final Object manager;
|
||||||
private Method injectInputEventMethod;
|
private Method injectInputEventMethod;
|
||||||
|
|
||||||
private static Method setDisplayIdMethod;
|
private static Method setDisplayIdMethod;
|
||||||
private static Method setActionButtonMethod;
|
private static Method setActionButtonMethod;
|
||||||
|
|
||||||
public InputManager(android.hardware.input.InputManager manager) {
|
public InputManager(Object manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,11 +62,21 @@ public final class ServiceManager {
|
|||||||
return displayManager;
|
return displayManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Class<?> getInputManagerClass() {
|
||||||
|
try {
|
||||||
|
// Parts of the InputManager class have been moved to a new InputManagerGlobal class in Android 14 preview
|
||||||
|
return Class.forName("android.hardware.input.InputManagerGlobal");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return android.hardware.input.InputManager.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static InputManager getInputManager() {
|
public static InputManager getInputManager() {
|
||||||
if (inputManager == null) {
|
if (inputManager == null) {
|
||||||
try {
|
try {
|
||||||
Method getInstanceMethod = android.hardware.input.InputManager.class.getDeclaredMethod("getInstance");
|
Class<?> inputManagerClass = getInputManagerClass();
|
||||||
android.hardware.input.InputManager im = (android.hardware.input.InputManager) getInstanceMethod.invoke(null);
|
Method getInstanceMethod = inputManagerClass.getDeclaredMethod("getInstance");
|
||||||
|
Object im = (android.hardware.input.InputManager) getInstanceMethod.invoke(null);
|
||||||
inputManager = new InputManager(im);
|
inputManager = new InputManager(im);
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user