diff options
author | Jordan Bayles <jophba@chromium.org> | 2021-07-23 11:55:26 -0700 |
---|---|---|
committer | Openscreen LUCI CQ <openscreen-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2021-07-27 18:52:43 +0000 |
commit | d3d748595d324fb16043df329c9eb906f1d20bf4 (patch) | |
tree | a3cf9ff81ddda233de3c57d39340e48dffab768a /cast/standalone_receiver/sdl_glue.cc | |
parent | 7ad58ffa2b37ecb7ebe2e8b0e1b863925203fdd5 (diff) | |
download | openscreen-d3d748595d324fb16043df329c9eb906f1d20bf4.tar.gz |
[Cast Standalone] Implement Play/Pause
This patch adds play/pause support to the standalone receiver and sender
classes while remoting.
The implementation uses SDL keyboard event bindings to pick up on spacebar
presses when the SDL player window (e.g. the standalone receiver video)
is in focus. This event binding results in a SetPlaybackRate message being
sent over the RPCMessenger, and then the standalone sender class uses the
message's double value to toggle playback on the simulated capturer
implementations.
While falling far short of a full media player implementation, this patch
may help embedders see the basics of how RPC messenging and keeping the
sender and receiver media streams in sync can behave.
Change-Id: I4d2e1ed7f6d69f8a24385c9139320492c2101600
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/3034990
Reviewed-by: Ryan Keane <rwkeane@google.com>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Diffstat (limited to 'cast/standalone_receiver/sdl_glue.cc')
-rw-r--r-- | cast/standalone_receiver/sdl_glue.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cast/standalone_receiver/sdl_glue.cc b/cast/standalone_receiver/sdl_glue.cc index 7c2c94da..c4619f09 100644 --- a/cast/standalone_receiver/sdl_glue.cc +++ b/cast/standalone_receiver/sdl_glue.cc @@ -4,6 +4,8 @@ #include "cast/standalone_receiver/sdl_glue.h" +#include <utility> + #include "platform/api/task_runner.h" #include "platform/api/time.h" #include "util/osp_logging.h" @@ -21,6 +23,11 @@ SDLEventLoopProcessor::SDLEventLoopProcessor( SDLEventLoopProcessor::~SDLEventLoopProcessor() = default; +void SDLEventLoopProcessor::RegisterForKeyboardEvent( + SDLEventLoopProcessor::KeyboardEventCallback cb) { + keyboard_callbacks_.push_back(std::move(cb)); +} + void SDLEventLoopProcessor::ProcessPendingEvents() { // Process all pending events. SDL_Event event; @@ -30,6 +37,10 @@ void SDLEventLoopProcessor::ProcessPendingEvents() { if (quit_callback_) { quit_callback_(); } + } else if (event.type == SDL_KEYUP) { + for (auto& cb : keyboard_callbacks_) { + cb(event.key); + } } } |