Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
obs-studio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yunxiang Li
obs-studio
Commits
8d95a7fb
Commit
8d95a7fb
authored
10 years ago
by
fryshorts
Browse files
Options
Downloads
Patches
Plain Diff
Use helper function to set input in v4l2 input.
parent
0abf0f57
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/linux-v4l2/v4l2-helpers.c
+11
-0
11 additions, 0 deletions
plugins/linux-v4l2/v4l2-helpers.c
plugins/linux-v4l2/v4l2-helpers.h
+12
-0
12 additions, 0 deletions
plugins/linux-v4l2/v4l2-helpers.h
plugins/linux-v4l2/v4l2-input.c
+7
-4
7 additions, 4 deletions
plugins/linux-v4l2/v4l2-input.c
with
30 additions
and
4 deletions
plugins/linux-v4l2/v4l2-helpers.c
+
11
−
0
View file @
8d95a7fb
...
...
@@ -123,3 +123,14 @@ int_fast32_t v4l2_destroy_mmap(struct v4l2_buffer_data *buf)
return
0
;
}
int_fast32_t
v4l2_set_input
(
int_fast32_t
dev
,
int
*
input
)
{
if
(
!
dev
||
!
input
)
return
-
1
;
return
(
*
input
==
-
1
)
?
v4l2_ioctl
(
dev
,
VIDIOC_G_INPUT
,
input
)
:
v4l2_ioctl
(
dev
,
VIDIOC_S_INPUT
,
input
);
}
This diff is collapsed.
Click to expand it.
plugins/linux-v4l2/v4l2-helpers.h
+
12
−
0
View file @
8d95a7fb
...
...
@@ -175,6 +175,18 @@ int_fast32_t v4l2_create_mmap(int_fast32_t dev, struct v4l2_buffer_data *buf);
*/
int_fast32_t
v4l2_destroy_mmap
(
struct
v4l2_buffer_data
*
buf
);
/**
* Set the video input on the device.
*
* If the action succeeds input is set to the currently selected input.
*
* @param dev handle for the v4l2 device
* @param input index of the input or -1 to leave it as is
*
* @return negative on failure
*/
int_fast32_t
v4l2_set_input
(
int_fast32_t
dev
,
int
*
input
);
#ifdef __cplusplus
}
#endif
This diff is collapsed.
Click to expand it.
plugins/linux-v4l2/v4l2-input.c
+
7
−
4
View file @
8d95a7fb
...
...
@@ -61,7 +61,7 @@ struct v4l2_data {
os_event_t
event
;
char
*
set_device
;
int
_fast32_t
set_input
;
int
set_input
;
int_fast32_t
set_pixfmt
;
int_fast32_t
set_res
;
int_fast32_t
set_fps
;
...
...
@@ -305,7 +305,8 @@ static void v4l2_input_list(int_fast32_t dev, obs_property_t prop)
if
(
in
.
type
&
V4L2_INPUT_TYPE_CAMERA
)
{
obs_property_list_add_int
(
prop
,
(
char
*
)
in
.
name
,
in
.
index
);
blog
(
LOG_INFO
,
"Found input '%s'"
,
in
.
name
);
blog
(
LOG_INFO
,
"Found input '%s' (Index %d)"
,
in
.
name
,
in
.
index
);
}
in
.
index
++
;
}
...
...
@@ -609,10 +610,12 @@ static void v4l2_init(struct v4l2_data *data)
}
/* set input */
if
(
v4l2_ioctl
(
data
->
dev
,
VIDIOC_S_INPUT
,
&
data
->
set_input
)
<
0
)
{
blog
(
LOG_ERROR
,
"Unable to set input"
);
if
(
v4l2_set_input
(
data
->
dev
,
&
data
->
set_input
)
<
0
)
{
blog
(
LOG_ERROR
,
"Unable to set input %d"
,
data
->
set_input
);
goto
fail
;
}
blog
(
LOG_INFO
,
"Input: %d"
,
data
->
set_input
);
/* set pixel format and resolution */
unpack_tuple
(
&
width
,
&
height
,
data
->
set_res
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment