Bug 1210319 - p2. Minor intf clean-up, RIP trex - r=rillian
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 01 Dec 2015 13:45:55 -0800
changeset 309234 cddca26367a2cc6c693554ace02f964ffec634db
parent 309233 571d6fc4fcdde4b0587bbf22e84e5e7141bbaebf
child 309235 9e68f234636f55415f9803a06e83096e24d7884d
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs1210319
milestone45.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 1210319 - p2. Minor intf clean-up, RIP trex - r=rillian Made some class interfaces a bit more "C++11"-ish, to protect against some possible issues. Also removed 'trex', which was only used by code removed in previous patch.
media/libstagefright/frameworks/av/include/media/stagefright/MediaSource.h
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
media/libstagefright/frameworks/av/media/libstagefright/include/MPEG4Extractor.h
--- a/media/libstagefright/frameworks/av/include/media/stagefright/MediaSource.h
+++ b/media/libstagefright/frameworks/av/include/media/stagefright/MediaSource.h
@@ -47,15 +47,15 @@ struct MediaSource : public virtual RefB
     };
 
     virtual nsTArray<Indice> exportIndex() = 0;
 
 protected:
     virtual ~MediaSource();
 
 private:
-    MediaSource(const MediaSource &);
-    MediaSource &operator=(const MediaSource &);
+    MediaSource(const MediaSource &) = delete;
+    MediaSource &operator=(const MediaSource &) = delete;
 };
 
 }  // namespace stagefright
 
 #endif  // MEDIA_SOURCE_H_
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -45,64 +45,64 @@ static const uint32_t kMAX_ALLOCATION =
 namespace stagefright {
 
 class MPEG4Source : public MediaSource {
 public:
     MPEG4Source(const sp<MetaData> &format,
                 uint32_t timeScale,
                 const sp<SampleTable> &sampleTable);
 
-    virtual sp<MetaData> getFormat();
-
-    virtual nsTArray<Indice> exportIndex();
+    sp<MetaData> getFormat() override;
+
+    nsTArray<Indice> exportIndex() override;
 
 protected:
     virtual ~MPEG4Source();
 
 private:
     sp<MetaData> mFormat;
     uint32_t mTimescale;
     sp<SampleTable> mSampleTable;
 
-    MPEG4Source(const MPEG4Source &);
-    MPEG4Source &operator=(const MPEG4Source &);
+    MPEG4Source(const MPEG4Source &) = delete;
+    MPEG4Source &operator=(const MPEG4Source &) = delete;
 };
 
 // This custom data source wraps an existing one and satisfies requests
 // falling entirely within a cached range from the cache while forwarding
 // all remaining requests to the wrapped datasource.
 // This is used to cache the full sampletable metadata for a single track,
 // possibly wrapping multiple times to cover all tracks, i.e.
 // Each MPEG4DataSource caches the sampletable metadata for a single track.
 
 struct MPEG4DataSource : public DataSource {
     MPEG4DataSource(const sp<DataSource> &source);
 
-    virtual status_t initCheck() const;
-    virtual ssize_t readAt(off64_t offset, void *data, size_t size);
-    virtual status_t getSize(off64_t *size);
-    virtual uint32_t flags();
+    status_t initCheck() const override;
+    ssize_t readAt(off64_t offset, void *data, size_t size) override;
+    status_t getSize(off64_t *size) override;
+    uint32_t flags() override;
 
     status_t setCachedRange(off64_t offset, size_t size);
 
 protected:
     virtual ~MPEG4DataSource();
 
 private:
     Mutex mLock;
 
     sp<DataSource> mSource;
     off64_t mCachedOffset;
     size_t mCachedSize;
     uint8_t *mCache;
 
     void clearCache();
 
-    MPEG4DataSource(const MPEG4DataSource &);
-    MPEG4DataSource &operator=(const MPEG4DataSource &);
+    MPEG4DataSource(const MPEG4DataSource &) = delete;
+    MPEG4DataSource &operator=(const MPEG4DataSource &) = delete;
 };
 
 MPEG4DataSource::MPEG4DataSource(const sp<DataSource> &source)
     : mSource(source),
       mCachedOffset(0),
       mCachedSize(0),
       mCache(NULL) {
 }
@@ -995,27 +995,16 @@ status_t MPEG4Extractor::parseChunk(off6
             }
             mLastTrack->meta->setInt32(kKeyCryptoMode, defaultAlgorithmId);
             mLastTrack->meta->setInt32(kKeyCryptoDefaultIVSize, defaultIVSize);
             mLastTrack->meta->setData(kKeyCryptoKey, 'tenc', defaultKeyId, 16);
             *offset += chunk_size;
             break;
         }
 
-        case FOURCC('t', 'r', 'e', 'x'):
-        {
-            status_t err;
-            if ((err = parseTrackExtends(data_offset, chunk_data_size)) != OK) {
-                return err;
-            }
-
-            *offset += chunk_size;
-            break;
-        }
-
         case FOURCC('t', 'k', 'h', 'd'):
         {
             status_t err;
             if ((err = parseTrackHeader(data_offset, chunk_data_size)) != OK) {
                 return err;
             }
 
             *offset += chunk_size;
@@ -2140,37 +2129,16 @@ status_t MPEG4Extractor::parseSegmentInd
     }
     int64_t metaDuration;
     if (!mLastTrack->meta->findInt64(kKeyDuration, &metaDuration) || metaDuration == 0) {
         mLastTrack->meta->setInt64(kKeyDuration, mSidxDuration);
     }
     return OK;
 }
 
-status_t MPEG4Extractor::parseTrackExtends(
-    off64_t data_offset, off64_t data_size) {
-    if (data_size != 24) {
-        return ERROR_MALFORMED;
-    }
-    uint8_t buffer[24];
-    if (mDataSource->readAt(data_offset, buffer, 24) < 24) {
-        return ERROR_IO;
-    }
-    mTrackExtends.mVersion = buffer[0];
-    mTrackExtends.mFlags[0] = buffer[1];
-    mTrackExtends.mFlags[1] = buffer[2];
-    mTrackExtends.mFlags[2] = buffer[3];
-    mTrackExtends.mTrackId = U32_AT(&buffer[4]);
-    mTrackExtends.mDefaultSampleDescriptionIndex = U32_AT(&buffer[8]);
-    mTrackExtends.mDefaultSampleDuration = U32_AT(&buffer[12]);
-    mTrackExtends.mDefaultSampleSize = U32_AT(&buffer[16]);
-    mTrackExtends.mDefaultSampleFlags = U32_AT(&buffer[20]);
-    return OK;
-}
-
 status_t MPEG4Extractor::parseTrackHeader(
         off64_t data_offset, off64_t data_size) {
     if (data_size < 4) {
         return ERROR_MALFORMED;
     }
 
     uint8_t version;
     if (mDataSource->readAt(data_offset, &version, 1) < 1) {
--- a/media/libstagefright/frameworks/av/media/libstagefright/include/MPEG4Extractor.h
+++ b/media/libstagefright/frameworks/av/media/libstagefright/include/MPEG4Extractor.h
@@ -38,43 +38,25 @@ struct SidxEntry {
     size_t mSize;
     uint32_t mDurationUs;
 };
 
 class MPEG4Extractor : public MediaExtractor {
 public:
     MPEG4Extractor(const sp<DataSource> &source);
 
-    virtual size_t countTracks();
-    virtual sp<MediaSource> getTrack(size_t index);
-    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
+    size_t countTracks() override;
+    sp<MediaSource> getTrack(size_t index) override;
+    sp<MetaData> getTrackMetaData(size_t index, uint32_t flags) override;
 
-    virtual sp<MetaData> getMetaData();
-    virtual uint32_t flags() const;
+    sp<MetaData> getMetaData() override;
+    uint32_t flags() const override;
 
     // for DRM
-    virtual char* getDrmTrackInfo(size_t trackID, int *len);
-
-    struct TrackExtends {
-        TrackExtends(): mVersion(0), mTrackId(0),
-                mDefaultSampleDescriptionIndex(0), mDefaultSampleDuration(0),
-                mDefaultSampleSize(0), mDefaultSampleFlags(0)
-        {
-            mFlags[0] = 0;
-            mFlags[1] = 0;
-            mFlags[2] = 0;
-        }
-        uint8_t mVersion;
-        uint8_t mFlags[3];
-        uint32_t mTrackId;
-        uint32_t mDefaultSampleDescriptionIndex;
-        uint32_t mDefaultSampleDuration;
-        uint32_t mDefaultSampleSize;
-        uint32_t mDefaultSampleFlags;
-    };
+    char* getDrmTrackInfo(size_t trackID, int *len) override;
 
 protected:
     virtual ~MPEG4Extractor();
 
 private:
 
     struct PsshInfo {
         uint8_t uuid[16];
@@ -130,23 +112,20 @@ private:
         uint8_t IPMPDescriptorID;
         ssize_t len;
         char *IPMPData;
     };
 
     SINF *mFirstSINF;
 
     bool mIsDrm;
-    TrackExtends mTrackExtends;
     uint32_t mDrmScheme;
 
     status_t parseDrmSINF(off64_t *offset, off64_t data_offset);
 
-    status_t parseTrackExtends(off64_t data_offset, off64_t data_size);
-
     status_t parseTrackHeader(off64_t data_offset, off64_t data_size);
 
     status_t parseSegmentIndex(off64_t data_offset, size_t data_size);
 
     void storeEditList();
 
     MPEG4Extractor(const MPEG4Extractor &);
     MPEG4Extractor &operator=(const MPEG4Extractor &);