Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Obs Studio
提交
e7b25a98
O
Obs Studio
项目概览
小白菜888
/
Obs Studio
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Obs Studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e7b25a98
编写于
4月 14, 2019
作者:
J
Jim
提交者:
GitHub
4月 14, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1667 from grimmy/xshm-xrandr-support
linux-capture: Add randr support
上级
d14fa715
75886809
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
133 addition
and
6 deletion
+133
-6
CI/install-dependencies-linux-ubuntu16.sh
CI/install-dependencies-linux-ubuntu16.sh
+1
-0
CI/install-dependencies-linux.sh
CI/install-dependencies-linux.sh
+1
-0
plugins/linux-capture/CMakeLists.txt
plugins/linux-capture/CMakeLists.txt
+1
-1
plugins/linux-capture/xhelpers.c
plugins/linux-capture/xhelpers.c
+73
-0
plugins/linux-capture/xhelpers.h
plugins/linux-capture/xhelpers.h
+33
-0
plugins/linux-capture/xshm-input.c
plugins/linux-capture/xshm-input.c
+24
-5
未找到文件。
CI/install-dependencies-linux-ubuntu16.sh
浏览文件 @
e7b25a98
...
...
@@ -30,6 +30,7 @@ sudo apt-get install -y \
libvlc-dev
\
libx11-dev
\
libx264-dev
\
libxcb-randr0-dev
\
libxcb-shm0-dev
\
libxcb-xinerama0-dev
\
libxcomposite-dev
\
...
...
CI/install-dependencies-linux.sh
浏览文件 @
e7b25a98
...
...
@@ -33,6 +33,7 @@ sudo apt-get install -y \
libvlc-dev
\
libx11-dev
\
libx264-dev
\
libxcb-randr0-dev
\
libxcb-shm0-dev
\
libxcb-xinerama0-dev
\
libxcomposite-dev
\
...
...
plugins/linux-capture/CMakeLists.txt
浏览文件 @
e7b25a98
...
...
@@ -6,7 +6,7 @@ if(NOT X11_Xcomposite_FOUND)
return
()
endif
()
find_package
(
XCB COMPONENTS XCB SHM XFIXES XINERAMA REQUIRED
)
find_package
(
XCB COMPONENTS XCB
RANDR
SHM XFIXES XINERAMA REQUIRED
)
find_package
(
X11_XCB REQUIRED
)
include_directories
(
SYSTEM
...
...
plugins/linux-capture/xhelpers.c
浏览文件 @
e7b25a98
...
...
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include <sys/shm.h>
#include <xcb/randr.h>
#include <xcb/xcb.h>
#include <xcb/xinerama.h>
...
...
@@ -95,6 +96,78 @@ fail:
return
-
1
;
}
bool
randr_is_active
(
xcb_connection_t
*
xcb
)
{
if
(
!
xcb
||
!
xcb_get_extension_data
(
xcb
,
&
xcb_randr_id
)
->
present
)
return
false
;
return
true
;
}
int
randr_screen_count
(
xcb_connection_t
*
xcb
)
{
if
(
!
xcb
)
return
0
;
xcb_screen_t
*
screen
;
screen
=
xcb_setup_roots_iterator
(
xcb_get_setup
(
xcb
)).
data
;
xcb_randr_get_screen_resources_cookie_t
res_c
;
xcb_randr_get_screen_resources_reply_t
*
res_r
;
res_c
=
xcb_randr_get_screen_resources
(
xcb
,
screen
->
root
);
res_r
=
xcb_randr_get_screen_resources_reply
(
xcb
,
res_c
,
0
);
if
(
!
res_r
)
return
0
;
return
xcb_randr_get_screen_resources_crtcs_length
(
res_r
);
}
int
randr_screen_geo
(
xcb_connection_t
*
xcb
,
int_fast32_t
screen
,
int_fast32_t
*
x
,
int_fast32_t
*
y
,
int_fast32_t
*
w
,
int_fast32_t
*
h
,
xcb_screen_t
**
rscreen
)
{
xcb_screen_t
*
xscreen
;
xscreen
=
xcb_setup_roots_iterator
(
xcb_get_setup
(
xcb
)).
data
;
xcb_randr_get_screen_resources_cookie_t
res_c
;
xcb_randr_get_screen_resources_reply_t
*
res_r
;
res_c
=
xcb_randr_get_screen_resources
(
xcb
,
xscreen
->
root
);
res_r
=
xcb_randr_get_screen_resources_reply
(
xcb
,
res_c
,
0
);
if
(
!
res_r
)
goto
fail
;
int
screens
=
xcb_randr_get_screen_resources_crtcs_length
(
res_r
);
if
(
screen
<
0
||
screen
>=
screens
)
goto
fail
;
xcb_randr_crtc_t
*
crtc
=
xcb_randr_get_screen_resources_crtcs
(
res_r
);
xcb_randr_get_crtc_info_cookie_t
crtc_c
;
xcb_randr_get_crtc_info_reply_t
*
crtc_r
;
crtc_c
=
xcb_randr_get_crtc_info
(
xcb
,
*
(
crtc
+
screen
),
0
);
crtc_r
=
xcb_randr_get_crtc_info_reply
(
xcb
,
crtc_c
,
0
);
if
(
!
crtc_r
)
goto
fail
;
*
x
=
crtc_r
->
x
;
*
y
=
crtc_r
->
y
;
*
w
=
crtc_r
->
width
;
*
h
=
crtc_r
->
height
;
if
(
rscreen
)
*
rscreen
=
xscreen
;
return
0
;
fail:
*
x
=
*
y
=
*
w
=
*
h
=
0
;
return
-
1
;
}
int
x11_screen_geo
(
xcb_connection_t
*
xcb
,
int_fast32_t
screen
,
int_fast32_t
*
w
,
int_fast32_t
*
h
)
{
...
...
plugins/linux-capture/xhelpers.h
浏览文件 @
e7b25a98
...
...
@@ -64,6 +64,39 @@ int xinerama_screen_geo(xcb_connection_t *xcb, int_fast32_t screen,
int_fast32_t
*
x
,
int_fast32_t
*
y
,
int_fast32_t
*
w
,
int_fast32_t
*
h
);
/**
* Check for Randr extension
*
* @return true if randr is available which means it's active.
*/
bool
randr_is_active
(
xcb_connection_t
*
xcb
);
/**
* Get the number of Randr screens
*
* @return number of screens
*/
int
randr_screen_count
(
xcb_connection_t
*
xcb
);
/**
* Get screen geometry for a Rand crtc (screen)
*
* @note On error the passed coordinates/sizes will be set to 0.
*
* @param xcb xcb connection
* @param screen screen number to get geometry for
* @param x x-coordinate of the screen
* @param y y-coordinate of the screen
* @param w width of the screen
* @param h height of the screen
*
* @return < 0 on error
*/
int
randr_screen_geo
(
xcb_connection_t
*
xcb
,
int_fast32_t
screen
,
int_fast32_t
*
x
,
int_fast32_t
*
y
,
int_fast32_t
*
w
,
int_fast32_t
*
h
,
xcb_screen_t
**
rscreen
);
/**
* Get screen geometry for a X11 screen
*
...
...
plugins/linux-capture/xshm-input.c
浏览文件 @
e7b25a98
...
...
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <xcb/randr.h>
#include <xcb/shm.h>
#include <xcb/xfixes.h>
#include <xcb/xinerama.h>
...
...
@@ -50,6 +51,7 @@ struct xshm_data {
bool
show_cursor
;
bool
use_xinerama
;
bool
use_randr
;
bool
advanced
;
};
...
...
@@ -83,6 +85,9 @@ static bool xshm_check_extensions(xcb_connection_t *xcb)
if
(
!
xcb_get_extension_data
(
xcb
,
&
xcb_xinerama_id
)
->
present
)
blog
(
LOG_INFO
,
"Missing Xinerama extension !"
);
if
(
!
xcb_get_extension_data
(
xcb
,
&
xcb_randr_id
)
->
present
)
blog
(
LOG_INFO
,
"Missing Randr extension !"
);
return
ok
;
}
...
...
@@ -96,7 +101,15 @@ static int_fast32_t xshm_update_geometry(struct xshm_data *data)
int_fast32_t
old_width
=
data
->
width
;
int_fast32_t
old_height
=
data
->
height
;
if
(
data
->
use_xinerama
)
{
if
(
data
->
use_randr
)
{
if
(
randr_screen_geo
(
data
->
xcb
,
data
->
screen_id
,
&
data
->
x_org
,
&
data
->
y_org
,
&
data
->
width
,
&
data
->
height
,
&
data
->
xcb_screen
)
<
0
)
{
return
-
1
;
}
}
else
if
(
data
->
use_xinerama
)
{
if
(
xinerama_screen_geo
(
data
->
xcb
,
data
->
screen_id
,
&
data
->
x_org
,
&
data
->
y_org
,
&
data
->
width
,
&
data
->
height
)
<
0
)
{
...
...
@@ -189,6 +202,7 @@ static void xshm_capture_start(struct xshm_data *data)
if
(
!
xshm_check_extensions
(
data
->
xcb
))
goto
fail
;
data
->
use_randr
=
randr_is_active
(
data
->
xcb
)
?
true
:
false
;
data
->
use_xinerama
=
xinerama_is_active
(
data
->
xcb
)
?
true
:
false
;
if
(
xshm_update_geometry
(
data
)
<
0
)
{
...
...
@@ -287,16 +301,21 @@ static bool xshm_server_changed(obs_properties_t *props,
struct
dstr
screen_info
;
dstr_init
(
&
screen_info
);
bool
randr
=
randr_is_active
(
xcb
);
bool
xinerama
=
xinerama_is_active
(
xcb
);
int_fast32_t
count
=
(
xinerama
)
?
xinerama_screen_count
(
xcb
)
:
xcb_setup_roots_length
(
xcb_get_setup
(
xcb
));
int_fast32_t
count
=
(
randr
)
?
randr_screen_count
(
xcb
)
:
(
xinerama
)
?
xinerama_screen_count
(
xcb
)
:
xcb_setup_roots_length
(
xcb_get_setup
(
xcb
));
for
(
int_fast32_t
i
=
0
;
i
<
count
;
++
i
)
{
int_fast32_t
x
,
y
,
w
,
h
;
x
=
y
=
w
=
h
=
0
;
if
(
xinerama
)
if
(
randr
)
randr_screen_geo
(
xcb
,
i
,
&
x
,
&
y
,
&
w
,
&
h
,
NULL
);
else
if
(
xinerama
)
xinerama_screen_geo
(
xcb
,
i
,
&
x
,
&
y
,
&
w
,
&
h
);
else
x11_screen_geo
(
xcb
,
i
,
&
w
,
&
h
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录