Bug 1308076 - Move ClearKeyCencParser to PsshParser library. r?glandium draft
authorChris Pearce <cpearce@mozilla.com>
Thu, 06 Oct 2016 20:23:38 +1300
changeset 423459 084e489abc2d52911494039f98d58fa6414a72f8
parent 423092 fed2a26df89a5c2a600a6e6d1ab63ab86706fc45
child 423460 4dc7cf2be0092d3de076b2f8becc942de6e363dd
push id31912
push userbmo:cpearce@mozilla.com
push dateTue, 11 Oct 2016 08:02:34 +0000
reviewersglandium
bugs1308076
milestone52.0a1
Bug 1308076 - Move ClearKeyCencParser to PsshParser library. r?glandium To validate the PSSH init data passed to EME, I'd like to reuse the same PSSH parser that the ClearKey CDM shared library uses. So move the code out of gmp-clearkey and into its own library, so we can link it statically into code that needs to use it. MozReview-Commit-ID: 7xSUSmCueJz
config/external/moz.build
media/gmp-clearkey/0.1/ClearKeyCencParser.cpp
media/gmp-clearkey/0.1/ClearKeyCencParser.h
media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
media/gmp-clearkey/0.1/ClearKeySession.cpp
media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp
media/gmp-clearkey/0.1/gtest/moz.build
media/gmp-clearkey/0.1/moz.build
media/psshparser/PsshParser.cpp
media/psshparser/PsshParser.h
media/psshparser/moz.build
toolkit/library/moz.build
--- a/config/external/moz.build
+++ b/config/external/moz.build
@@ -53,11 +53,12 @@ external_dirs += [
     'media/libcubeb',
     'media/libnestegg',
     'media/libogg',
     'media/libopus',
     'media/libtheora',
     'media/libspeex_resampler',
     'media/libstagefright',
     'media/libsoundtouch',
+    'media/psshparser'
 ]
 
 DIRS += ['../../' + i for i in external_dirs]
--- a/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeyDecryptionManager.cpp
@@ -13,16 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include <string.h>
 #include <vector>
 
 #include "ClearKeyDecryptionManager.h"
+#include "psshparser/PsshParser.h"
 #include "gmp-api/gmp-decryption.h"
 #include <assert.h>
 
 class ClearKeyDecryptor : public RefCounted
 {
 public:
   ClearKeyDecryptor();
 
--- a/media/gmp-clearkey/0.1/ClearKeySession.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySession.cpp
@@ -14,17 +14,17 @@
  * limitations under the License.
  */
 
 #include "BigEndian.h"
 #include "ClearKeyDecryptionManager.h"
 #include "ClearKeySession.h"
 #include "ClearKeyUtils.h"
 #include "ClearKeyStorage.h"
-#include "ClearKeyCencParser.h"
+#include "psshparser/PsshParser.h"
 #include "gmp-task-utils.h"
 #include "gmp-api/gmp-decryption.h"
 #include <assert.h>
 #include <string.h>
 
 using namespace mozilla;
 
 ClearKeySession::ClearKeySession(const std::string& aSessionId,
--- a/media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp
+++ b/media/gmp-clearkey/0.1/gtest/TestClearKeyUtils.cpp
@@ -5,17 +5,17 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gtest/gtest.h"
 #include <algorithm>
 #include <stdint.h>
 #include <vector>
 
 #include "../ClearKeyBase64.cpp"
-#include "../ClearKeyCencParser.cpp"
+#include "psshparser/PsshParser.h"
 #include "../ArrayUtils.h"
 
 using namespace std;
 
 struct B64Test {
   string b64;
   vector<uint8_t> raw;
   bool shouldPass;
--- a/media/gmp-clearkey/0.1/gtest/moz.build
+++ b/media/gmp-clearkey/0.1/gtest/moz.build
@@ -3,13 +3,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 UNIFIED_SOURCES += [
     'TestClearKeyUtils.cpp',
 ]
 
+USE_LIBS += ['psshparser']
+
 FINAL_LIBRARY = 'xul-gtest'
 
 LOCAL_INCLUDES += [
     '..',
 ]
--- a/media/gmp-clearkey/0.1/moz.build
+++ b/media/gmp-clearkey/0.1/moz.build
@@ -8,17 +8,16 @@ SharedLibrary('clearkey')
 
 FINAL_TARGET = 'dist/bin/gmp-clearkey/0.1'
 
 FINAL_TARGET_PP_FILES += ['clearkey.info.in']
 
 UNIFIED_SOURCES += [
     'ClearKeyAsyncShutdown.cpp',
     'ClearKeyBase64.cpp',
-    'ClearKeyCencParser.cpp',
     'ClearKeyDecryptionManager.cpp',
     'ClearKeyPersistence.cpp',
     'ClearKeySession.cpp',
     'ClearKeySessionManager.cpp',
     'ClearKeyStorage.cpp',
     'ClearKeyUtils.cpp',
     'gmp-clearkey.cpp',
 ]
@@ -50,21 +49,21 @@ TEST_DIRS += [
     'gtest',
 ]
 
 
 LOCAL_INCLUDES += [
     '/dom/media/gmp',
 ]
 
-USE_STATIC_LIBS = True
-
 DISABLE_STL_WRAPPING = True
 DEFINES['MOZ_NO_MOZALLOC'] = True
 
+USE_LIBS += ['psshparser']
+
 # Suppress warnings in third-party code.
 if CONFIG['GNU_CXX']:
     CFLAGS += [
         '-Wno-missing-braces',
         '-Wno-pointer-to-int-cast',
         '-Wno-sign-compare',
         '-include', 'stdio.h',      # for sprintf() prototype
         '-include', 'unistd.h',     # for getpid() prototype
rename from media/gmp-clearkey/0.1/ClearKeyCencParser.cpp
rename to media/psshparser/PsshParser.cpp
--- a/media/gmp-clearkey/0.1/ClearKeyCencParser.cpp
+++ b/media/psshparser/PsshParser.cpp
@@ -9,21 +9,20 @@
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
-#include "ClearKeyCencParser.h"
+#include "PsshParser.h"
 
 #include "mozilla/Assertions.h"
-#include "ArrayUtils.h"
-#include "BigEndian.h"
+#include "mozilla/EndianUtils.h"
 #include <memory.h>
 #include <algorithm>
 #include <assert.h>
 #include <limits>
 
 // Stripped down version of mp4_demuxer::ByteReader, stripped down to make it
 // easier to link into ClearKey DLL and gtest.
 class ByteReader
rename from media/gmp-clearkey/0.1/ClearKeyCencParser.h
rename to media/psshparser/PsshParser.h
new file mode 100644
--- /dev/null
+++ b/media/psshparser/moz.build
@@ -0,0 +1,21 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+with Files('*'):
+    BUG_COMPONENT = ('Core', 'Video/Audio')
+
+EXPORTS.psshparser += [
+    'PsshParser.h',
+]
+
+UNIFIED_SOURCES += [
+    'PsshParser.cpp',
+]
+
+Library('psshparser')
+
+DISABLE_STL_WRAPPING = True
+DEFINES['MOZ_NO_MOZALLOC'] = True
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -112,16 +112,17 @@ USE_LIBS += [
     'js',
 ]
 
 USE_LIBS += [
     'gkmedias',
     'lgpllibs',
     'nspr',
     'nss',
+    'psshparser',
     'sqlite',
     'zlib',
 ]
 
 if CONFIG['USE_ICU']:
     USE_LIBS += [
         'icu',
     ]