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#ifndef MEDIA_EXTRACTOR_FACTORY_H_ 18 19#define MEDIA_EXTRACTOR_FACTORY_H_ 20 21#include <stdio.h> 22 23#include <media/IMediaExtractor.h> 24#include <media/MediaExtractor.h> 25#include <utils/List.h> 26 27namespace android { 28 29class DataSource; 30struct ExtractorPlugin; 31 32class MediaExtractorFactory { 33public: 34 static sp<IMediaExtractor> Create( 35 const sp<DataSource> &source, const char *mime = NULL); 36 static sp<IMediaExtractor> CreateFromService( 37 const sp<DataSource> &source, const char *mime = NULL); 38 static void LoadPlugins(const ::std::string& apkPath); 39 static status_t dump(int fd, const Vector<String16>& args); 40 41private: 42 static Mutex gPluginMutex; 43 static std::shared_ptr<List<sp<ExtractorPlugin>>> gPlugins; 44 static bool gPluginsRegistered; 45 46 static void RegisterExtractorsInApk( 47 const char *apkPath, List<sp<ExtractorPlugin>> &pluginList); 48 static void RegisterExtractorsInSystem( 49 const char *libDirPath, List<sp<ExtractorPlugin>> &pluginList); 50 static void RegisterExtractor( 51 const sp<ExtractorPlugin> &plugin, List<sp<ExtractorPlugin>> &pluginList); 52 53 static MediaExtractor::CreatorFunc sniff(DataSourceBase *source, 54 float *confidence, void **meta, MediaExtractor::FreeMetaFunc *freeMeta, 55 sp<ExtractorPlugin> &plugin); 56 57 static void UpdateExtractors(const char *newUpdateApkPath); 58}; 59 60} // namespace android 61 62#endif // MEDIA_EXTRACTOR_FACTORY_H_ 63