Compare commits
1 Commits
upgrade
...
hw_dec_poc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be6c6325d9 |
@@ -448,9 +448,6 @@ scrcpy --serial 0123456789abcdef
|
|||||||
scrcpy -s 0123456789abcdef # short version
|
scrcpy -s 0123456789abcdef # short version
|
||||||
```
|
```
|
||||||
|
|
||||||
The serial may also be provided via the environment variable `ANDROID_SERIAL`
|
|
||||||
(also used by `adb`).
|
|
||||||
|
|
||||||
If the device is connected over TCP/IP:
|
If the device is connected over TCP/IP:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -143,12 +143,12 @@ else
|
|||||||
|
|
||||||
prebuilt_libusb = meson.get_cross_property('prebuilt_libusb')
|
prebuilt_libusb = meson.get_cross_property('prebuilt_libusb')
|
||||||
prebuilt_libusb_root = meson.get_cross_property('prebuilt_libusb_root')
|
prebuilt_libusb_root = meson.get_cross_property('prebuilt_libusb_root')
|
||||||
libusb_bin_dir = meson.current_source_dir() + '/prebuilt-deps/data/' + prebuilt_libusb
|
libusb_bin_dir = meson.current_source_dir() + '/prebuilt-deps/data/' + prebuilt_libusb + '/dll'
|
||||||
libusb_include_dir = 'prebuilt-deps/data/' + prebuilt_libusb_root + '/include'
|
libusb_include_dir = 'prebuilt-deps/data/' + prebuilt_libusb_root + '/include'
|
||||||
|
|
||||||
libusb = declare_dependency(
|
libusb = declare_dependency(
|
||||||
dependencies: [
|
dependencies: [
|
||||||
cc.find_library('msys-usb-1.0', dirs: libusb_bin_dir),
|
cc.find_library('libusb-1.0', dirs: libusb_bin_dir),
|
||||||
],
|
],
|
||||||
include_directories: include_directories(libusb_include_dir)
|
include_directories: include_directories(libusb_include_dir)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
DEP_DIR=platform-tools-33.0.1
|
DEP_DIR=platform-tools-31.0.3
|
||||||
|
|
||||||
FILENAME=platform-tools_r33.0.1-windows.zip
|
FILENAME=platform-tools_r31.0.3-windows.zip
|
||||||
SHA256SUM=c1f02d42ea24ef4ff2a405ae7370e764ef4546f9b3e4520f5571a00ed5012c42
|
SHA256SUM=0f4b8fdd26af2c3733539d6eebb3c2ed499ea1d4bb1f4e0ecc2d6016961a6e24
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
DEP_DIR=libusb-1.0.26
|
DEP_DIR=libusb-1.0.25
|
||||||
|
|
||||||
FILENAME=libusb-1.0.26-binaries.7z
|
FILENAME=libusb-1.0.25.7z
|
||||||
SHA256SUM=9c242696342dbde9cdc47239391f71833939bf9f7aa2bbb28cdaabe890465ec5
|
SHA256SUM=3d1c98416f454026034b2b5d67f8a294053898cb70a8b489874e75b136c6674d
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
then
|
then
|
||||||
@@ -17,18 +17,12 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_file "https://github.com/libusb/libusb/releases/download/v1.0.26/$FILENAME" "$FILENAME" "$SHA256SUM"
|
get_file "https://github.com/libusb/libusb/releases/download/v1.0.25/$FILENAME" "$FILENAME" "$SHA256SUM"
|
||||||
|
|
||||||
mkdir "$DEP_DIR"
|
mkdir "$DEP_DIR"
|
||||||
cd "$DEP_DIR"
|
cd "$DEP_DIR"
|
||||||
|
|
||||||
# include/ is the same in all folders of the archive
|
|
||||||
7z x "../$FILENAME" \
|
7z x "../$FILENAME" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-Win32/bin/msys-usb-1.0.dll \
|
MinGW32/dll/libusb-1.0.dll \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-x64/bin/msys-usb-1.0.dll \
|
MinGW64/dll/libusb-1.0.dll \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-x64/include/
|
include /
|
||||||
|
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-Win32/bin MinGW-Win32
|
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-x64/bin MinGW-x64
|
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-x64/include .
|
|
||||||
rm -rf libusb-1.0.26-binaries
|
|
||||||
|
|||||||
@@ -477,10 +477,6 @@ Push file to device (see \fB\-\-push\-target\fR)
|
|||||||
.B ADB
|
.B ADB
|
||||||
Path to adb.
|
Path to adb.
|
||||||
|
|
||||||
.TP
|
|
||||||
.B ANDROID_SERIAL
|
|
||||||
Device serial to use if no selector (-s, -d, -e or --tcpip=<addr>) is specified.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B SCRCPY_ICON_PATH
|
.B SCRCPY_ICON_PATH
|
||||||
Path to the program icon.
|
Path to the program icon.
|
||||||
|
|||||||
@@ -473,12 +473,9 @@ sc_adb_accept_device(const struct sc_adb_device *device,
|
|||||||
}
|
}
|
||||||
return !strcmp(selector->serial, device->serial);
|
return !strcmp(selector->serial, device->serial);
|
||||||
case SC_ADB_DEVICE_SELECT_USB:
|
case SC_ADB_DEVICE_SELECT_USB:
|
||||||
return sc_adb_device_get_type(device->serial) ==
|
return !sc_adb_is_serial_tcpip(device->serial);
|
||||||
SC_ADB_DEVICE_TYPE_USB;
|
|
||||||
case SC_ADB_DEVICE_SELECT_TCPIP:
|
case SC_ADB_DEVICE_SELECT_TCPIP:
|
||||||
// Both emulators and TCP/IP devices are selected via -e
|
return sc_adb_is_serial_tcpip(device->serial);
|
||||||
return sc_adb_device_get_type(device->serial) !=
|
|
||||||
SC_ADB_DEVICE_TYPE_USB;
|
|
||||||
default:
|
default:
|
||||||
assert(!"Missing SC_ADB_DEVICE_SELECT_* handling");
|
assert(!"Missing SC_ADB_DEVICE_SELECT_* handling");
|
||||||
break;
|
break;
|
||||||
@@ -512,10 +509,8 @@ sc_adb_devices_log(enum sc_log_level level, struct sc_adb_device *devices,
|
|||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
struct sc_adb_device *d = &devices[i];
|
struct sc_adb_device *d = &devices[i];
|
||||||
const char *selection = d->selected ? "-->" : " ";
|
const char *selection = d->selected ? "-->" : " ";
|
||||||
bool is_usb =
|
const char *type = sc_adb_is_serial_tcpip(d->serial) ? "(tcpip)"
|
||||||
sc_adb_device_get_type(d->serial) == SC_ADB_DEVICE_TYPE_USB;
|
: " (usb)";
|
||||||
const char *type = is_usb ? " (usb)"
|
|
||||||
: "(tcpip)";
|
|
||||||
LOG(level, " %s %s %-20s %16s %s",
|
LOG(level, " %s %s %-20s %16s %s",
|
||||||
selection, type, d->serial, d->state, d->model ? d->model : "");
|
selection, type, d->serial, d->state, d->model ? d->model : "");
|
||||||
}
|
}
|
||||||
@@ -536,8 +531,6 @@ sc_adb_device_check_state(struct sc_adb_device *device,
|
|||||||
LOGE("A popup should open on the device to request authorization.");
|
LOGE("A popup should open on the device to request authorization.");
|
||||||
LOGE("Check the FAQ: "
|
LOGE("Check the FAQ: "
|
||||||
"<https://github.com/Genymobile/scrcpy/blob/master/FAQ.md>");
|
"<https://github.com/Genymobile/scrcpy/blob/master/FAQ.md>");
|
||||||
} else {
|
|
||||||
LOGE("Device could not be connected (state=%s)", state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -712,3 +705,8 @@ sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags) {
|
|||||||
|
|
||||||
return sc_adb_parse_device_ip_from_output(buf);
|
return sc_adb_parse_device_ip_from_output(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_adb_is_serial_tcpip(const char *serial) {
|
||||||
|
return strchr(serial, ':');
|
||||||
|
}
|
||||||
|
|||||||
@@ -114,4 +114,13 @@ sc_adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
|||||||
char *
|
char *
|
||||||
sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags);
|
sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate if the serial represents an IP address
|
||||||
|
*
|
||||||
|
* In practice, it just returns true if and only if it contains a ':', which is
|
||||||
|
* sufficient to distinguish an ip:port from a real USB serial.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
sc_adb_is_serial_tcpip(const char *serial);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "adb_device.h"
|
#include "adb_device.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_adb_device_destroy(struct sc_adb_device *device) {
|
sc_adb_device_destroy(struct sc_adb_device *device) {
|
||||||
@@ -26,18 +25,3 @@ sc_adb_devices_destroy(struct sc_vec_adb_devices *devices) {
|
|||||||
sc_vector_destroy(devices);
|
sc_vector_destroy(devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum sc_adb_device_type
|
|
||||||
sc_adb_device_get_type(const char *serial) {
|
|
||||||
// Starts with "emulator-"
|
|
||||||
if (!strncmp(serial, "emulator-", sizeof("emulator-") - 1)) {
|
|
||||||
return SC_ADB_DEVICE_TYPE_EMULATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the serial contains a ':', then it is a TCP/IP device (it is
|
|
||||||
// sufficient to distinguish an ip:port from a real USB serial)
|
|
||||||
if (strchr(serial, ':')) {
|
|
||||||
return SC_ADB_DEVICE_TYPE_TCPIP;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SC_ADB_DEVICE_TYPE_USB;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ struct sc_adb_device {
|
|||||||
bool selected;
|
bool selected;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum sc_adb_device_type {
|
|
||||||
SC_ADB_DEVICE_TYPE_USB,
|
|
||||||
SC_ADB_DEVICE_TYPE_TCPIP,
|
|
||||||
SC_ADB_DEVICE_TYPE_EMULATOR,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sc_vec_adb_devices SC_VECTOR(struct sc_adb_device);
|
struct sc_vec_adb_devices SC_VECTOR(struct sc_adb_device);
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -41,10 +35,4 @@ sc_adb_device_move(struct sc_adb_device *dst, struct sc_adb_device *src);
|
|||||||
void
|
void
|
||||||
sc_adb_devices_destroy(struct sc_vec_adb_devices *devices);
|
sc_adb_devices_destroy(struct sc_vec_adb_devices *devices);
|
||||||
|
|
||||||
/**
|
|
||||||
* Deduce the device type from the serial
|
|
||||||
*/
|
|
||||||
enum sc_adb_device_type
|
|
||||||
sc_adb_device_get_type(const char *serial);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -660,11 +660,6 @@ static const struct sc_envvar envvars[] = {
|
|||||||
.name = "ADB",
|
.name = "ADB",
|
||||||
.text = "Path to adb executable",
|
.text = "Path to adb executable",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.name = "ANDROID_SERIAL",
|
|
||||||
.text = "Device serial to use if no selector (-s, -d, -e or "
|
|
||||||
"--tcpip=<addr>) is specified",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
.name = "SCRCPY_ICON_PATH",
|
.name = "SCRCPY_ICON_PATH",
|
||||||
.text = "Path to the program icon",
|
.text = "Path to the program icon",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_COMMON_H
|
#ifndef COMMON_H
|
||||||
#define SC_COMMON_H
|
#define COMMON_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_COMPAT_H
|
#ifndef COMPAT_H
|
||||||
#define SC_COMPAT_H
|
#define COMPAT_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_CONTROLMSG_H
|
#ifndef CONTROLMSG_H
|
||||||
#define SC_CONTROLMSG_H
|
#define CONTROLMSG_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_CONTROLLER_H
|
#ifndef CONTROLLER_H
|
||||||
#define SC_CONTROLLER_H
|
#define CONTROLLER_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
|
#include <libavutil/pixdesc.h>
|
||||||
|
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
#include "video_buffer.h"
|
#include "video_buffer.h"
|
||||||
@@ -11,6 +12,39 @@
|
|||||||
/** Downcast packet_sink to decoder */
|
/** Downcast packet_sink to decoder */
|
||||||
#define DOWNCAST(SINK) container_of(SINK, struct sc_decoder, packet_sink)
|
#define DOWNCAST(SINK) container_of(SINK, struct sc_decoder, packet_sink)
|
||||||
|
|
||||||
|
static int hw_decoder_init(struct sc_decoder *decoder, const enum AVHWDeviceType type)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
AVBufferRef *hw_device_ctx;
|
||||||
|
if ((err = av_hwdevice_ctx_create(&hw_device_ctx, type,
|
||||||
|
NULL, NULL, 0)) < 0) {
|
||||||
|
LOGE("Failed to create specified HW device.");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
decoder->codec_ctx->hw_device_ctx = av_buffer_ref(hw_device_ctx);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum AVPixelFormat get_hw_format(AVCodecContext *ctx,
|
||||||
|
const enum AVPixelFormat *pix_fmts)
|
||||||
|
{
|
||||||
|
(void) ctx;
|
||||||
|
const enum AVPixelFormat *p;
|
||||||
|
|
||||||
|
LOGD("== get_hw_format ==");
|
||||||
|
|
||||||
|
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
|
||||||
|
LOGD("==== %s (%d)", av_get_pix_fmt_name(*p), *p);
|
||||||
|
if (*p == AV_PIX_FMT_VAAPI)
|
||||||
|
return *p;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGE("Failed to get HW surface format.");
|
||||||
|
return AV_PIX_FMT_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sc_decoder_close_first_sinks(struct sc_decoder *decoder, unsigned count) {
|
sc_decoder_close_first_sinks(struct sc_decoder *decoder, unsigned count) {
|
||||||
while (count) {
|
while (count) {
|
||||||
@@ -48,6 +82,10 @@ sc_decoder_open(struct sc_decoder *decoder, const AVCodec *codec) {
|
|||||||
|
|
||||||
decoder->codec_ctx->flags |= AV_CODEC_FLAG_LOW_DELAY;
|
decoder->codec_ctx->flags |= AV_CODEC_FLAG_LOW_DELAY;
|
||||||
|
|
||||||
|
int r = hw_decoder_init(decoder, AV_HWDEVICE_TYPE_VAAPI);
|
||||||
|
assert(!r);
|
||||||
|
decoder->codec_ctx->get_format = get_hw_format;
|
||||||
|
|
||||||
if (avcodec_open2(decoder->codec_ctx, codec, NULL) < 0) {
|
if (avcodec_open2(decoder->codec_ctx, codec, NULL) < 0) {
|
||||||
LOGE("Could not open codec");
|
LOGE("Could not open codec");
|
||||||
avcodec_free_context(&decoder->codec_ctx);
|
avcodec_free_context(&decoder->codec_ctx);
|
||||||
@@ -62,6 +100,9 @@ sc_decoder_open(struct sc_decoder *decoder, const AVCodec *codec) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
decoder->hw_frame = av_frame_alloc();
|
||||||
|
assert(decoder->hw_frame);
|
||||||
|
|
||||||
if (!sc_decoder_open_sinks(decoder)) {
|
if (!sc_decoder_open_sinks(decoder)) {
|
||||||
LOGE("Could not open decoder sinks");
|
LOGE("Could not open decoder sinks");
|
||||||
av_frame_free(&decoder->frame);
|
av_frame_free(&decoder->frame);
|
||||||
@@ -76,6 +117,7 @@ sc_decoder_open(struct sc_decoder *decoder, const AVCodec *codec) {
|
|||||||
static void
|
static void
|
||||||
sc_decoder_close(struct sc_decoder *decoder) {
|
sc_decoder_close(struct sc_decoder *decoder) {
|
||||||
sc_decoder_close_sinks(decoder);
|
sc_decoder_close_sinks(decoder);
|
||||||
|
av_frame_free(&decoder->hw_frame);
|
||||||
av_frame_free(&decoder->frame);
|
av_frame_free(&decoder->frame);
|
||||||
avcodec_close(decoder->codec_ctx);
|
avcodec_close(decoder->codec_ctx);
|
||||||
avcodec_free_context(&decoder->codec_ctx);
|
avcodec_free_context(&decoder->codec_ctx);
|
||||||
@@ -107,15 +149,26 @@ sc_decoder_push(struct sc_decoder *decoder, const AVPacket *packet) {
|
|||||||
LOGE("Could not send video packet: %d", ret);
|
LOGE("Could not send video packet: %d", ret);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ret = avcodec_receive_frame(decoder->codec_ctx, decoder->frame);
|
ret = avcodec_receive_frame(decoder->codec_ctx, decoder->hw_frame);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
// a frame was received
|
// a frame was received
|
||||||
|
|
||||||
|
sc_tick t = sc_tick_now();
|
||||||
|
ret = av_hwframe_transfer_data(decoder->frame, decoder->hw_frame, 0);
|
||||||
|
if (ret < 0) {
|
||||||
|
LOGE("HWFRAME transfer fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGD("av_hwframe_transfer_data: %ld", sc_tick_now() - t);
|
||||||
|
|
||||||
bool ok = push_frame_to_sinks(decoder, decoder->frame);
|
bool ok = push_frame_to_sinks(decoder, decoder->frame);
|
||||||
// A frame lost should not make the whole pipeline fail. The error, if
|
// A frame lost should not make the whole pipeline fail. The error, if
|
||||||
// any, is already logged.
|
// any, is already logged.
|
||||||
(void) ok;
|
(void) ok;
|
||||||
|
|
||||||
av_frame_unref(decoder->frame);
|
av_frame_unref(decoder->frame);
|
||||||
|
av_frame_unref(decoder->hw_frame);
|
||||||
} else if (ret != AVERROR(EAGAIN)) {
|
} else if (ret != AVERROR(EAGAIN)) {
|
||||||
LOGE("Could not receive video frame: %d", ret);
|
LOGE("Could not receive video frame: %d", ret);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ struct sc_decoder {
|
|||||||
|
|
||||||
AVCodecContext *codec_ctx;
|
AVCodecContext *codec_ctx;
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
|
AVFrame *hw_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_DEVICEMSG_H
|
#ifndef DEVICEMSG_H
|
||||||
#define SC_DEVICEMSG_H
|
#define DEVICEMSG_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_FPSCOUNTER_H
|
#ifndef FPSCOUNTER_H
|
||||||
#define SC_FPSCOUNTER_H
|
#define FPSCOUNTER_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_ICON_H
|
#ifndef ICON_H
|
||||||
#define SC_ICON_H
|
#define ICON_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_INPUTMANAGER_H
|
#ifndef INPUTMANAGER_H
|
||||||
#define SC_INPUTMANAGER_H
|
#define INPUTMANAGER_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ sc_opengl_init(struct sc_opengl *gl) {
|
|||||||
sizeof(OPENGL_ES_PREFIX) - 1);
|
sizeof(OPENGL_ES_PREFIX) - 1);
|
||||||
if (gl->is_opengles) {
|
if (gl->is_opengles) {
|
||||||
/* skip the prefix */
|
/* skip the prefix */
|
||||||
version += sizeof(OPENGL_ES_PREFIX) - 1;
|
version += sizeof(PREFIX) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = sscanf(version, "%d.%d", &gl->version_major, &gl->version_minor);
|
int r = sscanf(version, "%d.%d", &gl->version_major, &gl->version_minor);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_RECEIVER_H
|
#ifndef RECEIVER_H
|
||||||
#define SC_RECEIVER_H
|
#define RECEIVER_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ static inline SDL_Texture *
|
|||||||
create_texture(struct sc_screen *screen) {
|
create_texture(struct sc_screen *screen) {
|
||||||
SDL_Renderer *renderer = screen->renderer;
|
SDL_Renderer *renderer = screen->renderer;
|
||||||
struct sc_size size = screen->frame_size;
|
struct sc_size size = screen->frame_size;
|
||||||
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12,
|
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_NV12,
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
SDL_TEXTUREACCESS_STREAMING,
|
||||||
size.width, size.height);
|
size.width, size.height);
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
@@ -711,10 +711,11 @@ prepare_for_frame(struct sc_screen *screen, struct sc_size new_frame_size) {
|
|||||||
// write the frame into the texture
|
// write the frame into the texture
|
||||||
static void
|
static void
|
||||||
update_texture(struct sc_screen *screen, const AVFrame *frame) {
|
update_texture(struct sc_screen *screen, const AVFrame *frame) {
|
||||||
SDL_UpdateYUVTexture(screen->texture, NULL,
|
// SDL_UpdateYUVTexture(screen->texture, NULL,
|
||||||
frame->data[0], frame->linesize[0],
|
// frame->data[0], frame->linesize[0],
|
||||||
frame->data[1], frame->linesize[1],
|
// frame->data[1], frame->linesize[1],
|
||||||
frame->data[2], frame->linesize[2]);
|
// frame->data[2], frame->linesize[2]);
|
||||||
|
SDL_UpdateTexture(screen->texture, NULL, frame->data[0], frame->linesize[0]);
|
||||||
|
|
||||||
if (screen->mipmaps) {
|
if (screen->mipmaps) {
|
||||||
SDL_GL_BindTexture(screen->texture, NULL, NULL);
|
SDL_GL_BindTexture(screen->texture, NULL, NULL);
|
||||||
|
|||||||
@@ -649,8 +649,7 @@ sc_server_configure_tcpip_known_address(struct sc_server *server,
|
|||||||
static bool
|
static bool
|
||||||
sc_server_configure_tcpip_unknown_address(struct sc_server *server,
|
sc_server_configure_tcpip_unknown_address(struct sc_server *server,
|
||||||
const char *serial) {
|
const char *serial) {
|
||||||
bool is_already_tcpip =
|
bool is_already_tcpip = sc_adb_is_serial_tcpip(serial);
|
||||||
sc_adb_device_get_type(serial) == SC_ADB_DEVICE_TYPE_TCPIP;
|
|
||||||
if (is_already_tcpip) {
|
if (is_already_tcpip) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
LOGI("Device already connected via TCP/IP: %s", serial);
|
LOGI("Device already connected via TCP/IP: %s", serial);
|
||||||
@@ -708,15 +707,7 @@ run_server(void *data) {
|
|||||||
} else if (params->select_tcpip) {
|
} else if (params->select_tcpip) {
|
||||||
selector.type = SC_ADB_DEVICE_SELECT_TCPIP;
|
selector.type = SC_ADB_DEVICE_SELECT_TCPIP;
|
||||||
} else {
|
} else {
|
||||||
// No explicit selection, check $ANDROID_SERIAL
|
selector.type = SC_ADB_DEVICE_SELECT_ALL;
|
||||||
const char *env_serial = getenv("ANDROID_SERIAL");
|
|
||||||
if (env_serial) {
|
|
||||||
LOGI("Using ANDROID_SERIAL: %s", env_serial);
|
|
||||||
selector.type = SC_ADB_DEVICE_SELECT_SERIAL;
|
|
||||||
selector.serial = env_serial;
|
|
||||||
} else {
|
|
||||||
selector.type = SC_ADB_DEVICE_SELECT_ALL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
struct sc_adb_device device;
|
struct sc_adb_device device;
|
||||||
ok = sc_adb_select_device(&server->intr, &selector, 0, &device);
|
ok = sc_adb_select_device(&server->intr, &selector, 0, &device);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// generic circular buffer (bounded queue) implementation
|
// generic circular buffer (bounded queue) implementation
|
||||||
#ifndef SC_CBUF_H
|
#ifndef CBUF_H
|
||||||
#define SC_CBUF_H
|
#define CBUF_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef SC_NET_H
|
#ifndef NET_H
|
||||||
#define SC_NET_H
|
#define NET_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ ffmpeg_avformat = 'avformat-58'
|
|||||||
ffmpeg_avutil = 'avutil-56'
|
ffmpeg_avutil = 'avutil-56'
|
||||||
prebuilt_ffmpeg = 'ffmpeg-win32-4.3.1'
|
prebuilt_ffmpeg = 'ffmpeg-win32-4.3.1'
|
||||||
prebuilt_sdl2 = 'SDL2-2.0.20/i686-w64-mingw32'
|
prebuilt_sdl2 = 'SDL2-2.0.20/i686-w64-mingw32'
|
||||||
prebuilt_libusb_root = 'libusb-1.0.26'
|
prebuilt_libusb_root = 'libusb-1.0.25'
|
||||||
prebuilt_libusb = prebuilt_libusb_root + '/MinGW-Win32'
|
prebuilt_libusb = prebuilt_libusb_root + '/MinGW32'
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ ffmpeg_avformat = 'avformat-59'
|
|||||||
ffmpeg_avutil = 'avutil-57'
|
ffmpeg_avutil = 'avutil-57'
|
||||||
prebuilt_ffmpeg = 'ffmpeg-win64-5.0'
|
prebuilt_ffmpeg = 'ffmpeg-win64-5.0'
|
||||||
prebuilt_sdl2 = 'SDL2-2.0.20/x86_64-w64-mingw32'
|
prebuilt_sdl2 = 'SDL2-2.0.20/x86_64-w64-mingw32'
|
||||||
prebuilt_libusb_root = 'libusb-1.0.26'
|
prebuilt_libusb_root = 'libusb-1.0.25'
|
||||||
prebuilt_libusb = prebuilt_libusb_root + '/MinGW-x64'
|
prebuilt_libusb = prebuilt_libusb_root + '/MinGW64'
|
||||||
|
|||||||
@@ -75,10 +75,12 @@ prepare-deps-win64:
|
|||||||
@app/prebuilt-deps/prepare-libusb.sh
|
@app/prebuilt-deps/prepare-libusb.sh
|
||||||
|
|
||||||
build-win32: prepare-deps-win32
|
build-win32: prepare-deps-win32
|
||||||
|
# -Dusb=false because of libusb-win32 build issue, cf #3011
|
||||||
[ -d "$(WIN32_BUILD_DIR)" ] || ( mkdir "$(WIN32_BUILD_DIR)" && \
|
[ -d "$(WIN32_BUILD_DIR)" ] || ( mkdir "$(WIN32_BUILD_DIR)" && \
|
||||||
meson "$(WIN32_BUILD_DIR)" \
|
meson "$(WIN32_BUILD_DIR)" \
|
||||||
--cross-file cross_win32.txt \
|
--cross-file cross_win32.txt \
|
||||||
--buildtype release --strip -Db_lto=true \
|
--buildtype release --strip -Db_lto=true \
|
||||||
|
-Dusb=false \
|
||||||
-Dcompile_server=false \
|
-Dcompile_server=false \
|
||||||
-Dportable=true )
|
-Dportable=true )
|
||||||
ninja -C "$(WIN32_BUILD_DIR)"
|
ninja -C "$(WIN32_BUILD_DIR)"
|
||||||
@@ -109,7 +111,7 @@ dist-win32: build-server build-win32
|
|||||||
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/SDL2-2.0.20/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/SDL2-2.0.20/i686-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/libusb-1.0.26/MinGW-Win32/msys-usb-1.0.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
#cp app/prebuilt-deps/data/libusb-1.0.25/MinGW32/dll/libusb-1.0.dll "$(DIST)/$(WIN32_TARGET_DIR)/"
|
||||||
|
|
||||||
dist-win64: build-server build-win64
|
dist-win64: build-server build-win64
|
||||||
mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
|
mkdir -p "$(DIST)/$(WIN64_TARGET_DIR)"
|
||||||
@@ -128,7 +130,7 @@ dist-win64: build-server build-win64
|
|||||||
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/platform-tools-31.0.3/AdbWinUsbApi.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/SDL2-2.0.20/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/SDL2-2.0.20/x86_64-w64-mingw32/bin/SDL2.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
cp app/prebuilt-deps/data/libusb-1.0.26/MinGW-x64/msys-usb-1.0.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
cp app/prebuilt-deps/data/libusb-1.0.25/MinGW64/dll/libusb-1.0.dll "$(DIST)/$(WIN64_TARGET_DIR)/"
|
||||||
|
|
||||||
zip-win32: dist-win32
|
zip-win32: dist-win32
|
||||||
cd "$(DIST)/$(WIN32_TARGET_DIR)"; \
|
cd "$(DIST)/$(WIN32_TARGET_DIR)"; \
|
||||||
|
|||||||
2
run
2
run
@@ -20,6 +20,6 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCRCPY_ICON_PATH="app/data/icon.png" \
|
SCRCPY_ICON_PATH="data/icon.png" \
|
||||||
SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" \
|
SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" \
|
||||||
"$BUILDDIR/app/scrcpy" "$@"
|
"$BUILDDIR/app/scrcpy" "$@"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.genymobile.scrcpy.wrappers;
|
|||||||
|
|
||||||
import com.genymobile.scrcpy.Ln;
|
import com.genymobile.scrcpy.Ln;
|
||||||
|
|
||||||
|
import android.os.IInterface;
|
||||||
import android.view.InputEvent;
|
import android.view.InputEvent;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -13,18 +14,24 @@ 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 IInterface manager;
|
||||||
private Method injectInputEventMethod;
|
private Method injectInputEventMethod;
|
||||||
|
private boolean alternativeInjectInputEventMethod;
|
||||||
|
|
||||||
private static Method setDisplayIdMethod;
|
private static Method setDisplayIdMethod;
|
||||||
|
|
||||||
public InputManager(android.hardware.input.InputManager manager) {
|
public InputManager(IInterface manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Method getInjectInputEventMethod() throws NoSuchMethodException {
|
private Method getInjectInputEventMethod() throws NoSuchMethodException {
|
||||||
if (injectInputEventMethod == null) {
|
if (injectInputEventMethod == null) {
|
||||||
injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class);
|
try {
|
||||||
|
injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
injectInputEventMethod = manager.getClass().getMethod("injectInputEvent", InputEvent.class, int.class, int.class);
|
||||||
|
alternativeInjectInputEventMethod = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return injectInputEventMethod;
|
return injectInputEventMethod;
|
||||||
}
|
}
|
||||||
@@ -32,6 +39,10 @@ public final class InputManager {
|
|||||||
public boolean injectInputEvent(InputEvent inputEvent, int mode) {
|
public boolean injectInputEvent(InputEvent inputEvent, int mode) {
|
||||||
try {
|
try {
|
||||||
Method method = getInjectInputEventMethod();
|
Method method = getInjectInputEventMethod();
|
||||||
|
if (alternativeInjectInputEventMethod) {
|
||||||
|
// See <https://github.com/Genymobile/scrcpy/issues/2250>
|
||||||
|
return (boolean) method.invoke(manager, inputEvent, mode, 0);
|
||||||
|
}
|
||||||
return (boolean) method.invoke(manager, inputEvent, mode);
|
return (boolean) method.invoke(manager, inputEvent, mode);
|
||||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
Ln.e("Could not invoke method", e);
|
Ln.e("Could not invoke method", e);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.IInterface;
|
import android.os.IInterface;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
@SuppressLint("PrivateApi,DiscouragedPrivateApi")
|
@SuppressLint("PrivateApi,DiscouragedPrivateApi")
|
||||||
@@ -57,13 +56,7 @@ public final class ServiceManager {
|
|||||||
|
|
||||||
public InputManager getInputManager() {
|
public InputManager getInputManager() {
|
||||||
if (inputManager == null) {
|
if (inputManager == null) {
|
||||||
try {
|
inputManager = new InputManager(getService("input", "android.hardware.input.IInputManager"));
|
||||||
Method getInstanceMethod = android.hardware.input.InputManager.class.getDeclaredMethod("getInstance");
|
|
||||||
android.hardware.input.InputManager im = (android.hardware.input.InputManager) getInstanceMethod.invoke(null);
|
|
||||||
inputManager = new InputManager(im);
|
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return inputManager;
|
return inputManager;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user