Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
a1a25988
Commit
a1a25988
authored
Nov 05, 2014
by
Tristan Matthews
Committed by
Luca Barbato
Nov 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v4l2: Use av_strerror
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
e3e317e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
15 deletions
+34
-15
v4l2.c
libavdevice/v4l2.c
+34
-15
No files found.
libavdevice/v4l2.c
View file @
a1a25988
...
...
@@ -119,6 +119,7 @@ static int device_open(AVFormatContext *ctx)
int
fd
;
int
res
,
err
;
int
flags
=
O_RDWR
;
char
errbuf
[
128
];
if
(
ctx
->
flags
&
AVFMT_FLAG_NONBLOCK
)
{
flags
|=
O_NONBLOCK
;
...
...
@@ -126,19 +127,21 @@ static int device_open(AVFormatContext *ctx)
fd
=
avpriv_open
(
ctx
->
filename
,
flags
);
if
(
fd
<
0
)
{
err
=
errno
;
err
=
AVERROR
(
errno
);
av_strerror
(
err
,
errbuf
,
sizeof
(
errbuf
));
av_log
(
ctx
,
AV_LOG_ERROR
,
"Cannot open video device %s : %s
\n
"
,
ctx
->
filename
,
strerror
(
err
)
);
ctx
->
filename
,
errbuf
);
return
AVERROR
(
err
)
;
return
err
;
}
res
=
ioctl
(
fd
,
VIDIOC_QUERYCAP
,
&
cap
);
if
(
res
<
0
)
{
err
=
errno
;
av_strerror
(
AVERROR
(
err
),
errbuf
,
sizeof
(
errbuf
));
av_log
(
ctx
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_QUERYCAP): %s
\n
"
,
strerror
(
err
)
);
errbuf
);
goto
fail
;
}
...
...
@@ -401,7 +404,9 @@ static int mmap_init(AVFormatContext *ctx)
s
->
fd
,
buf
.
m
.
offset
);
if
(
s
->
buf_start
[
i
]
==
MAP_FAILED
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"mmap: %s
\n
"
,
strerror
(
errno
));
char
errbuf
[
128
];
av_strerror
(
AVERROR
(
errno
),
errbuf
,
sizeof
(
errbuf
));
av_log
(
ctx
,
AV_LOG_ERROR
,
"mmap: %s
\n
"
,
errbuf
);
return
AVERROR
(
errno
);
}
...
...
@@ -423,6 +428,7 @@ static void mmap_release_buffer(void *opaque, uint8_t *data)
int
res
,
fd
;
struct
buff_data
*
buf_descriptor
=
opaque
;
struct
video_data
*
s
=
buf_descriptor
->
s
;
char
errbuf
[
128
];
buf
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
buf
.
memory
=
V4L2_MEMORY_MMAP
;
...
...
@@ -431,9 +437,11 @@ static void mmap_release_buffer(void *opaque, uint8_t *data)
av_free
(
buf_descriptor
);
res
=
ioctl
(
fd
,
VIDIOC_QBUF
,
&
buf
);
if
(
res
<
0
)
if
(
res
<
0
)
{
av_strerror
(
AVERROR
(
errno
),
errbuf
,
sizeof
(
errbuf
));
av_log
(
NULL
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_QBUF): %s
\n
"
,
strerror
(
errno
));
errbuf
);
}
avpriv_atomic_int_add_and_fetch
(
&
s
->
buffers_queued
,
1
);
}
...
...
@@ -457,13 +465,15 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
/* FIXME: Some special treatment might be needed in case of loss of signal... */
while
((
res
=
ioctl
(
s
->
fd
,
VIDIOC_DQBUF
,
&
buf
))
<
0
&&
(
errno
==
EINTR
));
if
(
res
<
0
)
{
char
errbuf
[
128
];
if
(
errno
==
EAGAIN
)
{
pkt
->
size
=
0
;
return
AVERROR
(
EAGAIN
);
}
av_strerror
(
AVERROR
(
errno
),
errbuf
,
sizeof
(
errbuf
));
av_log
(
ctx
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_DQBUF): %s
\n
"
,
strerror
(
errno
)
);
errbuf
);
return
AVERROR
(
errno
);
}
...
...
@@ -542,7 +552,8 @@ static int mmap_start(AVFormatContext *ctx)
{
struct
video_data
*
s
=
ctx
->
priv_data
;
enum
v4l2_buf_type
type
;
int
i
,
res
;
int
i
,
res
,
err
;
char
errbuf
[
128
];
for
(
i
=
0
;
i
<
s
->
buffers
;
i
++
)
{
struct
v4l2_buffer
buf
=
{
...
...
@@ -553,10 +564,12 @@ static int mmap_start(AVFormatContext *ctx)
res
=
ioctl
(
s
->
fd
,
VIDIOC_QBUF
,
&
buf
);
if
(
res
<
0
)
{
err
=
AVERROR
(
errno
);
av_strerror
(
err
,
errbuf
,
sizeof
(
errbuf
));
av_log
(
ctx
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_QBUF): %s
\n
"
,
strerror
(
errno
)
);
errbuf
);
return
AVERROR
(
errno
)
;
return
err
;
}
}
s
->
buffers_queued
=
s
->
buffers
;
...
...
@@ -564,10 +577,12 @@ static int mmap_start(AVFormatContext *ctx)
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
res
=
ioctl
(
s
->
fd
,
VIDIOC_STREAMON
,
&
type
);
if
(
res
<
0
)
{
err
=
AVERROR
(
errno
);
av_strerror
(
err
,
errbuf
,
sizeof
(
errbuf
));
av_log
(
ctx
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_STREAMON): %s
\n
"
,
strerror
(
errno
)
);
errbuf
);
return
AVERROR
(
errno
)
;
return
err
;
}
return
0
;
...
...
@@ -677,8 +692,10 @@ static int v4l2_set_parameters(AVFormatContext *s1)
}
}
else
{
if
(
ioctl
(
s
->
fd
,
VIDIOC_G_PARM
,
&
streamparm
)
!=
0
)
{
char
errbuf
[
128
];
av_strerror
(
AVERROR
(
errno
),
errbuf
,
sizeof
(
errbuf
));
av_log
(
s1
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_G_PARM): %s
\n
"
,
strerror
(
errno
)
);
errbuf
);
return
AVERROR
(
errno
);
}
}
...
...
@@ -779,8 +796,10 @@ static int v4l2_read_header(AVFormatContext *s1)
"Querying the device for the current frame size
\n
"
);
fmt
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
if
(
ioctl
(
s
->
fd
,
VIDIOC_G_FMT
,
&
fmt
)
<
0
)
{
char
errbuf
[
128
];
av_strerror
(
AVERROR
(
errno
),
errbuf
,
sizeof
(
errbuf
));
av_log
(
s1
,
AV_LOG_ERROR
,
"ioctl(VIDIOC_G_FMT): %s
\n
"
,
strerror
(
errno
)
);
errbuf
);
return
AVERROR
(
errno
);
}
...
...
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