Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Ffmpeg
提交
aee909ac
F
Ffmpeg
项目概览
小白菜888
/
Ffmpeg
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Ffmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aee909ac
编写于
7月 21, 2015
作者:
Z
Zhang Rui
提交者:
Michael Niedermayer
7月 21, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fate: add test for async protocol
Signed-off-by:
N
Michael Niedermayer
<
michael@niedermayer.cc
>
上级
5d0616ce
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
184 addition
and
1 deletion
+184
-1
libavformat/Makefile
libavformat/Makefile
+2
-1
libavformat/async.c
libavformat/async.c
+171
-0
tests/fate/libavformat.mak
tests/fate/libavformat.mak
+4
-0
tests/ref/fate/async
tests/ref/fate/async
+7
-0
未找到文件。
libavformat/Makefile
浏览文件 @
aee909ac
...
...
@@ -546,7 +546,8 @@ SLIBOBJS-$(HAVE_GNU_WINDRES) += avformatres.o
SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL)
+=
rtmpdh.h
SKIPHEADERS-$(CONFIG_NETWORK)
+=
network.h rtsp.h
TESTPROGS
=
seek
\
TESTPROGS
=
async
\
seek
\
srtp
\
url
\
...
...
libavformat/async.c
浏览文件 @
aee909ac
...
...
@@ -385,3 +385,174 @@ URLProtocol ff_async_protocol = {
.
priv_data_size
=
sizeof
(
Context
),
.
priv_data_class
=
&
async_context_class
,
};
#ifdef TEST
#define TEST_SEEK_POS (1536)
#define TEST_STREAM_SIZE (2048)
typedef
struct
TestContext
{
AVClass
*
class
;
size_t
logical_pos
;
size_t
logical_size
;
}
TestContext
;
static
int
async_test_open
(
URLContext
*
h
,
const
char
*
arg
,
int
flags
,
AVDictionary
**
options
)
{
TestContext
*
c
=
h
->
priv_data
;
c
->
logical_pos
=
0
;
c
->
logical_size
=
TEST_STREAM_SIZE
;
return
0
;
}
static
int
async_test_close
(
URLContext
*
h
)
{
return
0
;
}
static
int
async_test_read
(
URLContext
*
h
,
unsigned
char
*
buf
,
int
size
)
{
TestContext
*
c
=
h
->
priv_data
;
int
i
;
int
read_len
=
0
;
if
(
c
->
logical_pos
>=
c
->
logical_size
)
return
AVERROR_EOF
;
for
(
i
=
0
;
i
<
size
;
++
i
)
{
buf
[
i
]
=
c
->
logical_pos
&
0xFF
;
c
->
logical_pos
++
;
read_len
++
;
if
(
c
->
logical_pos
>=
c
->
logical_size
)
break
;
}
return
read_len
;
}
static
int64_t
async_test_seek
(
URLContext
*
h
,
int64_t
pos
,
int
whence
)
{
TestContext
*
c
=
h
->
priv_data
;
int64_t
new_logical_pos
;
if
(
whence
==
AVSEEK_SIZE
)
{
return
c
->
logical_size
;
}
if
(
whence
==
SEEK_CUR
)
{
new_logical_pos
=
pos
+
c
->
logical_pos
;
}
else
if
(
whence
==
SEEK_SET
){
new_logical_pos
=
pos
;
}
else
{
return
AVERROR
(
EINVAL
);
}
if
(
new_logical_pos
<
0
)
return
AVERROR
(
EINVAL
);
c
->
logical_pos
=
new_logical_pos
;
return
new_logical_pos
;
}
static
const
AVClass
async_test_context_class
=
{
.
class_name
=
"Async-Test"
,
.
item_name
=
av_default_item_name
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
URLProtocol
ff_async_test_protocol
=
{
.
name
=
"async-test"
,
.
url_open2
=
async_test_open
,
.
url_read
=
async_test_read
,
.
url_seek
=
async_test_seek
,
.
url_close
=
async_test_close
,
.
priv_data_size
=
sizeof
(
TestContext
),
.
priv_data_class
=
&
async_test_context_class
,
};
int
main
(
void
)
{
URLContext
*
h
=
NULL
;
int
i
;
int
ret
;
int64_t
size
;
int64_t
pos
;
int64_t
read_len
;
unsigned
char
buf
[
4096
];
ffurl_register_protocol
(
&
ff_async_protocol
);
ffurl_register_protocol
(
&
ff_async_test_protocol
);
ret
=
ffurl_open
(
&
h
,
"async:async-test:"
,
AVIO_FLAG_READ
,
NULL
,
NULL
);
printf
(
"open: %d
\n
"
,
ret
);
size
=
ffurl_size
(
h
);
printf
(
"size: %"
PRId64
"
\n
"
,
size
);
pos
=
ffurl_seek
(
h
,
0
,
SEEK_CUR
);
read_len
=
0
;
while
(
1
)
{
ret
=
ffurl_read
(
h
,
buf
,
sizeof
(
buf
));
if
(
ret
==
AVERROR_EOF
)
{
printf
(
"read-error: AVERROR_EOF at %"
PRId64
"
\n
"
,
ffurl_seek
(
h
,
0
,
SEEK_CUR
));
break
;
}
else
if
(
ret
==
0
)
break
;
else
if
(
ret
<
0
)
{
printf
(
"read-error: %d at %"
PRId64
"
\n
"
,
ret
,
ffurl_seek
(
h
,
0
,
SEEK_CUR
));
goto
fail
;
}
else
{
for
(
i
=
0
;
i
<
ret
;
++
i
)
{
if
(
buf
[
i
]
!=
(
pos
&
0xFF
))
{
printf
(
"read-mismatch: actual %d, expecting %d, at %"
PRId64
"
\n
"
,
(
int
)
buf
[
i
],
(
int
)(
pos
&
0xFF
),
pos
);
break
;
}
pos
++
;
}
}
read_len
+=
ret
;
}
printf
(
"read: %"
PRId64
"
\n
"
,
read_len
);
ret
=
ffurl_read
(
h
,
buf
,
1
);
printf
(
"read: %d
\n
"
,
ret
);
pos
=
ffurl_seek
(
h
,
TEST_SEEK_POS
,
SEEK_SET
);
printf
(
"seek: %"
PRId64
"
\n
"
,
pos
);
read_len
=
0
;
while
(
1
)
{
ret
=
ffurl_read
(
h
,
buf
,
sizeof
(
buf
));
if
(
ret
==
AVERROR_EOF
)
break
;
else
if
(
ret
==
0
)
break
;
else
if
(
ret
<
0
)
{
printf
(
"read-error: %d at %"
PRId64
"
\n
"
,
ret
,
ffurl_seek
(
h
,
0
,
SEEK_CUR
));
goto
fail
;
}
else
{
for
(
i
=
0
;
i
<
ret
;
++
i
)
{
if
(
buf
[
i
]
!=
(
pos
&
0xFF
))
{
printf
(
"read-mismatch: actual %d, expecting %d, at %"
PRId64
"
\n
"
,
(
int
)
buf
[
i
],
(
int
)(
pos
&
0xFF
),
pos
);
break
;
}
pos
++
;
}
}
read_len
+=
ret
;
}
printf
(
"read: %"
PRId64
"
\n
"
,
read_len
);
ret
=
ffurl_read
(
h
,
buf
,
1
);
printf
(
"read: %d
\n
"
,
ret
);
fail:
ffurl_close
(
h
);
return
0
;
}
#endif
tests/fate/libavformat.mak
浏览文件 @
aee909ac
FATE_LIBAVFORMAT-$(HAVE_PTHREADS)
+=
fate-async
fate-async
:
libavformat/async-test$(EXESUF)
fate-async
:
CMD = run libavformat/async-test
FATE_LIBAVFORMAT-$(CONFIG_NETWORK)
+=
fate-noproxy
fate-noproxy
:
libavformat/noproxy-test$(EXESUF)
fate-noproxy
:
CMD = run libavformat/noproxy-test
...
...
tests/ref/fate/async
0 → 100644
浏览文件 @
aee909ac
open: 0
size: 2048
read: 2048
read: 0
seek: 1536
read: 512
read: 0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录