未验证 提交 4a1ffb1c 编写于 作者: O openharmony_ci 提交者: Gitee

!9069 player_framework相关xts改成avcodec

Merge pull request !9069 from yj/master
......@@ -14,7 +14,7 @@
import("//test/xts/tools/build/suite.gni")
module_output_path = "acts/ActsAvcodecNdkTest"
MEDIA_ROOT_DIR = "//foundation/multimedia/player_framework/"
MEDIA_ROOT_DIR = "//foundation/multimedia/av_codec/"
ohos_moduletest_suite("ActsAvcodecNdkTest") {
module_out_path = module_output_path
......@@ -39,9 +39,6 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
"../../../../../../base/startup/init/interfaces/kits/syscap/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 = [
......@@ -63,7 +60,6 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
]
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",
......@@ -81,6 +77,6 @@ ohos_moduletest_suite("ActsAvcodecNdkTest") {
"hiviewdfx_hilog_native:libhilog",
]
part_name = "player_framework"
part_name = "av_codec"
subsystem_name = "multimedia"
}
......@@ -45,7 +45,7 @@ const string MIME_TYPE_MPEG4 = "video/mp4v-es";
constexpr uint32_t DEFAULT_WIDTH = 320;
constexpr uint32_t DEFAULT_HEIGHT = 240;
constexpr uint32_t DEFAULT_PIXELFORMAT = 2;
constexpr uint32_t DEFAULT_FRAMERATE = 60;
constexpr double DEFAULT_FRAMERATE = 60;
const char* READPATH = "/data/media/out_320_240_10s.h264";
bool CheckDecDesc(map<string, int> InDesc, OH_AVFormat* OutDesc)
......@@ -66,6 +66,12 @@ bool CheckDecDesc(map<string, int> InDesc, OH_AVFormat* OutDesc)
}
out = 0;
}
double dout;
bool res = OH_AVFormat_GetDoubleValue(OutDesc, OH_MD_KEY_FRAME_RATE, &dout);
if (!res || abs(dout - DEFAULT_FRAMERATE) > 1e-6) {
cout << "OH_AVFormat_GetDoubleValue error. key: " << OH_MD_KEY_FRAME_RATE << endl;
}
return true;
}
......@@ -89,7 +95,7 @@ struct OH_AVFormat* createFormat()
OH_AVFormat_SetIntValue(DefaultFormat, OH_MD_KEY_WIDTH, DEFAULT_WIDTH);
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_FRAME_RATE, DEFAULT_FRAMERATE);
OH_AVFormat_SetDoubleValue(DefaultFormat, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAMERATE);
OH_AVFormat_SetStringValue(DefaultFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_AVC);
return DefaultFormat;
}
......@@ -118,6 +124,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010
ASSERT_NE(nullptr, videoDec);
struct OH_AVCodec* videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_MPEG4);
videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_AVC);
ASSERT_NE(nullptr, videoEnc);
vDecEncSample->SetReadPath(READPATH);
vDecEncSample->SetSavePath("/data/media/video_001.h264");
......@@ -128,10 +135,10 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010
{OH_MD_KEY_WIDTH, DEFAULT_WIDTH},
{OH_MD_KEY_HEIGHT, DEFAULT_HEIGHT},
{OH_MD_KEY_PIXEL_FORMAT, DEFAULT_PIXELFORMAT},
{OH_MD_KEY_FRAME_RATE, DEFAULT_FRAMERATE},
};
ASSERT_EQ(true, SetFormat(VideoFormat, VideoParam));
OH_AVFormat_SetIntValue(VideoFormat, OH_MD_KEY_TRACK_TYPE, MEDIA_TYPE_VID);
OH_AVFormat_SetDoubleValue(VideoFormat, OH_MD_KEY_FRAME_RATE, DEFAULT_FRAMERATE);
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureDec(VideoFormat));
OH_AVFormat *OutDescDec = OH_VideoDecoder_GetOutputDescription(videoDec);
......@@ -141,7 +148,6 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ConfigureEnc(VideoFormat));
OH_AVFormat *OutDescEnc = OH_VideoEncoder_GetOutputDescription(videoEnc);
ASSERT_NE(nullptr, OutDescEnc);
ASSERT_EQ(true, CheckDecDesc(VideoParam, OutDescEnc));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->GetSurface());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->SetOutputSurface());
......@@ -191,9 +197,9 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_020
ASSERT_EQ(AV_ERR_OK, vDecEncSample->PrepareEnc());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->PrepareDec());
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->SetParameterEnc(VideoFormat));
ASSERT_EQ(AV_ERR_OK, vDecEncSample->StartDec());
ASSERT_EQ(AV_ERR_OK, vDecEncSample->SetParameterDec(VideoFormat));
while (!vDecEncSample->GetEncEosState()) {};
ASSERT_EQ(AV_ERR_OK, vDecEncSample->ResetDec());
......
......@@ -567,27 +567,12 @@ int32_t VDecEncNdkSample::SetParameterEnc(struct OH_AVFormat *format)
return OH_VideoEncoder_SetParameter(venc_, format);
}
struct VEncObject : public OH_AVCodec {
explicit VEncObject(const std::shared_ptr<AVCodecVideoEncoder> &encoder)
: OH_AVCodec(AVMagic::MEDIA_MAGIC_VIDEO_ENCODER), videoEncoder_(encoder) {}
~VEncObject() = default;
const std::shared_ptr<AVCodecVideoEncoder> videoEncoder_;
};
int32_t VDecEncNdkSample::GetSurface()
{
return OH_VideoEncoder_GetSurface(venc_, &nativeWindow_);
}
struct VDecObject : public OH_AVCodec {
explicit VDecObject(const std::shared_ptr<AVCodecVideoDecoder> &decoder)
: OH_AVCodec(AVMagic::MEDIA_MAGIC_VIDEO_DECODER), videoDecoder_(decoder) {}
~VDecObject() = default;
const std::shared_ptr<AVCodecVideoDecoder> videoDecoder_;
};
int32_t VDecEncNdkSample::SetOutputSurface()
{
return OH_VideoDecoder_SetSurface(vdec_, nativeWindow_);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册