1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <media/EffectsFactoryApi.h> 18 #include <unistd.h> 19 #include "EffectsXmlConfigLoader.h" 20 #include "EffectsConfigLoader.h" 21 22 int main(int argc, char* argv[]) { 23 const char* path = nullptr; 24 bool legacyFormat; 25 26 if (argc == 2 && strcmp(argv[1], "--legacy") == 0) { 27 legacyFormat = true; 28 fprintf(stderr, "Dumping legacy effect config file\n"); 29 } else if ((argc == 2 || argc == 3) && strcmp(argv[1], "--xml") == 0) { 30 legacyFormat = false; 31 if (argc == 3) { 32 fprintf(stderr, "Dumping XML effect config file: %s\n", path); 33 } else { 34 fprintf(stderr, "Dumping default XML effect config file.\n"); 35 } 36 } else { 37 fprintf(stderr, "Invalid arguments.\n" 38 "Usage: %s [--legacy|--xml [FILE]]\n", argv[0]); 39 return 1; 40 } 41 42 if (!legacyFormat) { 43 ssize_t ret = EffectLoadXmlEffectConfig(path); 44 if (ret < 0) { 45 fprintf(stderr, "loadXmlEffectConfig failed, see logcat for detail.\n"); 46 return 2; 47 } 48 if (ret > 0) { 49 fprintf(stderr, "Partially failed to load config. Skipped %zu elements, " 50 "see logcat for detail.\n", (size_t)ret); 51 } 52 } 53 54 if (legacyFormat) { 55 auto ret = EffectLoadEffectConfig(); 56 if (ret < 0) { 57 fprintf(stderr, "loadEffectConfig failed, see logcat for detail.\n"); 58 return 3; 59 } 60 fprintf(stderr, "legacy loadEffectConfig has probably succeed, see logcat to make sure.\n"); 61 } 62 63 if (EffectDumpEffects(STDOUT_FILENO) != 0) { 64 fprintf(stderr, "Effect dump failed, see logcat for detail.\n"); 65 return 4; 66 } 67 } 68