1 /* 2 * Copyright (C) 2021 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 #include <climits> 17 #include <iostream> 18 #include "player_demo.h" 19 #include "recorder_demo.h" 20 #include "avmetadatahelper_demo.h" 21 #include "avcodeclist_demo.h" 22 #include "avcodec_venc_demo.h" 23 #include "avcodec_vdec_demo.h" 24 #include "recorder_profiles_demo.h" 25 #include "avmuxer_demo.h" 26 27 using namespace OHOS; 28 using namespace OHOS::Media; 29 using namespace MediaDemo; 30 using namespace std; 31 RunPlayer(const string & path)32static int RunPlayer(const string &path) 33 { 34 auto player = std::make_unique<PlayerDemo>(); 35 if (player == nullptr) { 36 cout << "player is null" << endl; 37 return 0; 38 } 39 player->RunCase(path); 40 cout << "demo player end" << endl; 41 return 0; 42 } 43 RunCodecList(const string & path)44static int RunCodecList(const string &path) 45 { 46 auto avCodecList = std::make_unique<AVCodecListDemo>(); 47 if (avCodecList == nullptr) { 48 cout << "avCodecList is null" << endl; 49 return 0; 50 } 51 avCodecList->RunCase(path); 52 cout << "demo avCodecList end" << endl; 53 return 0; 54 } 55 RunRecorder()56static int RunRecorder() 57 { 58 auto recorder = std::make_unique<RecorderDemo>(); 59 if (recorder == nullptr) { 60 cout << "recorder is null" << endl; 61 return 0; 62 } 63 recorder->RunCase(); 64 cout << "demo recorder end" << endl; 65 return 0; 66 } 67 RunAVMetadataHelper(const string & path)68static int RunAVMetadataHelper(const string &path) 69 { 70 auto avMetadataHelper = std::make_unique<AVMetadataHelperDemo>(); 71 if (avMetadataHelper == nullptr) { 72 cout << "avMetadataHelper is null" << endl; 73 return 0; 74 } 75 avMetadataHelper->RunCase(path); 76 cout << "demo avMetadataHelper end" << endl; 77 return 0; 78 } 79 RunVideoEncoder(bool enableProp)80static int RunVideoEncoder(bool enableProp) 81 { 82 auto venc = std::make_unique<VEncDemo>(); 83 if (venc == nullptr) { 84 cout << "videoencoder is null" << endl; 85 return 0; 86 } 87 venc->RunCase(enableProp); 88 cout << "demo videoencoder end" << endl; 89 return 0; 90 } 91 RunMediaProfile(const string & path)92static int RunMediaProfile(const string &path) 93 { 94 auto profile = std::make_unique<RecorderProfilesDemo>(); 95 if (profile == nullptr) { 96 cout << "mediaprofile is null" << endl; 97 return 0; 98 } 99 profile->RunCase(path); 100 cout << "demo mediaprofile end" << endl; 101 return 0; 102 } 103 RunAVMuxer()104static int RunAVMuxer() 105 { 106 #ifdef SUPPORT_MUXER 107 auto avmuxer = std::make_unique<AVMuxerDemo>(); 108 if (avmuxer == nullptr) { 109 cout << "avmuxer is null" << endl; 110 return 0; 111 } 112 avmuxer->RunCase(); 113 #endif 114 cout << "demo avmuxer end" << endl; 115 return 0; 116 } 117 main(int argc,char * argv[])118int main(int argc, char *argv[]) 119 { 120 constexpr int minRequiredArgCount = 2; 121 string path; 122 if (argc >= minRequiredArgCount && argv[1] != nullptr) { 123 path = argv[1]; 124 } 125 cout << "Please select a demo scenario number(default player): " << endl; 126 cout << "0:player" << endl; 127 cout << "1:recorder" << endl; 128 cout << "2:avmetadatahelper" << endl; 129 cout << "3:codeclist" << endl; 130 cout << "4:video-encoder" << endl; 131 cout << "5:avmuxer" << endl; 132 cout << "6:recorder_profiles" << endl; 133 134 string mode; 135 (void)getline(cin, mode); 136 if (mode == "" || mode == "0") { 137 (void)RunPlayer(path); 138 } else if (mode == "1") { 139 (void)RunRecorder(); 140 } else if (mode == "2") { 141 (void)RunAVMetadataHelper(path); 142 } else if (mode == "3") { 143 (void)RunCodecList(path); 144 } else if (mode == "4") { 145 (void)RunVideoEncoder(false); 146 } else if (mode == "5") { 147 (void)RunAVMuxer(); 148 } else if (mode == "6") { 149 (void)RunMediaProfile(path); 150 } else { 151 cout << "no that selection" << endl; 152 } 153 return 0; 154 } 155