1 /* 2 * Copyright (C) 2024 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 #ifndef MAIN8_CARAUDIOCONFIGURATIONXMLCONVERTER_H 18 #define MAIN8_CARAUDIOCONFIGURATIONXMLCONVERTER_H 19 20 #include <string> 21 22 #include "../include/CarAudioConfigurationUtils.h" 23 24 #include <aidl/android/hardware/automotive/audiocontrol/AudioDeviceConfiguration.h> 25 #include <aidl/android/hardware/automotive/audiocontrol/AudioZone.h> 26 #include <aidl/android/hardware/automotive/audiocontrol/AudioZoneContext.h> 27 28 namespace android::hardware::automotive::audiocontrol { 29 class CarAudioConfigurationType; 30 } 31 32 namespace android { 33 namespace hardware { 34 namespace audiocontrol { 35 namespace internal { 36 37 class CarAudioConfigurationXmlConverter { 38 public: CarAudioConfigurationXmlConverter(const std::string & audioConfigFile,const std::string & fadeConfigFile)39 explicit CarAudioConfigurationXmlConverter(const std::string& audioConfigFile, 40 const std::string& fadeConfigFile) 41 : mAudioConfigFile(audioConfigFile), mFadeConfigFile(fadeConfigFile) { 42 init(); 43 } 44 45 ::aidl::android::hardware::automotive::audiocontrol::AudioDeviceConfiguration 46 getAudioDeviceConfiguration() const; 47 48 std::vector<::aidl::android::hardware::automotive::audiocontrol::AudioZone> getAudioZones() 49 const; 50 std::vector<::aidl::android::media::audio::common::AudioPort> getOutputMirroringDevices() const; 51 getErrors()52 const std::string getErrors() const { return mParseErrors; } 53 54 private: 55 void init(); 56 void initNonDynamicRouting(); 57 void initFadeConfigurations(); 58 void initAudioDeviceConfiguration( 59 const ::android::hardware::automotive::audiocontrol::CarAudioConfigurationType& 60 carAudioConfigurationType); 61 void initCarAudioConfigurations( 62 const ::android::hardware::automotive::audiocontrol::CarAudioConfigurationType& 63 carAudioConfigurationType); 64 void parseAudioDeviceConfigurations( 65 const ::android::hardware::automotive::audiocontrol::CarAudioConfigurationType& 66 carAudioConfigurationType); 67 68 const std::string mAudioConfigFile; 69 const std::string mFadeConfigFile; 70 ::aidl::android::hardware::automotive::audiocontrol::AudioDeviceConfiguration 71 mAudioDeviceConfiguration; 72 std::optional<::aidl::android::hardware::automotive::audiocontrol::AudioZoneContext> 73 mAudioZoneContext; 74 std::vector<::aidl::android::hardware::automotive::audiocontrol::AudioZone> mAudioZones; 75 std::vector<::aidl::android::media::audio::common::AudioPort> mOutputMirroringDevices; 76 std::string mParseErrors; 77 std::unordered_map<std::string, 78 ::aidl::android::hardware::automotive::audiocontrol::AudioFadeConfiguration> 79 mFadeConfigurations; 80 }; 81 82 } // namespace internal 83 } // namespace audiocontrol 84 } // namespace hardware 85 } // namespace android 86 87 #endif // MAIN8_CARAUDIOCONFIGURATIONXMLCONVERTER_H 88