Instead of instantiating StagefrightMetadataRetriever directly, instantiate a MediaMetadataRetriever which will do-the-right-thing(tm) even for .wma/.wmv/.asf files.
Change-Id: Ibda4b5268514934f14a3d49a564902bc670f4384
related-to-bug: 2074137
diff --git a/include/media/stagefright/StagefrightMediaScanner.h b/include/media/stagefright/StagefrightMediaScanner.h
index af125dc..4437eee 100644
--- a/include/media/stagefright/StagefrightMediaScanner.h
+++ b/include/media/stagefright/StagefrightMediaScanner.h
@@ -22,7 +22,7 @@
namespace android {
-struct StagefrightMetadataRetriever;
+struct MediaMetadataRetriever;
struct StagefrightMediaScanner : public MediaScanner {
StagefrightMediaScanner();
@@ -35,7 +35,7 @@
virtual char *extractAlbumArt(int fd);
private:
- sp<StagefrightMetadataRetriever> mRetriever;
+ sp<MediaMetadataRetriever> mRetriever;
StagefrightMediaScanner(const StagefrightMediaScanner &);
StagefrightMediaScanner &operator=(const StagefrightMediaScanner &);
diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp
index b1eca2b..34fb2bc 100644
--- a/media/libstagefright/StagefrightMediaScanner.cpp
+++ b/media/libstagefright/StagefrightMediaScanner.cpp
@@ -20,7 +20,8 @@
#include <media/stagefright/StagefrightMediaScanner.h>
-#include "include/StagefrightMetadataRetriever.h"
+#include <media/mediametadataretriever.h>
+#include <private/media/VideoFrame.h>
// Sonivox includes
#include <libsonivox/eas.h>
@@ -32,7 +33,7 @@
namespace android {
StagefrightMediaScanner::StagefrightMediaScanner()
- : mRetriever(new StagefrightMetadataRetriever) {
+ : mRetriever(new MediaMetadataRetriever) {
}
StagefrightMediaScanner::~StagefrightMediaScanner() {}
@@ -146,6 +147,8 @@
status_t StagefrightMediaScanner::processFile(
const char *path, const char *mimeType,
MediaScannerClient &client) {
+ LOGV("processFile '%s'.", path);
+
client.setLocale(locale());
client.beginFile();
@@ -218,6 +221,8 @@
}
char *StagefrightMediaScanner::extractAlbumArt(int fd) {
+ LOGV("extractAlbumArt %d", fd);
+
off_t size = lseek(fd, 0, SEEK_END);
if (size < 0) {
return NULL;
@@ -227,15 +232,14 @@
if (mRetriever->setDataSource(fd, 0, size) == OK
&& mRetriever->setMode(
METADATA_MODE_FRAME_CAPTURE_ONLY) == OK) {
- MediaAlbumArt *art = mRetriever->extractAlbumArt();
+ sp<IMemory> mem = mRetriever->extractAlbumArt();
- if (art != NULL) {
+ if (mem != NULL) {
+ MediaAlbumArt *art = static_cast<MediaAlbumArt *>(mem->pointer());
+
char *data = (char *)malloc(art->mSize + 4);
*(int32_t *)data = art->mSize;
- memcpy(&data[4], art->mData, art->mSize);
-
- delete art;
- art = NULL;
+ memcpy(&data[4], &art[1], art->mSize);
return data;
}