Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6da39cde
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
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看板
提交
6da39cde
编写于
9月 18, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
!654 media test native测试用例更新
Merge pull request !654 from bird_j/bird-j-master-patch-96770
上级
ee0b285a
5fcee66a
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
1548 addition
and
1032 deletion
+1548
-1032
multimedia/media/media_cpp_test_standard/include/mediatest_log.h
...dia/media/media_cpp_test_standard/include/mediatest_log.h
+21
-14
multimedia/media/media_cpp_test_standard/player/include/ActsPlayerAPITest.h
...edia_cpp_test_standard/player/include/ActsPlayerAPITest.h
+8
-6
multimedia/media/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h
...dia_cpp_test_standard/player/include/ActsPlayerFuncTest.h
+9
-6
multimedia/media/media_cpp_test_standard/player/include/TestParamsConfig.h
...media_cpp_test_standard/player/include/TestParamsConfig.h
+66
-0
multimedia/media/media_cpp_test_standard/player/include/Testplayer.h
...media/media_cpp_test_standard/player/include/Testplayer.h
+16
-16
multimedia/media/media_cpp_test_standard/player/src/TestParamsConfig.cpp
...a/media_cpp_test_standard/player/src/TestParamsConfig.cpp
+66
-0
multimedia/media/media_cpp_test_standard/player/src/TestPlayer.cpp
...a/media/media_cpp_test_standard/player/src/TestPlayer.cpp
+383
-0
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerFuncAsyncTest.cpp
..._standard/player/src/function/ActsPlayerFuncAsyncTest.cpp
+235
-235
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerFuncTest.cpp
..._test_standard/player/src/function/ActsPlayerFuncTest.cpp
+235
-235
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerStateAsyncTest.cpp
...standard/player/src/function/ActsPlayerStateAsyncTest.cpp
+256
-261
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerStateTest.cpp
...test_standard/player/src/function/ActsPlayerStateTest.cpp
+253
-259
未找到文件。
multimedia/media/media_cpp_test_standard/include/mediatest_log.h
浏览文件 @
6da39cde
...
...
@@ -13,28 +13,35 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "media_log.h"
#include "securec.h"
#define MEDIA_DEBUG_LOG(fmt, ...) \
#define LOGMAXSIZE 200
#define MEDIA_INFO_LOG(fmt, ...) \
do
{
\
printf
(
fmt
,
##
__VA_ARGS__
);
\
printf
(
"
\n
"
);
\
__MEDIA_LOG
(
::
OHOS
::
HiviewDFX
::
HiLog
::
Debug
,
fmt
,
##
__VA_ARGS__
);
\
}
while
(
0
)
\
char
ch
[
LOGMAXSIZE
];
\
(
void
)
sprintf_s
(
ch
,
LOGMAXSIZE
,
fmt
,
##
__VA_ARGS__
);
\
(
void
)
printf
(
"%s"
,
ch
);
\
(
void
)
printf
(
"
\n
"
);
\
__MEDIA_LOG
(
::
OHOS
::
HiviewDFX
::
HiLog
::
Info
,
"%{public}s"
,
ch
);
\
}
while
(
0
)
#define MEDIA_
INFO
_LOG(fmt, ...) \
#define MEDIA_
DEBUG
_LOG(fmt, ...) \
do
{
\
printf
(
fmt
,
##
__VA_ARGS__
)
;
\
printf
(
"
\n
"
);
\
__MEDIA_LOG
(
::
OHOS
::
HiviewDFX
::
HiLog
::
Info
,
fmt
,
##
__VA_ARGS__
);
\
}
while
(
0
)
\
char
ch
[
LOGMAXSIZE
]
;
\
(
void
)
sprintf_s
(
ch
,
LOGMAXSIZE
,
fmt
,
##
__VA_ARGS__
);
\
__MEDIA_LOG
(
::
OHOS
::
HiviewDFX
::
HiLog
::
Debug
,
"%{public}s"
,
ch
);
\
}
while
(
0
)
#define MEDIA_ERROR_LOG(fmt, ...) \
do
{
\
printf
(
fmt
,
##
__VA_ARGS__
);
\
printf
(
"
\n
"
);
\
__MEDIA_LOG
(
::
OHOS
::
HiviewDFX
::
HiLog
::
Error
,
fmt
,
##
__VA_ARGS__
);
\
}
while
(
0
)
\
char
ch
[
LOGMAXSIZE
];
\
(
void
)
sprintf_s
(
ch
,
LOGMAXSIZE
,
fmt
,
##
__VA_ARGS__
);
\
(
void
)
printf
(
"%s"
,
ch
);
\
(
void
)
printf
(
"
\n
"
);
\
__MEDIA_LOG
(
::
OHOS
::
HiviewDFX
::
HiLog
::
Error
,
"%{public}s"
,
ch
);
\
}
while
(
0
)
namespace
{
constexpr
OHOS
::
HiviewDFX
::
HiLogLabel
LABEL
=
{
LOG_CORE
,
LOG_DOMAIN
,
"MediaTest"
};
...
...
multimedia/media/media_cpp_test_standard/player/include/ActsPlayerAPITest.h
浏览文件 @
6da39cde
...
...
@@ -21,25 +21,27 @@ namespace OHOS {
namespace
Media
{
class
ActsPlayerAPITest
:
public
testing
::
Test
{
public:
// SetUpTestCase: before all testcase
e
// SetUpTestCase: before all testcase
s
static
void
SetUpTestCase
(
void
)
{
MEDIA_
INFO
_LOG
(
"ActsPlayerAPITest::SetUpTestCase"
);
MEDIA_
DEBUG
_LOG
(
"ActsPlayerAPITest::SetUpTestCase"
);
};
// TearDownTestCase: after all testcase
// TearDownTestCase: after all testcase
s
static
void
TearDownTestCase
(
void
)
{
MEDIA_
INFO
_LOG
(
"ActsPlayerAPITest::TearDownTestCase"
);
MEDIA_
DEBUG
_LOG
(
"ActsPlayerAPITest::TearDownTestCase"
);
};
// SetUp
void
SetUp
(
void
)
{
MEDIA_INFO_LOG
(
"ActsPlayerAPITest::SetUp"
);
const
::
testing
::
TestInfo
*
const
testInfo
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
MEDIA_DEBUG_LOG
(
"ActsPlayerAPITest::SetUp:%s"
,
testInfo
->
name
());
};
// TearDown
void
TearDown
(
void
)
{
MEDIA_INFO_LOG
(
"ActsPlayerAPITest::TearDown"
);
const
::
testing
::
TestInfo
*
const
testInfo
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
MEDIA_DEBUG_LOG
(
"ActsPlayerAPITest::TearDown:%s"
,
testInfo
->
name
());
};
void
LocalPlayFunc
(
const
std
::
string
uri
,
bool
isAsync
,
WindowConfig
config
=
g_config
);
};
...
...
multimedia/media/media_cpp_test_standard/player/include/ActsPlayerFuncTest.h
浏览文件 @
6da39cde
...
...
@@ -21,25 +21,28 @@ namespace OHOS {
namespace
Media
{
class
ActsPlayerFuncTest
:
public
testing
::
Test
{
public:
// SetUpTestCase: before all testcase
e
// SetUpTestCase: before all testcase
s
static
void
SetUpTestCase
(
void
)
{
MEDIA_INFO_LOG
(
"ActsPlayerFuncTest::SetUpTestCase"
);
MEDIA_DEBUG_LOG
(
"ActsPlayerFuncTest::SetUpTestCase"
);
TestPlayerBasic
::
TestParamsConfig
::
GetInstance
().
InitPlayProtocol
();
};
// TearDownTestCase: after all testcase
// TearDownTestCase: after all testcase
s
static
void
TearDownTestCase
(
void
)
{
MEDIA_
INFO
_LOG
(
"ActsPlayerFuncTest::TearDownTestCase"
);
MEDIA_
DEBUG
_LOG
(
"ActsPlayerFuncTest::TearDownTestCase"
);
};
// SetUp
void
SetUp
(
void
)
{
MEDIA_INFO_LOG
(
"ActsPlayerFuncTest::SetUp"
);
const
::
testing
::
TestInfo
*
const
testInfo
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
MEDIA_DEBUG_LOG
(
"ActsPlayerFuncTest::SetUp:%s"
,
testInfo
->
name
());
};
// TearDown
void
TearDown
(
void
)
{
MEDIA_INFO_LOG
(
"ActsPlayerFuncTest::TearDown"
);
const
::
testing
::
TestInfo
*
const
testInfo
=
::
testing
::
UnitTest
::
GetInstance
()
->
current_test_info
();
MEDIA_DEBUG_LOG
(
"ActsPlayerFuncTest::TearDown:%s"
,
testInfo
->
name
());
};
static
void
LocalPlayFunc
(
const
std
::
string
uri
,
bool
isAsync
,
WindowConfig
config
=
g_sub_config
);
static
void
*
LocalMulitPlayFunc
(
void
*
threadarg
);
...
...
multimedia/media/media_cpp_test_standard/player/include/TestParamsConfig.h
0 → 100644
浏览文件 @
6da39cde
/*
* 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.
*/
#ifndef PLAYER_COMMON_TEST_H
#define PLAYER_COMMON_TEST_H
#include "gtest/gtest.h"
#include "mediatest_log.h"
#include "player.h"
namespace
{
static
const
int32_t
PLAYING_TIME
=
3
;
static
const
int32_t
SEEK_TIME_5_SEC
=
5000
;
static
const
int32_t
SEEK_TIME_2_SEC
=
2000
;
static
const
int32_t
DELTA_TIME
=
1000
;
static
const
int32_t
CLOSEST_DELTA_TIME
=
300
;
static
const
int32_t
WAITSECOND
=
2
;
static
const
int32_t
RET_OK
=
0
;
static
const
int32_t
FILE_BEGIN
=
0
;
static
const
int32_t
PARA_MAX_LEN
=
256
;
static
const
int32_t
TIME_SEC2MS
=
1000
;
static
const
int32_t
WAIT_TIME
=
1000
;
static
const
OHOS
::
Media
::
PlayerSeekMode
SEEK_MODE
=
OHOS
::
Media
::
PlayerSeekMode
::
SEEK_CLOSEST
;
}
namespace
TestPlayerBasic
{
class
TestParamsConfig
{
public:
static
TestParamsConfig
&
GetInstance
()
{
static
TestParamsConfig
config
;
return
config
;
}
std
::
string
GetMountPath
()
const
{
return
mountPath_
;
}
void
SetMountPath
(
std
::
string
mountPath
)
{
mountPath_
=
mountPath
;
}
bool
CompareTime
(
int32_t
expectTime
,
int32_t
realTme
,
OHOS
::
Media
::
PlayerSeekMode
seekMode
);
std
::
string
GetUri
();
void
InitPlayProtocol
();
private:
TestParamsConfig
();
~
TestParamsConfig
();
std
::
string
mountPath_
=
""
;
};
}
#endif
\ No newline at end of file
multimedia/media/media_cpp_test_standard/player/include/Testplayer.h
浏览文件 @
6da39cde
...
...
@@ -13,9 +13,11 @@
* limitations under the License.
*/
#ifndef PLAYER_TEST_H
#define PLAYER_TEST_H
#include "securec.h"
#include "common.h"
#include "mediatest_log.h"
#include "TestParamsConfig.h"
#include "window_manager.h"
#include "surface_type.h"
#include "display_type.h"
...
...
@@ -65,13 +67,13 @@ public:
};
class
TestPlayer
{
public:
std
::
shared_ptr
<
Player
>
player
;
std
::
unique_ptr
<
Window
>
mwindow
;
std
::
unique_ptr
<
SubWindow
>
window
;
explicit
TestPlayer
(
PlayerSignal
*
test
);
~
TestPlayer
();
std
::
shared_ptr
<
Player
>
player_
;
sptr
<
Window
>
window_
;
explicit
TestPlayer
(
std
::
shared_ptr
<
PlayerSignal
>
test
);
virtual
~
TestPlayer
();
bool
CreatePlayer
();
int32_t
SetSource
(
const
std
::
string
&
uri
);
int32_t
SetDataSrc
(
const
std
::
string
&
uri
,
bool
seekable
);
int32_t
Play
();
int32_t
Prepare
();
int32_t
PrepareAsync
();
...
...
@@ -92,16 +94,14 @@ public:
int32_t
SetLooping
(
bool
loop
);
int32_t
SetPlayerCallback
(
const
std
::
shared_ptr
<
PlayerCallback
>
&
callback
);
private:
void
InitSubWindow
(
WindowConfig
sub_config
);
PlayerSignal
*
test_
;
std
::
shared_ptr
<
PlayerSignal
>
test_
;
};
class
TestPlayerCallback
:
public
PlayerCallback
{
public:
int
errorNum
=
0
;
int
errorNum
_
=
0
;
PlayerStates
state_
=
PLAYER_STATE_ERROR
;
explicit
TestPlayerCallback
(
PlayerSignal
*
test
);
~
TestPlayerCallback
();
explicit
TestPlayerCallback
(
std
::
shared_ptr
<
PlayerSignal
>
test
);
virtual
~
TestPlayerCallback
();
void
OnError
(
PlayerErrorType
errorType
,
int32_t
errorCode
);
int
WaitForSeekDone
(
int32_t
currentPositon
);
void
OnInfo
(
PlayerOnInfoType
type
,
int32_t
extra
,
const
Format
&
infoBody
=
{});
...
...
@@ -109,11 +109,11 @@ public:
private:
PlayerErrorType
errorType_
=
PLAYER_ERROR_UNKNOWN
;
int32_t
errorCode_
=
-
1
;
bool
seekDoneFlag
=
false
;
bool
seekDoneFlag
_
=
false
;
int32_t
postion_
=
0
;
void
PrintState
(
PlayerStates
state
);
PlayerSignal
*
test_
;
std
::
shared_ptr
<
PlayerSignal
>
test_
;
};
}
}
#endif
\ No newline at end of file
multimedia/media/media_cpp_test_standard/player/src/TestParamsConfig.cpp
0 → 100644
浏览文件 @
6da39cde
/*
* 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.
*/
#include "TestParamsConfig.h"
#include "parameter.h"
#include "media_errors.h"
using
namespace
OHOS
;
using
namespace
OHOS
::
Media
;
using
namespace
TestPlayerBasic
;
namespace
TestPlayerBasic
{
TestParamsConfig
::
TestParamsConfig
()
{
}
TestParamsConfig
::~
TestParamsConfig
()
{
}
std
::
string
TestParamsConfig
::
GetUri
()
{
char
path
[
PARA_MAX_LEN
]
=
"/data/media/1h264_320x240_60.3gp"
;
GetParameter
(
"sys.media.test.stream.path"
,
"/data/media/1h264_320x240_60.3gp"
,
&
path
[
0
],
PARA_MAX_LEN
);
MEDIA_INFO_LOG
(
"PATH : %s"
,
path
);
return
path
;
}
void
TestParamsConfig
::
InitPlayProtocol
()
{
MEDIA_INFO_LOG
(
"%s"
,
__FUNCTION__
);
char
protocol
[
PARA_MAX_LEN
]
=
"local"
;
GetParameter
(
"sys.media.test.play.protocol"
,
""
,
&
protocol
[
0
],
PARA_MAX_LEN
);
if
(
strcmp
(
protocol
,
"local"
)
==
0
)
{
TestPlayerBasic
::
TestParamsConfig
::
GetInstance
().
SetMountPath
(
"file://data/media/189"
);
MEDIA_INFO_LOG
(
"MOUNT_PATH %s"
,
TestPlayerBasic
::
TestParamsConfig
::
GetInstance
().
GetMountPath
().
c_str
());
}
}
bool
TestParamsConfig
::
CompareTime
(
int32_t
expectTime
,
int32_t
realTime
,
OHOS
::
Media
::
PlayerSeekMode
seekMode
)
{
MEDIA_INFO_LOG
(
"CompareTime: expectTime %d, realTime %d"
,
expectTime
,
realTime
);
if
(
seekMode
==
OHOS
::
Media
::
PlayerSeekMode
::
SEEK_CLOSEST
)
{
if
(
std
::
abs
(
expectTime
-
realTime
)
<
CLOSEST_DELTA_TIME
)
{
return
true
;
}
else
{
return
false
;
}
}
if
(
std
::
abs
(
expectTime
-
realTime
)
<
DELTA_TIME
)
{
return
true
;
}
return
false
;
}
}
multimedia/media/media_cpp_test_standard/player/src/TestPlayer.cpp
0 → 100644
浏览文件 @
6da39cde
/*
* 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.
*/
#include "Testplayer.h"
#include "parameter.h"
#include "media_errors.h"
using
namespace
OHOS
;
using
namespace
OHOS
::
Media
;
TestPlayer
::
TestPlayer
(
PlayerSignal
*
test
)
:
test_
(
test
)
{
}
TestPlayer
::~
TestPlayer
()
{
}
bool
TestPlayer
::
CreatePlayer
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
player_
=
PlayerFactory
::
CreatePlayer
();
if
(
player_
==
nullptr
)
{
return
false
;
}
return
true
;
}
int32_t
TestPlayer
::
SetSource
(
const
std
::
string
&
uri
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
SetSource
(
uri
);
}
int32_t
TestPlayer
::
Play
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
int32_t
ret
=
player_
->
Play
();
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
state_
!=
PLAYER_STARTED
)
{
std
::
unique_lock
<
std
::
mutex
>
lockPlay
(
test_
->
mutexPlay_
);
test_
->
condVarPlay_
.
wait_for
(
lockPlay
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
state_
!=
PLAYER_STARTED
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
Prepare
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
int32_t
ret
=
player_
->
Prepare
();
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
state_
!=
PLAYER_PREPARED
)
{
std
::
unique_lock
<
std
::
mutex
>
lockPrepare
(
test_
->
mutexPrepare_
);
test_
->
condVarPrepare_
.
wait_for
(
lockPrepare
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
state_
!=
PLAYER_PREPARED
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
PrepareAsync
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
int32_t
ret
=
player_
->
PrepareAsync
();
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
state_
!=
PLAYER_PREPARED
)
{
std
::
unique_lock
<
std
::
mutex
>
lockPrepare
(
test_
->
mutexPrepare_
);
test_
->
condVarPrepare_
.
wait_for
(
lockPrepare
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
state_
!=
PLAYER_PREPARED
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
Pause
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
int32_t
ret
=
player_
->
Pause
();
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
state_
!=
PLAYER_PAUSED
)
{
std
::
unique_lock
<
std
::
mutex
>
lockPause
(
test_
->
mutexPause_
);
test_
->
condVarPause_
.
wait_for
(
lockPause
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
state_
!=
PLAYER_PAUSED
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
Stop
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
int32_t
ret
=
player_
->
Stop
();
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
state_
!=
PLAYER_STOPPED
)
{
std
::
unique_lock
<
std
::
mutex
>
lockStop
(
test_
->
mutexStop_
);
test_
->
condVarStop_
.
wait_for
(
lockStop
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
state_
!=
PLAYER_STOPPED
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
Reset
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
int32_t
ret
=
player_
->
Reset
();
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
state_
!=
PLAYER_IDLE
)
{
std
::
unique_lock
<
std
::
mutex
>
lockReset
(
test_
->
mutexReset_
);
test_
->
condVarReset_
.
wait_for
(
lockReset
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
state_
!=
PLAYER_IDLE
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
Release
()
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
Release
();
}
int32_t
TestPlayer
::
SetVolume
(
float
leftVolume
,
float
rightVolume
)
{
MEDIA_INFO_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
SetVolume
(
leftVolume
,
rightVolume
);
}
int32_t
TestPlayer
::
Seek
(
int32_t
mseconds
,
PlayerSeekMode
mode
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
test_
->
seekDoneFlag_
=
false
;
test_
->
seekPositon_
=
mseconds
;
int32_t
ret
=
player_
->
Seek
(
mseconds
,
mode
);
if
(
ret
==
RET_OK
&&
test_
->
mutexFlag_
==
true
&&
test_
->
seekDoneFlag_
==
false
)
{
std
::
unique_lock
<
std
::
mutex
>
lockSeek
(
test_
->
mutexSeek_
);
test_
->
condVarSeek_
.
wait_for
(
lockSeek
,
std
::
chrono
::
seconds
(
WAITSECOND
));
if
(
test_
->
seekDoneFlag_
!=
true
)
{
return
-
1
;
}
}
return
ret
;
}
int32_t
TestPlayer
::
GetCurrentTime
(
int32_t
&
currentTime
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
GetCurrentTime
(
currentTime
);
}
int32_t
TestPlayer
::
GetDuration
(
int32_t
&
duration
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
GetDuration
(
duration
);
}
int32_t
TestPlayer
::
SetPlaybackSpeed
(
PlaybackRateMode
mode
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
SetPlaybackSpeed
(
mode
);
}
int32_t
TestPlayer
::
GetPlaybackSpeed
(
PlaybackRateMode
&
mode
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
GetPlaybackSpeed
(
mode
);
}
sptr
<
Surface
>
TestPlayer
::
GetVideoSurface
(
WindowConfig
sub_config
)
{
char
surface
[
PARA_MAX_LEN
]
=
"window"
;
GetParameter
(
"sys.media.test.surface"
,
"window"
,
&
surface
[
0
],
PARA_MAX_LEN
);
sptr
<
Surface
>
videoSurface
=
nullptr
;
if
(
strcmp
(
surface
,
"null"
)
==
0
)
{
return
videoSurface
;
}
if
(
strcmp
(
surface
,
"window"
)
==
0
)
{
sptr
<
WindowManager
>
wmi
=
WindowManager
::
GetInstance
();
if
(
wmi
==
nullptr
)
{
return
nullptr
;
}
(
void
)
wmi
->
Init
();
sptr
<
WindowOption
>
option
=
WindowOption
::
Get
();
if
(
option
==
nullptr
)
{
return
nullptr
;
}
(
void
)
option
->
SetWindowType
(
WINDOW_TYPE_NORMAL
);
(
void
)
wmi
->
CreateWindow
(
window_
,
option
);
if
(
window_
==
nullptr
)
{
return
nullptr
;
}
videoSurface
=
window_
->
GetSurface
();
if
(
videoSurface
==
nullptr
)
{
return
nullptr
;
}
(
void
)
videoSurface
->
SetUserData
(
SURFACE_FORMAT
,
std
::
to_string
(
PIXEL_FMT_RGBA_8888
));
}
return
videoSurface
;
}
int32_t
TestPlayer
::
SetVideoSurface
(
const
sptr
<
Surface
>
surface
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
char
parameter
[
PARA_MAX_LEN
]
=
"window"
;
GetParameter
(
"sys.media.test.surface"
,
"window"
,
&
parameter
[
0
],
PARA_MAX_LEN
);
if
(
strcmp
(
parameter
,
"null"
)
==
0
)
{
MEDIA_INFO_LOG
(
"sys.media.test.surface null"
);
return
0
;
}
return
player_
->
SetVideoSurface
(
surface
);
}
bool
TestPlayer
::
IsPlaying
()
{
return
player_
->
IsPlaying
();
}
bool
TestPlayer
::
IsLooping
()
{
return
player_
->
IsLooping
();
}
int32_t
TestPlayer
::
SetLooping
(
bool
loop
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
SetLooping
(
loop
);
}
int32_t
TestPlayer
::
SetPlayerCallback
(
const
std
::
shared_ptr
<
PlayerCallback
>
&
callback
)
{
MEDIA_DEBUG_LOG
(
"%s"
,
__FUNCTION__
);
return
player_
->
SetPlayerCallback
(
callback
);
}
TestPlayerCallback
::
TestPlayerCallback
(
PlayerSignal
*
test
)
:
test_
(
test
)
{
}
TestPlayerCallback
::~
TestPlayerCallback
()
{
}
void
TestPlayerCallback
::
OnError
(
PlayerErrorType
errorType
,
int32_t
errorCode
)
{
errorNum_
++
;
errorType_
=
errorType
;
errorCode_
=
errorCode
;
std
::
string
errorTypeMsg
=
PlayerErrorTypeToString
(
errorType
);
std
::
string
errorCodeMsg
=
MSErrorToString
(
static_cast
<
MediaServiceErrCode
>
(
errorCode
));
MEDIA_ERROR_LOG
(
"TestPlayerCallback: OnError errorType is %s, errorCode is %s"
,
errorTypeMsg
.
c_str
(),
errorCodeMsg
.
c_str
());
}
void
TestPlayerCallback
::
OnInfo
(
PlayerOnInfoType
type
,
int32_t
extra
,
const
Format
&
infoBody
)
{
switch
(
type
)
{
case
INFO_TYPE_SEEKDONE
:
seekDoneFlag_
=
true
;
test_
->
SetSeekResult
(
true
);
MEDIA_INFO_LOG
(
"TestPlayerCallback: OnSeekDone currentPositon is %d"
,
extra
);
if
(
abs
(
test_
->
seekPositon_
-
extra
)
<=
DELTA_TIME
)
{
test_
->
condVarSeek_
.
notify_all
();
}
else
{
test_
->
SetSeekResult
(
false
);
}
break
;
case
INFO_TYPE_EOS
:
MEDIA_INFO_LOG
(
"TestPlayerCallback: OnEndOfStream isLooping is %d"
,
extra
);
break
;
case
INFO_TYPE_STATE_CHANGE
:
state_
=
static_cast
<
PlayerStates
>
(
extra
);
PrintState
(
state_
);
break
;
case
INFO_TYPE_POSITION_UPDATE
:
postion_
=
extra
;
break
;
case
INFO_TYPE_MESSAGE
:
MEDIA_INFO_LOG
(
"TestPlayerCallback: OnMessage type is %d"
,
extra
);
break
;
default:
break
;
}
}
int
TestPlayerCallback
::
WaitForSeekDone
(
int32_t
currentPositon
)
{
int64_t
waitTime
=
0
;
seekDoneFlag_
=
false
;
while
(
seekDoneFlag_
!=
true
&&
waitTime
<
WAITSECOND
*
TIME_SEC2MS
)
{
(
void
)
usleep
(
WAIT_TIME
);
waitTime
+=
1
;
}
seekDoneFlag_
=
false
;
if
(
waitTime
>=
WAITSECOND
*
TIME_SEC2MS
)
{
MEDIA_ERROR_LOG
(
"Failed to seek [%d]s "
,
currentPositon
);
return
-
1
;
}
return
0
;
}
int
TestPlayerCallback
::
WaitForState
(
PlayerStates
state
)
{
int64_t
waitTime
=
0
;
while
(
state_
!=
state
&&
waitTime
<
WAITSECOND
*
TIME_SEC2MS
)
{
(
void
)
usleep
(
WAIT_TIME
);
waitTime
+=
1
;
}
if
(
waitTime
>=
WAITSECOND
*
TIME_SEC2MS
)
{
MEDIA_ERROR_LOG
(
"Failed to wait for state[%d] down"
,
state
);
return
-
1
;
}
return
0
;
}
void
TestPlayerCallback
::
PrintState
(
PlayerStates
state
)
{
switch
(
state
)
{
case
PLAYER_STATE_ERROR
:
MEDIA_INFO_LOG
(
"State: Error"
);
break
;
case
PLAYER_IDLE
:
MEDIA_INFO_LOG
(
"State: IDLE"
);
test_
->
SetState
(
state
);
test_
->
condVarReset_
.
notify_all
();
break
;
case
PLAYER_INITIALIZED
:
MEDIA_INFO_LOG
(
"State: Initialized"
);
break
;
case
PLAYER_PREPARED
:
MEDIA_INFO_LOG
(
"State: Prepared"
);
test_
->
SetState
(
state
);
test_
->
condVarPrepare_
.
notify_all
();
break
;
case
PLAYER_STARTED
:
MEDIA_INFO_LOG
(
"State: Started"
);
test_
->
SetState
(
state
);
test_
->
condVarPlay_
.
notify_all
();
break
;
case
PLAYER_PAUSED
:
MEDIA_INFO_LOG
(
"State: Paused"
);
test_
->
SetState
(
state
);
test_
->
condVarPause_
.
notify_all
();
break
;
case
PLAYER_STOPPED
:
MEDIA_INFO_LOG
(
"State: Stopped"
);
test_
->
SetState
(
state
);
test_
->
condVarStop_
.
notify_all
();
break
;
case
PLAYER_PLAYBACK_COMPLETE
:
MEDIA_INFO_LOG
(
"State: Complete"
);
break
;
default:
MEDIA_INFO_LOG
(
"Invalid state"
);
break
;
}
}
void
PlayerSignal
::
SetState
(
PlayerStates
state
)
{
state_
=
state
;
}
void
PlayerSignal
::
SetSeekResult
(
bool
seekDoneFlag
)
{
seekDoneFlag_
=
seekDoneFlag
;
}
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerFuncAsyncTest.cpp
浏览文件 @
6da39cde
此差异已折叠。
点击以展开。
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerFuncTest.cpp
浏览文件 @
6da39cde
此差异已折叠。
点击以展开。
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerStateAsyncTest.cpp
浏览文件 @
6da39cde
此差异已折叠。
点击以展开。
multimedia/media/media_cpp_test_standard/player/src/function/ActsPlayerStateTest.cpp
浏览文件 @
6da39cde
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录