Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6871cbaf
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看板
提交
6871cbaf
编写于
10月 18, 2022
作者:
L
ling990
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add testcases Signed-off-by: ling990 <liling96@huawei.com>
Signed-off-by:
N
ling990
<
ling990@qq.com
>
上级
1ce227dc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
352 addition
and
51 deletion
+352
-51
multimedia/media/media_cpp_standard/BUILD.gn
multimedia/media/media_cpp_standard/BUILD.gn
+20
-11
multimedia/media/media_cpp_standard/audioDecEncNdk/include/ADecEncNdkSample.h
...ia_cpp_standard/audioDecEncNdk/include/ADecEncNdkSample.h
+6
-2
multimedia/media/media_cpp_standard/audioDecEncNdk/src/ADecEncNdkSample.cpp
...edia_cpp_standard/audioDecEncNdk/src/ADecEncNdkSample.cpp
+53
-4
multimedia/media/media_cpp_standard/audioDecEncNdk/src/ActsAudioDecEncNdkTest.cpp
...pp_standard/audioDecEncNdk/src/ActsAudioDecEncNdkTest.cpp
+26
-18
multimedia/media/media_cpp_standard/codecFormatNdk/ActsCodecFormatNdkTest.cpp
...ia_cpp_standard/codecFormatNdk/ActsCodecFormatNdkTest.cpp
+191
-0
multimedia/media/media_cpp_standard/videoDecEncNdk/include/VDecEncNdkSample.h
...ia_cpp_standard/videoDecEncNdk/include/VDecEncNdkSample.h
+4
-0
multimedia/media/media_cpp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp
...pp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp
+24
-13
multimedia/media/media_cpp_standard/videoDecEncNdk/src/VDecEncNdkSample.cpp
...edia_cpp_standard/videoDecEncNdk/src/VDecEncNdkSample.cpp
+28
-3
未找到文件。
multimedia/media/media_cpp_standard/BUILD.gn
浏览文件 @
6871cbaf
...
@@ -14,12 +14,14 @@
...
@@ -14,12 +14,14 @@
import("//test/xts/tools/build/suite.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "acts/ActsAvcodecNdkTest"
module_output_path = "acts/ActsAvcodecNdkTest"
MEDIA_ROOT_DIR = "//foundation/multimedia/player_framework/"
ohos_moduletest_suite("ActsAvcodecNdkTest") {
ohos_moduletest_suite("ActsAvcodecNdkTest") {
module_out_path = module_output_path
module_out_path = module_output_path
sources = [
sources = [
"audioDecEncNdk/src/ADecEncNdkSample.cpp",
"audioDecEncNdk/src/ADecEncNdkSample.cpp",
"audioDecEncNdk/src/ActsAudioDecEncNdkTest.cpp",
"audioDecEncNdk/src/ActsAudioDecEncNdkTest.cpp",
"codecFormatNdk/ActsCodecFormatNdkTest.cpp",
"videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp",
"videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp",
"videoDecEncNdk/src/VDecEncNdkSample.cpp",
"videoDecEncNdk/src/VDecEncNdkSample.cpp",
]
]
...
@@ -28,13 +30,17 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
...
@@ -28,13 +30,17 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
"audioDecEncNdk/include",
"audioDecEncNdk/include",
"videoDecEncNdk/include",
"videoDecEncNdk/include",
"//foundation/multimedia/audio_framework/interfaces/inner_api/native/audiocommon/include",
"//foundation/multimedia/audio_framework/interfaces/inner_api/native/audiocommon/include",
"//foundation/
multimedia/player_framework/interfaces/inner_api/nativ
e",
"//foundation/
graphic/graphic_2d/frameworks/surface/includ
e",
"//foundation/
multimedia/player_framework/interfaces/kits/c
",
"//foundation/
graphic/graphic_2d/interfaces/inner_api/surface
",
"//foundation/
multimedia/player_framework/frameworks/native/c
api/common",
"//foundation/
graphic/graphic_2d/interfaces/inner_
api/common",
"//
commonlibrary/c_utils/base/include
",
"//
foundation//window/window_manager/interfaces/innerkits/wm
",
"//graphic/graphic_2d/interfaces/kits/surface",
"//graphic/graphic_2d/interfaces/kits/surface",
"//graphic/graphic_2d/interfaces/inner_api/surface",
"//graphic/graphic_2d/interfaces/inner_api/surface",
"//foundation/graphic/graphic_2d/frameworks/surface/include",
"$MEDIA_ROOT_DIR/interfaces/inner_api/native",
"$MEDIA_ROOT_DIR/interfaces/kits/c",
"$MEDIA_ROOT_DIR/frameworks/native/capi/common",
"$MEDIA_ROOT_DIR/interfaces/kits/c",
"$MEDIA_ROOT_DIR/interfaces/inner_api/native",
]
]
cflags = [
cflags = [
...
@@ -56,14 +62,17 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
...
@@ -56,14 +62,17 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
]
]
deps = [
deps = [
"$MEDIA_ROOT_DIR/interfaces/inner_api/native:media_client",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_adec",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_aenc",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_codecbase",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_core",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_vdec",
"$MEDIA_ROOT_DIR/interfaces/kits/c:native_media_venc",
"//foundation/graphic/graphic_2d:libsurface",
"//foundation/graphic/graphic_2d:libsurface",
"//foundation/graphic/graphic_2d/frameworks/surface:surface",
"//foundation/graphic/graphic_2d/frameworks/surface:surface",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_adec",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_aenc",
"//foundation/window/window_manager/wm:libwm",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_codecbase",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_core",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_vdec",
"//foundation/multimedia/player_framework/interfaces/kits/c:native_media_venc",
]
]
external_deps = [
external_deps = [
"c_utils:utils",
"c_utils:utils",
...
...
multimedia/media/media_cpp_standard/audioDecEncNdk/include/ADecEncNdkSample.h
浏览文件 @
6871cbaf
...
@@ -64,8 +64,10 @@ public:
...
@@ -64,8 +64,10 @@ public:
ADecEncNdkSample
()
=
default
;
ADecEncNdkSample
()
=
default
;
~
ADecEncNdkSample
();
~
ADecEncNdkSample
();
struct
OH_AVCodec
*
CreateAudioDecoder
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateAudioDecoderByMime
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateAudioDecoderByName
(
std
::
string
name
);
int32_t
ConfigureDec
(
struct
OH_AVFormat
*
format
);
int32_t
ConfigureDec
(
struct
OH_AVFormat
*
format
);
int32_t
SetParameterDec
(
struct
OH_AVFormat
*
format
);
int32_t
PrepareDec
();
int32_t
PrepareDec
();
int32_t
StartDec
();
int32_t
StartDec
();
int32_t
StopDec
();
int32_t
StopDec
();
...
@@ -73,8 +75,10 @@ public:
...
@@ -73,8 +75,10 @@ public:
int32_t
ResetDec
();
int32_t
ResetDec
();
int32_t
ReleaseDec
();
int32_t
ReleaseDec
();
struct
OH_AVCodec
*
CreateAudioEncoder
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateAudioEncoderByMime
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateAudioEncoderByName
(
std
::
string
name
);
int32_t
ConfigureEnc
(
struct
OH_AVFormat
*
format
);
int32_t
ConfigureEnc
(
struct
OH_AVFormat
*
format
);
int32_t
SetParameterEnc
(
struct
OH_AVFormat
*
format
);
int32_t
PrepareEnc
();
int32_t
PrepareEnc
();
int32_t
StartEnc
();
int32_t
StartEnc
();
int32_t
StopEnc
();
int32_t
StopEnc
();
...
...
multimedia/media/media_cpp_standard/audioDecEncNdk/src/ADecEncNdkSample.cpp
浏览文件 @
6871cbaf
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#include "ADecEncNdkSample.h"
#include "ADecEncNdkSample.h"
#include "native_avmemory.h"
#include "native_avmemory.h"
#include "native_averrors.h"
#include "native_averrors.h"
#include "native_avcodec_base.h"
using
namespace
OHOS
;
using
namespace
OHOS
;
using
namespace
OHOS
::
Media
;
using
namespace
OHOS
::
Media
;
using
namespace
std
;
using
namespace
std
;
...
@@ -124,9 +126,13 @@ ADecEncNdkSample::~ADecEncNdkSample()
...
@@ -124,9 +126,13 @@ ADecEncNdkSample::~ADecEncNdkSample()
acodecSignal_
=
nullptr
;
acodecSignal_
=
nullptr
;
}
}
struct
OH_AVCodec
*
ADecEncNdkSample
::
CreateAudioDecoder
(
std
::
string
mimetype
)
struct
OH_AVCodec
*
ADecEncNdkSample
::
CreateAudioDecoder
ByMime
(
std
::
string
mimetype
)
{
{
adec_
=
OH_AudioDecoder_CreateByMime
(
mimetype
.
c_str
());
if
(
mimetype
==
"audio/mp4a-latm"
)
{
adec_
=
OH_AudioDecoder_CreateByMime
(
OH_AVCODEC_MIMETYPE_AUDIO_AAC
);
}
else
{
adec_
=
OH_AudioDecoder_CreateByMime
(
mimetype
.
c_str
());
}
NDK_CHECK_AND_RETURN_RET_LOG
(
adec_
!=
nullptr
,
nullptr
,
"Fatal: OH_AudioDecoder_CreateByMime"
);
NDK_CHECK_AND_RETURN_RET_LOG
(
adec_
!=
nullptr
,
nullptr
,
"Fatal: OH_AudioDecoder_CreateByMime"
);
acodecSignal_
=
new
ADecEncSignal
();
acodecSignal_
=
new
ADecEncSignal
();
...
@@ -141,11 +147,33 @@ struct OH_AVCodec* ADecEncNdkSample::CreateAudioDecoder(std::string mimetype)
...
@@ -141,11 +147,33 @@ struct OH_AVCodec* ADecEncNdkSample::CreateAudioDecoder(std::string mimetype)
return
adec_
;
return
adec_
;
}
}
struct
OH_AVCodec
*
ADecEncNdkSample
::
CreateAudioDecoderByName
(
std
::
string
name
)
{
adec_
=
OH_AudioDecoder_CreateByName
(
name
.
c_str
());
NDK_CHECK_AND_RETURN_RET_LOG
(
adec_
!=
nullptr
,
nullptr
,
"Fatal: OH_AudioDecoder_CreateByName"
);
acodecSignal_
=
new
ADecEncSignal
();
NDK_CHECK_AND_RETURN_RET_LOG
(
acodecSignal_
!=
nullptr
,
nullptr
,
"Fatal: No Memory"
);
cbDec_
.
onError
=
AdecAsyncError
;
cbDec_
.
onStreamChanged
=
AdecAsyncStreamChanged
;
cbDec_
.
onNeedInputData
=
AdecAsyncNeedInputData
;
cbDec_
.
onNeedOutputData
=
AdecAsyncNewOutputData
;
int32_t
ret
=
OH_AudioDecoder_SetCallback
(
adec_
,
cbDec_
,
static_cast
<
void
*>
(
acodecSignal_
));
NDK_CHECK_AND_RETURN_RET_LOG
(
ret
==
AV_ERR_OK
,
NULL
,
"Fatal: OH_AudioDecoder_SetCallback"
);
return
adec_
;
}
int32_t
ADecEncNdkSample
::
ConfigureDec
(
struct
OH_AVFormat
*
format
)
int32_t
ADecEncNdkSample
::
ConfigureDec
(
struct
OH_AVFormat
*
format
)
{
{
return
OH_AudioDecoder_Configure
(
adec_
,
format
);
return
OH_AudioDecoder_Configure
(
adec_
,
format
);
}
}
int32_t
ADecEncNdkSample
::
SetParameterDec
(
struct
OH_AVFormat
*
format
)
{
return
OH_AudioDecoder_SetParameter
(
adec_
,
format
);
}
int32_t
ADecEncNdkSample
::
PrepareDec
()
int32_t
ADecEncNdkSample
::
PrepareDec
()
{
{
return
OH_AudioDecoder_Prepare
(
adec_
);
return
OH_AudioDecoder_Prepare
(
adec_
);
...
@@ -385,9 +413,13 @@ void ADecEncNdkSample::InputFuncDec()
...
@@ -385,9 +413,13 @@ void ADecEncNdkSample::InputFuncDec()
}
}
}
}
struct
OH_AVCodec
*
ADecEncNdkSample
::
CreateAudioEncoder
(
std
::
string
mimetype
)
struct
OH_AVCodec
*
ADecEncNdkSample
::
CreateAudioEncoder
ByMime
(
std
::
string
mimetype
)
{
{
aenc_
=
OH_AudioEncoder_CreateByMime
(
mimetype
.
c_str
());
if
(
mimetype
==
"audio/mp4a-latm"
)
{
aenc_
=
OH_AudioEncoder_CreateByMime
(
OH_AVCODEC_MIMETYPE_AUDIO_AAC
);
}
else
{
aenc_
=
OH_AudioEncoder_CreateByMime
(
mimetype
.
c_str
());
}
NDK_CHECK_AND_RETURN_RET_LOG
(
aenc_
!=
nullptr
,
nullptr
,
"Fatal: OH_AudioEncoder_CreateByMime"
);
NDK_CHECK_AND_RETURN_RET_LOG
(
aenc_
!=
nullptr
,
nullptr
,
"Fatal: OH_AudioEncoder_CreateByMime"
);
cbEnc_
.
onError
=
AencAsyncError
;
cbEnc_
.
onError
=
AencAsyncError
;
cbEnc_
.
onStreamChanged
=
AencAsyncStreamChanged
;
cbEnc_
.
onStreamChanged
=
AencAsyncStreamChanged
;
...
@@ -398,11 +430,28 @@ struct OH_AVCodec* ADecEncNdkSample::CreateAudioEncoder(std::string mimetype)
...
@@ -398,11 +430,28 @@ struct OH_AVCodec* ADecEncNdkSample::CreateAudioEncoder(std::string mimetype)
return
aenc_
;
return
aenc_
;
}
}
struct
OH_AVCodec
*
ADecEncNdkSample
::
CreateAudioEncoderByName
(
std
::
string
name
)
{
aenc_
=
OH_AudioEncoder_CreateByName
(
name
.
c_str
());
NDK_CHECK_AND_RETURN_RET_LOG
(
aenc_
!=
nullptr
,
nullptr
,
"Fatal: OH_AudioEncoder_CreateByName"
);
cbEnc_
.
onError
=
AencAsyncError
;
cbEnc_
.
onStreamChanged
=
AencAsyncStreamChanged
;
cbEnc_
.
onNeedInputData
=
AencAsyncNeedInputData
;
cbEnc_
.
onNeedOutputData
=
AencAsyncNewOutputData
;
int32_t
ret
=
OH_AudioEncoder_SetCallback
(
aenc_
,
cbEnc_
,
static_cast
<
void
*>
(
acodecSignal_
));
NDK_CHECK_AND_RETURN_RET_LOG
(
ret
==
AV_ERR_OK
,
NULL
,
"Fatal: OH_AudioEncoder_SetCallback"
);
return
aenc_
;
}
int32_t
ADecEncNdkSample
::
ConfigureEnc
(
struct
OH_AVFormat
*
format
)
int32_t
ADecEncNdkSample
::
ConfigureEnc
(
struct
OH_AVFormat
*
format
)
{
{
return
OH_AudioEncoder_Configure
(
aenc_
,
format
);
return
OH_AudioEncoder_Configure
(
aenc_
,
format
);
}
}
int32_t
ADecEncNdkSample
::
SetParameterEnc
(
struct
OH_AVFormat
*
format
)
{
return
OH_AudioEncoder_SetParameter
(
aenc_
,
format
);
}
int32_t
ADecEncNdkSample
::
PrepareEnc
()
int32_t
ADecEncNdkSample
::
PrepareEnc
()
{
{
...
...
multimedia/media/media_cpp_standard/audioDecEncNdk/src/ActsAudioDecEncNdkTest.cpp
浏览文件 @
6871cbaf
...
@@ -48,8 +48,11 @@ uint32_t ES_AAC_48000_32_1[] = {
...
@@ -48,8 +48,11 @@ uint32_t ES_AAC_48000_32_1[] = {
381
,
375
,
373
,
349
,
391
,
357
,
384
,
395
,
384
,
380
,
386
,
372
,
386
,
383
,
378
,
385
,
385
,
381
,
375
,
373
,
349
,
391
,
357
,
384
,
395
,
384
,
380
,
386
,
372
,
386
,
383
,
378
,
385
,
385
,
384
,
342
,
390
,
379
,
387
,
386
,
393
,
397
,
362
,
393
,
394
,
391
,
383
,
385
,
377
,
379
,
381
,
384
,
342
,
390
,
379
,
387
,
386
,
393
,
397
,
362
,
393
,
394
,
391
,
383
,
385
,
377
,
379
,
381
,
369
,
375
,
379
,
346
,
382
,
356
,
361
,
366
,
394
,
393
,
385
,
362
,
406
,
399
,
384
,
377
,
385
};
369
,
375
,
379
,
346
,
382
,
356
,
361
,
366
,
394
,
393
,
385
,
362
,
406
,
399
,
384
,
377
,
385
};
constexpr
uint32_t
ES_AAC_48000_32_1_Length
=
sizeof
(
ES_AAC_48000_32_1
)
/
sizeof
(
uint32_t
);
constexpr
uint32_t
ES_AAC_48000_32_1_Length
=
sizeof
(
ES_AAC_48000_32_1
)
/
sizeof
(
uint32_t
);
const
string
MIME_TYPE_AAC
=
"audio/mp4a-latm"
;
const
string
MIME_TYPE_AAC
=
"audio/mp4a-latm"
;
const
string
DECODER_AAC
=
"avdec_aac"
;
const
string
ENCODER_AAC
=
"avenc_aac"
;
constexpr
uint32_t
DEFAULT_SAMPLE_RATE
=
44100
;
constexpr
uint32_t
DEFAULT_SAMPLE_RATE
=
44100
;
constexpr
uint32_t
DEFAULT_CHANNELS
=
2
;
constexpr
uint32_t
DEFAULT_CHANNELS
=
2
;
const
char
*
READPATH
=
"/data/media/AAC_48000_32_1.aac"
;
const
char
*
READPATH
=
"/data/media/AAC_48000_32_1.aac"
;
...
@@ -107,8 +110,9 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
...
@@ -107,8 +110,9 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_EQ
(
true
,
SetFormat
(
AudioFormat
,
AudioParam
));
ASSERT_EQ
(
true
,
SetFormat
(
AudioFormat
,
AudioParam
));
OH_AVFormat_SetStringValue
(
AudioFormat
,
OH_MD_KEY_CODEC_MIME
,
OH_AVCODEC_MIMETYPE_AUDIO_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE
_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByName
(
DECODER
_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
OH_AVFormat
*
OutDescDec
=
OH_AudioDecoder_GetOutputDescription
(
audDec
);
OH_AVFormat
*
OutDescDec
=
OH_AudioDecoder_GetOutputDescription
(
audDec
);
...
@@ -116,7 +120,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
...
@@ -116,7 +120,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
ASSERT_EQ
(
true
,
CheckDecDesc
(
AudioParam
,
OutDescDec
));
ASSERT_EQ
(
true
,
CheckDecDesc
(
AudioParam
,
OutDescDec
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE
_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByName
(
ENCODER
_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
OH_AVFormat
*
OutDescEnc
=
OH_AudioEncoder_GetOutputDescription
(
audEnc
);
OH_AVFormat
*
OutDescEnc
=
OH_AudioEncoder_GetOutputDescription
(
audEnc
);
...
@@ -127,7 +131,9 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
...
@@ -127,7 +131,9 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_010
aDecEncSample
->
SetReadPath
(
READPATH
,
ES_AAC_48000_32_1
,
ES_AAC_48000_32_1_Length
);
aDecEncSample
->
SetReadPath
(
READPATH
,
ES_AAC_48000_32_1
,
ES_AAC_48000_32_1_Length
);
aDecEncSample
->
SetSavePath
(
"/data/media/AAC_48000_32_1_out1.aac"
);
aDecEncSample
->
SetSavePath
(
"/data/media/AAC_48000_32_1_out1.aac"
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
SetParameterEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
SetParameterDec
(
AudioFormat
));
while
(
!
aDecEncSample
->
GetEncEosState
())
{};
while
(
!
aDecEncSample
->
GetEncEosState
())
{};
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StopDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StopDec
());
...
@@ -150,17 +156,19 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_020
...
@@ -150,17 +156,19 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_020
{
{
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_CHANNEL_COUNT
,
DEFAULT_CHANNELS
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_CHANNEL_COUNT
,
DEFAULT_CHANNELS
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_SAMPLE_RATE
,
DEFAULT_SAMPLE_RATE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_SAMPLE_RATE
,
DEFAULT_SAMPLE_RATE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUDIO_SAMPLE_FORMAT
,
AudioStandard
::
SAMPLE_S16LE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUDIO_SAMPLE_FORMAT
,
AudioStandard
::
SAMPLE_S16LE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_TRACK_TYPE
,
MEDIA_TYPE_AUD
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
...
@@ -190,17 +198,19 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_030
...
@@ -190,17 +198,19 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_030
{
{
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_CHANNEL_COUNT
,
DEFAULT_CHANNELS
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_CHANNEL_COUNT
,
DEFAULT_CHANNELS
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_SAMPLE_RATE
,
DEFAULT_SAMPLE_RATE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUD_SAMPLE_RATE
,
DEFAULT_SAMPLE_RATE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUDIO_SAMPLE_FORMAT
,
AudioStandard
::
SAMPLE_S16LE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_AUDIO_SAMPLE_FORMAT
,
AudioStandard
::
SAMPLE_S16LE
);
OH_AVFormat_SetIntValue
(
AudioFormat
,
OH_MD_KEY_PROFILE
,
AAC_PROFILE_LC
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
...
@@ -228,7 +238,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
...
@@ -228,7 +238,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
{
{
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
...
@@ -238,7 +248,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
...
@@ -238,7 +248,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
...
@@ -248,7 +258,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
...
@@ -248,7 +258,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_040
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
while
(
aDecEncSample
->
GetFrameCount
()
<
50
)
{};
while
(
aDecEncSample
->
GetFrameCount
()
<
3
50
)
{};
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
FlushDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
FlushDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
FlushEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
FlushEnc
());
aDecEncSample
->
ReRead
();
aDecEncSample
->
ReRead
();
...
@@ -278,7 +288,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
...
@@ -278,7 +288,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
{
{
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
...
@@ -288,7 +298,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
...
@@ -288,7 +298,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
...
@@ -310,8 +320,6 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
...
@@ -310,8 +320,6 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_050
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
aDecEncSample
->
SetEosState
(
true
);
aDecEncSample
->
SetEosState
(
true
);
sleep
(
2
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
CalcuError
());
while
(
!
aDecEncSample
->
GetEncEosState
())
{};
while
(
!
aDecEncSample
->
GetEncEosState
())
{};
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ReleaseDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ReleaseDec
());
...
@@ -333,7 +341,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
...
@@ -333,7 +341,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
{
{
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
...
@@ -343,7 +351,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
...
@@ -343,7 +351,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
...
@@ -353,7 +361,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
...
@@ -353,7 +361,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_060
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StartDec
());
while
(
aDecEncSample
->
GetFrameCount
()
<
50
)
{};
while
(
aDecEncSample
->
GetFrameCount
()
<
3
50
)
{};
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StopDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StopDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StopEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
StopEnc
());
aDecEncSample
->
ReRead
();
aDecEncSample
->
ReRead
();
...
@@ -385,7 +393,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_070
...
@@ -385,7 +393,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_070
{
{
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
ADecEncNdkSample
*
aDecEncSample
=
new
ADecEncNdkSample
();
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audDec
=
aDecEncSample
->
CreateAudioDecoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audDec
);
ASSERT_NE
(
nullptr
,
audDec
);
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
AudioFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
AudioFormat
);
ASSERT_NE
(
nullptr
,
AudioFormat
);
...
@@ -395,7 +403,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_070
...
@@ -395,7 +403,7 @@ HWTEST_F(ActsAudioDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_AUDIO_DEC_ENC_FUNCTION_070
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureDec
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareDec
());
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
(
MIME_TYPE_AAC
);
struct
OH_AVCodec
*
audEnc
=
aDecEncSample
->
CreateAudioEncoder
ByMime
(
MIME_TYPE_AAC
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_NE
(
nullptr
,
audEnc
);
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
ConfigureEnc
(
AudioFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
aDecEncSample
->
PrepareEnc
());
...
...
multimedia/media/media_cpp_standard/codecFormatNdk/ActsCodecFormatNdkTest.cpp
0 → 100644
浏览文件 @
6871cbaf
/*
* Copyright (c) 2022 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 <string>
#include "securec.h"
#include "gtest/gtest.h"
#include "audio_info.h"
#include "native_avcodec_base.h"
#include "native_avformat.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
{
class
ActsCodecFormatNdkTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
();
static
void
TearDownTestCase
();
void
SetUp
()
override
;
void
TearDown
()
override
;
};
void
ActsCodecFormatNdkTest
::
SetUpTestCase
()
{}
void
ActsCodecFormatNdkTest
::
TearDownTestCase
()
{}
void
ActsCodecFormatNdkTest
::
SetUp
()
{}
void
ActsCodecFormatNdkTest
::
TearDown
()
{}
const
int32_t
intValue
=
1
;
const
int64_t
longValue
=
1
;
const
float
floatValue
=
1.0
;
const
double
doubleValue
=
1.0
;
const
char
*
stringValue
=
"string_value"
;
const
char
*
intKey
=
"int value key"
;
const
char
*
longKey
=
"long value key"
;
const
char
*
floatKey
=
"float value key"
;
const
char
*
doubleKey
=
"double value key"
;
const
char
*
stringKey
=
"string value key"
;
const
char
*
bufferKey
=
"buffer value key"
;
bool
CheckDecDesc
(
map
<
string
,
int
>
InDesc
,
OH_AVFormat
*
OutDesc
)
{
int32_t
out
;
for
(
const
auto
&
t
:
InDesc
)
{
bool
res
=
OH_AVFormat_GetIntValue
(
OutDesc
,
t
.
first
.
c_str
(),
&
out
);
cout
<<
"key: "
<<
t
.
first
<<
"; out: "
<<
out
<<
endl
;
if
(
!
res
)
{
cout
<<
"OH_AVFormat_GetIntValue Fail. key:"
<<
t
.
first
<<
endl
;
return
false
;
}
if
(
out
!=
t
.
second
)
{
cout
<<
"OH_AVFormat_GetIntValue error. key: "
<<
t
.
first
<<
"; expect: "
<<
t
.
second
<<
", actual: "
<<
out
<<
endl
;
return
false
;
}
out
=
0
;
}
return
true
;
}
bool
SetFormat
(
struct
OH_AVFormat
*
format
,
map
<
string
,
int
>
mediaDescription
)
{
const
char
*
key
;
for
(
const
auto
&
t
:
mediaDescription
)
{
key
=
t
.
first
.
c_str
();
if
(
not
OH_AVFormat_SetIntValue
(
format
,
key
,
t
.
second
))
{
cout
<<
"OH_AV_FormatPutIntValue Fail. format key: "
<<
t
.
first
<<
", value: "
<<
t
.
second
<<
endl
;
return
false
;
}
}
return
true
;
}
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0100
* @tc.name : test codec format set key
* @tc.desc : Basic function test
*/
HWTEST_F
(
ActsCodecFormatNdkTest
,
SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0100
,
TestSize
.
Level1
)
{
OH_AVFormat
*
codecFormatIn
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
codecFormatIn
);
OH_AVFormat
*
codecFormatOut
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
codecFormatOut
);
map
<
string
,
int
>
CodecParam
=
{
{
OH_ED_KEY_TIME_STAMP
,
200
},
// set timestamp 200ms
{
OH_ED_KEY_EOS
,
1
},
// set end of stream
{
OH_MD_KEY_TRACK_TYPE
,
1
},
// set track type video
{
OH_MD_KEY_DURATION
,
200
},
// set key duration 200ms
{
OH_MD_KEY_BITRATE
,
48000
},
// set key bitrate 48000
{
OH_MD_KEY_MAX_INPUT_SIZE
,
2000
},
// set key max input size 2000
{
OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE
,
0
},
// set videoencoder bitrate mode CBR
{
OH_MD_KEY_PROFILE
,
1
},
// set encode profile AVC_PROFILE_BASELINE
{
OH_MD_KEY_I_FRAME_INTERVAL
,
1
},
// set key i frame 1ms
{
OH_MD_KEY_ROTATION
,
90
},
// set key rotation 0 degree
};
ASSERT_EQ
(
true
,
SetFormat
(
codecFormatIn
,
CodecParam
));
OH_AVFormat_Copy
(
codecFormatOut
,
codecFormatIn
);
ASSERT_EQ
(
true
,
CheckDecDesc
(
CodecParam
,
codecFormatOut
));
ASSERT_NE
(
nullptr
,
OH_AVFormat_DumpInfo
(
codecFormatOut
));
cout
<<
OH_AVFormat_DumpInfo
(
codecFormatIn
)
<<
endl
;
OH_AVFormat_Destroy
(
codecFormatIn
);
codecFormatIn
=
nullptr
;
OH_AVFormat_Destroy
(
codecFormatOut
);
codecFormatIn
=
nullptr
;
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0200
* @tc.name : test codec format set and get value
* @tc.desc : Basic function test
*/
HWTEST_F
(
ActsCodecFormatNdkTest
,
SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0200
,
TestSize
.
Level1
)
{
OH_AVFormat
*
codecFormatIn
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
codecFormatIn
);
OH_AVFormat
*
codecFormatOut
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
codecFormatOut
);
OH_AVFormat_SetIntValue
(
codecFormatIn
,
intKey
,
intValue
);
OH_AVFormat_SetLongValue
(
codecFormatIn
,
longKey
,
longValue
);
OH_AVFormat_SetFloatValue
(
codecFormatIn
,
floatKey
,
floatValue
);
OH_AVFormat_SetDoubleValue
(
codecFormatIn
,
doubleKey
,
doubleValue
);
OH_AVFormat_SetStringValue
(
codecFormatIn
,
stringKey
,
stringValue
);
OH_AVFormat_Copy
(
codecFormatOut
,
codecFormatIn
);
int32_t
intValueOut
;
OH_AVFormat_GetIntValue
(
codecFormatOut
,
intKey
,
&
intValueOut
);
ASSERT_EQ
(
intValueOut
,
intValue
);
int64_t
longValueOut
;
OH_AVFormat_GetLongValue
(
codecFormatOut
,
longKey
,
&
longValueOut
);
ASSERT_EQ
(
longValueOut
,
longValue
);
float
floatValueOut
;
OH_AVFormat_GetFloatValue
(
codecFormatOut
,
floatKey
,
&
floatValueOut
);
ASSERT_EQ
(
floatValueOut
,
floatValue
);
double
doubleValueOut
;
OH_AVFormat_GetDoubleValue
(
codecFormatOut
,
doubleKey
,
&
doubleValueOut
);
ASSERT_EQ
(
doubleValueOut
,
doubleValue
);
const
char
*
stringValueOut
;
OH_AVFormat_GetStringValue
(
codecFormatOut
,
stringKey
,
&
stringValueOut
);
ASSERT_EQ
(
*
stringValueOut
,
*
stringValue
);
OH_AVFormat_Destroy
(
codecFormatIn
);
codecFormatIn
=
nullptr
;
OH_AVFormat_Destroy
(
codecFormatOut
);
codecFormatOut
=
nullptr
;
}
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0300
* @tc.name : test codec format set and get buffer
* @tc.desc : Basic function test
*/
HWTEST_F
(
ActsCodecFormatNdkTest
,
SUB_MULTIMEDIA_MEDIA_CODEC_FORMAT_0300
,
TestSize
.
Level1
)
{
OH_AVFormat
*
codecFormatIn
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
codecFormatIn
);
OH_AVFormat
*
codecFormatOut
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
codecFormatOut
);
int32_t
buffernum
=
10
;
size_t
sizeIn
=
buffernum
*
sizeof
(
uint8_t
);
uint8_t
*
buffer
=
reinterpret_cast
<
uint8_t
*>
(
malloc
(
sizeIn
));
(
void
)
memset_s
(
buffer
,
sizeIn
,
1
,
sizeIn
);
OH_AVFormat_SetBuffer
(
codecFormatIn
,
bufferKey
,
buffer
,
sizeIn
);
OH_AVFormat_Copy
(
codecFormatOut
,
codecFormatIn
);
uint8_t
*
addrout
;
size_t
sizeOut
;
OH_AVFormat_GetBuffer
(
codecFormatOut
,
bufferKey
,
&
addrout
,
&
sizeOut
);
ASSERT_EQ
(
sizeIn
,
sizeOut
);
for
(
int32_t
i
=
0
;
i
<
buffernum
;
i
++
)
{
ASSERT_EQ
(
buffer
[
i
],
addrout
[
i
]);
}
OH_AVFormat_Destroy
(
codecFormatIn
);
codecFormatIn
=
nullptr
;
OH_AVFormat_Destroy
(
codecFormatOut
);
codecFormatOut
=
nullptr
;
}
\ No newline at end of file
multimedia/media/media_cpp_standard/videoDecEncNdk/include/VDecEncNdkSample.h
浏览文件 @
6871cbaf
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "ndktest_log.h"
#include "ndktest_log.h"
#include "native_avmagic.h"
#include "native_avmagic.h"
#include "surface.h"
#include "surface.h"
#include "native_avcodec_base.h"
#include "native_avcodec_videodecoder.h"
#include "native_avcodec_videodecoder.h"
#include "native_avcodec_videoencoder.h"
#include "native_avcodec_videoencoder.h"
...
@@ -69,6 +70,7 @@ public:
...
@@ -69,6 +70,7 @@ public:
struct
OH_AVCodec
*
CreateVideoDecoderByMime
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateVideoDecoderByMime
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateVideoDecoderByName
(
std
::
string
name
);
struct
OH_AVCodec
*
CreateVideoDecoderByName
(
std
::
string
name
);
int32_t
ConfigureDec
(
struct
OH_AVFormat
*
format
);
int32_t
ConfigureDec
(
struct
OH_AVFormat
*
format
);
int32_t
SetParameterDec
(
struct
OH_AVFormat
*
format
);
int32_t
SetOutputSurface
();
int32_t
SetOutputSurface
();
int32_t
PrepareDec
();
int32_t
PrepareDec
();
int32_t
StartDec
();
int32_t
StartDec
();
...
@@ -80,6 +82,7 @@ public:
...
@@ -80,6 +82,7 @@ public:
struct
OH_AVCodec
*
CreateVideoEncoderByMime
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateVideoEncoderByMime
(
std
::
string
mimetype
);
struct
OH_AVCodec
*
CreateVideoEncoderByName
(
std
::
string
name
);
struct
OH_AVCodec
*
CreateVideoEncoderByName
(
std
::
string
name
);
int32_t
ConfigureEnc
(
struct
OH_AVFormat
*
format
);
int32_t
ConfigureEnc
(
struct
OH_AVFormat
*
format
);
int32_t
SetParameterEnc
(
struct
OH_AVFormat
*
format
);
int32_t
GetSurface
();
int32_t
GetSurface
();
int32_t
PrepareEnc
();
int32_t
PrepareEnc
();
int32_t
StartEnc
();
int32_t
StartEnc
();
...
@@ -108,6 +111,7 @@ public:
...
@@ -108,6 +111,7 @@ public:
bool
isDecOutputEOS
=
false
;
bool
isDecOutputEOS
=
false
;
bool
isEncOutputEOS
=
false
;
bool
isEncOutputEOS
=
false
;
bool
setEos
=
true
;
bool
setEos
=
true
;
bool
needRender
=
true
;
private:
private:
OHNativeWindow
*
nativeWindow_
;
OHNativeWindow
*
nativeWindow_
;
...
...
multimedia/media/media_cpp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp
浏览文件 @
6871cbaf
...
@@ -89,6 +89,7 @@ struct OH_AVFormat* createFormat()
...
@@ -89,6 +89,7 @@ struct OH_AVFormat* createFormat()
OH_AVFormat_SetIntValue
(
DefaultFormat
,
OH_MD_KEY_HEIGHT
,
DEFAULT_HEIGHT
);
OH_AVFormat_SetIntValue
(
DefaultFormat
,
OH_MD_KEY_HEIGHT
,
DEFAULT_HEIGHT
);
OH_AVFormat_SetIntValue
(
DefaultFormat
,
OH_MD_KEY_PIXEL_FORMAT
,
DEFAULT_PIXELFORMAT
);
OH_AVFormat_SetIntValue
(
DefaultFormat
,
OH_MD_KEY_PIXEL_FORMAT
,
DEFAULT_PIXELFORMAT
);
OH_AVFormat_SetIntValue
(
DefaultFormat
,
OH_MD_KEY_FRAME_RATE
,
DEFAULT_FRAMERATE
);
OH_AVFormat_SetIntValue
(
DefaultFormat
,
OH_MD_KEY_FRAME_RATE
,
DEFAULT_FRAMERATE
);
OH_AVFormat_SetStringValue
(
DefaultFormat
,
OH_MD_KEY_CODEC_MIME
,
OH_AVCODEC_MIMETYPE_VIDEO_AVC
);
return
DefaultFormat
;
return
DefaultFormat
;
}
}
}
}
...
@@ -101,13 +102,13 @@ struct OH_AVFormat* createFormat()
...
@@ -101,13 +102,13 @@ struct OH_AVFormat* createFormat()
HWTEST_F
(
ActsVideoDecEncNdkTest
,
SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_0100
,
TestSize
.
Level1
)
HWTEST_F
(
ActsVideoDecEncNdkTest
,
SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_0100
,
TestSize
.
Level1
)
{
{
VDecEncNdkSample
*
vDecEncSample
=
new
VDecEncNdkSample
();
VDecEncNdkSample
*
vDecEncSample
=
new
VDecEncNdkSample
();
struct
OH_AVCodec
*
videoDec
=
vDecEncSample
->
CreateVideoDecoderByMime
(
MIME_TYPE_AVC
);
struct
OH_AVCodec
*
videoDec
=
vDecEncSample
->
CreateVideoDecoderByMime
(
MIME_TYPE_AVC
);
ASSERT_NE
(
nullptr
,
videoDec
);
ASSERT_NE
(
nullptr
,
videoDec
);
struct
OH_AVCodec
*
videoEnc
=
vDecEncSample
->
CreateVideoEncoderByMime
(
MIME_TYPE_MPEG4
);
struct
OH_AVCodec
*
videoEnc
=
vDecEncSample
->
CreateVideoEncoderByMime
(
MIME_TYPE_MPEG4
);
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_001.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_001.
h264
"
);
OH_AVFormat
*
VideoFormat
=
OH_AVFormat_Create
();
OH_AVFormat
*
VideoFormat
=
OH_AVFormat_Create
();
ASSERT_NE
(
nullptr
,
VideoFormat
);
ASSERT_NE
(
nullptr
,
VideoFormat
);
...
@@ -118,6 +119,8 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010
...
@@ -118,6 +119,8 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010
{
OH_MD_KEY_FRAME_RATE
,
DEFAULT_FRAMERATE
},
{
OH_MD_KEY_FRAME_RATE
,
DEFAULT_FRAMERATE
},
};
};
ASSERT_EQ
(
true
,
SetFormat
(
VideoFormat
,
VideoParam
));
ASSERT_EQ
(
true
,
SetFormat
(
VideoFormat
,
VideoParam
));
OH_AVFormat_SetIntValue
(
VideoFormat
,
OH_MD_KEY_TRACK_TYPE
,
MEDIA_TYPE_VID
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
OH_AVFormat
*
OutDescDec
=
OH_VideoDecoder_GetOutputDescription
(
videoDec
);
OH_AVFormat
*
OutDescDec
=
OH_VideoDecoder_GetOutputDescription
(
videoDec
);
ASSERT_NE
(
nullptr
,
OutDescDec
);
ASSERT_NE
(
nullptr
,
OutDescDec
);
...
@@ -161,17 +164,20 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
...
@@ -161,17 +164,20 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
struct
OH_AVCodec
*
videoEnc
=
vDecEncSample
->
CreateVideoEncoderByMime
(
MIME_TYPE_AVC
);
struct
OH_AVCodec
*
videoEnc
=
vDecEncSample
->
CreateVideoEncoderByMime
(
MIME_TYPE_AVC
);
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_002.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_002.
h264
"
);
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat
*
VideoFormat
=
createFormat
();
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
OH_AVFormat_SetIntValue
(
VideoFormat
,
OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE
,
CBR
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
SetOutputSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
SetOutputSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
PrepareEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
PrepareDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
SetParameterDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
SetParameterEnc
(
VideoFormat
));
while
(
!
vDecEncSample
->
GetEncEosState
())
{};
while
(
!
vDecEncSample
->
GetEncEosState
())
{};
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ResetDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ResetDec
());
...
@@ -185,7 +191,6 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
...
@@ -185,7 +191,6 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
CalcuError
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
CalcuError
());
}
}
/**
/**
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_0300
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_0300
* @tc.name : release at end of stream
* @tc.name : release at end of stream
...
@@ -200,9 +205,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_030
...
@@ -200,9 +205,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_030
struct
OH_AVCodec
*
videoEnc
=
vDecEncSample
->
CreateVideoEncoderByMime
(
MIME_TYPE_AVC
);
struct
OH_AVCodec
*
videoEnc
=
vDecEncSample
->
CreateVideoEncoderByMime
(
MIME_TYPE_AVC
);
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_003.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_003.
h264
"
);
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat_SetIntValue
(
VideoFormat
,
OH_MD_KEY_PROFILE
,
AVC_PROFILE_BASELINE
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
...
@@ -237,9 +244,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_040
...
@@ -237,9 +244,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_040
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_004.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_004.
h264
"
);
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat_SetIntValue
(
VideoFormat
,
OH_MD_KEY_PROFILE
,
AVC_PROFILE_HIGH
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
...
@@ -256,7 +265,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_040
...
@@ -256,7 +265,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_040
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
SetEosState
(
true
);
vDecEncSample
->
SetEosState
(
true
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_004_2.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_004_2.
h264
"
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
...
@@ -287,9 +296,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_050
...
@@ -287,9 +296,11 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_050
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_005.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_005.
h264
"
);
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat_SetIntValue
(
VideoFormat
,
OH_MD_KEY_PROFILE
,
AVC_PROFILE_MAIN
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureEnc
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
GetSurface
());
...
@@ -306,7 +317,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_050
...
@@ -306,7 +317,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_050
vDecEncSample
->
ReRead
();
vDecEncSample
->
ReRead
();
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
SetSavePath
(
"/data/media/video_005_2.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_005_2.
h264
"
);
vDecEncSample
->
SetEosState
(
true
);
vDecEncSample
->
SetEosState
(
true
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
CalcuError
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
CalcuError
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
...
@@ -338,7 +349,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_060
...
@@ -338,7 +349,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_060
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_006.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_006.
h264
"
);
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat
*
VideoFormat
=
createFormat
();
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
...
@@ -357,7 +368,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_060
...
@@ -357,7 +368,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_060
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
SetEosState
(
true
);
vDecEncSample
->
SetEosState
(
true
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_006_2.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_006_2.
h264
"
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
...
@@ -389,7 +400,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_070
...
@@ -389,7 +400,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_070
ASSERT_NE
(
nullptr
,
videoEnc
);
ASSERT_NE
(
nullptr
,
videoEnc
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetReadPath
(
READPATH
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetEosState
(
false
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_007.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_007.
h264
"
);
OH_AVFormat
*
VideoFormat
=
createFormat
();
OH_AVFormat
*
VideoFormat
=
createFormat
();
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
ConfigureDec
(
VideoFormat
));
...
@@ -408,7 +419,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_070
...
@@ -408,7 +419,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_070
vDecEncSample
->
ReRead
();
vDecEncSample
->
ReRead
();
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetDecParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
ResetEncParam
();
vDecEncSample
->
SetSavePath
(
"/data/media/video_007_2.
es
"
);
vDecEncSample
->
SetSavePath
(
"/data/media/video_007_2.
h264
"
);
vDecEncSample
->
SetEosState
(
true
);
vDecEncSample
->
SetEosState
(
true
);
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartEnc
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
ASSERT_EQ
(
AV_ERR_OK
,
vDecEncSample
->
StartDec
());
...
...
multimedia/media/media_cpp_standard/videoDecEncNdk/src/VDecEncNdkSample.cpp
浏览文件 @
6871cbaf
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "audio_info.h"
#include "audio_info.h"
#include "av_common.h"
#include "av_common.h"
#include "native_avcodec_base.h"
#include "avcodec_video_encoder.h"
#include "avcodec_video_encoder.h"
#include "avcodec_video_decoder.h"
#include "avcodec_video_decoder.h"
#include "native_avmemory.h"
#include "native_avmemory.h"
...
@@ -196,7 +197,12 @@ void VDecEncNdkSample::ResetEncParam()
...
@@ -196,7 +197,12 @@ void VDecEncNdkSample::ResetEncParam()
struct
OH_AVCodec
*
VDecEncNdkSample
::
CreateVideoDecoderByMime
(
std
::
string
mimetype
)
struct
OH_AVCodec
*
VDecEncNdkSample
::
CreateVideoDecoderByMime
(
std
::
string
mimetype
)
{
{
vdec_
=
OH_VideoDecoder_CreateByMime
(
mimetype
.
c_str
());
if
(
mimetype
==
"video/avc"
)
{
cout
<<
"mimetype == 'video/avc'"
<<
endl
;
vdec_
=
OH_VideoDecoder_CreateByMime
(
OH_AVCODEC_MIMETYPE_VIDEO_AVC
);
}
else
{
vdec_
=
OH_VideoDecoder_CreateByMime
(
mimetype
.
c_str
());
}
NDK_CHECK_AND_RETURN_RET_LOG
(
vdec_
!=
nullptr
,
nullptr
,
"Fatal: OH_VideoDecoder_CreateByMime"
);
NDK_CHECK_AND_RETURN_RET_LOG
(
vdec_
!=
nullptr
,
nullptr
,
"Fatal: OH_VideoDecoder_CreateByMime"
);
if
(
vcodecSignal_
==
nullptr
)
{
if
(
vcodecSignal_
==
nullptr
)
{
vcodecSignal_
=
new
VDecEncSignal
();
vcodecSignal_
=
new
VDecEncSignal
();
...
@@ -233,6 +239,11 @@ int32_t VDecEncNdkSample::ConfigureDec(struct OH_AVFormat *format)
...
@@ -233,6 +239,11 @@ int32_t VDecEncNdkSample::ConfigureDec(struct OH_AVFormat *format)
return
OH_VideoDecoder_Configure
(
vdec_
,
format
);
return
OH_VideoDecoder_Configure
(
vdec_
,
format
);
}
}
int32_t
VDecEncNdkSample
::
SetParameterDec
(
struct
OH_AVFormat
*
format
)
{
return
OH_VideoDecoder_SetParameter
(
vdec_
,
format
);
}
int32_t
VDecEncNdkSample
::
PrepareDec
()
int32_t
VDecEncNdkSample
::
PrepareDec
()
{
{
return
OH_VideoDecoder_Prepare
(
vdec_
);
return
OH_VideoDecoder_Prepare
(
vdec_
);
...
@@ -485,7 +496,12 @@ void VDecEncNdkSample::OutputFuncDec()
...
@@ -485,7 +496,12 @@ void VDecEncNdkSample::OutputFuncDec()
uint32_t
index
=
vcodecSignal_
->
outQueueDec_
.
front
();
uint32_t
index
=
vcodecSignal_
->
outQueueDec_
.
front
();
uint32_t
outflag
=
vcodecSignal_
->
flagQueueDec_
.
front
();
uint32_t
outflag
=
vcodecSignal_
->
flagQueueDec_
.
front
();
if
(
outflag
==
0
)
{
if
(
outflag
==
0
)
{
uint32_t
ret
=
OH_VideoDecoder_RenderOutputData
(
vdec_
,
index
);
uint32_t
ret
;
if
(
needRender
)
{
ret
=
OH_VideoDecoder_RenderOutputData
(
vdec_
,
index
);
}
else
{
ret
=
OH_VideoDecoder_FreeOutputData
(
vdec_
,
index
);
}
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
decOutCnt_
+=
1
;
decOutCnt_
+=
1
;
cout
<<
"DEC OUT.: render output success, decOutCnt_ is "
<<
decOutCnt_
<<
endl
;
cout
<<
"DEC OUT.: render output success, decOutCnt_ is "
<<
decOutCnt_
<<
endl
;
...
@@ -505,7 +521,11 @@ void VDecEncNdkSample::OutputFuncDec()
...
@@ -505,7 +521,11 @@ void VDecEncNdkSample::OutputFuncDec()
struct
OH_AVCodec
*
VDecEncNdkSample
::
CreateVideoEncoderByMime
(
std
::
string
mimetype
)
struct
OH_AVCodec
*
VDecEncNdkSample
::
CreateVideoEncoderByMime
(
std
::
string
mimetype
)
{
{
venc_
=
OH_VideoEncoder_CreateByMime
(
mimetype
.
c_str
());
if
(
mimetype
==
"video/avc"
)
{
venc_
=
OH_VideoEncoder_CreateByMime
(
OH_AVCODEC_MIMETYPE_VIDEO_AVC
);
}
else
{
venc_
=
OH_VideoEncoder_CreateByMime
(
mimetype
.
c_str
());
}
NDK_CHECK_AND_RETURN_RET_LOG
(
venc_
!=
nullptr
,
nullptr
,
"Fatal: OH_VideoEncoder_CreateByMime"
);
NDK_CHECK_AND_RETURN_RET_LOG
(
venc_
!=
nullptr
,
nullptr
,
"Fatal: OH_VideoEncoder_CreateByMime"
);
if
(
vcodecSignal_
==
nullptr
)
{
if
(
vcodecSignal_
==
nullptr
)
{
...
@@ -542,6 +562,11 @@ int32_t VDecEncNdkSample::ConfigureEnc(struct OH_AVFormat *format)
...
@@ -542,6 +562,11 @@ int32_t VDecEncNdkSample::ConfigureEnc(struct OH_AVFormat *format)
return
OH_VideoEncoder_Configure
(
venc_
,
format
);
return
OH_VideoEncoder_Configure
(
venc_
,
format
);
}
}
int32_t
VDecEncNdkSample
::
SetParameterEnc
(
struct
OH_AVFormat
*
format
)
{
return
OH_VideoEncoder_SetParameter
(
venc_
,
format
);
}
struct
VEncObject
:
public
OH_AVCodec
{
struct
VEncObject
:
public
OH_AVCodec
{
explicit
VEncObject
(
const
std
::
shared_ptr
<
AVCodecVideoEncoder
>
&
encoder
)
explicit
VEncObject
(
const
std
::
shared_ptr
<
AVCodecVideoEncoder
>
&
encoder
)
:
OH_AVCodec
(
AVMagic
::
MEDIA_MAGIC_VIDEO_ENCODER
),
videoEncoder_
(
encoder
)
{}
:
OH_AVCodec
(
AVMagic
::
MEDIA_MAGIC_VIDEO_ENCODER
),
videoEncoder_
(
encoder
)
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录