Compare commits
4 Commits
broadcast
...
scan_media
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
190a90f45d | ||
|
|
cda4aa1623 | ||
|
|
310f5721d9 | ||
|
|
af228706f1 |
@@ -22,6 +22,18 @@
|
||||
# define SCRCPY_LAVF_REQUIRES_REGISTER_ALL
|
||||
#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)
|
||||
// <https://wiki.libsdl.org/SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH>
|
||||
# define SCRCPY_SDL_HAS_HINT_MOUSE_FOCUS_CLICKTHROUGH
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "adb.h"
|
||||
#include "control_msg.h"
|
||||
#include "controller.h"
|
||||
#include "util/log.h"
|
||||
|
||||
#define DEFAULT_PUSH_TARGET "/sdcard/"
|
||||
@@ -14,7 +16,8 @@ file_handler_request_destroy(struct file_handler_request *req) {
|
||||
}
|
||||
|
||||
bool
|
||||
file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||
file_handler_init(struct file_handler *file_handler,
|
||||
struct controller *controller, const char *serial,
|
||||
const char *push_target) {
|
||||
|
||||
cbuf_init(&file_handler->queue);
|
||||
@@ -50,6 +53,8 @@ file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||
|
||||
file_handler->push_target = push_target ? push_target : DEFAULT_PUSH_TARGET;
|
||||
|
||||
file_handler->controller = controller;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -103,6 +108,24 @@ file_handler_request(struct file_handler *file_handler,
|
||||
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
|
||||
run_file_handler(void *data) {
|
||||
struct file_handler *file_handler = data;
|
||||
@@ -145,6 +168,7 @@ run_file_handler(void *data) {
|
||||
if (process_check_success(process, "adb push", false)) {
|
||||
LOGI("%s successfully pushed to %s", req.file,
|
||||
file_handler->push_target);
|
||||
request_scan_media(file_handler);
|
||||
} else {
|
||||
LOGE("Failed to push %s to %s", req.file,
|
||||
file_handler->push_target);
|
||||
|
||||
@@ -22,6 +22,7 @@ struct file_handler_request {
|
||||
struct file_handler_request_queue CBUF(struct file_handler_request, 16);
|
||||
|
||||
struct file_handler {
|
||||
struct controller *controller;
|
||||
char *serial;
|
||||
const char *push_target;
|
||||
sc_thread thread;
|
||||
@@ -34,7 +35,8 @@ struct file_handler {
|
||||
};
|
||||
|
||||
bool
|
||||
file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||
file_handler_init(struct file_handler *file_handler,
|
||||
struct controller *controller, const char *serial,
|
||||
const char *push_target);
|
||||
|
||||
void
|
||||
|
||||
@@ -297,14 +297,6 @@ scrcpy(const struct scrcpy_options *options) {
|
||||
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;
|
||||
bool needs_decoder = options->display;
|
||||
#ifdef HAVE_V4L2
|
||||
@@ -353,6 +345,12 @@ scrcpy(const struct scrcpy_options *options) {
|
||||
goto end;
|
||||
}
|
||||
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 =
|
||||
|
||||
@@ -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)
|
||||
// <https://github.com/FFmpeg/FFmpeg/commit/0694d8702421e7aff1340038559c438b61bb30dd>
|
||||
vs->format_ctx->oformat = (AVOutputFormat *) format;
|
||||
#ifdef SCRCPY_LAVF_HAS_AVFORMATCONTEXT_URL
|
||||
vs->format_ctx->url = strdup(vs->device_name);
|
||||
if (!vs->format_ctx->url) {
|
||||
LOGE("Could not strdup v4l2 device name");
|
||||
goto error_avformat_free_context;
|
||||
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);
|
||||
if (!ostream) {
|
||||
|
||||
@@ -140,6 +140,7 @@ public class Controller {
|
||||
break;
|
||||
case ControlMessage.TYPE_SCAN_MEDIA:
|
||||
String path = msg.getText();
|
||||
@SuppressWarnings("deprecation")
|
||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
intent.setData(Uri.fromFile(new File(path)));
|
||||
Device.sendBroadcast(intent);
|
||||
|
||||
Reference in New Issue
Block a user