Loading media/codec2/hal/aidl/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ cc_library { ], static_libs: [ "libPlatformProperties", "libaidlcommonsupport", ], Loading Loading @@ -97,6 +98,7 @@ cc_library { ], static_libs: [ "libPlatformProperties", "libaidlcommonsupport", ], Loading media/codec2/hal/aidl/ParamTypes.cpp +26 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #define LOG_TAG "Codec2-AIDL-ParamTypes" #include <android-base/logging.h> #include <android/binder_manager.h> #include <android/sysprop/MediaProperties.sysprop.h> #include <codec2/aidl/ParamTypes.h> #include <codec2/common/ParamTypes.h> Loading Loading @@ -157,8 +159,30 @@ namespace media { namespace c2 { namespace utils { // TODO: read it from aconfig flags bool IsEnabled() { return false; } bool IsSelected() { // TODO: read from aconfig flags const bool enabled = false; if (!enabled) { // Cannot select AIDL if not enabled return false; } using ::android::sysprop::MediaProperties::codec2_hal_selection; using ::android::sysprop::MediaProperties::codec2_hal_selection_values; constexpr codec2_hal_selection_values AIDL = codec2_hal_selection_values::AIDL; constexpr codec2_hal_selection_values HIDL = codec2_hal_selection_values::HIDL; codec2_hal_selection_values selection = codec2_hal_selection().value_or(HIDL); switch (selection) { case AIDL: return true; case HIDL: return false; default: LOG(FATAL) << "Unexpected codec2 HAL selection value: " << (int)selection; } return false; } const char* asString(Status status, const char* def) { return asString(static_cast<c2_status_t>(status.status), def); Loading media/codec2/hal/aidl/include/codec2/aidl/ParamTypes.h +2 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ namespace media { namespace c2 { namespace utils { // Returns true iff AIDL c2 HAL is enabled bool IsEnabled(); // Returns true iff AIDL c2 HAL is selected for the system bool IsSelected(); // Make asString() and operator<< work with Status as well as c2_status_t. C2_DECLARE_AS_STRING_AND_DEFINE_STREAM_OUT(Status); Loading media/codec2/hal/client/client.cpp +38 −35 Original line number Diff line number Diff line Loading @@ -1438,15 +1438,14 @@ std::shared_ptr<C2ParamReflector> Codec2Client::getParamReflector() { std::vector<std::string> Codec2Client::CacheServiceNames() { std::vector<std::string> names; if (c2_aidl::utils::IsEnabled()) { if (c2_aidl::utils::IsSelected()) { // Get AIDL service names AServiceManager_forEachDeclaredInstance( AidlBase::descriptor, &names, [](const char *name, void *context) { std::vector<std::string> *names = (std::vector<std::string> *)context; names->emplace_back(name); }); } } else { // Get HIDL service names using ::android::hardware::media::c2::V1_0::IComponentStore; using ::android::hidl::manager::V1_2::IServiceManager; Loading @@ -1468,6 +1467,7 @@ std::vector<std::string> Codec2Client::CacheServiceNames() { << IComponentStore::descriptor << ". Retrying..."; } } // Sort service names in each category. std::stable_sort( names.begin(), names.end(), Loading Loading @@ -1545,7 +1545,7 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) { std::string const& name = GetServiceNames()[index]; LOG(VERBOSE) << "Creating a Codec2 client to service \"" << name << "\""; if (c2_aidl::utils::IsEnabled()) { if (c2_aidl::utils::IsSelected()) { std::string instanceName = ::android::base::StringPrintf("%s/%s", AidlBase::descriptor, name.c_str()); if (AServiceManager_isDeclared(instanceName.c_str())) { Loading @@ -1559,9 +1559,10 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) { CHECK(transStatus.isOk()) << "Codec2 AIDL service \"" << name << "\"" "does not have IConfigurable."; return std::make_shared<Codec2Client>(baseStore, configurable, index); } else { LOG(ERROR) << "Codec2 AIDL service \"" << name << "\" is not declared"; } } } else { std::string instanceName = "android.hardware.media.c2/" + name; sp<HidlBase> baseStore = HidlBase::getService(name); CHECK(baseStore) << "Codec2 service \"" << name << "\"" Loading @@ -1574,6 +1575,8 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) { static_cast<sp<c2_hidl::IConfigurable>>(transResult); return std::make_shared<Codec2Client>(baseStore, configurable, index); } return nullptr; } c2_status_t Codec2Client::ForAllServices( const std::string &key, Loading Loading
media/codec2/hal/aidl/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ cc_library { ], static_libs: [ "libPlatformProperties", "libaidlcommonsupport", ], Loading Loading @@ -97,6 +98,7 @@ cc_library { ], static_libs: [ "libPlatformProperties", "libaidlcommonsupport", ], Loading
media/codec2/hal/aidl/ParamTypes.cpp +26 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #define LOG_TAG "Codec2-AIDL-ParamTypes" #include <android-base/logging.h> #include <android/binder_manager.h> #include <android/sysprop/MediaProperties.sysprop.h> #include <codec2/aidl/ParamTypes.h> #include <codec2/common/ParamTypes.h> Loading Loading @@ -157,8 +159,30 @@ namespace media { namespace c2 { namespace utils { // TODO: read it from aconfig flags bool IsEnabled() { return false; } bool IsSelected() { // TODO: read from aconfig flags const bool enabled = false; if (!enabled) { // Cannot select AIDL if not enabled return false; } using ::android::sysprop::MediaProperties::codec2_hal_selection; using ::android::sysprop::MediaProperties::codec2_hal_selection_values; constexpr codec2_hal_selection_values AIDL = codec2_hal_selection_values::AIDL; constexpr codec2_hal_selection_values HIDL = codec2_hal_selection_values::HIDL; codec2_hal_selection_values selection = codec2_hal_selection().value_or(HIDL); switch (selection) { case AIDL: return true; case HIDL: return false; default: LOG(FATAL) << "Unexpected codec2 HAL selection value: " << (int)selection; } return false; } const char* asString(Status status, const char* def) { return asString(static_cast<c2_status_t>(status.status), def); Loading
media/codec2/hal/aidl/include/codec2/aidl/ParamTypes.h +2 −2 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ namespace media { namespace c2 { namespace utils { // Returns true iff AIDL c2 HAL is enabled bool IsEnabled(); // Returns true iff AIDL c2 HAL is selected for the system bool IsSelected(); // Make asString() and operator<< work with Status as well as c2_status_t. C2_DECLARE_AS_STRING_AND_DEFINE_STREAM_OUT(Status); Loading
media/codec2/hal/client/client.cpp +38 −35 Original line number Diff line number Diff line Loading @@ -1438,15 +1438,14 @@ std::shared_ptr<C2ParamReflector> Codec2Client::getParamReflector() { std::vector<std::string> Codec2Client::CacheServiceNames() { std::vector<std::string> names; if (c2_aidl::utils::IsEnabled()) { if (c2_aidl::utils::IsSelected()) { // Get AIDL service names AServiceManager_forEachDeclaredInstance( AidlBase::descriptor, &names, [](const char *name, void *context) { std::vector<std::string> *names = (std::vector<std::string> *)context; names->emplace_back(name); }); } } else { // Get HIDL service names using ::android::hardware::media::c2::V1_0::IComponentStore; using ::android::hidl::manager::V1_2::IServiceManager; Loading @@ -1468,6 +1467,7 @@ std::vector<std::string> Codec2Client::CacheServiceNames() { << IComponentStore::descriptor << ". Retrying..."; } } // Sort service names in each category. std::stable_sort( names.begin(), names.end(), Loading Loading @@ -1545,7 +1545,7 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) { std::string const& name = GetServiceNames()[index]; LOG(VERBOSE) << "Creating a Codec2 client to service \"" << name << "\""; if (c2_aidl::utils::IsEnabled()) { if (c2_aidl::utils::IsSelected()) { std::string instanceName = ::android::base::StringPrintf("%s/%s", AidlBase::descriptor, name.c_str()); if (AServiceManager_isDeclared(instanceName.c_str())) { Loading @@ -1559,9 +1559,10 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) { CHECK(transStatus.isOk()) << "Codec2 AIDL service \"" << name << "\"" "does not have IConfigurable."; return std::make_shared<Codec2Client>(baseStore, configurable, index); } else { LOG(ERROR) << "Codec2 AIDL service \"" << name << "\" is not declared"; } } } else { std::string instanceName = "android.hardware.media.c2/" + name; sp<HidlBase> baseStore = HidlBase::getService(name); CHECK(baseStore) << "Codec2 service \"" << name << "\"" Loading @@ -1574,6 +1575,8 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) { static_cast<sp<c2_hidl::IConfigurable>>(transResult); return std::make_shared<Codec2Client>(baseStore, configurable, index); } return nullptr; } c2_status_t Codec2Client::ForAllServices( const std::string &key, Loading