Bug 1254731: [mp4] P2. Remove unused parsing of creation date. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 15 Mar 2016 09:04:35 +1100
changeset 288913 1bc37c8758c3c8b2ecc4e2101ad8a44ab3ac4e29
parent 288912 621392c805bb87b273138fd8a057cc151503f0aa
child 288914 f437498da477bac3d8e9852e67c89d6a5c0d7422
push id73612
push userjyavenard@mozilla.com
push dateWed, 16 Mar 2016 05:56:49 +0000
treeherdermozilla-inbound@1bc37c8758c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1254731
milestone48.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 1254731: [mp4] P2. Remove unused parsing of creation date. r=gerald We just don't care about it in our use. Additionally, gmtime and strftime are not thread safe at all (they use global static internally) MozReview-Commit-ID: HfRpCyx4MpK
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -32,19 +32,16 @@
 #include <media/stagefright/foundation/ABitReader.h>
 #include <media/stagefright/foundation/ABuffer.h>
 #include <media/stagefright/foundation/ADebug.h>
 #include <media/stagefright/foundation/AMessage.h>
 #include <media/stagefright/MediaBuffer.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MediaSource.h>
 #include <media/stagefright/MetaData.h>
-#include <utils/String8.h>
-
-#include <limits>
 
 static const uint32_t kMAX_ALLOCATION =
     (SIZE_MAX < INT32_MAX ? SIZE_MAX : INT32_MAX) - 128;
 
 namespace stagefright {
 
 class MPEG4Source : public MediaSource {
 public:
@@ -620,45 +617,16 @@ private:
 static bool underMetaDataPath(const nsTArray<uint32_t> &path) {
     return path.Length() >= 5
         && path[0] == FOURCC('m', 'o', 'o', 'v')
         && path[1] == FOURCC('u', 'd', 't', 'a')
         && path[2] == FOURCC('m', 'e', 't', 'a')
         && path[3] == FOURCC('i', 'l', 's', 't');
 }
 
-// Given a time in seconds since Jan 1 1904, produce a human-readable string.
-static bool convertTimeToDate(int64_t time_1904, String8 *s) {
-    if (!s) {
-        return false;
-    }
-
-    int64_t time_1970 = time_1904 - (((66 * 365 + 17) * 24) * 3600);
-    if (time_1970 < 0) {
-        return false;
-    }
-    if (time_1970 >= std::numeric_limits<time_t>::max()) {
-        return false;
-    }
-    time_t time_checked = time_1970;
-
-    struct tm* time_gm = gmtime(&time_checked);
-    if (!time_gm) {
-        return false;
-    }
-
-    char tmp[32];
-    if (!strftime(tmp, sizeof(tmp), "%Y%m%dT%H%M%S.000Z", time_gm)) {
-        return false;
-    }
-
-    s->setTo(tmp);
-    return true;
-}
-
 static bool ValidInputSize(int32_t size) {
   // Reject compressed samples larger than an uncompressed UHD
   // frame. This is a reasonable cut-off for a lossy codec,
   // combined with the current Firefox limit to 5k video.
   return (size > 0 && size <= 4 * (1920 * 1080) * 3 / 2);
 }
 
 status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
@@ -1778,32 +1746,24 @@ status_t MPEG4Extractor::parseChunk(off6
 
             uint8_t header[24];
             if (mDataSource->readAt(
                         data_offset, header, sizeof(header))
                     < (ssize_t)sizeof(header)) {
                 return ERROR_IO;
             }
 
-            uint64_t creationTime;
             if (header[0] == 1) {
-                creationTime = U64_AT(&header[4]);
                 mHeaderTimescale = U32_AT(&header[20]);
             } else if (header[0] != 0) {
                 return ERROR_MALFORMED;
             } else {
-                creationTime = U32_AT(&header[4]);
                 mHeaderTimescale = U32_AT(&header[12]);
             }
 
-            String8 s;
-            if (convertTimeToDate(creationTime, &s)) {
-                mFileMetaData->setCString(kKeyDate, s.string());
-            }
-
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('m', 'e', 'h', 'd'):
         {
             if (chunk_data_size < 8) {
                 return ERROR_MALFORMED;