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
77cd4230
Commit
77cd4230
authored
Mar 15, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v4l2: inline OpenVideo()
parent
c0a980e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
53 deletions
+73
-53
modules/access/v4l2/access.c
modules/access/v4l2/access.c
+34
-5
modules/access/v4l2/demux.c
modules/access/v4l2/demux.c
+35
-5
modules/access/v4l2/v4l2.h
modules/access/v4l2/v4l2.h
+2
-1
modules/access/v4l2/video.c
modules/access/v4l2/video.c
+2
-42
No files found.
modules/access/v4l2/access.c
View file @
77cd4230
...
...
@@ -28,11 +28,14 @@
#endif
#include "v4l2.h"
#include <vlc_access.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <vlc_access.h>
#include <vlc_fs.h>
static
block_t
*
AccessRead
(
access_t
*
);
static
ssize_t
AccessReadStream
(
access_t
*
,
uint8_t
*
,
size_t
);
static
int
AccessControl
(
access_t
*
,
int
,
va_list
);
...
...
@@ -49,13 +52,36 @@ int AccessOpen( vlc_object_t *obj )
access
->
p_sys
=
(
access_sys_t
*
)
sys
;
ParseMRL
(
obj
,
access
->
psz_location
);
sys
->
i_fd
=
OpenVideo
(
obj
,
sys
,
false
);
if
(
sys
->
i_fd
==
-
1
)
char
*
path
=
var_InheritString
(
obj
,
CFG_PREFIX
"dev"
);
if
(
unlikely
(
path
==
NULL
))
goto
error
;
/* probably OOM */
msg_Dbg
(
obj
,
"opening device '%s'"
,
path
);
int
rawfd
=
vlc_open
(
path
,
O_RDWR
);
if
(
rawfd
==
-
1
)
{
msg_Err
(
obj
,
"cannot open device '%s': %m"
,
path
);
free
(
path
);
goto
error
;
}
free
(
path
);
int
fd
=
v4l2_fd_open
(
rawfd
,
0
);
if
(
fd
==
-
1
)
{
msg_Warn
(
obj
,
"cannot initialize user-space library: %m"
);
/* fallback to direct kernel mode anyway */
fd
=
rawfd
;
}
if
(
InitVideo
(
obj
,
fd
,
sys
,
false
))
{
free
(
sys
);
return
VLC_EGENERIC
;
v4l2_close
(
fd
);
goto
error
;
}
sys
->
i_fd
=
fd
;
if
(
sys
->
io
==
IO_METHOD_READ
)
access
->
pf_read
=
AccessReadStream
;
else
...
...
@@ -63,6 +89,9 @@ int AccessOpen( vlc_object_t *obj )
access
->
pf_seek
=
NULL
;
access
->
pf_control
=
AccessControl
;
return
VLC_SUCCESS
;
error:
free
(
sys
);
return
VLC_EGENERIC
;
}
void
AccessClose
(
vlc_object_t
*
obj
)
...
...
modules/access/v4l2/demux.c
View file @
77cd4230
...
...
@@ -28,37 +28,67 @@
#endif
#include "v4l2.h"
#include <vlc_demux.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <poll.h>
#include <vlc_demux.h>
#include <vlc_fs.h>
static
int
DemuxControl
(
demux_t
*
,
int
,
va_list
);
static
int
Demux
(
demux_t
*
);
int
DemuxOpen
(
vlc_object_t
*
obj
)
{
demux_t
*
demux
=
(
demux_t
*
)
obj
;
demux_sys_t
*
sys
=
calloc
(
1
,
sizeof
(
demux_sys_t
)
);
if
(
unlikely
(
sys
==
NULL
)
)
return
VLC_ENOMEM
;
demux
->
p_sys
=
sys
;
ParseMRL
(
obj
,
demux
->
psz_location
);
sys
->
i_fd
=
OpenVideo
(
obj
,
sys
,
true
);
if
(
sys
->
i_fd
==
-
1
)
char
*
path
=
var_InheritString
(
obj
,
CFG_PREFIX
"dev"
);
if
(
unlikely
(
path
==
NULL
))
goto
error
;
/* probably OOM */
msg_Dbg
(
obj
,
"opening device '%s'"
,
path
);
int
rawfd
=
vlc_open
(
path
,
O_RDWR
);
if
(
rawfd
==
-
1
)
{
free
(
sys
);
return
VLC_EGENERIC
;
msg_Err
(
obj
,
"cannot open device '%s': %m"
,
path
);
free
(
path
);
goto
error
;
}
free
(
path
);
int
fd
=
v4l2_fd_open
(
rawfd
,
0
);
if
(
fd
==
-
1
)
{
msg_Warn
(
obj
,
"cannot initialize user-space library: %m"
);
/* fallback to direct kernel mode anyway */
fd
=
rawfd
;
}
if
(
InitVideo
(
obj
,
fd
,
sys
,
true
))
{
v4l2_close
(
fd
);
goto
error
;
}
sys
->
i_fd
=
fd
;
demux
->
pf_demux
=
Demux
;
demux
->
pf_control
=
DemuxControl
;
demux
->
info
.
i_update
=
0
;
demux
->
info
.
i_title
=
0
;
demux
->
info
.
i_seekpoint
=
0
;
return
VLC_SUCCESS
;
error:
free
(
sys
);
return
VLC_EGENERIC
;
}
void
DemuxClose
(
vlc_object_t
*
obj
)
...
...
modules/access/v4l2/v4l2.h
View file @
77cd4230
...
...
@@ -112,8 +112,9 @@ struct buffer_t
/* video.c */
void
ParseMRL
(
vlc_object_t
*
,
const
char
*
);
int
OpenVideo
(
vlc_object_t
*
,
demux_sys_t
*
,
bool
);
int
SetupAudio
(
vlc_object_t
*
,
int
,
const
struct
v4l2_input
*
);
block_t
*
GrabVideo
(
vlc_object_t
*
,
demux_sys_t
*
);
int
InitVideo
(
vlc_object_t
*
,
int
fd
,
demux_sys_t
*
,
bool
demux
);
/* demux.c */
int
DemuxOpen
(
vlc_object_t
*
);
...
...
modules/access/v4l2/video.c
View file @
77cd4230
...
...
@@ -39,13 +39,11 @@
#include "v4l2.h"
#include <vlc_plugin.h>
#include <vlc_fs.h>
#include <vlc_demux.h>
#include <math.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <poll.h>
...
...
@@ -776,46 +774,8 @@ static bool IsPixelFormatSupported( struct v4l2_fmtdesc *codecs, size_t n,
}
static
int
InitVideo
(
vlc_object_t
*
p_obj
,
int
i_fd
,
demux_sys_t
*
p_sys
,
bool
b_demux
);
/**
* Opens and sets up a video device
* \return file descriptor or -1 on error
*/
int
OpenVideo
(
vlc_object_t
*
obj
,
demux_sys_t
*
sys
,
bool
b_demux
)
{
char
*
path
=
var_InheritString
(
obj
,
CFG_PREFIX
"dev"
);
if
(
unlikely
(
path
==
NULL
)
)
return
-
1
;
/* probably OOM */
msg_Dbg
(
obj
,
"opening device '%s'"
,
path
);
int
fd
=
vlc_open
(
path
,
O_RDWR
);
if
(
fd
==
-
1
)
{
msg_Err
(
obj
,
"cannot open device '%s': %m"
,
path
);
free
(
path
);
return
-
1
;
}
free
(
path
);
int
libfd
=
v4l2_fd_open
(
fd
,
0
);
if
(
libfd
==
-
1
)
goto
error
;
libfd
=
fd
;
if
(
InitVideo
(
obj
,
fd
,
sys
,
b_demux
)
)
goto
error
;
return
fd
;
error:
close
(
fd
);
return
-
1
;
}
static
int
InitVideo
(
vlc_object_t
*
p_obj
,
int
i_fd
,
demux_sys_t
*
p_sys
,
bool
b_demux
)
int
InitVideo
(
vlc_object_t
*
p_obj
,
int
i_fd
,
demux_sys_t
*
p_sys
,
bool
b_demux
)
{
struct
v4l2_cropcap
cropcap
;
struct
v4l2_crop
crop
;
...
...
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