1/* 2 * Copyright (c) 2022 Shenzhen Kaihong DID 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#ifndef PARSE_COMMAND_H 16#define PARSE_COMMAND_H 17#include <cinttypes> 18#include <string> 19enum class CodecMime { AVC, HEVC, MPEG4, VP9 }; 20enum class ColorFormat { YUV420SP = 0, RGBA8888, BGRA8888 }; 21enum class MyOptIndex { 22 OPT_INDEX_UNKONWN = 0, 23 OPT_INDEX_BUFFER_HANDLE, 24 OPT_INDEX_HEVC, 25 OPT_INDEX_MPEG4, 26 OPT_INDEX_VP9, 27 OPT_INDEX_HELP, 28 OPT_INDEX_HEIGHT = 'h', 29 OPT_INDEX_INPUT = 'i', 30 OPT_INDEX_OUTPUT = 'o', 31 OPT_INDEX_WIDTH = 'w', 32 OPT_INDEX_COLOR = 'c' 33}; 34struct CommandOpt { 35 std::string fileInput = ""; 36 std::string fileOutput = ""; 37 uint32_t width = 0; 38 uint32_t height = 0; 39 bool useBuffer = false; 40 CodecMime codec = CodecMime::AVC; 41 ColorFormat colorForamt = ColorFormat::YUV420SP; 42}; 43 44class CommandParse { 45public: 46 CommandParse() 47 {} 48 ~CommandParse() 49 {} 50 bool Parse(int argc, char *argv[], CommandOpt &opt); 51 52private: 53 void ShowUsage(); 54 void ParseCodingType(const MyOptIndex index, CommandOpt &opt); 55}; 56#endif