| 15 | namespace WasmEdgeFFmpeg { |
| 16 | |
| 17 | TEST_F(FFmpegTest, AVCodecParameters) { |
| 18 | ASSERT_TRUE(AVCodecMod != nullptr); |
| 19 | |
| 20 | uint32_t AVCodecParamPtr = UINT32_C(60); |
| 21 | |
| 22 | std::string FileName = "ffmpeg-assets/sample_video.mp4"; // 32 chars |
| 23 | initFFmpegStructs(UINT32_C(20), UINT32_C(24), UINT32_C(28), FileName, |
| 24 | AVCodecParamPtr, UINT32_C(64), UINT32_C(68), UINT32_C(72)); |
| 25 | |
| 26 | uint32_t AVCodecParamId = readUInt32(MemInst, AVCodecParamPtr); |
| 27 | |
| 28 | auto *FuncInst = AVCodecMod->findFuncExports( |
| 29 | "wasmedge_ffmpeg_avcodec_avcodecparam_codec_id"); |
| 30 | EXPECT_NE(FuncInst, nullptr); |
| 31 | EXPECT_TRUE(FuncInst->isHostFunction()); |
| 32 | |
| 33 | auto &HostFuncAVCodecParamCodecId = dynamic_cast< |
| 34 | WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecParamCodecId &>( |
| 35 | FuncInst->getHostFunc()); |
| 36 | |
| 37 | { |
| 38 | EXPECT_TRUE(HostFuncAVCodecParamCodecId.run( |
| 39 | CallFrame, std::initializer_list<WasmEdge::ValVariant>{AVCodecParamId}, |
| 40 | Result)); |
| 41 | EXPECT_EQ(Result[0].get<int32_t>(), 27); // H264 |
| 42 | } |
| 43 | |
| 44 | FuncInst = AVCodecMod->findFuncExports( |
| 45 | "wasmedge_ffmpeg_avcodec_avcodecparam_codec_type"); |
| 46 | EXPECT_NE(FuncInst, nullptr); |
| 47 | EXPECT_TRUE(FuncInst->isHostFunction()); |
| 48 | |
| 49 | auto &HostFuncAVCodecParamCodecType = dynamic_cast< |
| 50 | WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecParamCodecType &>( |
| 51 | FuncInst->getHostFunc()); |
| 52 | |
| 53 | { |
| 54 | EXPECT_TRUE(HostFuncAVCodecParamCodecType.run( |
| 55 | CallFrame, std::initializer_list<WasmEdge::ValVariant>{AVCodecParamId}, |
| 56 | Result)); |
| 57 | EXPECT_EQ(Result[0].get<int32_t>(), 0); // MediaType Video |
| 58 | } |
| 59 | |
| 60 | FuncInst = AVCodecMod->findFuncExports( |
| 61 | "wasmedge_ffmpeg_avcodec_avcodecparam_set_codec_tag"); |
| 62 | EXPECT_NE(FuncInst, nullptr); |
| 63 | EXPECT_TRUE(FuncInst->isHostFunction()); |
| 64 | |
| 65 | auto &HostFuncAVCodecParamSetCodecTag = dynamic_cast< |
| 66 | WasmEdge::Host::WasmEdgeFFmpeg::AVcodec::AVCodecParamSetCodecTag &>( |
| 67 | FuncInst->getHostFunc()); |
| 68 | |
| 69 | { |
| 70 | EXPECT_TRUE(HostFuncAVCodecParamSetCodecTag.run( |
| 71 | CallFrame, |
| 72 | std::initializer_list<WasmEdge::ValVariant>{AVCodecParamId, 20}, |
| 73 | Result)); |
| 74 | EXPECT_EQ(Result[0].get<int32_t>(), static_cast<int32_t>(ErrNo::Success)); |
nothing calls this directly
no test coverage detected