});
}
+void CEFCapture::resize(unsigned width, unsigned height)
+{
+ lock_guard<mutex> lock(resolution_mutex);
+ this->width = width;
+ this->height = height;
+}
+
void CEFCapture::OnPaint(const void *buffer, int width, int height)
{
steady_clock::time_point timestamp = steady_clock::now();
bool NageruCEFClient::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect)
{
+ return parent->GetViewRect(rect);
+}
+
+bool CEFCapture::GetViewRect(CefRect &rect)
+{
+ lock_guard<mutex> lock(resolution_mutex);
rect = CefRect(0, 0, width, height);
return true;
}
void reload();
void set_max_fps(int max_fps);
void execute_javascript_async(const std::string &js);
+ void resize(unsigned width, unsigned height);
+ // Callbacks from NageruCEFClient.
void OnPaint(const void *buffer, int width, int height);
-
+ bool GetViewRect(CefRect &rect);
void OnLoadEnd();
// CaptureInterface.
void post_to_cef_ui_thread(std::function<void()> &&func);
CefRefPtr<NageruCEFClient> cef_client;
- unsigned width, height;
+
+ // Needs to be different from browser_mutex below, since GetViewRect
+ // can be called unpredictably from when we are already holding
+ // <browser_mutex>.
+ std::mutex resolution_mutex;
+ unsigned width, height; // Under <resolution_mutex>.
+
int card_index = -1;
bool has_dequeue_callbacks = false;
return 0;
}
+int HTMLInput_resize(lua_State* L)
+{
+ assert(lua_gettop(L) == 3);
+ CEFCapture **video_input = (CEFCapture **)luaL_checkudata(L, 1, "HTMLInput");
+ unsigned width = lrint(luaL_checknumber(L, 2));
+ unsigned height = lrint(luaL_checknumber(L, 3));
+ (*video_input)->resize(width, height);
+ return 0;
+}
+
int HTMLInput_get_signal_num(lua_State* L)
{
assert(lua_gettop(L) == 1);
{ "reload", HTMLInput_reload },
{ "set_max_fps", HTMLInput_set_max_fps },
{ "execute_javascript_async", HTMLInput_execute_javascript_async },
+ { "resize", HTMLInput_resize },
{ "get_signal_num", HTMLInput_get_signal_num },
#endif
{ NULL, NULL }