|
|
|
@ -137,7 +137,7 @@ sdl_set_hints(const char *render_driver) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sdl_configure(bool playback, bool disable_screensaver) {
|
|
|
|
|
sdl_configure(bool video_playback, bool disable_screensaver) {
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
// Clean up properly on Ctrl+C on Windows
|
|
|
|
|
bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE);
|
|
|
|
@ -146,7 +146,7 @@ sdl_configure(bool playback, bool disable_screensaver) {
|
|
|
|
|
}
|
|
|
|
|
#endif // _WIN32
|
|
|
|
|
|
|
|
|
|
if (!playback) {
|
|
|
|
|
if (!video_playback) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -386,22 +386,26 @@ scrcpy(struct scrcpy_options *options) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options->playback) {
|
|
|
|
|
sdl_set_hints(options->render_driver);
|
|
|
|
|
// playback implies capture
|
|
|
|
|
assert(!options->video_playback || options->video);
|
|
|
|
|
assert(!options->audio_playback || options->audio);
|
|
|
|
|
|
|
|
|
|
// Initialize SDL video and audio in addition if playback is enabled
|
|
|
|
|
if (options->video && SDL_Init(SDL_INIT_VIDEO)) {
|
|
|
|
|
if (options->video_playback) {
|
|
|
|
|
sdl_set_hints(options->render_driver);
|
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO)) {
|
|
|
|
|
LOGE("Could not initialize SDL video: %s", SDL_GetError());
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options->audio && SDL_Init(SDL_INIT_AUDIO)) {
|
|
|
|
|
if (options->audio_playback) {
|
|
|
|
|
if (SDL_Init(SDL_INIT_AUDIO)) {
|
|
|
|
|
LOGE("Could not initialize SDL audio: %s", SDL_GetError());
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sdl_configure(options->playback, options->disable_screensaver);
|
|
|
|
|
sdl_configure(options->video_playback, options->disable_screensaver);
|
|
|
|
|
|
|
|
|
|
// Await for server without blocking Ctrl+C handling
|
|
|
|
|
bool connected;
|
|
|
|
@ -427,7 +431,8 @@ scrcpy(struct scrcpy_options *options) {
|
|
|
|
|
|
|
|
|
|
struct sc_file_pusher *fp = NULL;
|
|
|
|
|
|
|
|
|
|
assert(!options->control || options->playback); // control implies playback
|
|
|
|
|
// control implies video playback
|
|
|
|
|
assert(!options->control || options->video_playback);
|
|
|
|
|
if (options->control) {
|
|
|
|
|
if (!sc_file_pusher_init(&s->file_pusher, serial,
|
|
|
|
|
options->push_target)) {
|
|
|
|
@ -453,8 +458,8 @@ scrcpy(struct scrcpy_options *options) {
|
|
|
|
|
&audio_demuxer_cbs, options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool needs_video_decoder = options->playback && options->video;
|
|
|
|
|
bool needs_audio_decoder = options->playback && options->audio;
|
|
|
|
|
bool needs_video_decoder = options->video_playback;
|
|
|
|
|
bool needs_audio_decoder = options->audio_playback;
|
|
|
|
|
#ifdef HAVE_V4L2
|
|
|
|
|
needs_video_decoder |= !!options->v4l2_device;
|
|
|
|
|
#endif
|
|
|
|
@ -650,7 +655,7 @@ aoa_hid_end:
|
|
|
|
|
// There is a controller if and only if control is enabled
|
|
|
|
|
assert(options->control == !!controller);
|
|
|
|
|
|
|
|
|
|
if (options->playback) {
|
|
|
|
|
if (options->video_playback) {
|
|
|
|
|
const char *window_title =
|
|
|
|
|
options->window_title ? options->window_title : info->device_name;
|
|
|
|
|
|
|
|
|
@ -684,21 +689,19 @@ aoa_hid_end:
|
|
|
|
|
src = &s->display_buffer.frame_source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options->video) {
|
|
|
|
|
if (!sc_screen_init(&s->screen, &screen_params)) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
screen_initialized = true;
|
|
|
|
|
|
|
|
|
|
sc_frame_source_add_sink(src, &s->screen.frame_sink);
|
|
|
|
|
if (!sc_screen_init(&s->screen, &screen_params)) {
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
screen_initialized = true;
|
|
|
|
|
|
|
|
|
|
if (options->audio) {
|
|
|
|
|
sc_audio_player_init(&s->audio_player, options->audio_buffer,
|
|
|
|
|
options->audio_output_buffer);
|
|
|
|
|
sc_frame_source_add_sink(&s->audio_decoder.frame_source,
|
|
|
|
|
&s->audio_player.frame_sink);
|
|
|
|
|
}
|
|
|
|
|
sc_frame_source_add_sink(src, &s->screen.frame_sink);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options->audio_playback) {
|
|
|
|
|
sc_audio_player_init(&s->audio_player, options->audio_buffer,
|
|
|
|
|
options->audio_output_buffer);
|
|
|
|
|
sc_frame_source_add_sink(&s->audio_decoder.frame_source,
|
|
|
|
|
&s->audio_player.frame_sink);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_V4L2
|
|
|
|
|