Fix for issue 3453519: do not allow editing of DRM protected contents

Change-Id: I19f56cbdaab0ddb3d1ab0aec8dcf625a3ff3ead2
diff --git a/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h b/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h
index b9d60d2..cd3a7f3 100755
--- a/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h
+++ b/libvideoeditor/vss/mcs/inc/M4MCS_ErrorCodes.h
@@ -119,6 +119,6 @@
 /* ----- OTHERS ERRORS ----- */
 #define M4MCS_ERR_OUTPUT_FILE_SIZE_TOO_SMALL                M4OSA_ERR_CREATE( M4_ERR, M4MCS, 0x50)
 #define M4MCS_ERR_NOMORE_SPACE                              M4OSA_ERR_CREATE(M4_ERR, M4MCS, 0x51)
-
+#define M4MCS_ERR_FILE_DRM_PROTECTED                        M4OSA_ERR_CREATE(M4_ERR, M4MCS, 0x52)
 #endif /* __M4MCS_ErrorCodes_H__ */
 
diff --git a/libvideoeditor/vss/mcs/src/M4MCS_API.c b/libvideoeditor/vss/mcs/src/M4MCS_API.c
index e5b9367..981662c 100644
--- a/libvideoeditor/vss/mcs/src/M4MCS_API.c
+++ b/libvideoeditor/vss/mcs/src/M4MCS_API.c
@@ -10690,13 +10690,18 @@
         M4OSA_UInt32 uiDummy, uiCoreId;
         M4OSA_TRACE1_1("M4MCS_open_normalMode(): m_pReader->m_pFctOpen returns 0x%x", err);
 
-        /**
-        * If the error is from the core reader, we change it to a public VXS error */
-        M4OSA_ERR_SPLIT(err, uiDummy, uiCoreId, uiDummy);
-        if (M4MP4_READER == uiCoreId)
-        {
-            M4OSA_TRACE1_0("M4MCS_open_normalMode(): returning M4MCS_ERR_INVALID_INPUT_FILE");
-            return M4MCS_ERR_INVALID_INPUT_FILE;
+        if (err == ((M4OSA_UInt32)M4ERR_UNSUPPORTED_MEDIA_TYPE)) {
+            M4OSA_TRACE1_0("M4MCS_open_normalMode(): returning M4MCS_ERR_FILE_DRM_PROTECTED");
+            return M4MCS_ERR_FILE_DRM_PROTECTED;
+        } else {
+            /**
+            * If the error is from the core reader, we change it to a public VXS error */
+            M4OSA_ERR_SPLIT(err, uiDummy, uiCoreId, uiDummy);
+            if (M4MP4_READER == uiCoreId)
+            {
+                M4OSA_TRACE1_0("M4MCS_open_normalMode(): returning M4MCS_ERR_INVALID_INPUT_FILE");
+                return M4MCS_ERR_INVALID_INPUT_FILE;
+            }
         }
         return err;
     }
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
index 92116f6..84c1ec5 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
@@ -467,6 +467,8 @@
 *                                       the media to open
 * @return   M4NO_ERROR                  there is no error
 * @return   M4ERR_PARAMETER             the context is NULL
+* @return   M4ERR_UNSUPPORTED_MEDIA_TYPE
+*                                       the media is DRM protected
 ************************************************************************
 */
 
@@ -499,6 +501,14 @@
         return M4ERR_PARAMETER;
     }
 
+    int32_t isDRMProtected = 0;
+    sp<MetaData> meta = pC->mExtractor->getMetaData();
+    meta->findInt32(kKeyIsDRM, &isDRMProtected);
+    if (isDRMProtected) {
+        LOGV("VideoEditorMp3Reader_open error - DRM Protected");
+        return M4ERR_UNSUPPORTED_MEDIA_TYPE;
+    }
+
     LOGV("VideoEditor3gpReader_open end ");
     return err;
 }
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp
index 322881a..c55b89b 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorMp3Reader.cpp
@@ -147,7 +147,8 @@
 
  * @return    M4NO_ERROR                     there is no error
  * @return    M4ERR_PARAMETER                the context is NULL
- * @return    M4ERR_BAD_CONTEXT            provided context is not a valid one
+ * @return    M4ERR_BAD_CONTEXT              provided context is not a valid one
+ * @return    M4ERR_UNSUPPORTED_MEDIA_TYPE   the media is DRM protected
  ******************************************************************************
 */
 M4OSA_ERR VideoEditorMp3Reader_open(M4OSA_Context context,
@@ -184,6 +185,14 @@
     }
     pReaderContext->mStreamNumber = 0;
 
+    int32_t isDRMProtected = 0;
+    sp<MetaData> meta = pReaderContext->mExtractor->getMetaData();
+    meta->findInt32(kKeyIsDRM, &isDRMProtected);
+    if (isDRMProtected) {
+        LOGV("VideoEditorMp3Reader_open error - DRM Protected");
+        return M4ERR_UNSUPPORTED_MEDIA_TYPE;
+    }
+
     LOGV("VideoEditorMp3Reader_open end");
     return err;
 }