Loading media/libstagefright/MediaExtractorFactory.cpp +47 −5 Original line number Original line Diff line number Diff line Loading @@ -38,8 +38,6 @@ namespace android { namespace android { static const char *kSystemApkPath = "/system/app/MediaComponents/MediaComponents.apk"; // static // static sp<IMediaExtractor> MediaExtractorFactory::Create( sp<IMediaExtractor> MediaExtractorFactory::Create( const sp<DataSource> &source, const char *mime) { const sp<DataSource> &source, const char *mime) { Loading Loading @@ -246,7 +244,7 @@ void MediaExtractorFactory::RegisterExtractor(const sp<ExtractorPlugin> &plugin, } } //static //static void MediaExtractorFactory::RegisterExtractors( void MediaExtractorFactory::RegisterExtractorsInApk( const char *apkPath, List<sp<ExtractorPlugin>> &pluginList) { const char *apkPath, List<sp<ExtractorPlugin>> &pluginList) { ALOGV("search for plugins at %s", apkPath); ALOGV("search for plugins at %s", apkPath); ZipArchiveHandle zipHandle; ZipArchiveHandle zipHandle; Loading @@ -264,6 +262,8 @@ void MediaExtractorFactory::RegisterExtractors( while (Next(cookie, &entry, &name) == 0) { while (Next(cookie, &entry, &name) == 0) { String8 libPath = String8(apkPath) + "!/" + String8 libPath = String8(apkPath) + "!/" + String8(reinterpret_cast<const char*>(name.name), name.name_length); String8(reinterpret_cast<const char*>(name.name), name.name_length); // TODO: Open with a linker namespace so that it can be linked with sub-libraries // within the apk instead of system libraries already loaded. void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL); void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL); if (libHandle) { if (libHandle) { MediaExtractor::GetExtractorDef getDef = MediaExtractor::GetExtractorDef getDef = Loading @@ -290,6 +290,38 @@ void MediaExtractorFactory::RegisterExtractors( } } } } //static void MediaExtractorFactory::RegisterExtractorsInSystem( const char *libDirPath, List<sp<ExtractorPlugin>> &pluginList) { ALOGV("search for plugins at %s", libDirPath); DIR *libDir = opendir(libDirPath); if (libDir) { struct dirent* libEntry; while ((libEntry = readdir(libDir))) { String8 libPath = String8(libDirPath) + "/" + libEntry->d_name; void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL); if (libHandle) { MediaExtractor::GetExtractorDef getDef = (MediaExtractor::GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF"); if (getDef) { ALOGV("registering sniffer for %s", libPath.string()); RegisterExtractor( new ExtractorPlugin(getDef(), libHandle, libPath), pluginList); } else { ALOGW("%s does not contain sniffer", libPath.string()); dlclose(libHandle); } } else { ALOGW("couldn't dlopen(%s) %s", libPath.string(), strerror(errno)); } } closedir(libDir); } else { ALOGE("couldn't opendir(%s)", libDirPath); } } // static // static void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) { void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) { Mutex::Autolock autoLock(gPluginMutex); Mutex::Autolock autoLock(gPluginMutex); Loading @@ -302,10 +334,20 @@ void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) { std::shared_ptr<List<sp<ExtractorPlugin>>> newList(new List<sp<ExtractorPlugin>>()); std::shared_ptr<List<sp<ExtractorPlugin>>> newList(new List<sp<ExtractorPlugin>>()); RegisterExtractors(kSystemApkPath, *newList); RegisterExtractorsInSystem("/system/lib" #ifdef __LP64__ "64" #endif "/extractors", *newList); RegisterExtractorsInSystem("/vendor/lib" #ifdef __LP64__ "64" #endif "/extractors", *newList); if (newUpdateApkPath != nullptr) { if (newUpdateApkPath != nullptr) { RegisterExtractors(newUpdateApkPath, *newList); RegisterExtractorsInApk(newUpdateApkPath, *newList); } } gPlugins = newList; gPlugins = newList; Loading media/libstagefright/include/media/stagefright/MediaExtractorFactory.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -48,8 +48,10 @@ private: static std::shared_ptr<List<sp<ExtractorPlugin>>> gPlugins; static std::shared_ptr<List<sp<ExtractorPlugin>>> gPlugins; static bool gPluginsRegistered; static bool gPluginsRegistered; static void RegisterExtractors( static void RegisterExtractorsInApk( const char *apkPath, List<sp<ExtractorPlugin>> &pluginList); const char *apkPath, List<sp<ExtractorPlugin>> &pluginList); static void RegisterExtractorsInSystem( const char *libDirPath, List<sp<ExtractorPlugin>> &pluginList); static void RegisterExtractor( static void RegisterExtractor( const sp<ExtractorPlugin> &plugin, List<sp<ExtractorPlugin>> &pluginList); const sp<ExtractorPlugin> &plugin, List<sp<ExtractorPlugin>> &pluginList); Loading packages/MediaComponents/Android.mk +12 −15 Original line number Original line Diff line number Diff line Loading @@ -34,22 +34,19 @@ LOCAL_MULTILIB := first LOCAL_JAVA_LIBRARIES += android-support-annotations LOCAL_JAVA_LIBRARIES += android-support-annotations # Embed native libraries in package, rather than installing to /system/lib*. # TODO: Find a right way to include libs in the apk. b/72066556 LOCAL_MODULE_TAGS := samples # To embed native libraries in package, uncomment the lines below. # To embed native libraries in package, uncomment the lines below. LOCAL_JNI_SHARED_LIBRARIES := \ #LOCAL_MODULE_TAGS := samples libaacextractor \ #LOCAL_JNI_SHARED_LIBRARIES := \ libamrextractor \ # libaacextractor \ libflacextractor \ # libamrextractor \ libmidiextractor \ # libflacextractor \ libmkvextractor \ # libmidiextractor \ libmp3extractor \ # libmkvextractor \ libmp4extractor \ # libmp3extractor \ libmpeg2extractor \ # libmp4extractor \ liboggextractor \ # libmpeg2extractor \ libwavextractor \ # liboggextractor \ # libwavextractor \ # TODO: Remove dependency with other support libraries. # TODO: Remove dependency with other support libraries. LOCAL_STATIC_ANDROID_LIBRARIES += \ LOCAL_STATIC_ANDROID_LIBRARIES += \ Loading services/mediaextractor/Android.mk +10 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,16 @@ LOCAL_REQUIRED_MODULES_x86 := mediaextractor.policy # extractor libraries # extractor libraries LOCAL_REQUIRED_MODULES := \ LOCAL_REQUIRED_MODULES := \ libaacextractor \ libamrextractor \ libflacextractor \ libmidiextractor \ libmkvextractor \ libmp3extractor \ libmp4extractor \ libmpeg2extractor \ liboggextractor \ libwavextractor \ MediaComponents \ MediaComponents \ LOCAL_SRC_FILES := main_extractorservice.cpp LOCAL_SRC_FILES := main_extractorservice.cpp Loading Loading
media/libstagefright/MediaExtractorFactory.cpp +47 −5 Original line number Original line Diff line number Diff line Loading @@ -38,8 +38,6 @@ namespace android { namespace android { static const char *kSystemApkPath = "/system/app/MediaComponents/MediaComponents.apk"; // static // static sp<IMediaExtractor> MediaExtractorFactory::Create( sp<IMediaExtractor> MediaExtractorFactory::Create( const sp<DataSource> &source, const char *mime) { const sp<DataSource> &source, const char *mime) { Loading Loading @@ -246,7 +244,7 @@ void MediaExtractorFactory::RegisterExtractor(const sp<ExtractorPlugin> &plugin, } } //static //static void MediaExtractorFactory::RegisterExtractors( void MediaExtractorFactory::RegisterExtractorsInApk( const char *apkPath, List<sp<ExtractorPlugin>> &pluginList) { const char *apkPath, List<sp<ExtractorPlugin>> &pluginList) { ALOGV("search for plugins at %s", apkPath); ALOGV("search for plugins at %s", apkPath); ZipArchiveHandle zipHandle; ZipArchiveHandle zipHandle; Loading @@ -264,6 +262,8 @@ void MediaExtractorFactory::RegisterExtractors( while (Next(cookie, &entry, &name) == 0) { while (Next(cookie, &entry, &name) == 0) { String8 libPath = String8(apkPath) + "!/" + String8 libPath = String8(apkPath) + "!/" + String8(reinterpret_cast<const char*>(name.name), name.name_length); String8(reinterpret_cast<const char*>(name.name), name.name_length); // TODO: Open with a linker namespace so that it can be linked with sub-libraries // within the apk instead of system libraries already loaded. void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL); void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL); if (libHandle) { if (libHandle) { MediaExtractor::GetExtractorDef getDef = MediaExtractor::GetExtractorDef getDef = Loading @@ -290,6 +290,38 @@ void MediaExtractorFactory::RegisterExtractors( } } } } //static void MediaExtractorFactory::RegisterExtractorsInSystem( const char *libDirPath, List<sp<ExtractorPlugin>> &pluginList) { ALOGV("search for plugins at %s", libDirPath); DIR *libDir = opendir(libDirPath); if (libDir) { struct dirent* libEntry; while ((libEntry = readdir(libDir))) { String8 libPath = String8(libDirPath) + "/" + libEntry->d_name; void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL); if (libHandle) { MediaExtractor::GetExtractorDef getDef = (MediaExtractor::GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF"); if (getDef) { ALOGV("registering sniffer for %s", libPath.string()); RegisterExtractor( new ExtractorPlugin(getDef(), libHandle, libPath), pluginList); } else { ALOGW("%s does not contain sniffer", libPath.string()); dlclose(libHandle); } } else { ALOGW("couldn't dlopen(%s) %s", libPath.string(), strerror(errno)); } } closedir(libDir); } else { ALOGE("couldn't opendir(%s)", libDirPath); } } // static // static void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) { void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) { Mutex::Autolock autoLock(gPluginMutex); Mutex::Autolock autoLock(gPluginMutex); Loading @@ -302,10 +334,20 @@ void MediaExtractorFactory::UpdateExtractors(const char *newUpdateApkPath) { std::shared_ptr<List<sp<ExtractorPlugin>>> newList(new List<sp<ExtractorPlugin>>()); std::shared_ptr<List<sp<ExtractorPlugin>>> newList(new List<sp<ExtractorPlugin>>()); RegisterExtractors(kSystemApkPath, *newList); RegisterExtractorsInSystem("/system/lib" #ifdef __LP64__ "64" #endif "/extractors", *newList); RegisterExtractorsInSystem("/vendor/lib" #ifdef __LP64__ "64" #endif "/extractors", *newList); if (newUpdateApkPath != nullptr) { if (newUpdateApkPath != nullptr) { RegisterExtractors(newUpdateApkPath, *newList); RegisterExtractorsInApk(newUpdateApkPath, *newList); } } gPlugins = newList; gPlugins = newList; Loading
media/libstagefright/include/media/stagefright/MediaExtractorFactory.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -48,8 +48,10 @@ private: static std::shared_ptr<List<sp<ExtractorPlugin>>> gPlugins; static std::shared_ptr<List<sp<ExtractorPlugin>>> gPlugins; static bool gPluginsRegistered; static bool gPluginsRegistered; static void RegisterExtractors( static void RegisterExtractorsInApk( const char *apkPath, List<sp<ExtractorPlugin>> &pluginList); const char *apkPath, List<sp<ExtractorPlugin>> &pluginList); static void RegisterExtractorsInSystem( const char *libDirPath, List<sp<ExtractorPlugin>> &pluginList); static void RegisterExtractor( static void RegisterExtractor( const sp<ExtractorPlugin> &plugin, List<sp<ExtractorPlugin>> &pluginList); const sp<ExtractorPlugin> &plugin, List<sp<ExtractorPlugin>> &pluginList); Loading
packages/MediaComponents/Android.mk +12 −15 Original line number Original line Diff line number Diff line Loading @@ -34,22 +34,19 @@ LOCAL_MULTILIB := first LOCAL_JAVA_LIBRARIES += android-support-annotations LOCAL_JAVA_LIBRARIES += android-support-annotations # Embed native libraries in package, rather than installing to /system/lib*. # TODO: Find a right way to include libs in the apk. b/72066556 LOCAL_MODULE_TAGS := samples # To embed native libraries in package, uncomment the lines below. # To embed native libraries in package, uncomment the lines below. LOCAL_JNI_SHARED_LIBRARIES := \ #LOCAL_MODULE_TAGS := samples libaacextractor \ #LOCAL_JNI_SHARED_LIBRARIES := \ libamrextractor \ # libaacextractor \ libflacextractor \ # libamrextractor \ libmidiextractor \ # libflacextractor \ libmkvextractor \ # libmidiextractor \ libmp3extractor \ # libmkvextractor \ libmp4extractor \ # libmp3extractor \ libmpeg2extractor \ # libmp4extractor \ liboggextractor \ # libmpeg2extractor \ libwavextractor \ # liboggextractor \ # libwavextractor \ # TODO: Remove dependency with other support libraries. # TODO: Remove dependency with other support libraries. LOCAL_STATIC_ANDROID_LIBRARIES += \ LOCAL_STATIC_ANDROID_LIBRARIES += \ Loading
services/mediaextractor/Android.mk +10 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,16 @@ LOCAL_REQUIRED_MODULES_x86 := mediaextractor.policy # extractor libraries # extractor libraries LOCAL_REQUIRED_MODULES := \ LOCAL_REQUIRED_MODULES := \ libaacextractor \ libamrextractor \ libflacextractor \ libmidiextractor \ libmkvextractor \ libmp3extractor \ libmp4extractor \ libmpeg2extractor \ liboggextractor \ libwavextractor \ MediaComponents \ MediaComponents \ LOCAL_SRC_FILES := main_extractorservice.cpp LOCAL_SRC_FILES := main_extractorservice.cpp Loading