diff options
author | Gloria Wang <gwang@google.com> | 2011-07-06 09:22:05 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-06 09:22:05 -0700 |
commit | 2da9eb7175e59a4ad8b9cec185f9cfdf8e075859 (patch) | |
tree | 40d9bb596b5ae3de67c9e311892e706dd934f9dc /media | |
parent | 4481c35567d8564b52f0af5aa7c010ff8c3ff4a8 (diff) | |
parent | 82428a862f325238cfb5646bbd65de3f1a11e7cc (diff) | |
download | frameworks_base-2da9eb7175e59a4ad8b9cec185f9cfdf8e075859.zip frameworks_base-2da9eb7175e59a4ad8b9cec185f9cfdf8e075859.tar.gz frameworks_base-2da9eb7175e59a4ad8b9cec185f9cfdf8e075859.tar.bz2 |
Merge "- 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"
Diffstat (limited to 'media')
-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 |
8 files changed, 40 insertions, 11 deletions
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: |