Compare commits
2 Commits
scan_media
...
broadcast
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64ea0d1a4a | ||
|
|
4dd78f523c |
@@ -22,18 +22,6 @@
|
|||||||
# 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
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "adb.h"
|
#include "adb.h"
|
||||||
#include "control_msg.h"
|
|
||||||
#include "controller.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
#define DEFAULT_PUSH_TARGET "/sdcard/"
|
#define DEFAULT_PUSH_TARGET "/sdcard/"
|
||||||
@@ -16,8 +14,7 @@ file_handler_request_destroy(struct file_handler_request *req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
file_handler_init(struct file_handler *file_handler,
|
file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||||
struct controller *controller, const char *serial,
|
|
||||||
const char *push_target) {
|
const char *push_target) {
|
||||||
|
|
||||||
cbuf_init(&file_handler->queue);
|
cbuf_init(&file_handler->queue);
|
||||||
@@ -53,8 +50,6 @@ file_handler_init(struct file_handler *file_handler,
|
|||||||
|
|
||||||
file_handler->push_target = push_target ? push_target : DEFAULT_PUSH_TARGET;
|
file_handler->push_target = push_target ? push_target : DEFAULT_PUSH_TARGET;
|
||||||
|
|
||||||
file_handler->controller = controller;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,24 +103,6 @@ file_handler_request(struct file_handler *file_handler,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
request_scan_media(struct file_handler *file_handler) {
|
|
||||||
struct control_msg msg;
|
|
||||||
msg.type = CONTROL_MSG_TYPE_SCAN_MEDIA;
|
|
||||||
msg.scan_media.path = strdup(file_handler->push_target);
|
|
||||||
if (!msg.scan_media.path) {
|
|
||||||
LOGW("Could not strdup() media path");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!controller_push_msg(file_handler->controller, &msg)) {
|
|
||||||
LOGW("Could not request 'scan media'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
run_file_handler(void *data) {
|
run_file_handler(void *data) {
|
||||||
struct file_handler *file_handler = data;
|
struct file_handler *file_handler = data;
|
||||||
@@ -168,7 +145,6 @@ run_file_handler(void *data) {
|
|||||||
if (process_check_success(process, "adb push", false)) {
|
if (process_check_success(process, "adb push", false)) {
|
||||||
LOGI("%s successfully pushed to %s", req.file,
|
LOGI("%s successfully pushed to %s", req.file,
|
||||||
file_handler->push_target);
|
file_handler->push_target);
|
||||||
request_scan_media(file_handler);
|
|
||||||
} else {
|
} else {
|
||||||
LOGE("Failed to push %s to %s", req.file,
|
LOGE("Failed to push %s to %s", req.file,
|
||||||
file_handler->push_target);
|
file_handler->push_target);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ struct file_handler_request {
|
|||||||
struct file_handler_request_queue CBUF(struct file_handler_request, 16);
|
struct file_handler_request_queue CBUF(struct file_handler_request, 16);
|
||||||
|
|
||||||
struct file_handler {
|
struct file_handler {
|
||||||
struct controller *controller;
|
|
||||||
char *serial;
|
char *serial;
|
||||||
const char *push_target;
|
const char *push_target;
|
||||||
sc_thread thread;
|
sc_thread thread;
|
||||||
@@ -35,8 +34,7 @@ struct file_handler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
file_handler_init(struct file_handler *file_handler,
|
file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||||
struct controller *controller, const char *serial,
|
|
||||||
const char *push_target);
|
const char *push_target);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -297,6 +297,14 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options->display && options->control) {
|
||||||
|
if (!file_handler_init(&s->file_handler, s->server.serial,
|
||||||
|
options->push_target)) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
file_handler_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
struct decoder *dec = NULL;
|
struct decoder *dec = NULL;
|
||||||
bool needs_decoder = options->display;
|
bool needs_decoder = options->display;
|
||||||
#ifdef HAVE_V4L2
|
#ifdef HAVE_V4L2
|
||||||
@@ -345,12 +353,6 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
controller_started = true;
|
controller_started = true;
|
||||||
|
|
||||||
if (!file_handler_init(&s->file_handler, &s->controller,
|
|
||||||
s->server.serial, options->push_target)) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
file_handler_initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *window_title =
|
const char *window_title =
|
||||||
|
|||||||
@@ -180,17 +180,12 @@ 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) {
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ public class Controller {
|
|||||||
break;
|
break;
|
||||||
case ControlMessage.TYPE_SCAN_MEDIA:
|
case ControlMessage.TYPE_SCAN_MEDIA:
|
||||||
String path = msg.getText();
|
String path = msg.getText();
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||||
intent.setData(Uri.fromFile(new File(path)));
|
intent.setData(Uri.fromFile(new File(path)));
|
||||||
Device.sendBroadcast(intent);
|
Device.sendBroadcast(intent);
|
||||||
|
|||||||
Reference in New Issue
Block a user