1 /* 2 * Copyright (C) 2024 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 TRANSCODER_PARAM_H 17 #define TRANSCODER_PARAM_H 18 19 #include <cstdint> 20 #include <string> 21 #include "transcoder.h" 22 23 namespace OHOS { 24 namespace Media { 25 26 enum TransCoderPublicParamType : uint32_t { 27 // video begin 28 VIDEO_PUBLIC_PARAM_BEGIN, 29 VIDEO_ENC_FMT, 30 VIDEO_RECTANGLE, 31 VIDEO_BITRATE, 32 VIDEO_PUBLIC_PARAM_END, 33 // audio begin 34 AUDIO_PUBLIC_PARAM_BEGIN, 35 AUDIO_ENC_FMT, 36 AUDIO_BITRATE, 37 AUDIO_PUBIC_PARAM_END, 38 // input begin, 39 INPUT_PATH, 40 INPUT_URL, 41 INPUT_FD, 42 // output begin, 43 OUTPUT_PATH, 44 OUTPUT_FD, 45 }; 46 47 /* 48 * TransCoder parameter base structure, inherite to it to extend the new parameter. 49 */ 50 struct TransCoderParam { TransCoderParamTransCoderParam51 explicit TransCoderParam(uint32_t t) : type(t) {} 52 TransCoderParam() = delete; 53 virtual ~TransCoderParam() = default; 54 uint32_t type; 55 }; 56 57 struct VideoEnc : public TransCoderParam { VideoEncVideoEnc58 explicit VideoEnc(VideoCodecFormat fmt) : TransCoderParam(TransCoderPublicParamType::VIDEO_ENC_FMT), encFmt(fmt) {} 59 VideoCodecFormat encFmt; 60 }; 61 62 struct VideoRectangle : public TransCoderParam { VideoRectangleVideoRectangle63 VideoRectangle(int32_t w, int32_t h) : TransCoderParam(TransCoderPublicParamType::VIDEO_RECTANGLE), 64 width(w), height(h) {} 65 int32_t width; 66 int32_t height; 67 }; 68 69 struct VideoBitRate : public TransCoderParam { VideoBitRateVideoBitRate70 explicit VideoBitRate(int32_t br) : TransCoderParam(TransCoderPublicParamType::VIDEO_BITRATE), bitRate(br) {} 71 int32_t bitRate; 72 }; 73 74 struct AudioEnc : public TransCoderParam { AudioEncAudioEnc75 explicit AudioEnc(AudioCodecFormat fmt) : TransCoderParam(TransCoderPublicParamType::AUDIO_ENC_FMT), encFmt(fmt) {} 76 AudioCodecFormat encFmt; 77 }; 78 79 struct AudioBitRate : public TransCoderParam { AudioBitRateAudioBitRate80 explicit AudioBitRate(int32_t br) : TransCoderParam(TransCoderPublicParamType::AUDIO_BITRATE), bitRate(br) {} 81 int32_t bitRate; 82 }; 83 84 struct InputFilePath : public TransCoderParam { InputFilePathInputFilePath85 explicit InputFilePath(const std::string &filePath) : TransCoderParam(TransCoderPublicParamType::INPUT_PATH), 86 path(filePath) {} 87 std::string path; 88 }; 89 90 struct InputUrl : public TransCoderParam { InputUrlInputUrl91 explicit InputUrl(std::string inputUrl) : TransCoderParam(TransCoderPublicParamType::INPUT_URL), url(inputUrl) {} 92 std::string url; 93 }; 94 95 struct InputFd : public TransCoderParam { InputFdInputFd96 explicit InputFd(int32_t inputFd, int64_t inputOffset, int64_t inputSize) 97 : TransCoderParam(TransCoderPublicParamType::INPUT_FD), fd(inputFd), offset(inputOffset), size(inputSize) {} 98 int32_t fd; 99 int64_t offset; 100 int64_t size; 101 }; 102 103 struct OutputFilePath : public TransCoderParam { OutputFilePathOutputFilePath104 explicit OutputFilePath(const std::string &filePath) 105 : TransCoderParam(TransCoderPublicParamType::OUTPUT_PATH), path(filePath) {} 106 std::string path; 107 }; 108 109 struct OutputFd : public TransCoderParam { OutputFdOutputFd110 explicit OutputFd(int32_t outFd) : TransCoderParam(TransCoderPublicParamType::OUTPUT_FD), fd(outFd) {} 111 int32_t fd; 112 }; 113 } // namespace Media 114 } // namespace OHOS 115 #endif 116