Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
5b6e25e9
Commit
5b6e25e9
authored
Oct 01, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add V4L2 64-bits integer controls (refs #5302)
parent
13d609ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
111 additions
and
13 deletions
+111
-13
modules/access/v4l2/controls.c
modules/access/v4l2/controls.c
+111
-13
No files found.
modules/access/v4l2/controls.c
View file @
5b6e25e9
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include "v4l2.h"
#include "v4l2.h"
#include <ctype.h>
#include <ctype.h>
#include <assert.h>
#include <sys/ioctl.h>
#include <sys/ioctl.h>
typedef
struct
vlc_v4l2_ctrl_name
typedef
struct
vlc_v4l2_ctrl_name
...
@@ -90,12 +91,52 @@ static int ControlSet (const vlc_v4l2_ctrl_t *c, int_fast32_t value)
...
@@ -90,12 +91,52 @@ static int ControlSet (const vlc_v4l2_ctrl_t *c, int_fast32_t value)
return
0
;
return
0
;
}
}
static
int
ControlSet64
(
const
vlc_v4l2_ctrl_t
*
c
,
int64_t
value
)
{
struct
v4l2_ext_control
ext_ctrl
=
{
.
id
=
c
->
id
,
.
size
=
0
,
.
value64
=
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
,
static
int
ControlSetCallback
(
vlc_object_t
*
obj
,
const
char
*
var
,
vlc_value_t
old
,
vlc_value_t
cur
,
void
*
data
)
vlc_value_t
old
,
vlc_value_t
cur
,
void
*
data
)
{
{
const
vlc_v4l2_ctrl_t
*
ctrl
=
data
;
const
vlc_v4l2_ctrl_t
*
ctrl
=
data
;
int
ret
;
if
(
ControlSet
(
ctrl
,
cur
.
i_int
))
switch
(
ctrl
->
type
)
{
case
V4L2_CTRL_TYPE_INTEGER
:
case
V4L2_CTRL_TYPE_MENU
:
case
V4L2_CTRL_TYPE_BITMASK
:
ret
=
ControlSet
(
ctrl
,
cur
.
i_int
);
break
;
case
V4L2_CTRL_TYPE_BOOLEAN
:
ret
=
ControlSet
(
ctrl
,
cur
.
b_bool
);
break
;
case
V4L2_CTRL_TYPE_BUTTON
:
ret
=
ControlSet
(
ctrl
,
0
);
break
;
case
V4L2_CTRL_TYPE_INTEGER64
:
ret
=
ControlSet64
(
ctrl
,
cur
.
i_int
);
break
;
default:
assert
(
0
);
}
if
(
ret
)
{
{
msg_Err
(
obj
,
"cannot set control %s: %m"
,
var
);
msg_Err
(
obj
,
"cannot set control %s: %m"
,
var
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
...
@@ -167,17 +208,53 @@ next:
...
@@ -167,17 +208,53 @@ next:
*
(
end
++
)
=
'\0'
;
*
(
end
++
)
=
'\0'
;
value
=
end
;
value
=
end
;
for
(
const
vlc_v4l2_ctrl_t
*
c
=
list
;
c
!=
NULL
;
c
=
c
->
next
)
if
(
!
strcasecmp
(
name
,
c
->
name
))
switch
(
c
->
type
)
{
case
V4L2_CTRL_TYPE_INTEGER
:
case
V4L2_CTRL_TYPE_BOOLEAN
:
case
V4L2_CTRL_TYPE_MENU
:
{
long
val
=
strtol
(
value
,
&
end
,
0
);
long
val
=
strtol
(
value
,
&
end
,
0
);
if
(
*
end
)
if
(
*
end
)
{
{
msg_Err
(
obj
,
"syntax error in
\"
%s
\"
: not an integer"
,
value
);
msg_Err
(
obj
,
"syntax error in
\"
%s
\"
: "
continue
;
" not an integer"
,
value
);
goto
next
;
}
ControlSet
(
c
,
val
);
break
;
}
}
for
(
const
vlc_v4l2_ctrl_t
*
c
=
list
;
c
!=
NULL
;
c
=
c
->
next
)
case
V4L2_CTRL_TYPE_INTEGER64
:
if
(
!
strcasecmp
(
name
,
c
->
name
))
{
{
long
long
val
=
strtoll
(
value
,
&
end
,
0
);
if
(
*
end
)
{
msg_Err
(
obj
,
"syntax error in
\"
%s
\"
: "
" not an integer"
,
value
);
goto
next
;
}
ControlSet64
(
c
,
val
);
break
;
}
case
V4L2_CTRL_TYPE_BITMASK
:
{
unsigned
long
val
=
strtoul
(
value
,
&
end
,
0
);
if
(
*
end
)
{
msg_Err
(
obj
,
"syntax error in
\"
%s
\"
: "
" not an integer"
,
value
);
goto
next
;
}
ControlSet
(
c
,
val
);
ControlSet
(
c
,
val
);
break
;
}
default:
msg_Err
(
obj
,
"setting
\"
%s
\"
not supported"
,
name
);
goto
next
;
goto
next
;
}
}
...
@@ -388,6 +465,26 @@ static vlc_v4l2_ctrl_t *ControlAddButton (vlc_object_t *obj, int fd,
...
@@ -388,6 +465,26 @@ static vlc_v4l2_ctrl_t *ControlAddButton (vlc_object_t *obj, int fd,
return
c
;
return
c
;
}
}
static
vlc_v4l2_ctrl_t
*
ControlAddInteger64
(
vlc_object_t
*
obj
,
int
fd
,
const
struct
v4l2_queryctrl
*
query
)
{
msg_Dbg
(
obj
,
" 64-bits %s (%08"
PRIX32
")"
,
query
->
name
,
query
->
id
);
if
(
query
->
flags
&
(
CTRL_FLAGS_IGNORE
|
V4L2_CTRL_FLAG_WRITE_ONLY
))
return
NULL
;
vlc_v4l2_ctrl_t
*
c
=
ControlCreate
(
fd
,
query
);
if
(
unlikely
(
c
==
NULL
))
return
NULL
;
if
(
var_Create
(
obj
,
c
->
name
,
VLC_VAR_INTEGER
|
VLC_VAR_ISCOMMAND
))
{
free
(
c
);
return
NULL
;
}
return
c
;
}
static
vlc_v4l2_ctrl_t
*
ControlAddClass
(
vlc_object_t
*
obj
,
int
fd
,
static
vlc_v4l2_ctrl_t
*
ControlAddClass
(
vlc_object_t
*
obj
,
int
fd
,
const
struct
v4l2_queryctrl
*
query
)
const
struct
v4l2_queryctrl
*
query
)
{
{
...
@@ -460,6 +557,7 @@ vlc_v4l2_ctrl_t *ControlsInit (vlc_object_t *obj, int fd)
...
@@ -460,6 +557,7 @@ vlc_v4l2_ctrl_t *ControlsInit (vlc_object_t *obj, int fd)
[
V4L2_CTRL_TYPE_BOOLEAN
]
=
ControlAddBoolean
,
[
V4L2_CTRL_TYPE_BOOLEAN
]
=
ControlAddBoolean
,
[
V4L2_CTRL_TYPE_MENU
]
=
ControlAddMenu
,
[
V4L2_CTRL_TYPE_MENU
]
=
ControlAddMenu
,
[
V4L2_CTRL_TYPE_BUTTON
]
=
ControlAddButton
,
[
V4L2_CTRL_TYPE_BUTTON
]
=
ControlAddButton
,
[
V4L2_CTRL_TYPE_INTEGER64
]
=
ControlAddInteger64
,
[
V4L2_CTRL_TYPE_CTRL_CLASS
]
=
ControlAddClass
,
[
V4L2_CTRL_TYPE_CTRL_CLASS
]
=
ControlAddClass
,
[
V4L2_CTRL_TYPE_BITMASK
]
=
ControlAddBitMask
,
[
V4L2_CTRL_TYPE_BITMASK
]
=
ControlAddBitMask
,
};
};
...
@@ -506,7 +604,7 @@ vlc_v4l2_ctrl_t *ControlsInit (vlc_object_t *obj, int fd)
...
@@ -506,7 +604,7 @@ vlc_v4l2_ctrl_t *ControlsInit (vlc_object_t *obj, int fd)
int64_t
val
=
var_InheritInteger
(
obj
,
varname
);
int64_t
val
=
var_InheritInteger
(
obj
,
varname
);
if
(
val
==
-
1
)
if
(
val
==
-
1
)
continue
;
/* the VLC default value: "do not modify" */
continue
;
/* the VLC default value: "do not modify" */
ControlSet
(
ctrl
,
val
);
ControlSet
(
ctrl
,
val
);
/* NOTE: all known are integers or booleans */
}
}
/* Set any control from the VLC configuration control string */
/* Set any control from the VLC configuration control string */
...
...
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