diff options
author | Gloria Wang <gwang@google.com> | 2011-06-27 11:09:00 -0700 |
---|---|---|
committer | Gloria Wang <gwang@google.com> | 2011-07-01 16:52:28 -0700 |
commit | 82428a862f325238cfb5646bbd65de3f1a11e7cc (patch) | |
tree | 409603a51c7b948ccbdda01548f6d35afe767b91 | |
parent | d0c18aabac682709e47b9b4a2fdd19cbb6820b7c (diff) | |
download | frameworks_base-82428a862f325238cfb5646bbd65de3f1a11e7cc.zip frameworks_base-82428a862f325238cfb5646bbd65de3f1a11e7cc.tar.gz frameworks_base-82428a862f325238cfb5646bbd65de3f1a11e7cc.tar.bz2 |
- Retrieve is_drm in MediaMetadataRetriever.
- Add one more column in MediaStore to indicate whether a
media file is drm-protected.
- Remove old DRM code from Ringtone
- Use the new DRM code in RingtoneManager
Change-Id: I1311fd1c04841c2cd47df6c901589966cf55a692
-rw-r--r-- | core/java/android/provider/MediaStore.java | 14 | ||||
-rw-r--r-- | include/media/mediametadataretriever.h | 1 | ||||
-rw-r--r-- | include/media/stagefright/MediaExtractor.h | 9 | ||||
-rw-r--r-- | media/java/android/media/MediaMetadataRetriever.java | 5 | ||||
-rw-r--r-- | media/java/android/media/MediaScanner.java | 5 | ||||
-rw-r--r-- | media/java/android/media/RingtoneManager.java | 21 | ||||
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/MediaExtractor.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/StagefrightMediaScanner.cpp | 1 | ||||
-rw-r--r-- | media/libstagefright/StagefrightMetadataRetriever.cpp | 5 | ||||
-rw-r--r-- | media/libstagefright/include/MPEG4Extractor.h | 1 |
11 files changed, 60 insertions, 15 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index 3bc1348..f799af3 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -275,6 +275,14 @@ public final class MediaStore { * @hide */ public static final String MEDIA_SCANNER_NEW_OBJECT_ID = "media_scanner_new_object_id"; + + /** + * Non-zero if the media file is drm-protected + * <P>Type: INTEGER (boolean)</P> + * @hide + */ + public static final String IS_DRM = "is_drm"; + } /** @@ -1124,19 +1132,19 @@ public final class MediaStore { public static final String IS_PODCAST = "is_podcast"; /** - * Non-zero id the audio file may be a ringtone + * Non-zero if the audio file may be a ringtone * <P>Type: INTEGER (boolean)</P> */ public static final String IS_RINGTONE = "is_ringtone"; /** - * Non-zero id the audio file may be an alarm + * Non-zero if the audio file may be an alarm * <P>Type: INTEGER (boolean)</P> */ public static final String IS_ALARM = "is_alarm"; /** - * Non-zero id the audio file may be a notification sound + * Non-zero if the audio file may be a notification sound * <P>Type: INTEGER (boolean)</P> */ public static final String IS_NOTIFICATION = "is_notification"; diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h index 28f305d..9aa6700 100644 --- a/include/media/mediametadataretriever.h +++ b/include/media/mediametadataretriever.h @@ -53,6 +53,7 @@ enum { METADATA_KEY_VIDEO_HEIGHT = 19, METADATA_KEY_BITRATE = 20, METADATA_KEY_TIMED_TEXT_LANGUAGES = 21, + METADATA_KEY_IS_DRM = 22, // Add more here... }; diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h index a82106e..eb45237 100644 --- a/include/media/stagefright/MediaExtractor.h +++ b/include/media/stagefright/MediaExtractor.h @@ -56,7 +56,12 @@ public: virtual uint32_t flags() const; // for DRM - virtual void setDrmFlag(bool flag) {}; + virtual void setDrmFlag(bool flag) { + mIsDrm = flag; + }; + virtual bool getDrmFlag() { + return mIsDrm; + } virtual char* getDrmTrackInfo(size_t trackID, int *len) { return NULL; } @@ -66,6 +71,8 @@ protected: virtual ~MediaExtractor() {} private: + bool mIsDrm; + MediaExtractor(const MediaExtractor &); MediaExtractor &operator=(const MediaExtractor &); }; diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index 7ebedaf..10694c3 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -453,5 +453,10 @@ public class MediaMetadataRetriever * @hide */ public static final int METADATA_KEY_TIMED_TEXT_LANGUAGES = 21; + /** + * If this key exists the media is drm-protected. + * @hide + */ + public static final int METADATA_KEY_IS_DRM = 22; // Add more here... } diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java index 790eaa3..c55338a 100644 --- a/media/java/android/media/MediaScanner.java +++ b/media/java/android/media/MediaScanner.java @@ -422,6 +422,7 @@ public class MediaScanner private long mFileSize; private String mWriter; private int mCompilation; + private boolean mIsDrm; private boolean mNoMedia; // flag to suppress file from appearing in media tables public FileCacheEntry beginFile(String path, String mimeType, long lastModified, @@ -497,6 +498,7 @@ public class MediaScanner mLastModified = lastModified; mWriter = null; mCompilation = 0; + mIsDrm = false; return entry; } @@ -599,6 +601,8 @@ public class MediaScanner mWriter = value.trim(); } else if (name.equalsIgnoreCase("compilation")) { mCompilation = parseSubstring(value, 0, 0); + } else if (name.equalsIgnoreCase("isdrm")) { + mIsDrm = (parseSubstring(value, 0, 0) == 1); } } @@ -671,6 +675,7 @@ public class MediaScanner map.put(MediaStore.MediaColumns.DATE_MODIFIED, mLastModified); map.put(MediaStore.MediaColumns.SIZE, mFileSize); map.put(MediaStore.MediaColumns.MIME_TYPE, mMimeType); + map.put(MediaStore.MediaColumns.IS_DRM, mIsDrm); if (!mNoMedia) { if (MediaFile.isVideoFileType(mFileType)) { diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java index 8481410..9c0819f 100644 --- a/media/java/android/media/RingtoneManager.java +++ b/media/java/android/media/RingtoneManager.java @@ -487,7 +487,7 @@ public class RingtoneManager { private Cursor getInternalRingtones() { return query( MediaStore.Audio.Media.INTERNAL_CONTENT_URI, INTERNAL_COLUMNS, - constructBooleanTrueWhereClause(mFilterColumns), + constructBooleanTrueWhereClause(mFilterColumns, mIncludeDrm), null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER); } @@ -506,7 +506,7 @@ public class RingtoneManager { status.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) ? query( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MEDIA_COLUMNS, - constructBooleanTrueWhereClause(mFilterColumns), null, + constructBooleanTrueWhereClause(mFilterColumns, mIncludeDrm), null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER) : null; } @@ -536,11 +536,13 @@ public class RingtoneManager { * @param columns The columns that must be true. * @return The where clause. */ - private static String constructBooleanTrueWhereClause(List<String> columns) { + private static String constructBooleanTrueWhereClause(List<String> columns, boolean includeDrm) { if (columns == null) return null; StringBuilder sb = new StringBuilder(); + sb.append("("); + for (int i = columns.size() - 1; i >= 0; i--) { sb.append(columns.get(i)).append("=1 or "); } @@ -549,7 +551,18 @@ public class RingtoneManager { // Remove last ' or ' sb.setLength(sb.length() - 4); } - + + sb.append(")"); + + if (!includeDrm) { + // If not DRM files should be shown, the where clause + // will be something like "(is_notification=1) and is_drm=0" + sb.append(" and "); + sb.append(MediaStore.MediaColumns.IS_DRM); + sb.append("=0"); + } + + return sb.toString(); } diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 5582f92..73a05a5 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -387,10 +387,6 @@ status_t MPEG4Extractor::readMetaData() { return mInitCheck; } -void MPEG4Extractor::setDrmFlag(bool flag) { - mIsDrm = flag; -} - char* MPEG4Extractor::getDrmTrackInfo(size_t trackID, int *len) { if (mFirstSINF == NULL) { return NULL; diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cpp index af0131e..a8023df 100644 --- a/media/libstagefright/MediaExtractor.cpp +++ b/media/libstagefright/MediaExtractor.cpp @@ -116,8 +116,13 @@ sp<MediaExtractor> MediaExtractor::Create( } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) { ret = new AACExtractor(source); } - if (ret != NULL && isDrm) { - ret->getMetaData()->setInt32(kKeyIsDRM, 1); + + if (ret != NULL) { + if (isDrm) { + ret->setDrmFlag(true); + } else { + ret->setDrmFlag(false); + } } return ret; diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp index f82ff32..89faff7 100644 --- a/media/libstagefright/StagefrightMediaScanner.cpp +++ b/media/libstagefright/StagefrightMediaScanner.cpp @@ -158,6 +158,7 @@ status_t StagefrightMediaScanner::processFile( { "duration", METADATA_KEY_DURATION }, { "writer", METADATA_KEY_WRITER }, { "compilation", METADATA_KEY_COMPILATION }, + { "isdrm", METADATA_KEY_IS_DRM }, }; static const size_t kNumEntries = sizeof(kKeyMap) / sizeof(kKeyMap[0]); diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp index de3957b..778c0b5 100644 --- a/media/libstagefright/StagefrightMetadataRetriever.cpp +++ b/media/libstagefright/StagefrightMetadataRetriever.cpp @@ -530,6 +530,11 @@ void StagefrightMetadataRetriever::parseMetaData() { } } } + + // To check whether the media file is drm-protected + if (mExtractor->getDrmFlag()) { + mMetaData.add(METADATA_KEY_IS_DRM, String8("1")); + } } } // namespace android diff --git a/media/libstagefright/include/MPEG4Extractor.h b/media/libstagefright/include/MPEG4Extractor.h index 3bd4c7e..eae62c6 100644 --- a/media/libstagefright/include/MPEG4Extractor.h +++ b/media/libstagefright/include/MPEG4Extractor.h @@ -40,7 +40,6 @@ public: virtual sp<MetaData> getMetaData(); // for DRM - virtual void setDrmFlag(bool flag); virtual char* getDrmTrackInfo(size_t trackID, int *len); protected: |