mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Update x11 capture module
This commit is contained in:
@@ -11,16 +11,20 @@ ScreenCaptureX11::~ScreenCaptureX11() {}
|
||||
|
||||
int ScreenCaptureX11::Init(const RECORD_DESKTOP_RECT &rect, const int fps,
|
||||
cb_desktop_data cb) {
|
||||
if (cb) {
|
||||
_on_data = cb;
|
||||
}
|
||||
|
||||
pFormatCtx_ = avformat_alloc_context();
|
||||
|
||||
avdevice_register_all();
|
||||
|
||||
// grabbing frame rate
|
||||
av_dict_set(&options_, "framerate", "5", 0);
|
||||
av_dict_set(&options_, "framerate", "30", 0);
|
||||
// Make the grabbed area follow the mouse
|
||||
av_dict_set(&options_, "follow_mouse", "centered", 0);
|
||||
// Video frame size. The default is to capture the full screen
|
||||
av_dict_set(&options_, "video_size", "1280x720", 0);
|
||||
// av_dict_set(&options_, "video_size", "1280x720", 0);
|
||||
ifmt_ = (AVInputFormat *)av_find_input_format("x11grab");
|
||||
if (!ifmt_) {
|
||||
printf("Couldn't find_input_format\n");
|
||||
@@ -103,6 +107,10 @@ int ScreenCaptureX11::Start() {
|
||||
sws_scale(img_convert_ctx_, pFrame_->data, pFrame_->linesize, 0,
|
||||
pFrame_->height, pFrameNV12_->data,
|
||||
pFrameNV12_->linesize);
|
||||
|
||||
_on_data((unsigned char *)nv12_buffer_,
|
||||
pFrame_->width * pFrame_->height * 3 / 2, pFrame_->width,
|
||||
pFrame_->height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,12 @@ int X11SessionImpl::Start() {
|
||||
|
||||
int X11SessionImpl::Stop() { return 0; }
|
||||
|
||||
int X11SessionImpl::Pause() {}
|
||||
int X11SessionImpl::Pause() { return 0; }
|
||||
|
||||
int X11SessionImpl::Resume() {}
|
||||
int X11SessionImpl::Resume() { return 0; }
|
||||
|
||||
void X11SessionImpl::OnFrame() {}
|
||||
|
||||
void X11SessionImpl::OnClosed() {}
|
||||
|
||||
int X11SessionImpl::Initialize() { return 0; }
|
||||
|
||||
void X11SessionImpl::CleanUp() {}
|
||||
@@ -28,7 +28,6 @@ class X11SessionImpl : public X11Session {
|
||||
void OnFrame();
|
||||
void OnClosed();
|
||||
|
||||
int Initialize();
|
||||
void CleanUp();
|
||||
|
||||
// void message_func();
|
||||
|
||||
Reference in New Issue
Block a user