Compare commits
10 Commits
broadcast
...
fix_androi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29b47ad5ac | ||
|
|
a1f2094787 | ||
|
|
9b89b7ab72 | ||
|
|
7343b233e4 | ||
|
|
cd2894570d | ||
|
|
4af317d40d | ||
|
|
318b6a572e | ||
|
|
e8b053ad2f | ||
|
|
a5d71eee45 | ||
|
|
af228706f1 |
@@ -303,7 +303,8 @@ To start scrcpy using a v4l2 sink:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
scrcpy --v4l2-sink=/dev/videoN
|
scrcpy --v4l2-sink=/dev/videoN
|
||||||
scrcpy --v4l2-sink=/dev/videoN -N # --no-display to disable mirroring window
|
scrcpy --v4l2-sink=/dev/videoN --no-display # disable mirroring window
|
||||||
|
scrcpy --v4l2-sink=/dev/videoN -N # short version
|
||||||
```
|
```
|
||||||
|
|
||||||
(replace `N` by the device ID, check with `ls /dev/video*`)
|
(replace `N` by the device ID, check with `ls /dev/video*`)
|
||||||
@@ -709,15 +710,15 @@ There is no visual feedback, a log is printed to the console.
|
|||||||
|
|
||||||
#### Push file to device
|
#### Push file to device
|
||||||
|
|
||||||
To push a file to `/sdcard/` on the device, drag & drop a (non-APK) file to the
|
To push a file to `/sdcard/Download/` on the device, drag & drop a (non-APK)
|
||||||
_scrcpy_ window.
|
file to the _scrcpy_ window.
|
||||||
|
|
||||||
There is no visual feedback, a log is printed to the console.
|
There is no visual feedback, a log is printed to the console.
|
||||||
|
|
||||||
The target directory can be changed on start:
|
The target directory can be changed on start:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
scrcpy --push-target=/sdcard/Download/
|
scrcpy --push-target=/sdcard/Movies/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ but breaks the expected behavior of alpha keys in games (typically WASD).
|
|||||||
.BI "\-\-push\-target " path
|
.BI "\-\-push\-target " path
|
||||||
Set the target directory for pushing files to the device by drag & drop. It is passed as\-is to "adb push".
|
Set the target directory for pushing files to the device by drag & drop. It is passed as\-is to "adb push".
|
||||||
|
|
||||||
Default is "/sdcard/".
|
Default is "/sdcard/Download/".
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-r, \-\-record " file
|
.BI "\-r, \-\-record " file
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
" --push-target path\n"
|
" --push-target path\n"
|
||||||
" Set the target directory for pushing files to the device by\n"
|
" Set the target directory for pushing files to the device by\n"
|
||||||
" drag & drop. It is passed as-is to \"adb push\".\n"
|
" drag & drop. It is passed as-is to \"adb push\".\n"
|
||||||
" Default is \"/sdcard/\".\n"
|
" Default is \"/sdcard/Download/\".\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -r, --record file.mp4\n"
|
" -r, --record file.mp4\n"
|
||||||
" Record screen to file.\n"
|
" Record screen to file.\n"
|
||||||
|
|||||||
@@ -22,6 +22,18 @@
|
|||||||
# define SCRCPY_LAVF_REQUIRES_REGISTER_ALL
|
# define SCRCPY_LAVF_REQUIRES_REGISTER_ALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// In ffmpeg/doc/APIchanges:
|
||||||
|
// 2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
|
||||||
|
// Deprecate AVFormatContext filename field which had limited length, use the
|
||||||
|
// new dynamically allocated url field instead.
|
||||||
|
//
|
||||||
|
// 2018-01-28 - ea3672b7d6 - lavf 58.7.100 - avformat.h
|
||||||
|
// Add url field to AVFormatContext and add ff_format_set_url helper function.
|
||||||
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 100)
|
||||||
|
# define SCRCPY_LAVF_HAS_AVFORMATCONTEXT_URL
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
#if SDL_VERSION_ATLEAST(2, 0, 5)
|
||||||
// <https://wiki.libsdl.org/SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH>
|
// <https://wiki.libsdl.org/SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH>
|
||||||
# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH
|
# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH
|
||||||
|
|||||||
@@ -80,13 +80,6 @@ control_msg_serialize(const struct control_msg *msg, unsigned char *buf) {
|
|||||||
case CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE:
|
case CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE:
|
||||||
buf[1] = msg->set_screen_power_mode.mode;
|
buf[1] = msg->set_screen_power_mode.mode;
|
||||||
return 2;
|
return 2;
|
||||||
case CONTROL_MSG_TYPE_SCAN_MEDIA:
|
|
||||||
{
|
|
||||||
size_t len = write_string(msg->scan_media.path,
|
|
||||||
CONTROL_MSG_SCAN_MEDIA_PATH_MAX_LENGTH,
|
|
||||||
&buf[1]);
|
|
||||||
return 1 + len;
|
|
||||||
}
|
|
||||||
case CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL:
|
case CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL:
|
||||||
case CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL:
|
case CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL:
|
||||||
case CONTROL_MSG_TYPE_COLLAPSE_PANELS:
|
case CONTROL_MSG_TYPE_COLLAPSE_PANELS:
|
||||||
@@ -109,9 +102,6 @@ control_msg_destroy(struct control_msg *msg) {
|
|||||||
case CONTROL_MSG_TYPE_SET_CLIPBOARD:
|
case CONTROL_MSG_TYPE_SET_CLIPBOARD:
|
||||||
free(msg->set_clipboard.text);
|
free(msg->set_clipboard.text);
|
||||||
break;
|
break;
|
||||||
case CONTROL_MSG_TYPE_SCAN_MEDIA:
|
|
||||||
free(msg->scan_media.path);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// do nothing
|
// do nothing
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
||||||
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
||||||
|
|
||||||
#define CONTROL_MSG_SCAN_MEDIA_PATH_MAX_LENGTH 256
|
|
||||||
|
|
||||||
#define POINTER_ID_MOUSE UINT64_C(-1);
|
#define POINTER_ID_MOUSE UINT64_C(-1);
|
||||||
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2);
|
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2);
|
||||||
|
|
||||||
@@ -35,7 +33,6 @@ enum control_msg_type {
|
|||||||
CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
||||||
CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
|
CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
|
||||||
CONTROL_MSG_TYPE_ROTATE_DEVICE,
|
CONTROL_MSG_TYPE_ROTATE_DEVICE,
|
||||||
CONTROL_MSG_TYPE_SCAN_MEDIA,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum screen_power_mode {
|
enum screen_power_mode {
|
||||||
@@ -79,9 +76,6 @@ struct control_msg {
|
|||||||
struct {
|
struct {
|
||||||
enum screen_power_mode mode;
|
enum screen_power_mode mode;
|
||||||
} set_screen_power_mode;
|
} set_screen_power_mode;
|
||||||
struct {
|
|
||||||
char *path; // owned, to be freed by free()
|
|
||||||
} scan_media;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "adb.h"
|
#include "adb.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
#define DEFAULT_PUSH_TARGET "/sdcard/"
|
#define DEFAULT_PUSH_TARGET "/sdcard/Download/"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
file_handler_request_destroy(struct file_handler_request *req) {
|
file_handler_request_destroy(struct file_handler_request *req) {
|
||||||
|
|||||||
@@ -35,11 +35,14 @@ record_packet_new(const AVPacket *packet) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// av_packet_ref() does not initialize all fields in old FFmpeg versions
|
rec->packet = av_packet_alloc();
|
||||||
// See <https://github.com/Genymobile/scrcpy/issues/707>
|
if (!rec->packet) {
|
||||||
av_init_packet(&rec->packet);
|
free(rec);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (av_packet_ref(&rec->packet, packet)) {
|
if (av_packet_ref(rec->packet, packet)) {
|
||||||
|
av_packet_free(&rec->packet);
|
||||||
free(rec);
|
free(rec);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -48,7 +51,8 @@ record_packet_new(const AVPacket *packet) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
record_packet_delete(struct record_packet *rec) {
|
record_packet_delete(struct record_packet *rec) {
|
||||||
av_packet_unref(&rec->packet);
|
av_packet_unref(rec->packet);
|
||||||
|
av_packet_free(&rec->packet);
|
||||||
free(rec);
|
free(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +148,8 @@ run_recorder(void *data) {
|
|||||||
struct record_packet *last = recorder->previous;
|
struct record_packet *last = recorder->previous;
|
||||||
if (last) {
|
if (last) {
|
||||||
// assign an arbitrary duration to the last packet
|
// assign an arbitrary duration to the last packet
|
||||||
last->packet.duration = 100000;
|
last->packet->duration = 100000;
|
||||||
bool ok = recorder_write(recorder, &last->packet);
|
bool ok = recorder_write(recorder, last->packet);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// failing to write the last frame is not very serious, no
|
// failing to write the last frame is not very serious, no
|
||||||
// future frame may depend on it, so the resulting file
|
// future frame may depend on it, so the resulting file
|
||||||
@@ -172,13 +176,14 @@ run_recorder(void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// config packets have no PTS, we must ignore them
|
// config packets have no PTS, we must ignore them
|
||||||
if (rec->packet.pts != AV_NOPTS_VALUE
|
if (rec->packet->pts != AV_NOPTS_VALUE
|
||||||
&& previous->packet.pts != AV_NOPTS_VALUE) {
|
&& previous->packet->pts != AV_NOPTS_VALUE) {
|
||||||
// we now know the duration of the previous packet
|
// we now know the duration of the previous packet
|
||||||
previous->packet.duration = rec->packet.pts - previous->packet.pts;
|
previous->packet->duration =
|
||||||
|
rec->packet->pts - previous->packet->pts;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = recorder_write(recorder, &previous->packet);
|
bool ok = recorder_write(recorder, previous->packet);
|
||||||
record_packet_delete(previous);
|
record_packet_delete(previous);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Could not record packet");
|
LOGE("Could not record packet");
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "util/thread.h"
|
#include "util/thread.h"
|
||||||
|
|
||||||
struct record_packet {
|
struct record_packet {
|
||||||
AVPacket packet;
|
AVPacket *packet;
|
||||||
struct record_packet *next;
|
struct record_packet *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ get_window_size(const struct screen *screen) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct point
|
||||||
|
get_window_position(const struct screen *screen) {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
SDL_GetWindowPosition(screen->window, &x, &y);
|
||||||
|
|
||||||
|
struct point point;
|
||||||
|
point.x = x;
|
||||||
|
point.y = y;
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
// set the window size to be applied when fullscreen is disabled
|
// set the window size to be applied when fullscreen is disabled
|
||||||
static void
|
static void
|
||||||
set_window_size(struct screen *screen, struct size new_size) {
|
set_window_size(struct screen *screen, struct size new_size) {
|
||||||
@@ -122,13 +134,6 @@ get_optimal_size(struct size current_size, struct size content_size) {
|
|||||||
return window_size;
|
return window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// same as get_optimal_size(), but read the current size from the window
|
|
||||||
static inline struct size
|
|
||||||
get_optimal_window_size(const struct screen *screen, struct size content_size) {
|
|
||||||
struct size window_size = get_window_size(screen);
|
|
||||||
return get_optimal_size(window_size, content_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// initially, there is no current size, so use the frame size as current size
|
// initially, there is no current size, so use the frame size as current size
|
||||||
// req_width and req_height, if not 0, are the sizes requested by the user
|
// req_width and req_height, if not 0, are the sizes requested by the user
|
||||||
static inline struct size
|
static inline struct size
|
||||||
@@ -662,9 +667,20 @@ screen_resize_to_fit(struct screen *screen) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct point point = get_window_position(screen);
|
||||||
|
struct size window_size = get_window_size(screen);
|
||||||
|
|
||||||
struct size optimal_size =
|
struct size optimal_size =
|
||||||
get_optimal_window_size(screen, screen->content_size);
|
get_optimal_size(window_size, screen->content_size);
|
||||||
|
|
||||||
|
// Center the window related to the device screen
|
||||||
|
assert(optimal_size.width <= window_size.width);
|
||||||
|
assert(optimal_size.height <= window_size.height);
|
||||||
|
uint32_t new_x = point.x + (window_size.width - optimal_size.width) / 2;
|
||||||
|
uint32_t new_y = point.y + (window_size.height - optimal_size.height) / 2;
|
||||||
|
|
||||||
SDL_SetWindowSize(screen->window, optimal_size.width, optimal_size.height);
|
SDL_SetWindowSize(screen->window, optimal_size.width, optimal_size.height);
|
||||||
|
SDL_SetWindowPosition(screen->window, new_x, new_y);
|
||||||
LOGD("Resized to optimal size: %ux%u", optimal_size.width,
|
LOGD("Resized to optimal size: %ux%u", optimal_size.width,
|
||||||
optimal_size.height);
|
optimal_size.height);
|
||||||
}
|
}
|
||||||
@@ -726,6 +742,7 @@ screen_handle_event(struct screen *screen, SDL_Event *event) {
|
|||||||
}
|
}
|
||||||
screen->maximized = false;
|
screen->maximized = false;
|
||||||
apply_pending_resize(screen);
|
apply_pending_resize(screen);
|
||||||
|
screen_render(screen, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -104,33 +104,38 @@ static bool
|
|||||||
stream_push_packet(struct stream *stream, AVPacket *packet) {
|
stream_push_packet(struct stream *stream, AVPacket *packet) {
|
||||||
bool is_config = packet->pts == AV_NOPTS_VALUE;
|
bool is_config = packet->pts == AV_NOPTS_VALUE;
|
||||||
|
|
||||||
// A config packet must not be decoded immetiately (it contains no
|
// A config packet must not be decoded immediately (it contains no
|
||||||
// frame); instead, it must be concatenated with the future data packet.
|
// frame); instead, it must be concatenated with the future data packet.
|
||||||
if (stream->has_pending || is_config) {
|
if (stream->pending || is_config) {
|
||||||
size_t offset;
|
size_t offset;
|
||||||
if (stream->has_pending) {
|
if (stream->pending) {
|
||||||
offset = stream->pending.size;
|
offset = stream->pending->size;
|
||||||
if (av_grow_packet(&stream->pending, packet->size)) {
|
if (av_grow_packet(stream->pending, packet->size)) {
|
||||||
LOGE("Could not grow packet");
|
LOGE("Could not grow packet");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
if (av_new_packet(&stream->pending, packet->size)) {
|
stream->pending = av_packet_alloc();
|
||||||
LOGE("Could not create packet");
|
if (!stream->pending) {
|
||||||
|
LOGE("Could not allocate packet");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (av_new_packet(stream->pending, packet->size)) {
|
||||||
|
LOGE("Could not create packet");
|
||||||
|
av_packet_free(&stream->pending);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
stream->has_pending = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(stream->pending.data + offset, packet->data, packet->size);
|
memcpy(stream->pending->data + offset, packet->data, packet->size);
|
||||||
|
|
||||||
if (!is_config) {
|
if (!is_config) {
|
||||||
// prepare the concat packet to send to the decoder
|
// prepare the concat packet to send to the decoder
|
||||||
stream->pending.pts = packet->pts;
|
stream->pending->pts = packet->pts;
|
||||||
stream->pending.dts = packet->dts;
|
stream->pending->dts = packet->dts;
|
||||||
stream->pending.flags = packet->flags;
|
stream->pending->flags = packet->flags;
|
||||||
packet = &stream->pending;
|
packet = stream->pending;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,10 +149,10 @@ stream_push_packet(struct stream *stream, AVPacket *packet) {
|
|||||||
// data packet
|
// data packet
|
||||||
bool ok = stream_parse(stream, packet);
|
bool ok = stream_parse(stream, packet);
|
||||||
|
|
||||||
if (stream->has_pending) {
|
if (stream->pending) {
|
||||||
// the pending packet must be discarded (consumed or error)
|
// the pending packet must be discarded (consumed or error)
|
||||||
stream->has_pending = false;
|
av_packet_unref(stream->pending);
|
||||||
av_packet_unref(&stream->pending);
|
av_packet_free(&stream->pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@@ -215,16 +220,21 @@ run_stream(void *data) {
|
|||||||
// It's more complicated, but this allows to reduce the latency by 1 frame!
|
// It's more complicated, but this allows to reduce the latency by 1 frame!
|
||||||
stream->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
|
stream->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
|
||||||
|
|
||||||
|
AVPacket *packet = av_packet_alloc();
|
||||||
|
if (!packet) {
|
||||||
|
LOGE("Could not allocate packet");
|
||||||
|
goto finally_close_parser;
|
||||||
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
AVPacket packet;
|
bool ok = stream_recv_packet(stream, packet);
|
||||||
bool ok = stream_recv_packet(stream, &packet);
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// end of stream
|
// end of stream
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = stream_push_packet(stream, &packet);
|
ok = stream_push_packet(stream, packet);
|
||||||
av_packet_unref(&packet);
|
av_packet_unref(packet);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// cannot process packet (error already logged)
|
// cannot process packet (error already logged)
|
||||||
break;
|
break;
|
||||||
@@ -233,10 +243,13 @@ run_stream(void *data) {
|
|||||||
|
|
||||||
LOGD("End of frames");
|
LOGD("End of frames");
|
||||||
|
|
||||||
if (stream->has_pending) {
|
if (stream->pending) {
|
||||||
av_packet_unref(&stream->pending);
|
av_packet_unref(stream->pending);
|
||||||
|
av_packet_free(&stream->pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
av_packet_free(&packet);
|
||||||
|
finally_close_parser:
|
||||||
av_parser_close(stream->parser);
|
av_parser_close(stream->parser);
|
||||||
finally_close_sinks:
|
finally_close_sinks:
|
||||||
stream_close_sinks(stream);
|
stream_close_sinks(stream);
|
||||||
@@ -252,7 +265,7 @@ void
|
|||||||
stream_init(struct stream *stream, socket_t socket,
|
stream_init(struct stream *stream, socket_t socket,
|
||||||
const struct stream_callbacks *cbs, void *cbs_userdata) {
|
const struct stream_callbacks *cbs, void *cbs_userdata) {
|
||||||
stream->socket = socket;
|
stream->socket = socket;
|
||||||
stream->has_pending = false;
|
stream->pending = NULL;
|
||||||
stream->sink_count = 0;
|
stream->sink_count = 0;
|
||||||
|
|
||||||
assert(cbs && cbs->on_eos);
|
assert(cbs && cbs->on_eos);
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ struct stream {
|
|||||||
AVCodecParserContext *parser;
|
AVCodecParserContext *parser;
|
||||||
// successive packets may need to be concatenated, until a non-config
|
// successive packets may need to be concatenated, until a non-config
|
||||||
// packet is available
|
// packet is available
|
||||||
bool has_pending;
|
AVPacket *pending;
|
||||||
AVPacket pending;
|
|
||||||
|
|
||||||
const struct stream_callbacks *cbs;
|
const struct stream_callbacks *cbs;
|
||||||
void *cbs_userdata;
|
void *cbs_userdata;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ encode_and_write_frame(struct sc_v4l2_sink *vs, const AVFrame *frame) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVPacket *packet = &vs->packet;
|
AVPacket *packet = vs->packet;
|
||||||
ret = avcodec_receive_packet(vs->encoder_ctx, packet);
|
ret = avcodec_receive_packet(vs->encoder_ctx, packet);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
// A packet was received
|
// A packet was received
|
||||||
@@ -180,12 +180,17 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
|||||||
// still expects a pointer-to-non-const (it has not be updated accordingly)
|
// still expects a pointer-to-non-const (it has not be updated accordingly)
|
||||||
// <https://github.com/FFmpeg/FFmpeg/commit/0694d8702421e7aff1340038559c438b61bb30dd>
|
// <https://github.com/FFmpeg/FFmpeg/commit/0694d8702421e7aff1340038559c438b61bb30dd>
|
||||||
vs->format_ctx->oformat = (AVOutputFormat *) format;
|
vs->format_ctx->oformat = (AVOutputFormat *) format;
|
||||||
|
#ifdef SCRCPY_LAVF_HAS_AVFORMATCONTEXT_URL
|
||||||
vs->format_ctx->url = strdup(vs->device_name);
|
vs->format_ctx->url = strdup(vs->device_name);
|
||||||
if (!vs->format_ctx->url) {
|
if (!vs->format_ctx->url) {
|
||||||
LOGE("Could not strdup v4l2 device name");
|
LOGE("Could not strdup v4l2 device name");
|
||||||
goto error_avformat_free_context;
|
goto error_avformat_free_context;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
strncpy(vs->format_ctx->filename, vs->device_name,
|
||||||
|
sizeof(vs->format_ctx->filename));
|
||||||
|
#endif
|
||||||
|
|
||||||
AVStream *ostream = avformat_new_stream(vs->format_ctx, encoder);
|
AVStream *ostream = avformat_new_stream(vs->format_ctx, encoder);
|
||||||
if (!ostream) {
|
if (!ostream) {
|
||||||
@@ -230,11 +235,17 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
|||||||
goto error_avcodec_close;
|
goto error_avcodec_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vs->packet = av_packet_alloc();
|
||||||
|
if (!vs->packet) {
|
||||||
|
LOGE("Could not allocate packet");
|
||||||
|
goto error_av_frame_free;
|
||||||
|
}
|
||||||
|
|
||||||
LOGD("Starting v4l2 thread");
|
LOGD("Starting v4l2 thread");
|
||||||
ok = sc_thread_create(&vs->thread, run_v4l2_sink, "v4l2", vs);
|
ok = sc_thread_create(&vs->thread, run_v4l2_sink, "v4l2", vs);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGC("Could not start v4l2 thread");
|
LOGC("Could not start v4l2 thread");
|
||||||
goto error_av_frame_free;
|
goto error_av_packet_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
vs->header_written = false;
|
vs->header_written = false;
|
||||||
@@ -244,6 +255,8 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
error_av_packet_free:
|
||||||
|
av_packet_free(&vs->packet);
|
||||||
error_av_frame_free:
|
error_av_frame_free:
|
||||||
av_frame_free(&vs->frame);
|
av_frame_free(&vs->frame);
|
||||||
error_avcodec_close:
|
error_avcodec_close:
|
||||||
@@ -273,6 +286,7 @@ sc_v4l2_sink_close(struct sc_v4l2_sink *vs) {
|
|||||||
|
|
||||||
sc_thread_join(&vs->thread, NULL);
|
sc_thread_join(&vs->thread, NULL);
|
||||||
|
|
||||||
|
av_packet_free(&vs->packet);
|
||||||
av_frame_free(&vs->frame);
|
av_frame_free(&vs->frame);
|
||||||
avcodec_close(vs->encoder_ctx);
|
avcodec_close(vs->encoder_ctx);
|
||||||
avcodec_free_context(&vs->encoder_ctx);
|
avcodec_free_context(&vs->encoder_ctx);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ struct sc_v4l2_sink {
|
|||||||
bool header_written;
|
bool header_written;
|
||||||
|
|
||||||
AVFrame *frame;
|
AVFrame *frame;
|
||||||
AVPacket packet;
|
AVPacket *packet;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -278,28 +278,6 @@ static void test_serialize_rotate_device(void) {
|
|||||||
assert(!memcmp(buf, expected, sizeof(expected)));
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_serialize_scan_media(void) {
|
|
||||||
struct control_msg msg = {
|
|
||||||
.type = CONTROL_MSG_TYPE_SCAN_MEDIA,
|
|
||||||
.scan_media = {
|
|
||||||
.path = "/sdcard/Download/",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned char buf[CONTROL_MSG_MAX_SIZE];
|
|
||||||
size_t size = control_msg_serialize(&msg, buf);
|
|
||||||
assert(size == 22);
|
|
||||||
|
|
||||||
const unsigned char expected[] = {
|
|
||||||
CONTROL_MSG_TYPE_SCAN_MEDIA,
|
|
||||||
0x00, 0x00, 0x00, 0x11, // path length
|
|
||||||
'/', 's', 'd', 'c', 'a', 'r', 'd', '/',
|
|
||||||
'D', 'o', 'w', 'n', 'l', 'o', 'a', 'd',
|
|
||||||
'/' // path
|
|
||||||
};
|
|
||||||
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
(void) argc;
|
(void) argc;
|
||||||
(void) argv;
|
(void) argv;
|
||||||
@@ -317,6 +295,5 @@ int main(int argc, char *argv[]) {
|
|||||||
test_serialize_set_clipboard();
|
test_serialize_set_clipboard();
|
||||||
test_serialize_set_screen_power_mode();
|
test_serialize_set_screen_power_mode();
|
||||||
test_serialize_rotate_device();
|
test_serialize_rotate_device();
|
||||||
test_serialize_scan_media();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ public final class ControlMessage {
|
|||||||
public static final int TYPE_SET_CLIPBOARD = 9;
|
public static final int TYPE_SET_CLIPBOARD = 9;
|
||||||
public static final int TYPE_SET_SCREEN_POWER_MODE = 10;
|
public static final int TYPE_SET_SCREEN_POWER_MODE = 10;
|
||||||
public static final int TYPE_ROTATE_DEVICE = 11;
|
public static final int TYPE_ROTATE_DEVICE = 11;
|
||||||
public static final int TYPE_SCAN_MEDIA = 12;
|
|
||||||
|
|
||||||
private int type;
|
private int type;
|
||||||
private String text;
|
private String text;
|
||||||
@@ -98,13 +97,6 @@ public final class ControlMessage {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ControlMessage createScanMedia(String path) {
|
|
||||||
ControlMessage msg = new ControlMessage();
|
|
||||||
msg.type = TYPE_SCAN_MEDIA;
|
|
||||||
msg.text = path;
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ControlMessage createEmpty(int type) {
|
public static ControlMessage createEmpty(int type) {
|
||||||
ControlMessage msg = new ControlMessage();
|
ControlMessage msg = new ControlMessage();
|
||||||
msg.type = type;
|
msg.type = type;
|
||||||
|
|||||||
@@ -76,9 +76,6 @@ public class ControlMessageReader {
|
|||||||
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
|
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
|
||||||
msg = parseSetScreenPowerMode();
|
msg = parseSetScreenPowerMode();
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_SCAN_MEDIA:
|
|
||||||
msg = parseScanMedia();
|
|
||||||
break;
|
|
||||||
case ControlMessage.TYPE_EXPAND_NOTIFICATION_PANEL:
|
case ControlMessage.TYPE_EXPAND_NOTIFICATION_PANEL:
|
||||||
case ControlMessage.TYPE_EXPAND_SETTINGS_PANEL:
|
case ControlMessage.TYPE_EXPAND_SETTINGS_PANEL:
|
||||||
case ControlMessage.TYPE_COLLAPSE_PANELS:
|
case ControlMessage.TYPE_COLLAPSE_PANELS:
|
||||||
@@ -185,14 +182,6 @@ public class ControlMessageReader {
|
|||||||
return ControlMessage.createSetScreenPowerMode(mode);
|
return ControlMessage.createSetScreenPowerMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ControlMessage parseScanMedia() {
|
|
||||||
String path = parseString();
|
|
||||||
if (path == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return ControlMessage.createScanMedia(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Position readPosition(ByteBuffer buffer) {
|
private static Position readPosition(ByteBuffer buffer) {
|
||||||
int x = buffer.getInt();
|
int x = buffer.getInt();
|
||||||
int y = buffer.getInt();
|
int y = buffer.getInt();
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
@@ -9,7 +7,6 @@ import android.view.KeyCharacterMap;
|
|||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
@@ -138,12 +135,6 @@ public class Controller {
|
|||||||
case ControlMessage.TYPE_ROTATE_DEVICE:
|
case ControlMessage.TYPE_ROTATE_DEVICE:
|
||||||
Device.rotateDevice();
|
Device.rotateDevice();
|
||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_SCAN_MEDIA:
|
|
||||||
String path = msg.getText();
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
|
||||||
intent.setData(Uri.fromFile(new File(path)));
|
|
||||||
Device.sendBroadcast(intent);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
|||||||
import com.genymobile.scrcpy.wrappers.WindowManager;
|
import com.genymobile.scrcpy.wrappers.WindowManager;
|
||||||
|
|
||||||
import android.content.IOnPrimaryClipChangedListener;
|
import android.content.IOnPrimaryClipChangedListener;
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
@@ -300,8 +299,4 @@ public final class Device {
|
|||||||
public static ContentProvider createSettingsProvider() {
|
public static ContentProvider createSettingsProvider() {
|
||||||
return SERVICE_MANAGER.getActivityManager().createSettingsProvider();
|
return SERVICE_MANAGER.getActivityManager().createSettingsProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendBroadcast(Intent intent) {
|
|
||||||
SERVICE_MANAGER.getActivityManager().sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package com.genymobile.scrcpy.wrappers;
|
|||||||
|
|
||||||
import com.genymobile.scrcpy.Ln;
|
import com.genymobile.scrcpy.Ln;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.IInterface;
|
import android.os.IInterface;
|
||||||
|
|
||||||
@@ -18,7 +16,6 @@ public class ActivityManager {
|
|||||||
private Method getContentProviderExternalMethod;
|
private Method getContentProviderExternalMethod;
|
||||||
private boolean getContentProviderExternalMethodNewVersion = true;
|
private boolean getContentProviderExternalMethodNewVersion = true;
|
||||||
private Method removeContentProviderExternalMethod;
|
private Method removeContentProviderExternalMethod;
|
||||||
private Method broadcastIntentMethod;
|
|
||||||
|
|
||||||
public ActivityManager(IInterface manager) {
|
public ActivityManager(IInterface manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
@@ -45,22 +42,6 @@ public class ActivityManager {
|
|||||||
return removeContentProviderExternalMethod;
|
return removeContentProviderExternalMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Method getBroadcastIntentMethod() throws NoSuchMethodException {
|
|
||||||
if (broadcastIntentMethod == null) {
|
|
||||||
try {
|
|
||||||
Class<?> iApplicationThreadClass = Class.forName("android.app.IApplicationThread");
|
|
||||||
Class<?> iIntentReceiverClass = Class.forName("android.content.IIntentReceiver");
|
|
||||||
broadcastIntentMethod = manager.getClass()
|
|
||||||
.getMethod("broadcastIntent", iApplicationThreadClass, Intent.class, String.class, iIntentReceiverClass, int.class,
|
|
||||||
String.class, Bundle.class, String[].class, int.class, Bundle.class, boolean.class, boolean.class, int.class);
|
|
||||||
return broadcastIntentMethod;
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return broadcastIntentMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ContentProvider getContentProviderExternal(String name, IBinder token) {
|
private ContentProvider getContentProviderExternal(String name, IBinder token) {
|
||||||
try {
|
try {
|
||||||
Method method = getGetContentProviderExternalMethod();
|
Method method = getGetContentProviderExternalMethod();
|
||||||
@@ -103,13 +84,4 @@ public class ActivityManager {
|
|||||||
public ContentProvider createSettingsProvider() {
|
public ContentProvider createSettingsProvider() {
|
||||||
return getContentProviderExternal("settings", new Binder());
|
return getContentProviderExternal("settings", new Binder());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendBroadcast(Intent intent) {
|
|
||||||
try {
|
|
||||||
Method method = getBroadcastIntentMethod();
|
|
||||||
method.invoke(manager, null, intent, null, null, 0, null, null, null, -1, null, true, false, ServiceManager.USER_ID);
|
|
||||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
|
||||||
Ln.e("Could not invoke method", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.genymobile.scrcpy.wrappers;
|
|||||||
|
|
||||||
import com.genymobile.scrcpy.Ln;
|
import com.genymobile.scrcpy.Ln;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
@@ -37,6 +38,8 @@ public class ContentProvider implements Closeable {
|
|||||||
private Method callMethod;
|
private Method callMethod;
|
||||||
private int callMethodVersion;
|
private int callMethodVersion;
|
||||||
|
|
||||||
|
private Object attributionSource;
|
||||||
|
|
||||||
ContentProvider(ActivityManager manager, Object provider, String name, IBinder token) {
|
ContentProvider(ActivityManager manager, Object provider, String name, IBinder token) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
@@ -46,42 +49,61 @@ public class ContentProvider implements Closeable {
|
|||||||
|
|
||||||
private Method getCallMethod() throws NoSuchMethodException {
|
private Method getCallMethod() throws NoSuchMethodException {
|
||||||
if (callMethod == null) {
|
if (callMethod == null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
callMethod = provider.getClass()
|
@SuppressLint("PrivateApi")
|
||||||
.getMethod("call", String.class, String.class, String.class, String.class, String.class, Bundle.class);
|
Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
|
||||||
callMethodVersion = 0;
|
callMethod = provider.getClass().getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException | ClassNotFoundException e0) {
|
||||||
// old versions
|
// old versions
|
||||||
try {
|
try {
|
||||||
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
|
callMethod = provider.getClass()
|
||||||
|
.getMethod("call", String.class, String.class, String.class, String.class, String.class, Bundle.class);
|
||||||
callMethodVersion = 1;
|
callMethodVersion = 1;
|
||||||
} catch (NoSuchMethodException e2) {
|
} catch (NoSuchMethodException e1) {
|
||||||
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
|
try {
|
||||||
callMethodVersion = 2;
|
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
|
||||||
|
callMethodVersion = 2;
|
||||||
|
} catch (NoSuchMethodException e2) {
|
||||||
|
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
|
||||||
|
callMethodVersion = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return callMethod;
|
return callMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getAttributionSource()
|
||||||
|
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
|
if (attributionSource == null) {
|
||||||
|
Class<?> cl = Class.forName("android.content.AttributionSource$Builder");
|
||||||
|
Object builder = cl.getConstructor(int.class).newInstance(ServiceManager.USER_ID);
|
||||||
|
cl.getDeclaredMethod("setPackageName", String.class).invoke(builder, ServiceManager.PACKAGE_NAME);
|
||||||
|
attributionSource = cl.getDeclaredMethod("build").invoke(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
return attributionSource;
|
||||||
|
}
|
||||||
|
|
||||||
private Bundle call(String callMethod, String arg, Bundle extras) {
|
private Bundle call(String callMethod, String arg, Bundle extras) {
|
||||||
try {
|
try {
|
||||||
Method method = getCallMethod();
|
Method method = getCallMethod();
|
||||||
Object[] args;
|
Object[] args;
|
||||||
switch (callMethodVersion) {
|
switch (callMethodVersion) {
|
||||||
case 0:
|
case 0:
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, null, "settings", callMethod, arg, extras};
|
args = new Object[]{getAttributionSource(), "settings", callMethod, arg, extras};
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
args = new Object[]{ServiceManager.PACKAGE_NAME, null, "settings", callMethod, arg, extras};
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
|
args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
||||||
break;
|
break;
|
||||||
}
|
} return (Bundle) method.invoke(provider, args);
|
||||||
return (Bundle) method.invoke(provider, args);
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException | InstantiationException e) {
|
||||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
|
||||||
Ln.e("Could not invoke method", e);
|
Ln.e("Could not invoke method", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,26 +314,6 @@ public class ControlMessageReaderTest {
|
|||||||
Assert.assertEquals(ControlMessage.TYPE_ROTATE_DEVICE, event.getType());
|
Assert.assertEquals(ControlMessage.TYPE_ROTATE_DEVICE, event.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testScanMedia() throws IOException {
|
|
||||||
ControlMessageReader reader = new ControlMessageReader();
|
|
||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(bos);
|
|
||||||
dos.writeByte(ControlMessage.TYPE_SCAN_MEDIA);
|
|
||||||
byte[] text = "/sdcard/Download/".getBytes(StandardCharsets.UTF_8);
|
|
||||||
dos.writeInt(text.length);
|
|
||||||
dos.write(text);
|
|
||||||
|
|
||||||
byte[] packet = bos.toByteArray();
|
|
||||||
|
|
||||||
reader.readFrom(new ByteArrayInputStream(packet));
|
|
||||||
ControlMessage event = reader.next();
|
|
||||||
|
|
||||||
Assert.assertEquals(ControlMessage.TYPE_SCAN_MEDIA, event.getType());
|
|
||||||
Assert.assertEquals("/sdcard/Download/", event.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultiEvents() throws IOException {
|
public void testMultiEvents() throws IOException {
|
||||||
ControlMessageReader reader = new ControlMessageReader();
|
ControlMessageReader reader = new ControlMessageReader();
|
||||||
|
|||||||
Reference in New Issue
Block a user