Bug 1049107 - Fix build with --disable-eme. r=kentuckyfriedtakahe
authorChris Pearce <cpearce@mozilla.com>
Fri, 08 Aug 2014 14:44:04 +1200
changeset 220102 d7680ff0e9608178b862a0b4be4e589eefecbe89
parent 220101 3c2b12761044ed9074cfa5b667aa69b842e22791
child 220103 a82f186dab8c7abcdc93e24e2ac88dc733f662af
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1049107
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1049107 - Fix build with --disable-eme. r=kentuckyfriedtakahe
content/html/content/src/HTMLMediaElement.cpp
content/media/AbstractMediaDecoder.h
content/media/MediaDecoder.cpp
content/media/MediaDecoder.h
content/media/MediaDecoderOwner.h
content/media/fmp4/MP4Decoder.cpp
content/media/fmp4/MP4Decoder.h
content/media/fmp4/MP4Reader.cpp
content/media/fmp4/MP4Reader.h
content/media/fmp4/PlatformDecoderModule.cpp
content/media/fmp4/PlatformDecoderModule.h
content/media/fmp4/eme/moz.build
content/media/fmp4/moz.build
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -2648,19 +2648,21 @@ nsresult HTMLMediaElement::FinishDecoder
   // available immediately.
   mDecoder->SetResource(aStream);
   mDecoder->SetAudioChannel(mAudioChannel);
   mDecoder->SetAudioCaptured(mAudioCaptured);
   mDecoder->SetVolume(mMuted ? 0.0 : mVolume);
   mDecoder->SetPreservesPitch(mPreservesPitch);
   mDecoder->SetPlaybackRate(mPlaybackRate);
 
+#ifdef MOZ_EME
   if (mMediaKeys) {
     mDecoder->SetCDMProxy(mMediaKeys->GetCDMProxy());
   }
+#endif
   if (mPreloadAction == HTMLMediaElement::PRELOAD_METADATA) {
     mDecoder->SetMinimizePrerollUntilPlaybackStarts();
   }
 
   // Update decoder principal before we start decoding, since it
   // can affect how we feed data to MediaStreams
   NotifyDecoderPrincipalChanged();
 
--- a/content/media/AbstractMediaDecoder.h
+++ b/content/media/AbstractMediaDecoder.h
@@ -20,17 +20,19 @@ namespace layers
 {
   class ImageContainer;
 }
 class MediaResource;
 class ReentrantMonitor;
 class VideoFrameContainer;
 class TimedMetadata;
 class MediaDecoderOwner;
+#ifdef MOZ_EME
 class CDMProxy;
+#endif
 
 typedef nsDataHashtable<nsCStringHashKey, nsCString> MetadataTags;
 
 static inline bool IsCurrentThread(nsIThread* aThread) {
   return NS_GetCurrentThread() == aThread;
 }
 
 /**
@@ -134,18 +136,20 @@ public:
       mDecoder->NotifyDecodedFrames(mParsed, mDecoded);
     }
   private:
     AbstractMediaDecoder* mDecoder;
     uint32_t& mParsed;
     uint32_t& mDecoded;
   };
 
+#ifdef MOZ_EME
   virtual nsresult SetCDMProxy(CDMProxy* aProxy) { return NS_ERROR_NOT_IMPLEMENTED; }
   virtual CDMProxy* GetCDMProxy() { return nullptr; }
+#endif
 };
 
 class MetadataEventRunner : public nsRunnable
 {
   private:
     nsRefPtr<AbstractMediaDecoder> mDecoder;
   public:
     MetadataEventRunner(AbstractMediaDecoder* aDecoder, MediaInfo* aInfo, MetadataTags* aTags)
--- a/content/media/MediaDecoder.cpp
+++ b/content/media/MediaDecoder.cpp
@@ -1661,16 +1661,17 @@ bool MediaDecoder::CanPlayThrough()
   // we don't suddenly discover that we need to buffer. This is particularly
   // required near the start of the media, when not much data is downloaded.
   int64_t readAheadMargin =
     static_cast<int64_t>(stats.mPlaybackRate * CAN_PLAY_THROUGH_MARGIN);
   return stats.mTotalBytes == stats.mDownloadPosition ||
          stats.mDownloadPosition > stats.mPlaybackPosition + readAheadMargin;
 }
 
+#ifdef MOZ_EME
 nsresult
 MediaDecoder::SetCDMProxy(CDMProxy* aProxy)
 {
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
   MOZ_ASSERT(NS_IsMainThread());
   mProxy = aProxy;
   // Awaken any readers waiting for the proxy.
   NotifyWaitingForResourcesStatusChanged();
@@ -1679,16 +1680,17 @@ MediaDecoder::SetCDMProxy(CDMProxy* aPro
 
 CDMProxy*
 MediaDecoder::GetCDMProxy()
 {
   GetReentrantMonitor().AssertCurrentThreadIn();
   MOZ_ASSERT(OnDecodeThread() || NS_IsMainThread());
   return mProxy;
 }
+#endif
 
 #ifdef MOZ_RAW
 bool
 MediaDecoder::IsRawEnabled()
 {
   return Preferences::GetBool("media.raw.enabled");
 }
 #endif
--- a/content/media/MediaDecoder.h
+++ b/content/media/MediaDecoder.h
@@ -185,17 +185,19 @@ destroying the MediaDecoder object.
 #include "MediaResource.h"
 #include "mozilla/dom/AudioChannelBinding.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/ReentrantMonitor.h"
 #include "mozilla/TimeStamp.h"
 #include "MediaStreamGraph.h"
 #include "AbstractMediaDecoder.h"
 #include "necko-config.h"
+#ifdef MOZ_EME
 #include "mozilla/CDMProxy.h"
+#endif
 
 class nsIStreamListener;
 class nsIPrincipal;
 class nsITimer;
 
 namespace mozilla {
 namespace dom {
 class TimeRanges;
@@ -845,21 +847,23 @@ public:
 
   // Returns true if we're logically playing, that is, if the Play() has
   // been called and Pause() has not or we have not yet reached the end
   // of media. This is irrespective of the seeking state; if the owner
   // calls Play() and then Seek(), we still count as logically playing.
   // The decoder monitor must be held.
   bool IsLogicallyPlaying();
 
+#ifdef MOZ_EME
   // This takes the decoder monitor.
   virtual nsresult SetCDMProxy(CDMProxy* aProxy) MOZ_OVERRIDE;
 
   // Decoder monitor must be held.
   virtual CDMProxy* GetCDMProxy() MOZ_OVERRIDE;
+#endif
 
 #ifdef MOZ_RAW
   static bool IsRawEnabled();
 #endif
 
   static bool IsOggEnabled();
   static bool IsOpusEnabled();
 
@@ -1102,17 +1106,19 @@ private:
     }
   private:
     ReentrantMonitor mReentrantMonitor;
   };
 
   // The |RestrictedAccessMonitor| member object.
   RestrictedAccessMonitor mReentrantMonitor;
 
+#ifdef MOZ_EME
   nsRefPtr<CDMProxy> mProxy;
+#endif
 
 protected:
   // Data about MediaStreams that are being fed by this decoder.
   nsTArray<OutputStreamData> mOutputStreams;
   // The SourceMediaStream we are using to feed the mOutputStreams. This stream
   // is never exposed outside the decoder.
   // Only written on the main thread while holding the monitor. Therefore it
   // can be read on any thread while holding the monitor, or on the main thread
--- a/content/media/MediaDecoderOwner.h
+++ b/content/media/MediaDecoderOwner.h
@@ -133,19 +133,21 @@ public:
   // Called by the media decoder and the video frame to get the
   // ImageContainer containing the video data.
   virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
 
   // Called by the media decoder object, on the main thread,
   // when the connection between Rtsp server and client gets lost.
   virtual void ResetConnectionState() = 0;
 
+#ifdef MOZ_EME
   // Dispatches a "needkey" event to the HTMLMediaElement, with the
   // provided init data.
   // Main thread only.
   virtual void DispatchNeedKey(const nsTArray<uint8_t>& aInitData,
                                const nsAString& aInitDataType) = 0;
+#endif
 };
 
 }
 
 #endif
 
--- a/content/media/fmp4/MP4Decoder.cpp
+++ b/content/media/fmp4/MP4Decoder.cpp
@@ -3,17 +3,19 @@
 /* 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/. */
 
 #include "MP4Decoder.h"
 #include "MP4Reader.h"
 #include "MediaDecoderStateMachine.h"
 #include "mozilla/Preferences.h"
+#ifdef MOZ_EME
 #include "mozilla/CDMProxy.h"
+#endif
 #include "prlog.h"
 
 #ifdef XP_WIN
 #include "mozilla/WindowsVersion.h"
 #endif
 #ifdef MOZ_FFMPEG
 #include "FFmpegRuntimeLinker.h"
 #endif
@@ -24,32 +26,34 @@
 
 namespace mozilla {
 
 MediaDecoderStateMachine* MP4Decoder::CreateStateMachine()
 {
   return new MediaDecoderStateMachine(this, new MP4Reader(this));
 }
 
+#ifdef MOZ_EME
 nsresult
 MP4Decoder::SetCDMProxy(CDMProxy* aProxy)
 {
   nsresult rv = MediaDecoder::SetCDMProxy(aProxy);
   NS_ENSURE_SUCCESS(rv, rv);
   {
     // The MP4Reader can't decrypt EME content until it has a CDMProxy,
     // and the CDMProxy knows the capabilities of the CDM. The MP4Reader
     // remains in "waiting for resources" state until then.
     CDMCaps::AutoLock caps(aProxy->Capabilites());
     nsRefPtr<nsIRunnable> task(
       NS_NewRunnableMethod(this, &MediaDecoder::NotifyWaitingForResourcesStatusChanged));
     caps.CallOnMainThreadWhenCapsAvailable(task);
   }
   return NS_OK;
 }
+#endif
 
 bool
 MP4Decoder::GetSupportedCodecs(const nsACString& aType,
                                char const *const ** aCodecList)
 {
   if (!IsEnabled()) {
     return false;
   }
--- a/content/media/fmp4/MP4Decoder.h
+++ b/content/media/fmp4/MP4Decoder.h
@@ -19,17 +19,19 @@ public:
     if (!IsEnabled()) {
       return nullptr;
     }
     return new MP4Decoder();
   }
 
   virtual MediaDecoderStateMachine* CreateStateMachine();
 
+#ifdef MOZ_EME
   virtual nsresult SetCDMProxy(CDMProxy* aProxy) MOZ_OVERRIDE;
+#endif
 
   // Returns true if aType is a MIME type that we can render with the
   // a MP4 platform decoder backend. If aCodecList is non null,
   // it is filled with a (static const) null-terminated list of strings
   // denoting the codecs we'll playback.
   static bool GetSupportedCodecs(const nsACString& aType,
                                  char const *const ** aCodecList);
 
--- a/content/media/fmp4/MP4Reader.cpp
+++ b/content/media/fmp4/MP4Reader.cpp
@@ -10,16 +10,20 @@
 #include "VideoUtils.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "ImageContainer.h"
 #include "Layers.h"
 #include "SharedThreadPool.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/TimeRanges.h"
 
+#ifdef MOZ_EME
+#include "mozilla/CDMProxy.h"
+#endif
+
 using mozilla::layers::Image;
 using mozilla::layers::LayerManager;
 using mozilla::layers::LayersBackend;
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* GetDemuxerLog() {
   static PRLogModuleInfo* log = nullptr;
   if (!log) {
@@ -199,16 +203,17 @@ MP4Reader::Init(MediaDecoderReader* aClo
   if (!sSetupPrefCache) {
     sSetupPrefCache = true;
     Preferences::AddBoolVarCache(&sIsEMEEnabled, "media.eme.enabled", false);
   }
 
   return NS_OK;
 }
 
+#ifdef MOZ_EME
 class DispatchKeyNeededEvent : public nsRunnable {
 public:
   DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder,
                          nsTArray<uint8_t>& aInitData,
                          const nsString& aInitDataType)
     : mDecoder(aDecoder)
     , mInitData(aInitData)
     , mInitDataType(aInitDataType)
@@ -224,19 +229,21 @@ public:
     mDecoder = nullptr;
     return NS_OK;
   }
 private:
   nsRefPtr<AbstractMediaDecoder> mDecoder;
   nsTArray<uint8_t> mInitData;
   nsString mInitDataType;
 };
+#endif
 
 bool MP4Reader::IsWaitingMediaResources()
 {
+#ifdef MOZ_EME
   nsRefPtr<CDMProxy> proxy;
   {
     ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     if (!mIsEncrypted) {
       // Not encrypted, no need to wait for CDMProxy.
       return false;
     }
     proxy = mDecoder->GetCDMProxy();
@@ -246,16 +253,19 @@ bool MP4Reader::IsWaitingMediaResources(
     }
   }
   // We'll keep waiting if the CDM hasn't informed Gecko of its capabilities.
   {
     CDMCaps::AutoLock caps(proxy->Capabilites());
     LOG("MP4Reader::IsWaitingMediaResources() capsKnown=%d", caps.AreCapsKnown());
     return !caps.AreCapsKnown();
   }
+#else
+  return false;
+#endif
 }
 
 void
 MP4Reader::ExtractCryptoInitData(nsTArray<uint8_t>& aInitData)
 {
   MOZ_ASSERT(mDemuxer->Crypto().valid);
   const nsTArray<mp4_demuxer::PsshInfo>& psshs = mDemuxer->Crypto().pssh;
   for (uint32_t i = 0; i < psshs.Length(); i++) {
@@ -291,16 +301,17 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo
     }
 
     // Remember that we've initialized the demuxer, so that if we're decoding
     // an encrypted stream and we need to wait for a CDM to be set, we don't
     // need to reinit the demuxer.
     mDemuxerInitialized = true;
   }
   if (mDemuxer->Crypto().valid) {
+#ifdef MOZ_EME
     if (!sIsEMEEnabled) {
       // TODO: Need to signal DRM/EME required somehow...
       return NS_ERROR_FAILURE;
     }
 
     // We have encrypted audio or video. We'll need a CDM to decrypt and
     // possibly decode this. Wait until we've received a CDM from the
     // JavaScript player app.
@@ -325,16 +336,20 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo
     }
     MOZ_ASSERT(proxy);
 
     mPlatform = PlatformDecoderModule::CreateCDMWrapper(proxy,
                                                         HasAudio(),
                                                         HasVideo(),
                                                         GetTaskQueue());
     NS_ENSURE_TRUE(mPlatform, NS_ERROR_FAILURE);
+#else
+    // EME not supported.
+    return NS_ERROR_FAILURE;
+#endif
   } else {
     mPlatform = PlatformDecoderModule::Create();
     NS_ENSURE_TRUE(mPlatform, NS_ERROR_FAILURE);
   }
 
   if (HasAudio()) {
     const AudioDecoderConfig& audio = mDemuxer->AudioConfig();
     mInfo.mAudio.mRate = audio.samples_per_second;
--- a/content/media/fmp4/MP4Reader.h
+++ b/content/media/fmp4/MP4Reader.h
@@ -7,17 +7,16 @@
 #if !defined(MP4Reader_h_)
 #define MP4Reader_h_
 
 #include "MediaDecoderReader.h"
 #include "nsAutoPtr.h"
 #include "PlatformDecoderModule.h"
 #include "mp4_demuxer/mp4_demuxer.h"
 #include "MediaTaskQueue.h"
-#include "mozilla/CDMProxy.h"
 
 #include <deque>
 #include "mozilla/Monitor.h"
 
 namespace mozilla {
 
 namespace dom {
 class TimeRanges;
--- a/content/media/fmp4/PlatformDecoderModule.cpp
+++ b/content/media/fmp4/PlatformDecoderModule.cpp
@@ -10,18 +10,20 @@
 #endif
 #ifdef MOZ_FFMPEG
 #include "FFmpegRuntimeLinker.h"
 #endif
 #ifdef MOZ_APPLEMEDIA
 #include "AppleDecoderModule.h"
 #endif
 #include "mozilla/Preferences.h"
+#ifdef MOZ_EME
 #include "EMEDecoderModule.h"
 #include "mozilla/CDMProxy.h"
+#endif
 #include "SharedThreadPool.h"
 #include "MediaTaskQueue.h"
 
 namespace mozilla {
 
 extern PlatformDecoderModule* CreateBlankDecoderModule();
 
 bool PlatformDecoderModule::sUseBlankDecoder = false;
@@ -65,16 +67,17 @@ CreateTaskQueue()
 {
   // We must create the MediaTaskQueue/SharedThreadPool on the main thread.
   nsRefPtr<CreateTaskQueueTask> t(new CreateTaskQueueTask());
   nsresult rv = NS_DispatchToMainThread(t, NS_DISPATCH_SYNC);
   NS_ENSURE_SUCCESS(rv, nullptr);
   return t->mTaskQueue.forget();
 }
 
+#ifdef MOZ_EME
 /* static */
 PlatformDecoderModule*
 PlatformDecoderModule::CreateCDMWrapper(CDMProxy* aProxy,
                                         bool aHasAudio,
                                         bool aHasVideo,
                                         MediaTaskQueue* aTaskQueue)
 {
   bool cdmDecodesAudio;
@@ -96,16 +99,17 @@ PlatformDecoderModule::CreateCDMWrapper(
   }
 
   return new EMEDecoderModule(aProxy,
                               pdm.forget(),
                               cdmDecodesAudio,
                               cdmDecodesVideo,
                               CreateTaskQueue());
 }
+#endif
 
 /* static */
 PlatformDecoderModule*
 PlatformDecoderModule::Create()
 {
   // Note: This runs on the decode thread.
   MOZ_ASSERT(!NS_IsMainThread());
 
--- a/content/media/fmp4/PlatformDecoderModule.h
+++ b/content/media/fmp4/PlatformDecoderModule.h
@@ -61,25 +61,27 @@ public:
   // Factory method that creates the appropriate PlatformDecoderModule for
   // the platform we're running on. Caller is responsible for deleting this
   // instance. It's expected that there will be multiple
   // PlatformDecoderModules alive at the same time. There is one
   // PlatformDecoderModule created per MP4Reader.
   // This is called on the decode task queue.
   static PlatformDecoderModule* Create();
 
+#ifdef MOZ_EME
   // Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
   // decrypt-and-decode EME encrypted content. If the CDM only decrypts and
   // does not decode, we create a PDM and use that to create MediaDataDecoders
   // that we use on on aTaskQueue to decode the decrypted stream.
   // This is called on the decode task queue.
   static PlatformDecoderModule* CreateCDMWrapper(CDMProxy* aProxy,
                                                  bool aHasAudio,
                                                  bool aHasVideo,
                                                  MediaTaskQueue* aTaskQueue);
+#endif
 
   // Called to shutdown the decoder module and cleanup state. The PDM
   // is deleted immediately after Shutdown() is called. Shutdown() is
   // called after Shutdown() has been called on all MediaDataDecoders
   // created from this PlatformDecoderModule.
   // This is called on the decode task queue.
   virtual nsresult Shutdown() = 0;
 
new file mode 100644
--- /dev/null
+++ b/content/media/fmp4/eme/moz.build
@@ -0,0 +1,30 @@
+# -*- Mode: python; c-basic-offset: 4; 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/.
+
+EXPORTS += [
+    'EMEAACDecoder.h',
+    'EMEDecoderModule.h',
+    'EMEH264Decoder.h',
+]
+
+UNIFIED_SOURCES += [
+    'EMEAACDecoder.cpp',
+    'EMEDecoderModule.cpp',
+    'EMEH264Decoder.cpp',
+]
+
+include('/ipc/chromium/chromium-config.mozbuild')
+
+LOCAL_INCLUDES += [
+    '../base',
+]
+  
+FINAL_LIBRARY = 'xul'
+
+FAIL_ON_WARNINGS = True
+
+if CONFIG['OS_ARCH'] == 'WINNT':
+    DEFINES['NOMINMAX'] = True
--- a/content/media/fmp4/moz.build
+++ b/content/media/fmp4/moz.build
@@ -1,39 +1,36 @@
 # -*- Mode: python; c-basic-offset: 4; 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/.
 
 EXPORTS += [
-    'eme/EMEAACDecoder.h',
-    'eme/EMEDecoderModule.h',
-    'eme/EMEH264Decoder.h',
     'MP4Decoder.h',
     'MP4Reader.h',
     'PlatformDecoderModule.h',
 ]
 
 UNIFIED_SOURCES += [
     'BlankDecoderModule.cpp',
-    'eme/EMEAACDecoder.cpp',
-    'eme/EMEDecoderModule.cpp',
-    'eme/EMEH264Decoder.cpp',
     'PlatformDecoderModule.cpp',
 ]
 
 SOURCES += [
     'MP4Decoder.cpp',
     'MP4Reader.cpp',
 ]
 
 if CONFIG['MOZ_WMF']:
     DIRS += [ 'wmf' ];
 
+if CONFIG['MOZ_EME']:
+    DIRS += ['eme']
+    
 if CONFIG['MOZ_FFMPEG']:
     EXPORTS += [
         'ffmpeg/FFmpegRuntimeLinker.h',
     ]
     UNIFIED_SOURCES += [
         'ffmpeg/FFmpegLog.cpp',
         'ffmpeg/FFmpegRuntimeLinker.cpp',
     ]