Bug 1254731: [mp4] P2. Remove unused parsing of creation date. r=gerald a=lizzard
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 15 Mar 2016 09:04:35 +1100
changeset 323818 9a085dffa2eab4094761233eb62655753822e23b
parent 323817 5dc679605d0b2397af99f4d072b71607721c41bc
child 323819 bceb0dcb8897b62191997048868272a836acdce1
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, lizzard
bugs1254731
milestone47.0a2
Bug 1254731: [mp4] P2. Remove unused parsing of creation date. r=gerald a=lizzard 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;