Merge "Reorganize some of the stagefright implementation related to metadata."

This commit is contained in:
Andreas Huber
2010-01-08 14:09:01 -08:00
committed by Android (Google) Code Review
10 changed files with 119 additions and 54 deletions

View File

@@ -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 &);
};

View File

@@ -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 += \

View File

@@ -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");

View File

@@ -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

View File

@@ -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

View File

@@ -19,7 +19,6 @@ LOCAL_SRC_FILES:= \
ifeq ($(BUILD_WITH_FULL_STAGEFRIGHT),true)
LOCAL_SRC_FILES += \
StagefrightMetadataRetriever.cpp \
StagefrightPlayer.cpp \
StagefrightRecorder.cpp

View File

@@ -31,6 +31,8 @@ LOCAL_SRC_FILES += \
MediaExtractor.cpp \
SampleTable.cpp \
ShoutcastSource.cpp \
StagefrightMediaScanner.cpp \
StagefrightMetadataRetriever.cpp \
TimeSource.cpp \
TimedEventQueue.cpp \
WAVExtractor.cpp \

View File

@@ -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

View File

@@ -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>