Bug 1341967 - remove MOZ_RUST_MP4PARSE. r=kinetik draft
authorAlfredo.Yang <ayang@mozilla.com>
Wed, 01 Mar 2017 14:44:42 +0800
changeset 490744 263a6cfcf50ee3582f3dc1bfc43d4fa0dcc00800
parent 490658 21aa6c5cb0548c080a6fc2d1980b807f14237743
child 490779 d436763326aa0630a402a3f7bb7d5ca4f7737b68
push id47212
push userbmo:ayang@mozilla.com
push dateWed, 01 Mar 2017 08:11:53 +0000
reviewerskinetik
bugs1341967
milestone54.0a1
Bug 1341967 - remove MOZ_RUST_MP4PARSE. r=kinetik MozReview-Commit-ID: SgTlIo8wEi
browser/confvars.sh
dom/media/MediaPrefs.h
media/libstagefright/binding/DecoderData.cpp
media/libstagefright/binding/MP4Metadata.cpp
media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
mobile/android/confvars.sh
toolkit/components/telemetry/Histograms.json
--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -51,15 +51,14 @@ MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3
 # This should usually be the same as the value MAR_CHANNEL_ID.
 # If more than one ID is needed, then you should use a comma separated list
 # of values.
 ACCEPTED_MAR_CHANNEL_IDS=firefox-mozilla-central
 # The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
 MAR_CHANNEL_ID=firefox-mozilla-central
 MOZ_PROFILE_MIGRATOR=1
 MOZ_JSDOWNLOADS=1
-MOZ_RUST_MP4PARSE=1
 
 # Enable checking that add-ons are signed by the trusted root
 MOZ_ADDON_SIGNING=1
 
 # Include the DevTools client, not just the server (which is the default)
 MOZ_DEVTOOLS=all
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -160,17 +160,17 @@ private:
   DECL_MEDIA_PREF("media.decoder.limit",                      MediaDecoderLimit, int32_t, MediaDecoderLimitDefault());
 
   // Ogg
   DECL_MEDIA_PREF("media.ogg.enabled",                        OggEnabled, bool, true);
   // Flac
   DECL_MEDIA_PREF("media.ogg.flac.enabled",                   FlacInOgg, bool, false);
   DECL_MEDIA_PREF("media.flac.enabled",                       FlacEnabled, bool, true);
 
-#if defined(MOZ_RUST_MP4PARSE) && !defined(RELEASE_OR_BETA)
+#if !defined(RELEASE_OR_BETA)
   DECL_MEDIA_PREF("media.rust.test_mode",                     RustTestMode, bool, false);
 #endif
 
 public:
   // Manage the singleton:
   static MediaPrefs& GetSingleton();
   static bool SingletonExists();
 
--- a/media/libstagefright/binding/DecoderData.cpp
+++ b/media/libstagefright/binding/DecoderData.cpp
@@ -8,21 +8,19 @@
 #include "mp4_demuxer/DecoderData.h"
 #include <media/stagefright/foundation/ABitReader.h>
 #include "media/stagefright/MetaData.h"
 #include "media/stagefright/MediaDefs.h"
 #include "media/stagefright/Utils.h"
 #include "mozilla/ArrayUtils.h"
 #include "include/ESDS.h"
 
-#ifdef MOZ_RUST_MP4PARSE
 // OpusDecoder header is really needed only by MP4 in rust
 #include "OpusDecoder.h"
 #include "mp4parse.h"
-#endif
 
 using namespace stagefright;
 
 namespace mp4_demuxer
 {
 
 static int32_t
 FindInt32(const MetaData* mMetaData, uint32_t mKey)
@@ -184,17 +182,16 @@ MP4VideoInfo::Update(const MetaData* aMe
         const uint8_t* cdata = reinterpret_cast<const uint8_t*>(data);
         mCodecSpecificConfig->AppendElements(cdata, size);
       }
     }
   }
 
 }
 
-#ifdef MOZ_RUST_MP4PARSE
 static void
 UpdateTrackProtectedInfo(mozilla::TrackInfo& aConfig,
                          const mp4parse_sinf_info& aSinf)
 {
   if (aSinf.is_encrypted != 0) {
     aConfig.mCrypto.mValid = true;
     aConfig.mCrypto.mMode = aSinf.is_encrypted;
     aConfig.mCrypto.mIVSize = aSinf.iv_size;
@@ -264,17 +261,16 @@ MP4VideoInfo::Update(const mp4parse_trac
   mDisplay.width = video->display_width;
   mDisplay.height = video->display_height;
   mImage.width = video->image_width;
   mImage.height = video->image_height;
   if (video->extra_data.data) {
     mExtraData->AppendElements(video->extra_data.data, video->extra_data.length);
   }
 }
-#endif
 
 bool
 MP4VideoInfo::IsValid() const
 {
   return (mDisplay.width > 0 && mDisplay.height > 0) ||
     (mImage.width > 0 && mImage.height > 0);
 }
 
--- a/media/libstagefright/binding/MP4Metadata.cpp
+++ b/media/libstagefright/binding/MP4Metadata.cpp
@@ -14,26 +14,24 @@
 #include "mozilla/RefPtr.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/UniquePtr.h"
 #include "VideoUtils.h"
 #include "mp4_demuxer/MoofParser.h"
 #include "mp4_demuxer/MP4Metadata.h"
 #include "mp4_demuxer/Stream.h"
 #include "MediaPrefs.h"
+#include "mp4parse.h"
 
 #include <limits>
 #include <stdint.h>
 #include <vector>
 
-#ifdef MOZ_RUST_MP4PARSE
-#include "mp4parse.h"
 
 struct FreeMP4Parser { void operator()(mp4parse_parser* aPtr) { mp4parse_free(aPtr); } };
-#endif
 
 using namespace stagefright;
 
 namespace mp4_demuxer
 {
 
 static LazyLogModule sLog("MP4Metadata");
 
@@ -99,18 +97,16 @@ private:
                                                     stagefright::MetaData* aMetaData,
                                                     int32_t aIndex) const;
   CryptoFile mCrypto;
   RefPtr<Stream> mSource;
   sp<MediaExtractor> mMetadataExtractor;
   bool mCanSeek;
 };
 
-#ifdef MOZ_RUST_MP4PARSE
-
 // Wrap an mp4_demuxer::Stream to remember the read offset.
 
 class RustStreamAdaptor {
 public:
   explicit RustStreamAdaptor(Stream* aSource)
     : mSource(aSource)
     , mOffset(0)
   {
@@ -146,29 +142,26 @@ private:
   void UpdateCrypto();
   Maybe<uint32_t> TrackTypeToGlobalTrackIndex(mozilla::TrackInfo::TrackType aType, size_t aTrackNumber) const;
 
   CryptoFile mCrypto;
   RefPtr<Stream> mSource;
   RustStreamAdaptor mRustSource;
   mozilla::UniquePtr<mp4parse_parser, FreeMP4Parser> mRustParser;
 };
-#endif
 
 MP4Metadata::MP4Metadata(Stream* aSource)
  : mStagefright(MakeUnique<MP4MetadataStagefright>(aSource))
-#ifdef MOZ_RUST_MP4PARSE
  , mRust(MakeUnique<MP4MetadataRust>(aSource))
  , mPreferRust(false)
  , mReportedAudioTrackTelemetry(false)
  , mReportedVideoTrackTelemetry(false)
 #ifndef RELEASE_OR_BETA
  , mRustTestMode(MediaPrefs::RustTestMode())
 #endif
-#endif
 {
 }
 
 MP4Metadata::~MP4Metadata()
 {
 }
 
 /*static*/ bool
@@ -196,17 +189,16 @@ TrackTypeToString(mozilla::TrackInfo::Tr
   }
 }
 
 uint32_t
 MP4Metadata::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const
 {
   uint32_t numTracks = mStagefright->GetNumberTracks(aType);
 
-#ifdef MOZ_RUST_MP4PARSE
   if (!mRust) {
     return numTracks;
   }
 
   uint32_t numTracksRust = mRust->GetNumberTracks(aType);
   MOZ_LOG(sLog, LogLevel::Info, ("%s tracks found: stagefright=%u rust=%u",
                                  TrackTypeToString(aType), numTracks, numTracksRust));
 
@@ -222,22 +214,20 @@ MP4Metadata::GetNumberTracks(mozilla::Tr
     mReportedVideoTrackTelemetry = true;
   }
 
   if (mPreferRust || ShouldPreferRust()) {
     MOZ_LOG(sLog, LogLevel::Info, ("Preferring rust demuxer"));
     mPreferRust = true;
     return numTracksRust;
   }
-#endif // MOZ_RUST_MP4PARSE
 
   return numTracks;
 }
 
-#ifdef MOZ_RUST_MP4PARSE
 bool MP4Metadata::ShouldPreferRust() const {
   if (!mRust) {
     return false;
   }
   // See if there's an Opus track.
   uint32_t numTracks = mRust->GetNumberTracks(TrackInfo::kAudioTrack);
   for (auto i = 0; i < numTracks; i++) {
     auto info = mRust->GetTrackInfo(TrackInfo::kAudioTrack, i);
@@ -258,26 +248,24 @@ bool MP4Metadata::ShouldPreferRust() con
     }
     if (info->mMimeType.EqualsASCII("video/vp9")) {
       return true;
     }
   }
   // Otherwise, fall back.
   return false;
 }
-#endif // MOZ_RUST_MP4PARSE
 
 mozilla::UniquePtr<mozilla::TrackInfo>
 MP4Metadata::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
                           size_t aTrackNumber) const
 {
   mozilla::UniquePtr<mozilla::TrackInfo> info =
       mStagefright->GetTrackInfo(aType, aTrackNumber);
 
-#ifdef MOZ_RUST_MP4PARSE
   if (!mRust) {
     return info;
   }
 
   mozilla::UniquePtr<mozilla::TrackInfo> infoRust =
       mRust->GetTrackInfo(aType, aTrackNumber);
 
 #ifndef RELEASE_OR_BETA
@@ -317,50 +305,44 @@ MP4Metadata::GetTrackInfo(mozilla::Track
       break;
     }
     default:
       break;
     }
   }
 #endif
 
-  if (!mPreferRust) {
-    return info;
+  if (mPreferRust) {
+    return infoRust;
   }
-  MOZ_ASSERT(infoRust);
-  return infoRust;
-#endif
 
   return info;
 }
 
 bool
 MP4Metadata::CanSeek() const
 {
   return mStagefright->CanSeek();
 }
 
 const CryptoFile&
 MP4Metadata::Crypto() const
 {
   const CryptoFile& crypto = mStagefright->Crypto();
-
-#ifdef MOZ_RUST_MP4PARSE
   const CryptoFile& rustCrypto = mRust->Crypto();
 
 #ifndef RELEASE_OR_BETA
   if (mRustTestMode) {
     MOZ_DIAGNOSTIC_ASSERT(rustCrypto.pssh == crypto.pssh);
   }
 #endif
 
   if (mPreferRust) {
     return rustCrypto;
   }
-#endif
 
   return crypto;
 }
 
 bool
 MP4Metadata::ReadTrackIndex(FallibleTArray<Index::Indice>& aDest, mozilla::TrackID aTrackID)
 {
   bool ret = mStagefright->ReadTrackIndex(aDest, aTrackID);
@@ -622,17 +604,16 @@ MP4MetadataStagefright::HasCompleteMetad
 
 /*static*/ already_AddRefed<mozilla::MediaByteBuffer>
 MP4MetadataStagefright::Metadata(Stream* aSource)
 {
   auto parser = mozilla::MakeUnique<MoofParser>(aSource, 0, false);
   return parser->Metadata();
 }
 
-#ifdef MOZ_RUST_MP4PARSE
 bool
 RustStreamAdaptor::Read(uint8_t* buffer, uintptr_t size, size_t* bytes_read)
 {
   if (!mOffset.isValid()) {
     MOZ_LOG(sLog, LogLevel::Error, ("Overflow in source stream offset"));
     return false;
   }
   bool rv = mSource->ReadAt(mOffset.value(), buffer, size, bytes_read);
@@ -895,11 +876,10 @@ MP4MetadataRust::HasCompleteMetadata(Str
 }
 
 /*static*/ already_AddRefed<mozilla::MediaByteBuffer>
 MP4MetadataRust::Metadata(Stream* aSource)
 {
   MOZ_ASSERT(false, "Not yet implemented");
   return nullptr;
 }
-#endif
 
 } // namespace mp4_demuxer
--- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
@@ -14,23 +14,21 @@
 #include "nsTArray.h"
 #include "nsString.h"
 
 namespace stagefright
 {
 class MetaData;
 }
 
-#ifdef MOZ_RUST_MP4PARSE
 extern "C" {
 typedef struct mp4parse_track_info mp4parse_track_info;
 typedef struct mp4parse_track_audio_info mp4parse_track_audio_info;
 typedef struct mp4parse_track_video_info mp4parse_track_video_info;
 }
-#endif
 
 namespace mp4_demuxer
 {
 
 class MP4Demuxer;
 
 struct PsshInfo
 {
@@ -68,35 +66,31 @@ private:
 class MP4AudioInfo : public mozilla::AudioInfo
 {
 public:
   MP4AudioInfo() = default;
 
   void Update(const stagefright::MetaData* aMetaData,
               const char* aMimeType);
 
-#ifdef MOZ_RUST_MP4PARSE
   void Update(const mp4parse_track_info* track,
               const mp4parse_track_audio_info* audio);
-#endif
 
   virtual bool IsValid() const override;
 };
 
 class MP4VideoInfo : public mozilla::VideoInfo
 {
 public:
   MP4VideoInfo() = default;
 
   void Update(const stagefright::MetaData* aMetaData,
               const char* aMimeType);
 
-#ifdef MOZ_RUST_MP4PARSE
   void Update(const mp4parse_track_info* track,
               const mp4parse_track_video_info* video);
-#endif
 
   virtual bool IsValid() const override;
 };
 
 }
 
 #endif
--- a/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
@@ -32,23 +32,21 @@ public:
   bool CanSeek() const;
 
   const CryptoFile& Crypto() const;
 
   bool ReadTrackIndex(FallibleTArray<Index::Indice>& aDest, mozilla::TrackID aTrackID);
 
 private:
   UniquePtr<MP4MetadataStagefright> mStagefright;
-#ifdef MOZ_RUST_MP4PARSE
   UniquePtr<MP4MetadataRust> mRust;
   mutable bool mPreferRust;
   mutable bool mReportedAudioTrackTelemetry;
   mutable bool mReportedVideoTrackTelemetry;
 #ifndef RELEASE_OR_BETA
   mutable bool mRustTestMode;
 #endif
   bool ShouldPreferRust() const;
-#endif
 };
 
 } // namespace mp4_demuxer
 
 #endif // MP4METADATA_H_
--- a/mobile/android/confvars.sh
+++ b/mobile/android/confvars.sh
@@ -25,18 +25,16 @@ MOZ_ANDROID_SEARCH_INTENT_CLASS=org.mozi
 
 MOZ_NO_SMART_CARDS=1
 
 MOZ_XULRUNNER=
 
 MOZ_CAPTURE=1
 MOZ_RAW=1
 
-MOZ_RUST_MP4PARSE=1
-
 # use custom widget for html:select
 MOZ_USE_NATIVE_POPUP_WINDOWS=1
 
 MOZ_APP_ID={aa3c5121-dab2-40e2-81ca-7ea25febc110}
 
 # Enable second screen using native Android libraries.
 MOZ_NATIVE_DEVICES=1
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -6934,43 +6934,39 @@
     "n_buckets": 1000,
     "description": "The time (in milliseconds) that it took to display a selected source to the user."
   },
   "MEDIA_RUST_MP4PARSE_SUCCESS": {
     "alert_emails": ["giles@mozilla.com", "kinetik@flim.org"],
     "expires_in_version": "55",
     "kind": "boolean",
     "bug_numbers": [1220885],
-    "description": "(Bug 1220885) Whether the rust mp4 demuxer successfully parsed a stream segment.",
-    "cpp_guard": "MOZ_RUST_MP4PARSE"
+    "description": "(Bug 1220885) Whether the rust mp4 demuxer successfully parsed a stream segment."
   },
   "MEDIA_RUST_MP4PARSE_ERROR_CODE": {
     "alert_emails": ["giles@mozilla.com", "kinetik@flim.org"],
     "expires_in_version": "55",
     "kind": "enumerated",
     "n_values": 32,
     "bug_numbers": [1238420],
-    "description": "The error code reported when an MP4 parse attempt has failed.0 = OK, 1 = bad argument, 2 = invalid data, 3 = unsupported, 4 = unexpected end of file, 5 = read error.",
-    "cpp_guard": "MOZ_RUST_MP4PARSE"
+    "description": "The error code reported when an MP4 parse attempt has failed.0 = OK, 1 = bad argument, 2 = invalid data, 3 = unsupported, 4 = unexpected end of file, 5 = read error."
   },
   "MEDIA_RUST_MP4PARSE_TRACK_MATCH_AUDIO": {
     "alert_emails": ["giles@mozilla.com", "kinetik@flim.org"],
     "expires_in_version": "55",
     "kind": "boolean",
     "bug_numbers": [1231169],
-    "description": "Whether rust and stagefight mp4 parser audio track results match.",
-    "cpp_guard": "MOZ_RUST_MP4PARSE"
+    "description": "Whether rust and stagefight mp4 parser audio track results match."
   },
   "MEDIA_RUST_MP4PARSE_TRACK_MATCH_VIDEO": {
     "alert_emails": ["giles@mozilla.com", "kinetik@flim.org"],
     "expires_in_version": "55",
     "kind": "boolean",
     "bug_numbers": [1231169],
-    "description": "Whether rust and stagefight mp4 parser video track results match.",
-    "cpp_guard": "MOZ_RUST_MP4PARSE"
+    "description": "Whether rust and stagefight mp4 parser video track results match."
   },
   "MEDIA_WMF_DECODE_ERROR": {
     "expires_in_version": "55",
     "kind": "enumerated",
     "n_values": 256,
     "description": "WMF media decoder error or success (0) codes."
   },
   "MEDIA_OGG_LOADED_IS_CHAINED": {