Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a0adc285
Commit
a0adc285
authored
Oct 02, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add V4L2 string type controls (fix #5302)
parent
bc40d784
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
modules/access/v4l2/controls.c
modules/access/v4l2/controls.c
+74
-0
No files found.
modules/access/v4l2/controls.c
View file @
a0adc285
...
...
@@ -120,6 +120,25 @@ static int ControlSet64 (const vlc_v4l2_ctrl_t *c, int64_t value)
return
0
;
}
static
int
ControlSetStr
(
const
vlc_v4l2_ctrl_t
*
c
,
const
char
*
restrict
value
)
{
struct
v4l2_ext_control
ext_ctrl
=
{
.
id
=
c
->
id
,
.
size
=
strlen
(
value
)
+
1
,
};
ext_ctrl
.
string
=
(
char
*
)
value
;
struct
v4l2_ext_controls
ext_ctrls
=
{
.
ctrl_class
=
V4L2_CTRL_ID2CLASS
(
c
->
id
),
.
count
=
1
,
.
error_idx
=
0
,
.
controls
=
&
ext_ctrl
,
};
if
(
v4l2_ioctl
(
c
->
fd
,
VIDIOC_S_EXT_CTRLS
,
&
ext_ctrls
)
<
0
)
return
-
1
;
return
0
;
}
static
int
ControlSetCallback
(
vlc_object_t
*
obj
,
const
char
*
var
,
vlc_value_t
old
,
vlc_value_t
cur
,
void
*
data
)
{
...
...
@@ -142,6 +161,9 @@ static int ControlSetCallback (vlc_object_t *obj, const char *var,
case
V4L2_CTRL_TYPE_INTEGER64
:
ret
=
ControlSet64
(
ctrl
,
cur
.
i_int
);
break
;
case
V4L2_CTRL_TYPE_STRING
:
ret
=
ControlSetStr
(
ctrl
,
cur
.
psz_string
);
break
;
default:
assert
(
0
);
}
...
...
@@ -250,6 +272,10 @@ next:
break
;
}
case
V4L2_CTRL_TYPE_STRING
:
ControlSetStr
(
c
,
value
);
break
;
case
V4L2_CTRL_TYPE_BITMASK
:
{
unsigned
long
val
=
strtoul
(
value
,
&
end
,
0
);
...
...
@@ -521,6 +547,53 @@ static vlc_v4l2_ctrl_t *ControlAddClass (vlc_object_t *obj, int fd,
return
NULL
;
}
static
vlc_v4l2_ctrl_t
*
ControlAddString
(
vlc_object_t
*
obj
,
int
fd
,
const
struct
v4l2_queryctrl
*
query
)
{
msg_Dbg
(
obj
,
" string %s (%08"
PRIX32
")"
,
query
->
name
,
query
->
id
);
if
(
query
->
flags
&
(
CTRL_FLAGS_IGNORE
|
V4L2_CTRL_FLAG_WRITE_ONLY
)
||
query
->
maximum
>
65535
)
return
NULL
;
vlc_v4l2_ctrl_t
*
c
=
ControlCreate
(
fd
,
query
);
if
(
unlikely
(
c
==
NULL
))
return
NULL
;
if
(
var_Create
(
obj
,
c
->
name
,
VLC_VAR_STRING
|
VLC_VAR_ISCOMMAND
))
{
free
(
c
);
return
NULL
;
}
/* Get current value */
char
*
buf
=
malloc
(
query
->
maximum
+
1
);
if
(
likely
(
buf
!=
NULL
))
{
struct
v4l2_ext_control
ext_ctrl
=
{
.
id
=
c
->
id
,
.
size
=
query
->
maximum
+
1
,
};
ext_ctrl
.
string
=
buf
;
struct
v4l2_ext_controls
ext_ctrls
=
{
.
ctrl_class
=
V4L2_CTRL_ID2CLASS
(
c
->
id
),
.
count
=
1
,
.
error_idx
=
0
,
.
controls
=
&
ext_ctrl
,
};
if
(
v4l2_ioctl
(
c
->
fd
,
VIDIOC_G_EXT_CTRLS
,
&
ext_ctrls
)
>=
0
)
{
vlc_value_t
val
=
{
.
psz_string
=
buf
};
msg_Dbg
(
obj
,
" current:
\"
%s
\"
"
,
buf
);
var_Change
(
obj
,
c
->
name
,
VLC_VAR_SETVALUE
,
&
val
,
NULL
);
}
free
(
buf
);
}
return
c
;
}
static
vlc_v4l2_ctrl_t
*
ControlAddBitMask
(
vlc_object_t
*
obj
,
int
fd
,
const
struct
v4l2_queryctrl
*
query
)
{
...
...
@@ -587,6 +660,7 @@ vlc_v4l2_ctrl_t *ControlsInit (vlc_object_t *obj, int fd)
[
V4L2_CTRL_TYPE_BUTTON
]
=
ControlAddButton
,
[
V4L2_CTRL_TYPE_INTEGER64
]
=
ControlAddInteger64
,
[
V4L2_CTRL_TYPE_CTRL_CLASS
]
=
ControlAddClass
,
[
V4L2_CTRL_TYPE_STRING
]
=
ControlAddString
,
[
V4L2_CTRL_TYPE_BITMASK
]
=
ControlAddBitMask
,
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment