Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f65c4206
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
接近 2 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f65c4206
编写于
2月 26, 2022
作者:
R
ruanmeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
surface 切换 xcompont方案 Signed-off-by: NOBUGGERS <ruanmeng@huawei.com>
Signed-off-by:
N
ruanmeng
<
ruanmeng@huawei.com
>
上级
558b2063
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
297 addition
and
316 deletion
+297
-316
multimedia/media/media_js_standard/videoDecoder/src/main/config.json
...media/media_js_standard/videoDecoder/src/main/config.json
+2
-1
multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.css
...ideoDecoder/src/main/js/default/pages/display/display.css
+46
-0
multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.hml
...ideoDecoder/src/main/js/default/pages/display/display.hml
+11
-0
multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.js
...videoDecoder/src/main/js/default/pages/display/display.js
+33
-0
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
...der/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
+25
-42
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
...oder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
+23
-29
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js
...der/src/main/js/test/VideoDecoderReliCallbackTest.test.js
+22
-37
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
...oder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
+22
-38
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
...main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
+36
-45
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
.../main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
+33
-52
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
...main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
+22
-36
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
.../main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
+22
-36
未找到文件。
multimedia/media/media_js_standard/videoDecoder/src/main/config.json
浏览文件 @
f65c4206
...
...
@@ -61,7 +61,8 @@
"js"
:
[
{
"pages"
:
[
"pages/index/index"
"pages/index/index"
,
"pages/display/display"
],
"name"
:
"default"
,
"window"
:
{
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.css
0 → 100644
浏览文件 @
f65c4206
.container
{
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
width
:
100%
;
height
:
100%
;
}
.title
{
font-size
:
40px
;
color
:
#000000
;
opacity
:
0.9
;
}
@media
screen
and
(
device-type
:
tablet
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
100px
;
}
}
@media
screen
and
(
device-type
:
wearable
)
{
.title
{
font-size
:
28px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
tv
)
{
.container
{
background-image
:
url("/common/images/Wallpaper.png")
;
background-size
:
cover
;
background-repeat
:
no-repeat
;
background-position
:
center
;
}
.title
{
font-size
:
100px
;
color
:
#FFFFFF
;
}
}
@media
screen
and
(
device-type
:
phone
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
60px
;
}
}
multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.hml
0 → 100644
浏览文件 @
f65c4206
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<xcomponent id = 'XcomponentId'
type = 'surface'
onload = 'LoadXcomponent'
style = 'width:720px; height:480px; border-color:red; border-width:5px';>
</xcomponent>
</div>
multimedia/media/media_js_standard/videoDecoder/src/main/js/default/pages/display/display.js
0 → 100644
浏览文件 @
f65c4206
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
Core
,
ExpectExtend
}
from
'
deccjsunit/index
'
export
default
{
data
:
{
title
:
""
},
onInit
()
{
console
.
info
(
'
onInit finish
'
)
this
.
title
=
this
.
$t
(
'
strings.world
'
);
},
onShow
()
{
},
onReady
()
{
},
LoadXcomponent
()
{
globalThis
.
value
=
this
.
$element
(
'
XcomponentId
'
).
getXComponentSurfaceId
();
},
}
\ No newline at end of file
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,11 +15,11 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncCallbackTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -84,11 +84,14 @@ describe('VideoDecoderFuncCallbackTest', function () {
232
,
250
,
248
,
281
,
219
,
243
,
293
,
287
,
253
,
328
,
3719
];
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
function
()
{
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -96,6 +99,7 @@ describe('VideoDecoderFuncCallbackTest', function () {
outputQueue
=
[];
isCodecData
=
false
;
inputEosFlag
=
false
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -106,12 +110,8 @@ describe('VideoDecoderFuncCallbackTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -126,7 +126,20 @@ describe('VideoDecoderFuncCallbackTest', function () {
console
.
info
(
`in case error failCatch called,errMessage is
${
error
.
message
}
`
);
expect
(
err
).
assertUndefined
();
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -136,18 +149,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
console
.
info
(
'
in case error readFile
'
+
e
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
function
getContent
(
buf
,
len
)
{
console
.
info
(
'
start get content, len
'
+
len
+
'
buf.byteLength
'
+
buf
.
byteLength
);
let
lengthReal
=
-
1
;
...
...
@@ -286,28 +287,10 @@ describe('VideoDecoderFuncCallbackTest', function () {
supportedQuality [
${
videoCaps
.
supportedQuality
.
min
}
,
${
videoCaps
.
supportedQuality
.
max
}
]
supportedComplexity [
${
videoCaps
.
supportedComplexity
.
min
}
,
${
videoCaps
.
supportedComplexity
.
max
}
]
`
);
eventEmitter
.
emit
(
'
createVideoPlayer
'
,
done
);
});
});
eventEmitter
.
on
(
'
createVideoPlayer
'
,
(
done
)
=>
{
media
.
createVideoPlayer
((
err
,
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
expect
(
videoPlayer
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case createVideoPlayer success!!
'
);
eventEmitter
.
emit
(
'
getDisplaySurface
'
,
done
);
}
eventEmitter
.
emit
(
'
setOutputSurface
'
,
done
);
});
});
eventEmitter
.
on
(
'
getDisplaySurface
'
,
(
done
)
=>
{
videoPlayer
.
getDisplaySurface
((
err
,
outputSurface
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
surfaceID
=
outputSurface
;
console
.
info
(
'
case getDisplaySurface success!!
'
);
eventEmitter
.
emit
(
'
setOutputSurface
'
);
}
})
});
eventEmitter
.
on
(
'
setOutputSurface
'
,
(
done
)
=>
{
videoDecodeProcessor
.
setOutputSurface
(
surfaceID
,
true
,
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,12 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncPromiseTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -88,8 +88,12 @@ describe('VideoDecoderFuncPromiseTest', function () {
// getSurfaceID();
})
beforeEach
(
function
()
{
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -97,6 +101,7 @@ describe('VideoDecoderFuncPromiseTest', function () {
outputQueue
=
[];
isCodecData
=
false
;
inputEosFlag
=
false
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -107,12 +112,8 @@ describe('VideoDecoderFuncPromiseTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -127,6 +128,20 @@ describe('VideoDecoderFuncPromiseTest', function () {
console
.
info
(
`in case error failCatch called,errMessage is
${
error
.
message
}
`
);
expect
(
err
).
assertUndefined
();
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -286,22 +301,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
readFile
(
srcPath
);
},
failCallback
).
catch
(
failCatch
);
}
async
function
setSurfaceID
(
done
)
{
await
media
.
createVideoPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
console
.
info
(
'
in case : createVideoPlayer success
'
);
}
else
{
expect
().
assertFail
();
console
.
info
(
'
in case error: createVideoPlayer fail
'
);
done
();
}
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
getDisplaySurface
().
then
((
outputSurface
)
=>
{
console
.
info
(
'
in case : getDisplaySurface success and surfaceID is
'
+
outputSurface
);
surfaceID
=
outputSurface
;
},
failCallback
).
catch
(
failCatch
);
}
async
function
toSetOutputSurface
(
isDisplay
)
{
await
videoDecodeProcessor
.
setOutputSurface
(
surfaceID
,
isDisplay
).
then
(()
=>
{
console
.
info
(
'
in case : setOutputSurface success. surfaceID
'
+
surfaceID
);
...
...
@@ -357,7 +356,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
toCreateVideoDecoderByMime
(
'
video/avc
'
,
done
);
await
toGetVideoDecoderCaps
();
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -389,7 +387,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
toCreateVideoDecoderByMime
(
'
video/h263
'
,
done
);
await
toGetVideoDecoderCaps
();
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -421,7 +418,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
toCreateVideoDecoderByMime
(
'
video/mpeg2
'
,
done
);
await
toGetVideoDecoderCaps
();
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -453,7 +449,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
toCreateVideoDecoderByMime
(
'
video/mp4v-es
'
,
done
);
await
toGetVideoDecoderCaps
();
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -513,7 +508,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
},
failCallback
).
catch
(
failCatch
);
}
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
releaseAllDecoder
'
,
done
);}
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,6 +15,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
export
const
DECODE_STEP
=
{
...
...
@@ -33,7 +34,6 @@ const DECODE_STEP = {
describe
(
'
VideoDecoderReliCallbackTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -68,11 +68,14 @@ describe('VideoDecoderReliCallbackTest', function () {
let
ES_FRAME_SIZE
=
H264_FRAME_SIZE_30FPS_1080
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -83,7 +86,7 @@ describe('VideoDecoderReliCallbackTest', function () {
eosFrameId
=
-
1
;
inputEosFlag
=
false
;
position
=
0
;
await
setSurfaceID
()
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -94,12 +97,8 @@ describe('VideoDecoderReliCallbackTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -120,6 +119,20 @@ describe('VideoDecoderReliCallbackTest', function () {
console
.
info
(
`in case error failCatch called,errMessage is
${
err
.
message
}
`
);
}
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -149,18 +162,6 @@ describe('VideoDecoderReliCallbackTest', function () {
console
.
error
(
'
in case error getContent err
'
+
err
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
/* push inputbuffers into codec */
async
function
enqueueInputs
()
{
...
...
@@ -274,22 +275,6 @@ describe('VideoDecoderReliCallbackTest', function () {
toNextStep
(
mySteps
,
done
);
});
}
async
function
setSurfaceID
()
{
await
media
.
createVideoPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
console
.
info
(
'
in case : createVideoPlayer success
'
);
}
else
{
expect
().
assertFail
();
console
.
info
(
'
in case error: createVideoPlayer fail
'
);
}
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
getDisplaySurface
().
then
((
outputSurface
)
=>
{
console
.
info
(
'
in case : getDisplaySurface success and surfaceID is
'
+
outputSurface
);
surfaceID
=
outputSurface
;
},
failCallback
).
catch
(
failCatch
);
}
function
toNextStep
(
mySteps
,
done
)
{
console
.
info
(
'
case myStep[0]:
'
+
mySteps
[
0
]);
if
(
mySteps
[
0
]
==
DECODE_STEP
.
RELEASE
)
{
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,6 +15,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
export
const
DECODE_STEP
=
{
...
...
@@ -33,7 +34,6 @@ const DECODE_STEP = {
describe
(
'
VideoDecoderReliPromiseTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -67,11 +67,14 @@ describe('VideoDecoderReliPromiseTest', function () {
let
ES_FRAME_SIZE
=
H264_FRAME_SIZE_30FPS_1080
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -82,7 +85,7 @@ describe('VideoDecoderReliPromiseTest', function () {
eosFrameId
=
-
1
;
inputEosFlag
=
false
;
position
=
0
;
await
setSurfaceID
()
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -93,12 +96,8 @@ describe('VideoDecoderReliPromiseTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -125,6 +124,20 @@ describe('VideoDecoderReliPromiseTest', function () {
expect
(
err
!=
undefined
).
assertTrue
();
toNextStep
(
mySteps
,
done
);
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -154,19 +167,6 @@ describe('VideoDecoderReliPromiseTest', function () {
console
.
error
(
'
in case error getContent err
'
+
err
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
/* push inputbuffers into codec */
async
function
enqueueInputs
()
{
console
.
info
(
'
in case: enqueueInputs in
'
);
...
...
@@ -272,22 +272,6 @@ describe('VideoDecoderReliPromiseTest', function () {
toNextStep
(
mySteps
,
done
);
},
(
err
)
=>
{
failureCallback
(
err
,
mySteps
,
done
)}).
catch
(
catchCallback
);
}
async
function
setSurfaceID
()
{
await
media
.
createVideoPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
console
.
info
(
'
in case : createVideoPlayer success
'
);
}
else
{
expect
().
assertFail
();
console
.
info
(
'
in case error: createVideoPlayer fail
'
);
}
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
getDisplaySurface
().
then
((
outputSurface
)
=>
{
console
.
info
(
'
in case : getDisplaySurface success and surfaceID is
'
+
outputSurface
);
surfaceID
=
outputSurface
;
},
failCallback
).
catch
(
failCatch
);
}
function
toNextStep
(
mySteps
,
done
)
{
console
.
info
(
'
case myStep[0]:
'
+
mySteps
[
0
]);
if
(
mySteps
[
0
]
==
DECODE_STEP
.
RELEASE
)
{
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,11 +15,11 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncCallbackTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -116,11 +116,14 @@ describe('VideoDecoderFuncCallbackTest', function () {
232
,
250
,
248
,
281
,
219
,
243
,
293
,
287
,
253
,
328
,
3719
];
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
function
()
{
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -128,6 +131,7 @@ describe('VideoDecoderFuncCallbackTest', function () {
outputQueue
=
[];
isCodecData
=
false
;
inputEosFlag
=
false
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -138,12 +142,8 @@ describe('VideoDecoderFuncCallbackTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -158,7 +158,20 @@ describe('VideoDecoderFuncCallbackTest', function () {
console
.
info
(
`in case error failCatch called,errMessage is
${
error
.
message
}
`
);
expect
(
err
).
assertUndefined
();
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -168,18 +181,6 @@ describe('VideoDecoderFuncCallbackTest', function () {
console
.
info
(
'
in case error readFile
'
+
e
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
function
getContent
(
buf
,
len
)
{
console
.
info
(
'
start get content, len
'
+
len
+
'
buf.byteLength
'
+
buf
.
byteLength
);
let
lengthReal
=
-
1
;
...
...
@@ -280,29 +281,9 @@ describe('VideoDecoderFuncCallbackTest', function () {
console
.
info
(
'
in case : configure success
'
);
readFile
(
srcPath
);
setCallback
(
nextStep
);
eventEmitter
.
emit
(
'
createVideoPlayer
'
,
done
);
// eventEmitter.emit('setOutputSurface', done);
});
});
eventEmitter
.
on
(
'
createVideoPlayer
'
,
(
done
)
=>
{
media
.
createVideoPlayer
((
err
,
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
expect
(
videoPlayer
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case createVideoPlayer success!!
'
);
eventEmitter
.
emit
(
'
getDisplaySurface
'
,
done
);
}
eventEmitter
.
emit
(
'
setOutputSurface
'
,
done
);
});
});
eventEmitter
.
on
(
'
getDisplaySurface
'
,
(
done
)
=>
{
videoPlayer
.
getDisplaySurface
((
err
,
outputSurface
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
surfaceID
=
outputSurface
;
console
.
info
(
'
case getDisplaySurface success!!
'
);
eventEmitter
.
emit
(
'
setOutputSurface
'
);
}
})
});
eventEmitter
.
on
(
'
setOutputSurface
'
,
(
done
)
=>
{
videoDecodeProcessor
.
setOutputSurface
(
surfaceID
,
true
,
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
...
...
@@ -500,7 +481,7 @@ describe('VideoDecoderFuncCallbackTest', function () {
});
});
eventEmitter
.
on
(
'
reset_for_callback_01_0600
'
,
(
done
)
=>
{
videoDecodeProcessor
.
reset
((
err
)
=>
{
videoDecodeProcessor
.
reset
(
async
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
console
.
info
(
'
in case : reset_for_callback_01_0600 success
'
);
frameCountIn
=
0
;
...
...
@@ -511,6 +492,11 @@ describe('VideoDecoderFuncCallbackTest', function () {
isCodecData
=
true
;
inputEosFlag
=
false
;
readStreamSync
=
null
;
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
surfaceID
=
globalThis
.
value
;
eventEmitter
.
emit
(
'
configure
'
,
mediaDescription
,
srcPath
,
function
()
{
eventEmitter
.
emit
(
'
stop
'
,
done
);
...
...
@@ -557,7 +543,7 @@ describe('VideoDecoderFuncCallbackTest', function () {
});
});
eventEmitter
.
on
(
'
reset_for_callback_01_0700
'
,
(
done
)
=>
{
videoDecodeProcessor
.
reset
((
err
)
=>
{
videoDecodeProcessor
.
reset
(
async
(
err
)
=>
{
expect
(
err
).
assertUndefined
();
console
.
info
(
'
in case : reset_for_callback_01_0700 success
'
);
srcPath
=
BASIC_PATH
+
'
out_320_240_10s.h264
'
;
...
...
@@ -579,6 +565,11 @@ describe('VideoDecoderFuncCallbackTest', function () {
inputEosFlag
=
false
;
readStreamSync
=
null
;
ES_FRAME_SIZE
=
H264_FRAME_SIZE_240
;
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
surfaceID
=
globalThis
.
value
;
eventEmitter
.
emit
(
'
configure
'
,
mediaDescription
,
srcPath
,
function
()
{
eventEmitter
.
emit
(
'
stop
'
,
done
);
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,12 +15,12 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoDecoderFuncPromiseTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -117,11 +117,14 @@ describe('VideoDecoderFuncPromiseTest', function () {
232
,
250
,
248
,
281
,
219
,
243
,
293
,
287
,
253
,
328
,
3719
];
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
function
()
{
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -129,6 +132,7 @@ describe('VideoDecoderFuncPromiseTest', function () {
outputQueue
=
[];
isCodecData
=
false
;
inputEosFlag
=
false
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -139,12 +143,8 @@ describe('VideoDecoderFuncPromiseTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -159,6 +159,20 @@ describe('VideoDecoderFuncPromiseTest', function () {
console
.
info
(
`in case error failCatch called,errMessage is
${
error
.
message
}
`
);
expect
(
err
).
assertUndefined
();
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -182,18 +196,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
console
.
error
(
'
in case error getContent
'
+
e
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
/* push inputbuffers into codec */
async
function
enqueueInputs
(){
...
...
@@ -296,22 +298,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
readFile
(
srcPath
);
},
failCallback
).
catch
(
failCatch
);
}
async
function
setSurfaceID
(
done
)
{
await
media
.
createVideoPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
console
.
info
(
'
in case : createVideoPlayer success
'
);
}
else
{
expect
().
assertFail
();
console
.
info
(
'
in case error: createVideoPlayer fail
'
);
done
();
}
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
getDisplaySurface
().
then
((
outputSurface
)
=>
{
console
.
info
(
'
in case : getDisplaySurface success and surfaceID is
'
+
outputSurface
);
surfaceID
=
outputSurface
;
},
failCallback
).
catch
(
failCatch
);
}
async
function
toSetOutputSurface
(
isDisplay
)
{
await
videoDecodeProcessor
.
setOutputSurface
(
surfaceID
,
isDisplay
).
then
(()
=>
{
console
.
info
(
'
in case : setOutputSurface success. surfaceID
'
+
surfaceID
);
...
...
@@ -366,7 +352,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
toCreateVideoDecoderByName
(
'
avdec_h264
'
,
done
);
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -397,7 +382,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
toCreateVideoDecoderByName
(
'
avdec_h263
'
,
done
);
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -428,7 +412,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
toCreateVideoDecoderByName
(
'
avdec_mpeg2video
'
,
done
);
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -459,7 +442,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
toCreateVideoDecoderByName
(
'
avdec_mpeg4
'
,
done
);
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -491,7 +473,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
toCreateVideoDecoderByName
(
'
avdec_h264
'
,
done
);
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
eventEmitter
.
once
(
'
reConfigure_for_promise_01_0600
'
,
async
(
done
)
=>
{
console
.
info
(
'
in case : reConfigure_for_promise_01_0600 success
'
);
...
...
@@ -501,9 +482,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
videoDecodeProcessor
.
reset
().
then
(()
=>
{
console
.
info
(
'
in case : reset success
'
);
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : release success
'
);
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -512,8 +490,12 @@ describe('VideoDecoderFuncPromiseTest', function () {
isCodecData
=
true
;
inputEosFlag
=
false
;
readStreamSync
=
null
;
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
surfaceID
=
globalThis
.
value
;
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
@@ -551,7 +533,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
}
await
toCreateVideoDecoderByName
(
'
avdec_h264
'
,
done
);
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
srcPath
=
BASIC_PATH
+
'
out_320_240_10s.h264
'
;
mediaDescription
=
{
...
...
@@ -571,10 +552,6 @@ describe('VideoDecoderFuncPromiseTest', function () {
await
videoDecodeProcessor
.
reset
().
then
(()
=>
{
console
.
info
(
'
in case : reset success
'
);
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -584,8 +561,12 @@ describe('VideoDecoderFuncPromiseTest', function () {
inputEosFlag
=
false
;
readStreamSync
=
null
;
ES_FRAME_SIZE
=
H264_FRAME_SIZE_240
;
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
surfaceID
=
globalThis
.
value
;
await
toConfigure
(
mediaDescription
,
srcPath
);
await
setSurfaceID
(
done
);
await
toSetOutputSurface
(
true
);
setCallback
(
function
(){
eventEmitter
.
emit
(
'
nextStep
'
,
done
);}
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,6 +15,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
export
const
DECODE_STEP
=
{
...
...
@@ -33,7 +34,6 @@ const DECODE_STEP = {
describe
(
'
VideoDecoderSoftwareReliCallbackTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -68,11 +68,14 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
let
ES_FRAME_SIZE
=
H264_FRAME_SIZE_30FPS_1080
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -83,7 +86,7 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
eosFrameId
=
-
1
;
inputEosFlag
=
false
;
position
=
0
;
await
setSurfaceID
()
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -94,12 +97,8 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -120,6 +119,20 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
console
.
info
(
`in case error failCatch called,errMessage is
${
err
.
message
}
`
);
}
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -149,18 +162,6 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
console
.
error
(
'
in case error getContent err
'
+
err
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
/* push inputbuffers into codec */
async
function
enqueueInputs
()
{
...
...
@@ -274,21 +275,6 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () {
toNextStep
(
mySteps
,
done
);
});
}
async
function
setSurfaceID
()
{
await
media
.
createVideoPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
console
.
info
(
'
in case : createVideoPlayer success
'
);
}
else
{
expect
().
assertFail
();
console
.
info
(
'
in case error: createVideoPlayer fail
'
);
}
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
getDisplaySurface
().
then
((
outputSurface
)
=>
{
console
.
info
(
'
in case : getDisplaySurface success and surfaceID is
'
+
outputSurface
);
surfaceID
=
outputSurface
;
},
failCallback
).
catch
(
failCatch
);
}
function
toNextStep
(
mySteps
,
done
)
{
console
.
info
(
'
case myStep[0]:
'
+
mySteps
[
0
]);
...
...
multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js
浏览文件 @
f65c4206
...
...
@@ -15,6 +15,7 @@
import
media
from
'
@ohos.multimedia.media
'
import
Fileio
from
'
@ohos.fileio
'
import
router
from
'
@system.router
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
export
const
DECODE_STEP
=
{
...
...
@@ -33,7 +34,6 @@ const DECODE_STEP = {
describe
(
'
VideoDecoderSoftwareReliPromiseTest
'
,
function
()
{
let
videoDecodeProcessor
=
null
;
let
videoPlayer
=
null
;
let
readStreamSync
=
undefined
;
let
frameCountIn
=
0
;
let
frameCountOut
=
0
;
...
...
@@ -67,11 +67,14 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
let
ES_FRAME_SIZE
=
H264_FRAME_SIZE_30FPS_1080
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
// getSurfaceID();
})
beforeEach
(
async
function
()
{
console
.
info
(
'
beforeEach case
'
);
await
toDisplayPage
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
await
msleep
(
1000
).
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
frameCountIn
=
0
;
frameCountOut
=
0
;
timestamp
=
0
;
...
...
@@ -82,7 +85,7 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
eosFrameId
=
-
1
;
inputEosFlag
=
false
;
position
=
0
;
await
setSurfaceID
()
;
surfaceID
=
globalThis
.
value
;
})
afterEach
(
async
function
()
{
...
...
@@ -93,12 +96,8 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
},
failCallback
).
catch
(
failCatch
);
videoDecodeProcessor
=
null
;
}
if
(
videoPlayer
!=
null
)
{
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
in case : videoPlayer release success
'
);
},
failCallback
).
catch
(
failCatch
);
videoPlayer
=
null
;
}
await
router
.
clear
().
then
(()
=>
{
},
failCallback
).
catch
(
failCatch
);
})
afterAll
(
function
()
{
...
...
@@ -125,6 +124,20 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
expect
(
err
!=
undefined
).
assertTrue
();
toNextStep
(
mySteps
,
done
);
}
function
msleep
(
ms
)
{
return
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
ms
));
}
async
function
toDisplayPage
()
{
let
path
=
'
pages/display/display
'
;
let
options
=
{
uri
:
path
,
}
try
{
await
router
.
push
(
options
);
}
catch
(
e
)
{
console
.
error
(
'
in case toDisplayPage
'
+
e
);
}
}
function
readFile
(
path
){
console
.
info
(
'
in case : read file start execution
'
);
try
{
...
...
@@ -154,18 +167,6 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
console
.
error
(
'
in case error getContent err
'
+
err
);
}
}
function
getSurfaceID
()
{
let
surfaceIDTest
=
new
ArrayBuffer
(
20
);
let
readSurfaceID
=
Fileio
.
createStreamSync
(
'
/data/media/surfaceID.txt
'
,
'
rb
'
);
readSurfaceID
.
readSync
(
surfaceIDTest
,
{
length
:
13
});
let
view2
=
new
Uint8Array
(
surfaceIDTest
);
for
(
let
i
=
0
;
i
<
13
;
i
++
)
{
let
value
=
view2
[
i
]
-
48
;
surfaceID
=
surfaceID
+
''
+
value
;
}
console
.
info
(
'
in case surfaceID
'
+
surfaceID
);
readSurfaceID
.
closeSync
();
}
/* push inputbuffers into codec */
async
function
enqueueInputs
()
{
...
...
@@ -272,21 +273,6 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () {
toNextStep
(
mySteps
,
done
);
},
(
err
)
=>
{
failureCallback
(
err
,
mySteps
,
done
)}).
catch
(
catchCallback
);
}
async
function
setSurfaceID
()
{
await
media
.
createVideoPlayer
().
then
((
video
)
=>
{
if
(
typeof
(
video
)
!=
'
undefined
'
)
{
videoPlayer
=
video
;
console
.
info
(
'
in case : createVideoPlayer success
'
);
}
else
{
expect
().
assertFail
();
console
.
info
(
'
in case error: createVideoPlayer fail
'
);
}
},
failCallback
).
catch
(
failCatch
);
await
videoPlayer
.
getDisplaySurface
().
then
((
outputSurface
)
=>
{
console
.
info
(
'
in case : getDisplaySurface success and surfaceID is
'
+
outputSurface
);
surfaceID
=
outputSurface
;
},
failCallback
).
catch
(
failCatch
);
}
function
toNextStep
(
mySteps
,
done
)
{
console
.
info
(
'
case myStep[0]:
'
+
mySteps
[
0
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录