summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-06-10 16:55:38 -0700
committerElliott Hughes <enh@google.com>2014-06-11 14:45:27 -0700
commitf3e80dddd7376aa9deeb27de25e1d50030a2ad98 (patch)
treea3ebf2e96fa0bb9b0375281692adf48333bca468 /include
parentd3af4265dca4c8ebcead5376f1c73a5dafc34778 (diff)
downloadframeworks_av-f3e80dddd7376aa9deeb27de25e1d50030a2ad98.zip
frameworks_av-f3e80dddd7376aa9deeb27de25e1d50030a2ad98.tar.gz
frameworks_av-f3e80dddd7376aa9deeb27de25e1d50030a2ad98.tar.bz2
Offer a type-safe album art interface.
Bug: 15514223 Change-Id: Iddfc33a00e6cd3779ca09c01a55f62b151f6ec95
Diffstat (limited to 'include')
-rw-r--r--include/media/MediaMetadataRetrieverInterface.h1
-rw-r--r--include/media/mediascanner.h28
-rw-r--r--include/media/stagefright/StagefrightMediaScanner.h2
-rw-r--r--include/private/media/VideoFrame.h58
4 files changed, 28 insertions, 61 deletions
diff --git a/include/media/MediaMetadataRetrieverInterface.h b/include/media/MediaMetadataRetrieverInterface.h
index ecc3b65..cd5bf88 100644
--- a/include/media/MediaMetadataRetrieverInterface.h
+++ b/include/media/MediaMetadataRetrieverInterface.h
@@ -20,6 +20,7 @@
#include <utils/RefBase.h>
#include <media/mediametadataretriever.h>
+#include <media/mediascanner.h>
#include <private/media/VideoFrame.h>
namespace android {
diff --git a/include/media/mediascanner.h b/include/media/mediascanner.h
index a73403b..a7bb6c1 100644
--- a/include/media/mediascanner.h
+++ b/include/media/mediascanner.h
@@ -41,6 +41,31 @@ enum MediaScanResult {
MEDIA_SCAN_RESULT_ERROR,
};
+struct MediaAlbumArt {
+public:
+ static MediaAlbumArt *fromData(int32_t size, const void* data);
+
+ static void init(MediaAlbumArt* instance, int32_t size, const void* data);
+
+ MediaAlbumArt *clone();
+
+ const char *data() {
+ return &mData[0];
+ }
+
+ int32_t size() {
+ return mSize;
+ }
+
+private:
+ int32_t mSize;
+ char mData[0];
+
+ // You can't construct instances of this class directly because this is a
+ // variable-sized object passed through the binder.
+ MediaAlbumArt();
+} __packed;
+
struct MediaScanner {
MediaScanner();
virtual ~MediaScanner();
@@ -53,8 +78,7 @@ struct MediaScanner {
void setLocale(const char *locale);
- // extracts album art as a block of data
- virtual char *extractAlbumArt(int fd) = 0;
+ virtual MediaAlbumArt *extractAlbumArt(int fd) = 0;
protected:
const char *locale() const;
diff --git a/include/media/stagefright/StagefrightMediaScanner.h b/include/media/stagefright/StagefrightMediaScanner.h
index 6510a59..eb3accc 100644
--- a/include/media/stagefright/StagefrightMediaScanner.h
+++ b/include/media/stagefright/StagefrightMediaScanner.h
@@ -30,7 +30,7 @@ struct StagefrightMediaScanner : public MediaScanner {
const char *path, const char *mimeType,
MediaScannerClient &client);
- virtual char *extractAlbumArt(int fd);
+ virtual MediaAlbumArt *extractAlbumArt(int fd);
private:
StagefrightMediaScanner(const StagefrightMediaScanner &);
diff --git a/include/private/media/VideoFrame.h b/include/private/media/VideoFrame.h
index a211ed9..5dd425b 100644
--- a/include/private/media/VideoFrame.h
+++ b/include/private/media/VideoFrame.h
@@ -25,64 +25,6 @@
namespace android {
-// A simple buffer to hold binary data
-class MediaAlbumArt
-{
-public:
- MediaAlbumArt(): mSize(0), mData(0) {}
-
- explicit MediaAlbumArt(const char* url) {
- mSize = 0;
- mData = NULL;
- FILE *in = fopen(url, "r");
- if (!in) {
- return;
- }
- fseek(in, 0, SEEK_END);
- mSize = ftell(in); // Allocating buffer of size equals to the external file size.
- if (mSize == 0 || (mData = new uint8_t[mSize]) == NULL) {
- fclose(in);
- if (mSize != 0) {
- mSize = 0;
- }
- return;
- }
- rewind(in);
- if (fread(mData, 1, mSize, in) != mSize) { // Read failed.
- delete[] mData;
- mData = NULL;
- mSize = 0;
- return;
- }
- fclose(in);
- }
-
- MediaAlbumArt(const MediaAlbumArt& copy) {
- mSize = copy.mSize;
- mData = NULL; // initialize it first
- if (mSize > 0 && copy.mData != NULL) {
- mData = new uint8_t[copy.mSize];
- if (mData != NULL) {
- memcpy(mData, copy.mData, mSize);
- } else {
- mSize = 0;
- }
- }
- }
-
- ~MediaAlbumArt() {
- if (mData != 0) {
- delete[] mData;
- }
- }
-
- // Intentional public access modifier:
- // We have to know the internal structure in order to share it between
- // processes?
- uint32_t mSize; // Number of bytes in mData
- uint8_t* mData; // Actual binary data
-};
-
// Represents a color converted (RGB-based) video frame
// with bitmap pixels stored in FrameBuffer
class VideoFrame