Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
810fbd89
Commit
810fbd89
authored
Oct 10, 2015
by
Zhang Rui
Committed by
Michael Niedermayer
Oct 10, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fate/async: test error code from underlying protocol
Signed-off-by:
Michael Niedermayer
<
michael@niedermayer.cc
>
parent
7dc42c9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
async.c
libavformat/async.c
+41
-0
async
tests/ref/fate/async
+2
-0
No files found.
libavformat/async.c
View file @
810fbd89
...
@@ -387,6 +387,9 @@ static const AVOption options[] = {
...
@@ -387,6 +387,9 @@ static const AVOption options[] = {
{
NULL
},
{
NULL
},
};
};
#undef D
#undef OFFSET
static
const
AVClass
async_context_class
=
{
static
const
AVClass
async_context_class
=
{
.
class_name
=
"Async"
,
.
class_name
=
"Async"
,
.
item_name
=
av_default_item_name
,
.
item_name
=
av_default_item_name
,
...
@@ -413,6 +416,9 @@ typedef struct TestContext {
...
@@ -413,6 +416,9 @@ typedef struct TestContext {
AVClass
*
class
;
AVClass
*
class
;
int64_t
logical_pos
;
int64_t
logical_pos
;
int64_t
logical_size
;
int64_t
logical_size
;
/* options */
int
opt_read_error
;
}
TestContext
;
}
TestContext
;
static
int
async_test_open
(
URLContext
*
h
,
const
char
*
arg
,
int
flags
,
AVDictionary
**
options
)
static
int
async_test_open
(
URLContext
*
h
,
const
char
*
arg
,
int
flags
,
AVDictionary
**
options
)
...
@@ -434,6 +440,9 @@ static int async_test_read(URLContext *h, unsigned char *buf, int size)
...
@@ -434,6 +440,9 @@ static int async_test_read(URLContext *h, unsigned char *buf, int size)
int
i
;
int
i
;
int
read_len
=
0
;
int
read_len
=
0
;
if
(
c
->
opt_read_error
)
return
c
->
opt_read_error
;
if
(
c
->
logical_pos
>=
c
->
logical_size
)
if
(
c
->
logical_pos
>=
c
->
logical_size
)
return
AVERROR_EOF
;
return
AVERROR_EOF
;
...
@@ -471,9 +480,22 @@ static int64_t async_test_seek(URLContext *h, int64_t pos, int whence)
...
@@ -471,9 +480,22 @@ static int64_t async_test_seek(URLContext *h, int64_t pos, int whence)
return
new_logical_pos
;
return
new_logical_pos
;
}
}
#define OFFSET(x) offsetof(TestContext, x)
#define D AV_OPT_FLAG_DECODING_PARAM
static
const
AVOption
async_test_options
[]
=
{
{
"async-test-read-error"
,
"cause read fail"
,
OFFSET
(
opt_read_error
),
AV_OPT_TYPE_INT
,
{
.
i64
=
0
},
INT_MIN
,
INT_MAX
,
.
flags
=
D
},
{
NULL
},
};
#undef D
#undef OFFSET
static
const
AVClass
async_test_context_class
=
{
static
const
AVClass
async_test_context_class
=
{
.
class_name
=
"Async-Test"
,
.
class_name
=
"Async-Test"
,
.
item_name
=
av_default_item_name
,
.
item_name
=
av_default_item_name
,
.
option
=
async_test_options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
};
...
@@ -496,10 +518,14 @@ int main(void)
...
@@ -496,10 +518,14 @@ int main(void)
int64_t
pos
;
int64_t
pos
;
int64_t
read_len
;
int64_t
read_len
;
unsigned
char
buf
[
4096
];
unsigned
char
buf
[
4096
];
AVDictionary
*
opts
=
NULL
;
ffurl_register_protocol
(
&
ff_async_protocol
);
ffurl_register_protocol
(
&
ff_async_protocol
);
ffurl_register_protocol
(
&
ff_async_test_protocol
);
ffurl_register_protocol
(
&
ff_async_test_protocol
);
/*
* test normal read
*/
ret
=
ffurl_open
(
&
h
,
"async:async-test:"
,
AVIO_FLAG_READ
,
NULL
,
NULL
);
ret
=
ffurl_open
(
&
h
,
"async:async-test:"
,
AVIO_FLAG_READ
,
NULL
,
NULL
);
printf
(
"open: %d
\n
"
,
ret
);
printf
(
"open: %d
\n
"
,
ret
);
...
@@ -534,6 +560,9 @@ int main(void)
...
@@ -534,6 +560,9 @@ int main(void)
}
}
printf
(
"read: %"
PRId64
"
\n
"
,
read_len
);
printf
(
"read: %"
PRId64
"
\n
"
,
read_len
);
/*
* test normal seek
*/
ret
=
ffurl_read
(
h
,
buf
,
1
);
ret
=
ffurl_read
(
h
,
buf
,
1
);
printf
(
"read: %d
\n
"
,
ret
);
printf
(
"read: %d
\n
"
,
ret
);
...
@@ -568,7 +597,19 @@ int main(void)
...
@@ -568,7 +597,19 @@ int main(void)
ret
=
ffurl_read
(
h
,
buf
,
1
);
ret
=
ffurl_read
(
h
,
buf
,
1
);
printf
(
"read: %d
\n
"
,
ret
);
printf
(
"read: %d
\n
"
,
ret
);
/*
* test read error
*/
ffurl_close
(
h
);
av_dict_set_int
(
&
opts
,
"async-test-read-error"
,
-
10000
,
0
);
ret
=
ffurl_open
(
&
h
,
"async:async-test:"
,
AVIO_FLAG_READ
,
NULL
,
&
opts
);
printf
(
"open: %d
\n
"
,
ret
);
ret
=
ffurl_read
(
h
,
buf
,
1
);
printf
(
"read: %d
\n
"
,
ret
);
fail:
fail:
av_dict_free
(
&
opts
);
ffurl_close
(
h
);
ffurl_close
(
h
);
return
0
;
return
0
;
}
}
...
...
tests/ref/fate/async
View file @
810fbd89
...
@@ -5,3 +5,5 @@ read: 0
...
@@ -5,3 +5,5 @@ read: 0
seek: 1536
seek: 1536
read: 512
read: 512
read: 0
read: 0
open: 0
read: -10000
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