1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef AWCOMMON_H 17 #define AWCOMMON_H 18 19 #include <string> 20 #include "window.h" 21 #include "recorder.h" 22 namespace OHOS { 23 namespace Media { 24 #define CHECK_INSTANCE_AND_RETURN_RET(cond, ret, ...) \ 25 do { \ 26 if (cond == nullptr) { \ 27 cout << cond << "is nullptr" << endl; \ 28 return ret; \ 29 } \ 30 } while (0) 31 32 #define CHECK_BOOL_AND_RETURN_RET(cond, ret, ...) \ 33 do { \ 34 if (!(cond)) { \ 35 return ret; \ 36 } \ 37 } while (0) 38 39 #define CHECK_STATE_AND_RETURN_RET(cond, ret, ...) \ 40 do { \ 41 if (cond != 0) { \ 42 return ret; \ 43 } \ 44 } while (0) 45 namespace PlayerTestParam { 46 int32_t WriteDataToFile(const std::string &path, const std::uint8_t *data, std::size_t size); 47 int32_t ProduceRandomNumberCrypt(void); 48 } // namespace PlayerTestParam 49 namespace RecorderTestParam { 50 struct VideoRecorderConfig_ { 51 int32_t audioSourceId = 0; 52 int32_t videoSourceId = 0; 53 int32_t dataSourceId = 0; 54 int32_t audioEncodingBitRate = 48000; 55 int32_t channelCount = 2; 56 int32_t duration = 60; 57 int32_t width = 1280; 58 int32_t height = 720; 59 int32_t frameRate = 30; 60 int32_t videoEncodingBitRate = 48000; 61 int32_t sampleRate = 48000; 62 double captureFps = 30; 63 int32_t outputFd = 0; 64 AudioCodecFormat audioFormat = AAC_LC; 65 AudioSourceType aSource = AUDIO_MIC; 66 DataSourceType dataType = METADATA; 67 OutputFormatType outPutFormat = FORMAT_MPEG_4; 68 VideoSourceType vSource = VIDEO_SOURCE_SURFACE_YUV; 69 VideoCodecFormat videoFormat = MPEG4; 70 }; 71 struct AudioRecorderConfig_ { 72 int32_t outputFd = 0; 73 int32_t audioSourceId = 0; 74 int32_t audioEncodingBitRate = 48000; 75 int32_t channelCount = 2; 76 int32_t duration = 60; 77 int32_t sampleRate = 48000; 78 AudioCodecFormat audioFormat = AAC_LC; 79 AudioSourceType inputSource = AUDIO_MIC; 80 OutputFormatType outPutFormat = FORMAT_M4A; 81 }; 82 } // namespace RecorderTestParam 83 } // namespace Media 84 } // namespace OHOS 85 86 #endif