diff options
-rw-r--r-- | include/media/stagefright/StagefrightMediaScanner.h (renamed from media/libmedia/StagefrightMediaScanner.h) | 4 | ||||
-rw-r--r-- | media/jni/Android.mk | 12 | ||||
-rw-r--r-- | media/jni/android_media_MediaScanner.cpp | 28 | ||||
-rw-r--r-- | media/libmedia/Android.mk | 5 | ||||
-rw-r--r-- | media/libmedia/StagefrightMediaScanner.cpp | 39 | ||||
-rw-r--r-- | media/libmediaplayerservice/Android.mk | 1 | ||||
-rw-r--r-- | media/libstagefright/Android.mk | 2 | ||||
-rw-r--r-- | media/libstagefright/StagefrightMediaScanner.cpp | 80 | ||||
-rw-r--r-- | media/libstagefright/StagefrightMetadataRetriever.cpp (renamed from media/libmediaplayerservice/StagefrightMetadataRetriever.cpp) | 2 | ||||
-rw-r--r-- | media/libstagefright/include/StagefrightMetadataRetriever.h (renamed from media/libmediaplayerservice/StagefrightMetadataRetriever.h) | 0 |
10 files changed, 119 insertions, 54 deletions
diff --git a/media/libmedia/StagefrightMediaScanner.h b/include/media/stagefright/StagefrightMediaScanner.h index 108acb4..af125dc 100644 --- a/media/libmedia/StagefrightMediaScanner.h +++ b/include/media/stagefright/StagefrightMediaScanner.h @@ -22,6 +22,8 @@ namespace android { +struct StagefrightMetadataRetriever; + struct StagefrightMediaScanner : public MediaScanner { StagefrightMediaScanner(); virtual ~StagefrightMediaScanner(); @@ -33,6 +35,8 @@ struct StagefrightMediaScanner : public MediaScanner { virtual char *extractAlbumArt(int fd); private: + sp<StagefrightMetadataRetriever> mRetriever; + StagefrightMediaScanner(const StagefrightMediaScanner &); StagefrightMediaScanner &operator=(const StagefrightMediaScanner &); }; diff --git a/media/jni/Android.mk b/media/jni/Android.mk index fdcf3d1..ca6230f 100644 --- a/media/jni/Android.mk +++ b/media/jni/Android.mk @@ -15,7 +15,8 @@ LOCAL_SHARED_LIBRARIES := \ libbinder \ libmedia \ libskia \ - libui + libui \ + libcutils ifneq ($(BUILD_WITHOUT_PV),true) LOCAL_SRC_FILES += \ @@ -28,6 +29,15 @@ else LOCAL_CFLAGS += -DNO_OPENCORE endif +ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true) + +LOCAL_CFLAGS += -DBUILD_WITH_FULL_STAGEFRIGHT=1 + +LOCAL_SHARED_LIBRARIES += \ + libstagefright + +endif + LOCAL_STATIC_LIBRARIES := LOCAL_C_INCLUDES += \ diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp index 144fba2..2ab2445 100644 --- a/media/jni/android_media_MediaScanner.cpp +++ b/media/jni/android_media_MediaScanner.cpp @@ -24,6 +24,7 @@ #include <limits.h> #include <unistd.h> #include <fcntl.h> +#include <cutils/properties.h> #include <utils/threads.h> #include "jni.h" @@ -32,8 +33,10 @@ #ifndef NO_OPENCORE #include "pvmediascanner.h" -#else -#include "StagefrightMediaScanner.h" +#endif + +#if BUILD_WITH_FULL_STAGEFRIGHT +#include <media/stagefright/StagefrightMediaScanner.h> #endif // ---------------------------------------------------------------------------- @@ -283,14 +286,25 @@ android_media_MediaScanner_native_init(JNIEnv *env) } } +static MediaScanner *createMediaScanner() { +#if BUILD_WITH_FULL_STAGEFRIGHT + char value[PROPERTY_VALUE_MAX]; + if (property_get("media.stagefright.enable-scan", value, NULL) + && (!strcmp(value, "1") || !strcasecmp(value, "true"))) { + return new StagefrightMediaScanner; + } +#endif +#ifndef NO_OPENCORE + return new PVMediaScanner(); +#endif + + return NULL; +} + static void android_media_MediaScanner_native_setup(JNIEnv *env, jobject thiz) { -#ifndef NO_OPENCORE - MediaScanner *mp = new PVMediaScanner(); -#else - MediaScanner *mp = new StagefrightMediaScanner(); -#endif + MediaScanner *mp = createMediaScanner(); if (mp == NULL) { jniThrowException(env, "java/lang/RuntimeException", "Out of memory"); diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk index 088ad6d..fc234ee 100644 --- a/media/libmedia/Android.mk +++ b/media/libmedia/Android.mk @@ -26,11 +26,6 @@ LOCAL_SRC_FILES:= \ MediaScannerClient.cpp \ autodetect.cpp -ifneq ($(BUILD_WITHOUT_PV),true) -else -LOCAL_SRC_FILES += StagefrightMediaScanner.cpp -endif - LOCAL_SHARED_LIBRARIES := \ libui libcutils libutils libbinder libsonivox libicuuc diff --git a/media/libmedia/StagefrightMediaScanner.cpp b/media/libmedia/StagefrightMediaScanner.cpp deleted file mode 100644 index 522ab5a..0000000 --- a/media/libmedia/StagefrightMediaScanner.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "StagefrightMediaScanner.h" - -namespace android { - -StagefrightMediaScanner::StagefrightMediaScanner() {} - -StagefrightMediaScanner::~StagefrightMediaScanner() {} - -status_t StagefrightMediaScanner::processFile( - const char *path, const char *mimeType, - MediaScannerClient &client) { - client.setLocale(locale()); - client.beginFile(); - client.endFile(); - - return OK; -} - -char *StagefrightMediaScanner::extractAlbumArt(int fd) { - return NULL; -} - -} // namespace android diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk index 5e59710..d51ab30 100644 --- a/media/libmediaplayerservice/Android.mk +++ b/media/libmediaplayerservice/Android.mk @@ -19,7 +19,6 @@ LOCAL_SRC_FILES:= \ ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true) LOCAL_SRC_FILES += \ - StagefrightMetadataRetriever.cpp \ StagefrightPlayer.cpp \ StagefrightRecorder.cpp diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index f7df69c..30b4506 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -31,6 +31,8 @@ LOCAL_SRC_FILES += \ MediaExtractor.cpp \ SampleTable.cpp \ ShoutcastSource.cpp \ + StagefrightMediaScanner.cpp \ + StagefrightMetadataRetriever.cpp \ TimeSource.cpp \ TimedEventQueue.cpp \ WAVExtractor.cpp \ diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp new file mode 100644 index 0000000..9b41929 --- /dev/null +++ b/media/libstagefright/StagefrightMediaScanner.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <media/stagefright/StagefrightMediaScanner.h> + +#include "include/StagefrightMetadataRetriever.h" + +namespace android { + +StagefrightMediaScanner::StagefrightMediaScanner() + : mRetriever(new StagefrightMetadataRetriever) { +} + +StagefrightMediaScanner::~StagefrightMediaScanner() {} + +status_t StagefrightMediaScanner::processFile( + const char *path, const char *mimeType, + MediaScannerClient &client) { + client.setLocale(locale()); + client.beginFile(); + + if (mRetriever->setDataSource(path) == OK + && mRetriever->setMode( + METADATA_MODE_METADATA_RETRIEVAL_ONLY) == OK) { + struct KeyMap { + const char *tag; + int key; + }; + static const KeyMap kKeyMap[] = { + { "tracknumber", METADATA_KEY_CD_TRACK_NUMBER }, + { "album", METADATA_KEY_ALBUM }, + { "artist", METADATA_KEY_ARTIST }, + { "composer", METADATA_KEY_COMPOSER }, + { "genre", METADATA_KEY_GENRE }, + { "title", METADATA_KEY_TITLE }, + { "year", METADATA_KEY_YEAR }, + { "duration", METADATA_KEY_DURATION }, + { "writer", METADATA_KEY_WRITER }, + }; + static const size_t kNumEntries = sizeof(kKeyMap) / sizeof(kKeyMap[0]); + + for (size_t i = 0; i < kNumEntries; ++i) { + const char *value; + if ((value = mRetriever->extractMetadata(kKeyMap[i].key)) != NULL) { + client.addStringTag(kKeyMap[i].tag, value); + } + } + } + + client.endFile(); + + return OK; +} + +char *StagefrightMediaScanner::extractAlbumArt(int fd) { + if (mRetriever->setDataSource(fd, 0, 0) == OK + && mRetriever->setMode( + METADATA_MODE_FRAME_CAPTURE_ONLY) == OK) { + MediaAlbumArt *art = mRetriever->extractAlbumArt(); + + // TODO: figure out what format the result should be in. + } + + return NULL; +} + +} // namespace android diff --git a/media/libmediaplayerservice/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp index 42c1877..128e776 100644 --- a/media/libmediaplayerservice/StagefrightMetadataRetriever.cpp +++ b/media/libstagefright/StagefrightMetadataRetriever.cpp @@ -19,7 +19,7 @@ #define LOG_TAG "StagefrightMetadataRetriever" #include <utils/Log.h> -#include "StagefrightMetadataRetriever.h" +#include "include/StagefrightMetadataRetriever.h" #include <media/stagefright/CachingDataSource.h> #include <media/stagefright/ColorConverter.h> diff --git a/media/libmediaplayerservice/StagefrightMetadataRetriever.h b/media/libstagefright/include/StagefrightMetadataRetriever.h index 16127d7..16127d7 100644 --- a/media/libmediaplayerservice/StagefrightMetadataRetriever.h +++ b/media/libstagefright/include/StagefrightMetadataRetriever.h |