extern CefRefPtr<NageruCefApp> cef_app;
CEFCapture::CEFCapture(const string &url, unsigned width, unsigned height)
- : cef_client(new NageruCEFClient(width, height, this)),
+ : cef_client(new NageruCEFClient(this)),
width(width),
height(height),
start_url(url)
this->height = height;
}
+void CEFCapture::request_new_frame()
+{
+ // By adding a delay, we make sure we don't get a new frame
+ // delivered immediately (we probably already are on the UI thread),
+ // where we couldn't really deal with it.
+ post_to_cef_ui_thread([this] {
+ lock_guard<recursive_mutex> lock(browser_mutex);
+ if (browser != nullptr) { // Could happen if we are shutting down.
+ browser->GetHost()->Invalidate(PET_VIEW);
+ }
+ }, 16);
+}
+
void CEFCapture::OnPaint(const void *buffer, int width, int height)
{
steady_clock::time_point timestamp = steady_clock::now();
// (CEF only sends OnPaint when there are actual changes,
// so we need to do this explicitly, or we could be stuck on an
// old frame forever if the image doesn't change.)
- //
- // By adding a delay, we make sure we don't get a new frame
- // delivered immediately (we probably already are on the UI thread),
- // where we couldn't really deal with it.
- post_to_cef_ui_thread([this] {
- lock_guard<recursive_mutex> lock(browser_mutex);
- if (browser != nullptr) { // Could happen if we are shutting down.
- browser->GetHost()->Invalidate(PET_VIEW);
- }
- }, 16);
+ request_new_frame();
++timecode;
} else {
assert(video_frame.size >= unsigned(width * height * 4));