Remove unused code path in MediaExtractor(Factory|Service)
Test: build, boot, dumpsys media.extractor
Bug: 125134086
Change-Id: I723570315285d7c2caadffd71cd2d15efde11819
diff --git a/media/libstagefright/MediaExtractorFactory.cpp b/media/libstagefright/MediaExtractorFactory.cpp
index f6e112e..a309ee4 100644
--- a/media/libstagefright/MediaExtractorFactory.cpp
+++ b/media/libstagefright/MediaExtractorFactory.cpp
@@ -23,8 +23,6 @@
#include <binder/PermissionCache.h>
#include <binder/IServiceManager.h>
#include <media/DataSource.h>
-#include <media/MediaAnalyticsItem.h>
-#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/InterfaceUtils.h>
#include <media/stagefright/MediaExtractor.h>
#include <media/stagefright/MediaExtractorFactory.h>
@@ -34,7 +32,6 @@
#include <private/android_filesystem_config.h>
#include <cutils/properties.h>
#include <utils/String8.h>
-#include <ziparchive/zip_archive.h>
#include <dirent.h>
#include <dlfcn.h>
@@ -130,13 +127,6 @@
std::shared_ptr<std::list<sp<ExtractorPlugin>>> MediaExtractorFactory::gPlugins;
bool MediaExtractorFactory::gPluginsRegistered = false;
bool MediaExtractorFactory::gIgnoreVersion = false;
-std::string MediaExtractorFactory::gLinkedLibraries;
-
-// static
-void MediaExtractorFactory::SetLinkedLibraries(const std::string& linkedLibraries) {
- Mutex::Autolock autoLock(gPluginMutex);
- gLinkedLibraries = linkedLibraries;
-}
// static
void *MediaExtractorFactory::sniff(
@@ -235,9 +225,11 @@
}
//static
-void MediaExtractorFactory::RegisterExtractorsInSystem(
- const char *libDirPath, std::list<sp<ExtractorPlugin>> &pluginList) {
+void MediaExtractorFactory::RegisterExtractors(
+ const char *libDirPath, const android_dlextinfo* dlextinfo,
+ std::list<sp<ExtractorPlugin>> &pluginList) {
ALOGV("search for plugins at %s", libDirPath);
+
DIR *libDir = opendir(libDirPath);
if (libDir) {
struct dirent* libEntry;
@@ -246,68 +238,12 @@
continue;
}
String8 libPath = String8(libDirPath) + "/" + libEntry->d_name;
- void *libHandle = dlopen(libPath.string(), RTLD_NOW | RTLD_LOCAL);
- if (libHandle) {
- GetExtractorDef getDef =
- (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
-void MediaExtractorFactory::RegisterExtractorsInApex(
- const char *libDirPath, std::list<sp<ExtractorPlugin>> &pluginList) {
- ALOGV("search for plugins at %s", libDirPath);
- ALOGV("linked libs %s", gLinkedLibraries.c_str());
-
- std::string libDirPathEx = libDirPath;
- libDirPathEx += "/extractors";
- android_namespace_t *mediaNs = android_get_exported_namespace("media");
- if (mediaNs == NULL) {
- ALOGE("couldn't find media namespace.");
- return;
- }
- const android_dlextinfo dlextinfo = {
- .flags = ANDROID_DLEXT_USE_NAMESPACE,
- .library_namespace = mediaNs,
- };
-
- // try extractors subfolder first
- DIR *libDir = opendir(libDirPathEx.c_str());
-
- if (libDir) {
- libDirPath = libDirPathEx.c_str();
- } else {
- libDir = opendir(libDirPath);
- }
- if (libDir) {
- struct dirent* libEntry;
- while ((libEntry = readdir(libDir))) {
- if (libEntry->d_name[0] == '.') {
- continue;
- }
- String8 libPath = String8(libDirPath) + "/" + libEntry->d_name;
if (!libPath.contains("extractor.so")) {
continue;
}
void *libHandle = android_dlopen_ext(
libPath.string(),
- RTLD_NOW | RTLD_LOCAL, &dlextinfo);
+ RTLD_NOW | RTLD_LOCAL, dlextinfo);
if (libHandle) {
GetExtractorDef getDef =
(GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF");
@@ -347,17 +283,27 @@
std::shared_ptr<std::list<sp<ExtractorPlugin>>> newList(new std::list<sp<ExtractorPlugin>>());
- RegisterExtractorsInApex("/apex/com.android.media/lib"
+ android_namespace_t *mediaNs = android_get_exported_namespace("media");
+ if (mediaNs != NULL) {
+ const android_dlextinfo dlextinfo = {
+ .flags = ANDROID_DLEXT_USE_NAMESPACE,
+ .library_namespace = mediaNs,
+ };
+ RegisterExtractors("/apex/com.android.media/lib"
#ifdef __LP64__
- "64"
+ "64"
#endif
- , *newList);
+ "/extractors", &dlextinfo, *newList);
- RegisterExtractorsInSystem("/system/lib"
+ } else {
+ ALOGE("couldn't find media namespace.");
+ }
+
+ RegisterExtractors("/system/lib"
#ifdef __LP64__
"64"
#endif
- "/extractors", *newList);
+ "/extractors", NULL, *newList);
newList->sort(compareFunc);
gPlugins = newList;
diff --git a/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h b/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h
index 4358aac..ea87948 100644
--- a/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h
+++ b/media/libstagefright/include/media/stagefright/MediaExtractorFactory.h
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <unordered_set>
+#include <android/dlext.h>
#include <media/IMediaExtractor.h>
namespace android {
@@ -36,19 +37,16 @@
const sp<DataSource> &source, const char *mime = NULL);
static status_t dump(int fd, const Vector<String16>& args);
static std::unordered_set<std::string> getSupportedTypes();
- static void SetLinkedLibraries(const std::string& linkedLibraries);
private:
static Mutex gPluginMutex;
static std::shared_ptr<std::list<sp<ExtractorPlugin>>> gPlugins;
static bool gPluginsRegistered;
static bool gIgnoreVersion;
- static std::string gLinkedLibraries;
- static void RegisterExtractorsInSystem(
- const char *libDirPath, std::list<sp<ExtractorPlugin>> &pluginList);
- static void RegisterExtractorsInApex(
- const char *libDirPath, std::list<sp<ExtractorPlugin>> &pluginList);
+ static void RegisterExtractors(
+ const char *libDirPath, const android_dlextinfo* dlextinfo,
+ std::list<sp<ExtractorPlugin>> &pluginList);
static void RegisterExtractor(
const sp<ExtractorPlugin> &plugin, std::list<sp<ExtractorPlugin>> &pluginList);
diff --git a/services/mediaextractor/Android.mk b/services/mediaextractor/Android.mk
index 7654982..65fcf40 100644
--- a/services/mediaextractor/Android.mk
+++ b/services/mediaextractor/Android.mk
@@ -8,24 +8,6 @@
LOCAL_SHARED_LIBRARIES := libmedia libstagefright libbinder libutils liblog
LOCAL_MODULE:= libmediaextractorservice
-
-sanitizer_runtime_libraries := $(call normalize-path-list,$(addsuffix .so,\
- $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
- $(UBSAN_RUNTIME_LIBRARY) \
- $(TSAN_RUNTIME_LIBRARY)))
-
-# $(info Sanitizer: $(sanitizer_runtime_libraries))
-
-ndk_libraries := $(call normalize-path-list,$(addprefix lib,$(addsuffix .so,\
- $(NDK_PREBUILT_SHARED_LIBRARIES))))
-
-# $(info NDK: $(ndk_libraries))
-
-LOCAL_CFLAGS += -DLINKED_LIBRARIES='"$(sanitizer_runtime_libraries):$(ndk_libraries)"'
-
-sanitizer_runtime_libraries :=
-ndk_libraries :=
-
include $(BUILD_SHARED_LIBRARY)
diff --git a/services/mediaextractor/MediaExtractorService.cpp b/services/mediaextractor/MediaExtractorService.cpp
index 0665930..de5c3e4 100644
--- a/services/mediaextractor/MediaExtractorService.cpp
+++ b/services/mediaextractor/MediaExtractorService.cpp
@@ -30,9 +30,7 @@
namespace android {
MediaExtractorService::MediaExtractorService()
- : BnMediaExtractorService() {
- MediaExtractorFactory::SetLinkedLibraries(std::string(LINKED_LIBRARIES));
-}
+ : BnMediaExtractorService() { }
sp<IMediaExtractor> MediaExtractorService::makeExtractor(
const sp<IDataSource> &remoteSource, const char *mime) {