1da853ecaSopenharmony_ci/* 2da853ecaSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3da853ecaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4da853ecaSopenharmony_ci * you may not use this file except in compliance with the License. 5da853ecaSopenharmony_ci * You may obtain a copy of the License at 6da853ecaSopenharmony_ci * 7da853ecaSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8da853ecaSopenharmony_ci * 9da853ecaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10da853ecaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11da853ecaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12da853ecaSopenharmony_ci * See the License for the specific language governing permissions and 13da853ecaSopenharmony_ci * limitations under the License. 14da853ecaSopenharmony_ci */ 15da853ecaSopenharmony_ci 16da853ecaSopenharmony_ci#include <string> 17da853ecaSopenharmony_ci#include "gtest/gtest.h" 18da853ecaSopenharmony_ci#include "AVMuxerDemo.h" 19da853ecaSopenharmony_ci#include "native_avbuffer.h" 20da853ecaSopenharmony_ci 21da853ecaSopenharmony_ciusing namespace std; 22da853ecaSopenharmony_ciusing namespace testing::ext; 23da853ecaSopenharmony_ciusing namespace OHOS; 24da853ecaSopenharmony_ciusing namespace OHOS::MediaAVCodec; 25da853ecaSopenharmony_ci 26da853ecaSopenharmony_cinamespace { 27da853ecaSopenharmony_ciclass NativeAVMuxerParamCheckTest : public testing::Test { 28da853ecaSopenharmony_cipublic: 29da853ecaSopenharmony_ci static void SetUpTestCase(); 30da853ecaSopenharmony_ci static void TearDownTestCase(); 31da853ecaSopenharmony_ci void SetUp() override; 32da853ecaSopenharmony_ci void TearDown() override; 33da853ecaSopenharmony_ci}; 34da853ecaSopenharmony_ci 35da853ecaSopenharmony_civoid NativeAVMuxerParamCheckTest::SetUpTestCase() {} 36da853ecaSopenharmony_civoid NativeAVMuxerParamCheckTest::TearDownTestCase() {} 37da853ecaSopenharmony_civoid NativeAVMuxerParamCheckTest::SetUp() {} 38da853ecaSopenharmony_civoid NativeAVMuxerParamCheckTest::TearDown() {} 39da853ecaSopenharmony_ci 40da853ecaSopenharmony_ciconstexpr int32_t ROTATION_0 = 0; 41da853ecaSopenharmony_ciconstexpr int32_t ROTATION_90 = 90; 42da853ecaSopenharmony_ciconstexpr int32_t ROTATION_180 = 180; 43da853ecaSopenharmony_ciconstexpr int32_t ROTATION_270 = 270; 44da853ecaSopenharmony_ciconstexpr int32_t ROTATION_ERROR = -90; 45da853ecaSopenharmony_ciconstexpr int32_t ROTATION_45 = 45; 46da853ecaSopenharmony_ci 47da853ecaSopenharmony_ciconstexpr int64_t AUDIO_BITRATE = 320000; 48da853ecaSopenharmony_ciconstexpr int64_t VIDEO_BITRATE = 524569; 49da853ecaSopenharmony_ciconstexpr int32_t CODEC_CONFIG = 100; 50da853ecaSopenharmony_ciconstexpr int32_t CHANNEL_COUNT = 1; 51da853ecaSopenharmony_ciconstexpr int32_t SAMPLE_RATE = 48000; 52da853ecaSopenharmony_ciconstexpr int32_t PROFILE = 0; 53da853ecaSopenharmony_ciconstexpr int32_t INFO_SIZE = 100; 54da853ecaSopenharmony_ci 55da853ecaSopenharmony_ciconstexpr int32_t WIDTH = 352; 56da853ecaSopenharmony_ciconstexpr int32_t HEIGHT = 288; 57da853ecaSopenharmony_ciconstexpr double FRAME_RATE = 60; 58da853ecaSopenharmony_ciconst std::string HEVC_LIB_PATH = std::string(AV_CODEC_PATH) + "/libav_codec_hevc_parser.z.so"; 59da853ecaSopenharmony_ci} // namespace 60da853ecaSopenharmony_ci 61da853ecaSopenharmony_ci/** 62da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_001 63da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_Create - fd check 64da853ecaSopenharmony_ci * @tc.desc : param check test 65da853ecaSopenharmony_ci */ 66da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_001, TestSize.Level2) 67da853ecaSopenharmony_ci{ 68da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 69da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_M4A; 70da853ecaSopenharmony_ci int32_t fd = -1; 71da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 72da853ecaSopenharmony_ci ASSERT_EQ(nullptr, handle); 73da853ecaSopenharmony_ci 74da853ecaSopenharmony_ci fd = muxerDemo->GetErrorFd(); 75da853ecaSopenharmony_ci handle = muxerDemo->NativeCreate(fd, format); 76da853ecaSopenharmony_ci ASSERT_EQ(nullptr, handle); 77da853ecaSopenharmony_ci 78da853ecaSopenharmony_ci fd = muxerDemo->GetFdByMode(format); 79da853ecaSopenharmony_ci handle = muxerDemo->NativeCreate(fd, format); 80da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 81da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 82da853ecaSopenharmony_ci delete muxerDemo; 83da853ecaSopenharmony_ci} 84da853ecaSopenharmony_ci 85da853ecaSopenharmony_ci/** 86da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_002 87da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_Create - format check 88da853ecaSopenharmony_ci * @tc.desc : param check test 89da853ecaSopenharmony_ci */ 90da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_002, TestSize.Level2) 91da853ecaSopenharmony_ci{ 92da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 93da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_DEFAULT; 94da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 95da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 96da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 97da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 98da853ecaSopenharmony_ci handle = nullptr; 99da853ecaSopenharmony_ci 100da853ecaSopenharmony_ci format = AV_OUTPUT_FORMAT_MPEG_4; 101da853ecaSopenharmony_ci fd = muxerDemo->GetFdByMode(format); 102da853ecaSopenharmony_ci handle = muxerDemo->NativeCreate(fd, format); 103da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 104da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 105da853ecaSopenharmony_ci handle = nullptr; 106da853ecaSopenharmony_ci 107da853ecaSopenharmony_ci format = AV_OUTPUT_FORMAT_M4A; 108da853ecaSopenharmony_ci fd = muxerDemo->GetFdByMode(format); 109da853ecaSopenharmony_ci handle = muxerDemo->NativeCreate(fd, format); 110da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 111da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 112da853ecaSopenharmony_ci handle = nullptr; 113da853ecaSopenharmony_ci delete muxerDemo; 114da853ecaSopenharmony_ci} 115da853ecaSopenharmony_ci 116da853ecaSopenharmony_ci/** 117da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_003 118da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_SetRotation - rotation check 119da853ecaSopenharmony_ci * @tc.desc : param check test 120da853ecaSopenharmony_ci */ 121da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_003, TestSize.Level2) 122da853ecaSopenharmony_ci{ 123da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 124da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 125da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 126da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 127da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 128da853ecaSopenharmony_ci 129da853ecaSopenharmony_ci int32_t rotation; 130da853ecaSopenharmony_ci 131da853ecaSopenharmony_ci rotation = ROTATION_0; 132da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeSetRotation(handle, rotation); 133da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 134da853ecaSopenharmony_ci 135da853ecaSopenharmony_ci rotation = ROTATION_90; 136da853ecaSopenharmony_ci ret = muxerDemo->NativeSetRotation(handle, rotation); 137da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 138da853ecaSopenharmony_ci 139da853ecaSopenharmony_ci rotation = ROTATION_180; 140da853ecaSopenharmony_ci ret = muxerDemo->NativeSetRotation(handle, rotation); 141da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 142da853ecaSopenharmony_ci 143da853ecaSopenharmony_ci rotation = ROTATION_270; 144da853ecaSopenharmony_ci ret = muxerDemo->NativeSetRotation(handle, rotation); 145da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 146da853ecaSopenharmony_ci 147da853ecaSopenharmony_ci rotation = ROTATION_ERROR; 148da853ecaSopenharmony_ci ret = muxerDemo->NativeSetRotation(handle, rotation); 149da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 150da853ecaSopenharmony_ci 151da853ecaSopenharmony_ci rotation = ROTATION_45; 152da853ecaSopenharmony_ci ret = muxerDemo->NativeSetRotation(handle, rotation); 153da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 154da853ecaSopenharmony_ci 155da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 156da853ecaSopenharmony_ci handle = nullptr; 157da853ecaSopenharmony_ci delete muxerDemo; 158da853ecaSopenharmony_ci} 159da853ecaSopenharmony_ci 160da853ecaSopenharmony_ci/** 161da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_004 162da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - trackFormat(OH_MD_KEY_CODEC_MIME) check 163da853ecaSopenharmony_ci * @tc.desc : param check test 164da853ecaSopenharmony_ci */ 165da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_004, TestSize.Level2) 166da853ecaSopenharmony_ci{ 167da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 168da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 169da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 170da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 171da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 172da853ecaSopenharmony_ci 173da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 174da853ecaSopenharmony_ci 175da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 176da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 177da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 178da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 179da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 180da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 181da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 182da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 183da853ecaSopenharmony_ci 184da853ecaSopenharmony_ci int32_t trackId; 185da853ecaSopenharmony_ci 186da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 187da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 188da853ecaSopenharmony_ci 189da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_MPEG); 190da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 191da853ecaSopenharmony_ci ASSERT_EQ(1, trackId); 192da853ecaSopenharmony_ci 193da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, "aaaaaa"); 194da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 195da853ecaSopenharmony_ci ASSERT_NE(AV_ERR_OK, ret); 196da853ecaSopenharmony_ci 197da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 198da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 199da853ecaSopenharmony_ci handle = nullptr; 200da853ecaSopenharmony_ci delete muxerDemo; 201da853ecaSopenharmony_ci} 202da853ecaSopenharmony_ci 203da853ecaSopenharmony_ci/** 204da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_005 205da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - trackFormat(OH_MD_KEY_AUD_CHANNEL_COUNT) check 206da853ecaSopenharmony_ci * @tc.desc : param check test 207da853ecaSopenharmony_ci */ 208da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_005, TestSize.Level2) 209da853ecaSopenharmony_ci{ 210da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 211da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 212da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 213da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 214da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 215da853ecaSopenharmony_ci 216da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 217da853ecaSopenharmony_ci 218da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 219da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 220da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 221da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 222da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 223da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 224da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 225da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 226da853ecaSopenharmony_ci 227da853ecaSopenharmony_ci int32_t trackId; 228da853ecaSopenharmony_ci 229da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 230da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 231da853ecaSopenharmony_ci 232da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, -1); 233da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 234da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 235da853ecaSopenharmony_ci 236da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, "aaaaaa"); 237da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 238da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 239da853ecaSopenharmony_ci 240da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, 0); 241da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 242da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 243da853ecaSopenharmony_ci 244da853ecaSopenharmony_ci OH_AVFormat_SetFloatValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, 0.1); 245da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 246da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 247da853ecaSopenharmony_ci 248da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, 0.1); 249da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 250da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 251da853ecaSopenharmony_ci 252da853ecaSopenharmony_ci uint8_t b[100]; 253da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, b, 100); 254da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 255da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 256da853ecaSopenharmony_ci 257da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 258da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 259da853ecaSopenharmony_ci handle = nullptr; 260da853ecaSopenharmony_ci delete muxerDemo; 261da853ecaSopenharmony_ci} 262da853ecaSopenharmony_ci 263da853ecaSopenharmony_ci/** 264da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_006 265da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - trackFormat(OH_MD_KEY_AUD_SAMPLE_RATE) check 266da853ecaSopenharmony_ci * @tc.desc : param check test 267da853ecaSopenharmony_ci */ 268da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_006, TestSize.Level2) 269da853ecaSopenharmony_ci{ 270da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 271da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 272da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 273da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 274da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 275da853ecaSopenharmony_ci 276da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 277da853ecaSopenharmony_ci 278da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 279da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 280da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 281da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 282da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 283da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 284da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 285da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 286da853ecaSopenharmony_ci 287da853ecaSopenharmony_ci int32_t trackId; 288da853ecaSopenharmony_ci 289da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 290da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 291da853ecaSopenharmony_ci 292da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, -1); 293da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 294da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 295da853ecaSopenharmony_ci 296da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, "aaaaaa"); 297da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 298da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 299da853ecaSopenharmony_ci 300da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, 0); 301da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 302da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 303da853ecaSopenharmony_ci 304da853ecaSopenharmony_ci OH_AVFormat_SetFloatValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, 0.1); 305da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 306da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 307da853ecaSopenharmony_ci 308da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, 0.1); 309da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 310da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 311da853ecaSopenharmony_ci 312da853ecaSopenharmony_ci uint8_t b[100]; 313da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, b, 100); 314da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 315da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 316da853ecaSopenharmony_ci 317da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 318da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 319da853ecaSopenharmony_ci handle = nullptr; 320da853ecaSopenharmony_ci delete muxerDemo; 321da853ecaSopenharmony_ci} 322da853ecaSopenharmony_ci 323da853ecaSopenharmony_ci/** 324da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_007 325da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - video trackFormat(OH_MD_KEY_CODEC_MIME) check 326da853ecaSopenharmony_ci * @tc.desc : param check test 327da853ecaSopenharmony_ci */ 328da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_007, TestSize.Level2) 329da853ecaSopenharmony_ci{ 330da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 331da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 332da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 333da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 334da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 335da853ecaSopenharmony_ci 336da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 337da853ecaSopenharmony_ci 338da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 339da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_AVC); 340da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, VIDEO_BITRATE); 341da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 342da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420); 343da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_WIDTH, WIDTH); 344da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_HEIGHT, HEIGHT); 345da853ecaSopenharmony_ci 346da853ecaSopenharmony_ci int32_t trackId; 347da853ecaSopenharmony_ci 348da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 349da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 350da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 351da853ecaSopenharmony_ci 352da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_MPEG4); 353da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 354da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 355da853ecaSopenharmony_ci ASSERT_EQ(1, trackId); 356da853ecaSopenharmony_ci 357da853ecaSopenharmony_ci if (access(HEVC_LIB_PATH.c_str(), F_OK) == 0) { 358da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_HEVC); 359da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 360da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 361da853ecaSopenharmony_ci ASSERT_EQ(2, trackId); 362da853ecaSopenharmony_ci } 363da853ecaSopenharmony_ci 364da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 365da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 366da853ecaSopenharmony_ci handle = nullptr; 367da853ecaSopenharmony_ci delete muxerDemo; 368da853ecaSopenharmony_ci} 369da853ecaSopenharmony_ci 370da853ecaSopenharmony_ci/** 371da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_008 372da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - video trackFormat(OH_MD_KEY_WIDTH) check 373da853ecaSopenharmony_ci * @tc.desc : param check test 374da853ecaSopenharmony_ci */ 375da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_008, TestSize.Level2) 376da853ecaSopenharmony_ci{ 377da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 378da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 379da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 380da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 381da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 382da853ecaSopenharmony_ci 383da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 384da853ecaSopenharmony_ci 385da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 386da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_AVC); 387da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, 524569); 388da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 389da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420); 390da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_WIDTH, WIDTH); 391da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_HEIGHT, HEIGHT); 392da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_FRAME_RATE, FRAME_RATE); 393da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 394da853ecaSopenharmony_ci 395da853ecaSopenharmony_ci int32_t trackId; 396da853ecaSopenharmony_ci 397da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 398da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 399da853ecaSopenharmony_ci 400da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_WIDTH, -1); 401da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 402da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 403da853ecaSopenharmony_ci 404da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_WIDTH, "aaa"); 405da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 406da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 407da853ecaSopenharmony_ci 408da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_WIDTH, 0); 409da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 410da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 411da853ecaSopenharmony_ci 412da853ecaSopenharmony_ci OH_AVFormat_SetFloatValue(trackFormat, OH_MD_KEY_WIDTH, 0.1); 413da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 414da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 415da853ecaSopenharmony_ci 416da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_WIDTH, 0.1); 417da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 418da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 419da853ecaSopenharmony_ci 420da853ecaSopenharmony_ci uint8_t b[100]; 421da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_WIDTH, b, 100); 422da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 423da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 424da853ecaSopenharmony_ci 425da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 426da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 427da853ecaSopenharmony_ci handle = nullptr; 428da853ecaSopenharmony_ci delete muxerDemo; 429da853ecaSopenharmony_ci} 430da853ecaSopenharmony_ci 431da853ecaSopenharmony_ci/** 432da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_009 433da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - video trackFormat(OH_MD_KEY_HEIGHT) check 434da853ecaSopenharmony_ci * @tc.desc : param check test 435da853ecaSopenharmony_ci */ 436da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_009, TestSize.Level2) 437da853ecaSopenharmony_ci{ 438da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 439da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 440da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 441da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 442da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 443da853ecaSopenharmony_ci 444da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 445da853ecaSopenharmony_ci 446da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 447da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_AVC); 448da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, 524569); 449da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 450da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PIXEL_FORMAT, AV_PIXEL_FORMAT_YUVI420); 451da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_WIDTH, WIDTH); 452da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_HEIGHT, HEIGHT); 453da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_FRAME_RATE, FRAME_RATE); 454da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 455da853ecaSopenharmony_ci 456da853ecaSopenharmony_ci int32_t trackId; 457da853ecaSopenharmony_ci 458da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 459da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 460da853ecaSopenharmony_ci 461da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_HEIGHT, -1); 462da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 463da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 464da853ecaSopenharmony_ci 465da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_HEIGHT, "aaa"); 466da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 467da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 468da853ecaSopenharmony_ci 469da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_HEIGHT, 0); 470da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 471da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 472da853ecaSopenharmony_ci 473da853ecaSopenharmony_ci OH_AVFormat_SetFloatValue(trackFormat, OH_MD_KEY_HEIGHT, 0.1); 474da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 475da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 476da853ecaSopenharmony_ci 477da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_HEIGHT, 0.1); 478da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 479da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 480da853ecaSopenharmony_ci 481da853ecaSopenharmony_ci uint8_t b[100]; 482da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_HEIGHT, b, 100); 483da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 484da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 485da853ecaSopenharmony_ci 486da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 487da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 488da853ecaSopenharmony_ci handle = nullptr; 489da853ecaSopenharmony_ci delete muxerDemo; 490da853ecaSopenharmony_ci} 491da853ecaSopenharmony_ci 492da853ecaSopenharmony_ci/** 493da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_010 494da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - trackFormat(any key) check 495da853ecaSopenharmony_ci * @tc.desc : param check test 496da853ecaSopenharmony_ci */ 497da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_010, TestSize.Level2) 498da853ecaSopenharmony_ci{ 499da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 500da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 501da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 502da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 503da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 504da853ecaSopenharmony_ci 505da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 506da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, "aaaaa", "bbbbb"); 507da853ecaSopenharmony_ci 508da853ecaSopenharmony_ci int32_t trackId; 509da853ecaSopenharmony_ci 510da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 511da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 512da853ecaSopenharmony_ci 513da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 514da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 515da853ecaSopenharmony_ci handle = nullptr; 516da853ecaSopenharmony_ci delete muxerDemo; 517da853ecaSopenharmony_ci} 518da853ecaSopenharmony_ci 519da853ecaSopenharmony_ci/** 520da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_011 521da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - trackIndex check 522da853ecaSopenharmony_ci * @tc.desc : param check test 523da853ecaSopenharmony_ci */ 524da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_011, TestSize.Level2) 525da853ecaSopenharmony_ci{ 526da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 527da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 528da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 529da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 530da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 531da853ecaSopenharmony_ci 532da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 533da853ecaSopenharmony_ci 534da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 535da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 536da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 537da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 538da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 539da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 540da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 541da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 542da853ecaSopenharmony_ci 543da853ecaSopenharmony_ci int32_t trackId; 544da853ecaSopenharmony_ci 545da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 546da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 547da853ecaSopenharmony_ci 548da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 549da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 550da853ecaSopenharmony_ci 551da853ecaSopenharmony_ci OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE); 552da853ecaSopenharmony_ci 553da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 554da853ecaSopenharmony_ci info.pts = 0; 555da853ecaSopenharmony_ci info.size = INFO_SIZE; 556da853ecaSopenharmony_ci info.offset = 0; 557da853ecaSopenharmony_ci info.flags = 0; 558da853ecaSopenharmony_ci 559da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 560da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 561da853ecaSopenharmony_ci 562da853ecaSopenharmony_ci trackId = -1; 563da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 564da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 565da853ecaSopenharmony_ci 566da853ecaSopenharmony_ci OH_AVMemory_Destroy(avMemBuffer); 567da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 568da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 569da853ecaSopenharmony_ci handle = nullptr; 570da853ecaSopenharmony_ci delete muxerDemo; 571da853ecaSopenharmony_ci} 572da853ecaSopenharmony_ci 573da853ecaSopenharmony_ci/** 574da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_012 575da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.pts check 576da853ecaSopenharmony_ci * @tc.desc : param check test 577da853ecaSopenharmony_ci */ 578da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_012, TestSize.Level2) 579da853ecaSopenharmony_ci{ 580da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 581da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 582da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 583da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 584da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 585da853ecaSopenharmony_ci 586da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 587da853ecaSopenharmony_ci 588da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 589da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 590da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 591da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 592da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 593da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 594da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 595da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 596da853ecaSopenharmony_ci 597da853ecaSopenharmony_ci int32_t trackId; 598da853ecaSopenharmony_ci 599da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 600da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 601da853ecaSopenharmony_ci 602da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 603da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 604da853ecaSopenharmony_ci 605da853ecaSopenharmony_ci OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE); 606da853ecaSopenharmony_ci 607da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 608da853ecaSopenharmony_ci info.pts = 0; 609da853ecaSopenharmony_ci info.size = INFO_SIZE; 610da853ecaSopenharmony_ci info.offset = 0; 611da853ecaSopenharmony_ci info.flags = 0; 612da853ecaSopenharmony_ci 613da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 614da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 615da853ecaSopenharmony_ci 616da853ecaSopenharmony_ci info.pts = -1; 617da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 618da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 619da853ecaSopenharmony_ci 620da853ecaSopenharmony_ci OH_AVMemory_Destroy(avMemBuffer); 621da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 622da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 623da853ecaSopenharmony_ci handle = nullptr; 624da853ecaSopenharmony_ci delete muxerDemo; 625da853ecaSopenharmony_ci} 626da853ecaSopenharmony_ci 627da853ecaSopenharmony_ci/** 628da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_013 629da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.size check 630da853ecaSopenharmony_ci * @tc.desc : param check test 631da853ecaSopenharmony_ci */ 632da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_013, TestSize.Level2) 633da853ecaSopenharmony_ci{ 634da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 635da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 636da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 637da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 638da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 639da853ecaSopenharmony_ci 640da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 641da853ecaSopenharmony_ci 642da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 643da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 644da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 645da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 646da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 647da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 648da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 649da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 650da853ecaSopenharmony_ci 651da853ecaSopenharmony_ci int32_t trackId; 652da853ecaSopenharmony_ci 653da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 654da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 655da853ecaSopenharmony_ci 656da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 657da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 658da853ecaSopenharmony_ci 659da853ecaSopenharmony_ci OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE); 660da853ecaSopenharmony_ci 661da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 662da853ecaSopenharmony_ci info.pts = 0; 663da853ecaSopenharmony_ci info.size = INFO_SIZE; 664da853ecaSopenharmony_ci info.offset = 0; 665da853ecaSopenharmony_ci info.flags = 0; 666da853ecaSopenharmony_ci 667da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 668da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 669da853ecaSopenharmony_ci 670da853ecaSopenharmony_ci info.size = -1; 671da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 672da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 673da853ecaSopenharmony_ci 674da853ecaSopenharmony_ci OH_AVMemory_Destroy(avMemBuffer); 675da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 676da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 677da853ecaSopenharmony_ci handle = nullptr; 678da853ecaSopenharmony_ci delete muxerDemo; 679da853ecaSopenharmony_ci} 680da853ecaSopenharmony_ci 681da853ecaSopenharmony_ci/** 682da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_014 683da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.offset check 684da853ecaSopenharmony_ci * @tc.desc : param check test 685da853ecaSopenharmony_ci */ 686da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_014, TestSize.Level2) 687da853ecaSopenharmony_ci{ 688da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 689da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 690da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 691da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 692da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 693da853ecaSopenharmony_ci 694da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 695da853ecaSopenharmony_ci 696da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 697da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 698da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 699da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 700da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 701da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 702da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 703da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 704da853ecaSopenharmony_ci 705da853ecaSopenharmony_ci int32_t trackId; 706da853ecaSopenharmony_ci 707da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 708da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 709da853ecaSopenharmony_ci 710da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 711da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 712da853ecaSopenharmony_ci 713da853ecaSopenharmony_ci OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE); 714da853ecaSopenharmony_ci 715da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 716da853ecaSopenharmony_ci info.pts = 0; 717da853ecaSopenharmony_ci info.size = INFO_SIZE; 718da853ecaSopenharmony_ci info.offset = 0; 719da853ecaSopenharmony_ci info.flags = 0; 720da853ecaSopenharmony_ci 721da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 722da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 723da853ecaSopenharmony_ci 724da853ecaSopenharmony_ci info.offset = -1; 725da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 726da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 727da853ecaSopenharmony_ci 728da853ecaSopenharmony_ci OH_AVMemory_Destroy(avMemBuffer); 729da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 730da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 731da853ecaSopenharmony_ci handle = nullptr; 732da853ecaSopenharmony_ci delete muxerDemo; 733da853ecaSopenharmony_ci} 734da853ecaSopenharmony_ci 735da853ecaSopenharmony_ci/** 736da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_015 737da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.flags check 738da853ecaSopenharmony_ci * @tc.desc : param check test 739da853ecaSopenharmony_ci */ 740da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_015, TestSize.Level2) 741da853ecaSopenharmony_ci{ 742da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 743da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 744da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 745da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 746da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 747da853ecaSopenharmony_ci 748da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 749da853ecaSopenharmony_ci 750da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 751da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 752da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 753da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 754da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 755da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 756da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 757da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 758da853ecaSopenharmony_ci 759da853ecaSopenharmony_ci int32_t trackId; 760da853ecaSopenharmony_ci 761da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 762da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 763da853ecaSopenharmony_ci 764da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 765da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 766da853ecaSopenharmony_ci 767da853ecaSopenharmony_ci OH_AVMemory *avMemBuffer = OH_AVMemory_Create(INFO_SIZE); 768da853ecaSopenharmony_ci 769da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 770da853ecaSopenharmony_ci info.pts = 0; 771da853ecaSopenharmony_ci info.size = INFO_SIZE; 772da853ecaSopenharmony_ci info.offset = 0; 773da853ecaSopenharmony_ci info.flags = 0; 774da853ecaSopenharmony_ci 775da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 776da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 777da853ecaSopenharmony_ci 778da853ecaSopenharmony_ci info.flags = -1; 779da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 780da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 781da853ecaSopenharmony_ci 782da853ecaSopenharmony_ci OH_AVMemory_Destroy(avMemBuffer); 783da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 784da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 785da853ecaSopenharmony_ci handle = nullptr; 786da853ecaSopenharmony_ci delete muxerDemo; 787da853ecaSopenharmony_ci} 788da853ecaSopenharmony_ci 789da853ecaSopenharmony_ci/** 790da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_016 791da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - sample check 792da853ecaSopenharmony_ci * @tc.desc : param check test 793da853ecaSopenharmony_ci */ 794da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_016, TestSize.Level2) 795da853ecaSopenharmony_ci{ 796da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 797da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 798da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 799da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 800da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 801da853ecaSopenharmony_ci 802da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 803da853ecaSopenharmony_ci 804da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 805da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 806da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 807da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 808da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUDIO_SAMPLE_FORMAT, SAMPLE_S16LE); 809da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 810da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 811da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 812da853ecaSopenharmony_ci 813da853ecaSopenharmony_ci int32_t trackId; 814da853ecaSopenharmony_ci 815da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 816da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 817da853ecaSopenharmony_ci 818da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 819da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 820da853ecaSopenharmony_ci 821da853ecaSopenharmony_ci OH_AVMemory *avMemBuffer = OH_AVMemory_Create(10); 822da853ecaSopenharmony_ci 823da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 824da853ecaSopenharmony_ci info.pts = 0; 825da853ecaSopenharmony_ci info.size = INFO_SIZE; 826da853ecaSopenharmony_ci info.offset = 0; 827da853ecaSopenharmony_ci info.flags = 0; 828da853ecaSopenharmony_ci 829da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avMemBuffer, info); 830da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 831da853ecaSopenharmony_ci 832da853ecaSopenharmony_ci OH_AVMemory_Destroy(avMemBuffer); 833da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 834da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 835da853ecaSopenharmony_ci handle = nullptr; 836da853ecaSopenharmony_ci delete muxerDemo; 837da853ecaSopenharmony_ci} 838da853ecaSopenharmony_ci 839da853ecaSopenharmony_ci/** 840da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_017 841da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_AddTrack - video trackFormat(OH_MD_KEY_COLOR_PRIMARIES) check 842da853ecaSopenharmony_ci * @tc.desc : param check test 843da853ecaSopenharmony_ci */ 844da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_017, TestSize.Level2) 845da853ecaSopenharmony_ci{ 846da853ecaSopenharmony_ci if (access(HEVC_LIB_PATH.c_str(), F_OK) != 0) { 847da853ecaSopenharmony_ci std::cout << "the hevc of mimetype is not supported" << std::endl; 848da853ecaSopenharmony_ci return; 849da853ecaSopenharmony_ci } 850da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 851da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 852da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 853da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 854da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 855da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 856da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 857da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_VIDEO_HEVC); 858da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, 524569); 859da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 860da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_WIDTH, WIDTH); 861da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_HEIGHT, HEIGHT); 862da853ecaSopenharmony_ci OH_AVFormat_SetDoubleValue(trackFormat, OH_MD_KEY_FRAME_RATE, FRAME_RATE); 863da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_COLOR_PRIMARIES, OH_ColorPrimary::COLOR_PRIMARY_BT709); 864da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_TRANSFER_CHARACTERISTICS, 865da853ecaSopenharmony_ci OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_BT709); 866da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_MATRIX_COEFFICIENTS, 867da853ecaSopenharmony_ci OH_MatrixCoefficient::MATRIX_COEFFICIENT_BT709); 868da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_RANGE_FLAG, 0); 869da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_VIDEO_IS_HDR_VIVID, 1); 870da853ecaSopenharmony_ci int32_t trackId; 871da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 872da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 873da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 874da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_COLOR_PRIMARIES, 0); 875da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 876da853ecaSopenharmony_ci ASSERT_NE(AV_ERR_OK, ret); 877da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_COLOR_PRIMARIES, OH_ColorPrimary::COLOR_PRIMARY_BT709); 878da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_TRANSFER_CHARACTERISTICS, 0); 879da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 880da853ecaSopenharmony_ci ASSERT_NE(AV_ERR_OK, ret); 881da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_TRANSFER_CHARACTERISTICS, 882da853ecaSopenharmony_ci OH_TransferCharacteristic::TRANSFER_CHARACTERISTIC_BT709); 883da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_MATRIX_COEFFICIENTS, 3); 884da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 885da853ecaSopenharmony_ci ASSERT_NE(AV_ERR_OK, ret); 886da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_MATRIX_COEFFICIENTS, 887da853ecaSopenharmony_ci OH_MatrixCoefficient::MATRIX_COEFFICIENT_BT709); 888da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_VIDEO_IS_HDR_VIVID, 0); 889da853ecaSopenharmony_ci ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 890da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 891da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 892da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 893da853ecaSopenharmony_ci delete muxerDemo; 894da853ecaSopenharmony_ci} 895da853ecaSopenharmony_ci 896da853ecaSopenharmony_ci 897da853ecaSopenharmony_ci/** 898da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_018 899da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - trackIndex check 900da853ecaSopenharmony_ci * @tc.desc : param check test 901da853ecaSopenharmony_ci */ 902da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_018, TestSize.Level2) 903da853ecaSopenharmony_ci{ 904da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 905da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 906da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 907da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 908da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 909da853ecaSopenharmony_ci 910da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 911da853ecaSopenharmony_ci 912da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 913da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 914da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 915da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 916da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 917da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 918da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 919da853ecaSopenharmony_ci 920da853ecaSopenharmony_ci int32_t trackId; 921da853ecaSopenharmony_ci 922da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 923da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 924da853ecaSopenharmony_ci 925da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 926da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 927da853ecaSopenharmony_ci 928da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 929da853ecaSopenharmony_ci 930da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 931da853ecaSopenharmony_ci info.pts = 0; 932da853ecaSopenharmony_ci info.size = INFO_SIZE; 933da853ecaSopenharmony_ci info.offset = 0; 934da853ecaSopenharmony_ci info.flags = 0; 935da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 936da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 937da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 938da853ecaSopenharmony_ci 939da853ecaSopenharmony_ci trackId = -1; 940da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 941da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 942da853ecaSopenharmony_ci 943da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 944da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 945da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 946da853ecaSopenharmony_ci handle = nullptr; 947da853ecaSopenharmony_ci delete muxerDemo; 948da853ecaSopenharmony_ci} 949da853ecaSopenharmony_ci 950da853ecaSopenharmony_ci/** 951da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_019 952da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.pts check 953da853ecaSopenharmony_ci * @tc.desc : param check test 954da853ecaSopenharmony_ci */ 955da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_019, TestSize.Level2) 956da853ecaSopenharmony_ci{ 957da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 958da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 959da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 960da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 961da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 962da853ecaSopenharmony_ci 963da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 964da853ecaSopenharmony_ci 965da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 966da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 967da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 968da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 969da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 970da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 971da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 972da853ecaSopenharmony_ci 973da853ecaSopenharmony_ci int32_t trackId; 974da853ecaSopenharmony_ci 975da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 976da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 977da853ecaSopenharmony_ci 978da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 979da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 980da853ecaSopenharmony_ci 981da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 982da853ecaSopenharmony_ci 983da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 984da853ecaSopenharmony_ci info.pts = 0; 985da853ecaSopenharmony_ci info.size = INFO_SIZE; 986da853ecaSopenharmony_ci info.offset = 0; 987da853ecaSopenharmony_ci info.flags = 0; 988da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 989da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 990da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 991da853ecaSopenharmony_ci 992da853ecaSopenharmony_ci info.pts = -1; 993da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 994da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 995da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 996da853ecaSopenharmony_ci 997da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 998da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 999da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1000da853ecaSopenharmony_ci handle = nullptr; 1001da853ecaSopenharmony_ci delete muxerDemo; 1002da853ecaSopenharmony_ci} 1003da853ecaSopenharmony_ci 1004da853ecaSopenharmony_ci/** 1005da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_020 1006da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.size check 1007da853ecaSopenharmony_ci * @tc.desc : param check test 1008da853ecaSopenharmony_ci */ 1009da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_020, TestSize.Level2) 1010da853ecaSopenharmony_ci{ 1011da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 1012da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 1013da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 1014da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 1015da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 1016da853ecaSopenharmony_ci 1017da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 1018da853ecaSopenharmony_ci 1019da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 1020da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 1021da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 1022da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 1023da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 1024da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 1025da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 1026da853ecaSopenharmony_ci 1027da853ecaSopenharmony_ci int32_t trackId; 1028da853ecaSopenharmony_ci 1029da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 1030da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 1031da853ecaSopenharmony_ci 1032da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 1033da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1034da853ecaSopenharmony_ci 1035da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 1036da853ecaSopenharmony_ci 1037da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 1038da853ecaSopenharmony_ci info.pts = 0; 1039da853ecaSopenharmony_ci info.size = INFO_SIZE; 1040da853ecaSopenharmony_ci info.offset = 0; 1041da853ecaSopenharmony_ci info.flags = 0; 1042da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1043da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1044da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1045da853ecaSopenharmony_ci 1046da853ecaSopenharmony_ci info.size = -1; 1047da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1048da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1049da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1050da853ecaSopenharmony_ci 1051da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 1052da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 1053da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1054da853ecaSopenharmony_ci handle = nullptr; 1055da853ecaSopenharmony_ci delete muxerDemo; 1056da853ecaSopenharmony_ci} 1057da853ecaSopenharmony_ci 1058da853ecaSopenharmony_ci/** 1059da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_021 1060da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.offset check 1061da853ecaSopenharmony_ci * @tc.desc : param check test 1062da853ecaSopenharmony_ci */ 1063da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_021, TestSize.Level2) 1064da853ecaSopenharmony_ci{ 1065da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 1066da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 1067da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 1068da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 1069da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 1070da853ecaSopenharmony_ci 1071da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 1072da853ecaSopenharmony_ci 1073da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 1074da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 1075da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 1076da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 1077da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 1078da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 1079da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 1080da853ecaSopenharmony_ci 1081da853ecaSopenharmony_ci int32_t trackId; 1082da853ecaSopenharmony_ci 1083da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 1084da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 1085da853ecaSopenharmony_ci 1086da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 1087da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1088da853ecaSopenharmony_ci 1089da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 1090da853ecaSopenharmony_ci 1091da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 1092da853ecaSopenharmony_ci info.pts = 0; 1093da853ecaSopenharmony_ci info.size = INFO_SIZE; 1094da853ecaSopenharmony_ci info.offset = 0; 1095da853ecaSopenharmony_ci info.flags = 0; 1096da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1097da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1098da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1099da853ecaSopenharmony_ci 1100da853ecaSopenharmony_ci info.offset = -1; 1101da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1102da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1103da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1104da853ecaSopenharmony_ci 1105da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 1106da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 1107da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1108da853ecaSopenharmony_ci handle = nullptr; 1109da853ecaSopenharmony_ci delete muxerDemo; 1110da853ecaSopenharmony_ci} 1111da853ecaSopenharmony_ci 1112da853ecaSopenharmony_ci/** 1113da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_022 1114da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - info.flags check 1115da853ecaSopenharmony_ci * @tc.desc : param check test 1116da853ecaSopenharmony_ci */ 1117da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_022, TestSize.Level2) 1118da853ecaSopenharmony_ci{ 1119da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 1120da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 1121da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 1122da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 1123da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 1124da853ecaSopenharmony_ci 1125da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 1126da853ecaSopenharmony_ci 1127da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 1128da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 1129da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 1130da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 1131da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 1132da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 1133da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 1134da853ecaSopenharmony_ci 1135da853ecaSopenharmony_ci int32_t trackId; 1136da853ecaSopenharmony_ci 1137da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 1138da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 1139da853ecaSopenharmony_ci 1140da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 1141da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1142da853ecaSopenharmony_ci 1143da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 1144da853ecaSopenharmony_ci 1145da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 1146da853ecaSopenharmony_ci info.pts = 0; 1147da853ecaSopenharmony_ci info.size = INFO_SIZE; 1148da853ecaSopenharmony_ci info.offset = 0; 1149da853ecaSopenharmony_ci info.flags = 0; 1150da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1151da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1152da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1153da853ecaSopenharmony_ci 1154da853ecaSopenharmony_ci info.flags = -1; 1155da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1156da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1157da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1158da853ecaSopenharmony_ci 1159da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 1160da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 1161da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1162da853ecaSopenharmony_ci handle = nullptr; 1163da853ecaSopenharmony_ci delete muxerDemo; 1164da853ecaSopenharmony_ci} 1165da853ecaSopenharmony_ci 1166da853ecaSopenharmony_ci/** 1167da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_025 1168da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - sample check 1169da853ecaSopenharmony_ci * @tc.desc : param check test 1170da853ecaSopenharmony_ci */ 1171da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_025, TestSize.Level2) 1172da853ecaSopenharmony_ci{ 1173da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 1174da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MP3; 1175da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 1176da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 1177da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 1178da853ecaSopenharmony_ci 1179da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 1180da853ecaSopenharmony_ci 1181da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 1182da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_MPEG); 1183da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 1184da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 1185da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 1186da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 1187da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 1188da853ecaSopenharmony_ci 1189da853ecaSopenharmony_ci int32_t trackId; 1190da853ecaSopenharmony_ci 1191da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 1192da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 1193da853ecaSopenharmony_ci 1194da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 1195da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1196da853ecaSopenharmony_ci 1197da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 1198da853ecaSopenharmony_ci 1199da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 1200da853ecaSopenharmony_ci info.pts = 0; 1201da853ecaSopenharmony_ci info.size = INFO_SIZE; 1202da853ecaSopenharmony_ci info.offset = 0; 1203da853ecaSopenharmony_ci info.flags = 0; 1204da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1205da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1206da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1207da853ecaSopenharmony_ci 1208da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 1209da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 1210da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1211da853ecaSopenharmony_ci handle = nullptr; 1212da853ecaSopenharmony_ci delete muxerDemo; 1213da853ecaSopenharmony_ci} 1214da853ecaSopenharmony_ci 1215da853ecaSopenharmony_ci/** 1216da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_023 1217da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - sample check 1218da853ecaSopenharmony_ci * @tc.desc : param check test 1219da853ecaSopenharmony_ci */ 1220da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_023, TestSize.Level2) 1221da853ecaSopenharmony_ci{ 1222da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 1223da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_MPEG_4; 1224da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 1225da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 1226da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 1227da853ecaSopenharmony_ci 1228da853ecaSopenharmony_ci uint8_t a[CODEC_CONFIG]; 1229da853ecaSopenharmony_ci 1230da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 1231da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AAC); 1232da853ecaSopenharmony_ci OH_AVFormat_SetLongValue(trackFormat, OH_MD_KEY_BITRATE, AUDIO_BITRATE); 1233da853ecaSopenharmony_ci OH_AVFormat_SetBuffer(trackFormat, OH_MD_KEY_CODEC_CONFIG, a, CODEC_CONFIG); 1234da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, CHANNEL_COUNT); 1235da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, SAMPLE_RATE); 1236da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_PROFILE, PROFILE); 1237da853ecaSopenharmony_ci 1238da853ecaSopenharmony_ci int32_t trackId; 1239da853ecaSopenharmony_ci 1240da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 1241da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 1242da853ecaSopenharmony_ci 1243da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 1244da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1245da853ecaSopenharmony_ci 1246da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(0x10); 1247da853ecaSopenharmony_ci 1248da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 1249da853ecaSopenharmony_ci info.pts = 0; 1250da853ecaSopenharmony_ci info.size = INFO_SIZE; 1251da853ecaSopenharmony_ci info.offset = 0; 1252da853ecaSopenharmony_ci info.flags = 0; 1253da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1254da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1255da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_INVALID_VAL, ret); 1256da853ecaSopenharmony_ci 1257da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 1258da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 1259da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1260da853ecaSopenharmony_ci handle = nullptr; 1261da853ecaSopenharmony_ci delete muxerDemo; 1262da853ecaSopenharmony_ci} 1263da853ecaSopenharmony_ci 1264da853ecaSopenharmony_ci/** 1265da853ecaSopenharmony_ci * @tc.number : SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_024 1266da853ecaSopenharmony_ci * @tc.name : OH_AVMuxer_WriteSampleBuffer - sample check 1267da853ecaSopenharmony_ci * @tc.desc : param check test 1268da853ecaSopenharmony_ci */ 1269da853ecaSopenharmony_ciHWTEST_F(NativeAVMuxerParamCheckTest, SUB_MULTIMEDIA_MEDIA_MUXER_PARAM_CHECK_024, TestSize.Level2) 1270da853ecaSopenharmony_ci{ 1271da853ecaSopenharmony_ci AVMuxerDemo *muxerDemo = new AVMuxerDemo(); 1272da853ecaSopenharmony_ci OH_AVOutputFormat format = AV_OUTPUT_FORMAT_AMR; 1273da853ecaSopenharmony_ci int32_t fd = muxerDemo->GetFdByMode(format); 1274da853ecaSopenharmony_ci OH_AVMuxer *handle = muxerDemo->NativeCreate(fd, format); 1275da853ecaSopenharmony_ci ASSERT_NE(nullptr, handle); 1276da853ecaSopenharmony_ci 1277da853ecaSopenharmony_ci OH_AVFormat *trackFormat = OH_AVFormat_Create(); 1278da853ecaSopenharmony_ci OH_AVFormat_SetStringValue(trackFormat, OH_MD_KEY_CODEC_MIME, OH_AVCODEC_MIMETYPE_AUDIO_AMR_NB); 1279da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_CHANNEL_COUNT, 1); // 1 audio channel, mono 1280da853ecaSopenharmony_ci OH_AVFormat_SetIntValue(trackFormat, OH_MD_KEY_AUD_SAMPLE_RATE, 8000); // 8000: 8khz sample rate 1281da853ecaSopenharmony_ci 1282da853ecaSopenharmony_ci int32_t trackId; 1283da853ecaSopenharmony_ci 1284da853ecaSopenharmony_ci OH_AVErrCode ret = muxerDemo->NativeAddTrack(handle, &trackId, trackFormat); 1285da853ecaSopenharmony_ci ASSERT_EQ(0, trackId); 1286da853ecaSopenharmony_ci 1287da853ecaSopenharmony_ci ret = muxerDemo->NativeStart(handle); 1288da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1289da853ecaSopenharmony_ci 1290da853ecaSopenharmony_ci OH_AVBuffer *avBuffer = OH_AVBuffer_Create(INFO_SIZE); 1291da853ecaSopenharmony_ci 1292da853ecaSopenharmony_ci OH_AVCodecBufferAttr info; 1293da853ecaSopenharmony_ci info.pts = 0; 1294da853ecaSopenharmony_ci info.size = INFO_SIZE; 1295da853ecaSopenharmony_ci info.offset = 0; 1296da853ecaSopenharmony_ci info.flags = 0; 1297da853ecaSopenharmony_ci OH_AVBuffer_SetBufferAttr(avBuffer, &info); 1298da853ecaSopenharmony_ci ret = muxerDemo->NativeWriteSampleBuffer(handle, trackId, avBuffer); 1299da853ecaSopenharmony_ci ASSERT_EQ(AV_ERR_OK, ret); 1300da853ecaSopenharmony_ci 1301da853ecaSopenharmony_ci OH_AVBuffer_Destroy(avBuffer); 1302da853ecaSopenharmony_ci muxerDemo->NativeDestroy(handle); 1303da853ecaSopenharmony_ci OH_AVFormat_Destroy(trackFormat); 1304da853ecaSopenharmony_ci handle = nullptr; 1305da853ecaSopenharmony_ci delete muxerDemo; 1306da853ecaSopenharmony_ci} 1307