From 794310f3f1a0a7638b85a3b236388f3d1265cab6 Mon Sep 17 00:00:00 2001 From: yj Date: Sun, 25 Jun 2023 21:24:18 +0800 Subject: [PATCH] =?UTF-8?q?player=5Fframework=E7=9B=B8=E5=85=B3xts?= =?UTF-8?q?=E6=94=B9=E6=88=90avcodec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yj --- .../src/ActsVideoDecEncNdkTest.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/multimedia/media/media_cpp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp b/multimedia/media/media_cpp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp index ef90951b0..b4828305a 100644 --- a/multimedia/media/media_cpp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp +++ b/multimedia/media/media_cpp_standard/videoDecEncNdk/src/ActsVideoDecEncNdkTest.cpp @@ -41,11 +41,10 @@ void ActsVideoDecEncNdkTest::TearDownTestCase() {} void ActsVideoDecEncNdkTest::SetUp() {} void ActsVideoDecEncNdkTest::TearDown() {} const string MIME_TYPE_AVC = "video/avc"; -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 InDesc, OH_AVFormat* OutDesc) @@ -66,6 +65,12 @@ bool CheckDecDesc(map 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 +94,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; } @@ -117,7 +122,7 @@ HWTEST_F(ActsVideoDecEncNdkTest, SUB_MULTIMEDIA_MEDIA_VIDEO_DEC_ENC_FUNCTION_010 struct OH_AVCodec* videoDec = vDecEncSample->CreateVideoDecoderByMime(MIME_TYPE_AVC); ASSERT_NE(nullptr, videoDec); - struct OH_AVCodec* videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_MPEG4); + struct OH_AVCodec* videoEnc = vDecEncSample->CreateVideoEncoderByMime(MIME_TYPE_AVC); ASSERT_NE(nullptr, videoEnc); vDecEncSample->SetReadPath(READPATH); vDecEncSample->SetSavePath("/data/media/video_001.h264"); @@ -128,10 +133,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, OH_MediaType::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 +146,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()); -- GitLab