Bug 1369950 - Update av1 mimetype when vendoring. r=froydnj,gerald
authorRalph Giles <giles@mozilla.com>
Fri, 02 Jun 2017 20:32:17 -0700
changeset 410544 e709485195e6ca9855a618036297ae5b988f7169
parent 410543 2d7a5edd935126b48e9dc389906bd11213c23648
child 410545 67152605b3678f74e688dca131c7cf9073e3e7c9
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, gerald
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 1369950 - Update av1 mimetype when vendoring. r=froydnj,gerald We record the commit id of the aom library we vendor in the gecko source so we can check it as part of the mimetype to verify compatibility with the encoder while the stream format is under development. Make the vendor script update the hash in the code, just like we do with README_MOZILLA. This can be removed when the bitstream becomes stable. MozReview-Commit-ID: 9zBiFhcEy2N
--- a/python/mozbuild/mozbuild/vendor_aom.py
+++ b/python/mozbuild/mozbuild/vendor_aom.py
@@ -81,16 +81,52 @@ class VendorAOM(MozbuildObject):
             new_readme = '%s\n\n%s %s.' % (readme, prefix, revision)
         if readme != new_readme:
             with open(filename, 'w') as f:
+    def update_mimetype(self, revision):
+        '''Update source tree references to the aom revision.
+        While the av1 bitstream is unstable, we track the git revision
+        of the reference implementation we're building, and are careful
+        to build with default feature flags. This lets us answer whether
+        a particular bitstream will be playable by comparing the encode-
+        side hash as part of the mime type.
+        '''
+        filename = mozpath.join(self.topsrcdir,
+                'dom/media/platforms/agnostic/AOMDecoder.cpp')
+        with open(filename) as f:
+            source = f.read()
+        new_source = ''
+        pattern = re.compile('version.AppendLiteral\("([a-f0-9]{40})"\);')
+        match = pattern.search(source)
+        if match:
+            old_revision = match.group(1)
+            if old_revision == revision:
+                # Nothing to update.
+                return
+            new_source = pattern.sub('version.AppendLiteral("%s");' % revision,
+                                     source)
+        if not match or new_source == source:
+            self.log(logging.ERROR, 'hash_update', {},
+                     '''Couldn't update commit hash in
+    {file}.
+Please check manually and update the vendor script.
+                     '''.format(file=filename))
+            sys.exit(1)
+        with open(filename, 'w') as f:
+            f.write(new_source)
     def clean_upstream(self, target):
         '''Remove files we don't want to import.'''
         mozfile.remove(mozpath.join(target, '.gitattributes'))
         mozfile.remove(mozpath.join(target, '.gitignore'))
         mozfile.remove(mozpath.join(target, 'build', '.gitattributes'))
         mozfile.remove(mozpath.join(target, 'build' ,'.gitignore'))
     def generate_sources(self, target):
@@ -140,16 +176,19 @@ Please commit or stash these changes bef
         self.fetch_and_unpack(commit, vendor_dir)
         self.log(logging.INFO, 'clean_upstream', {},
                  '''Removing unnecessary files.''')
         glue_dir = mozpath.join(self.topsrcdir, 'media/libaom')
         self.log(logging.INFO, 'generate_sources', {},
                  '''Generating build files...''')
+        self.log(logging.INFO, 'update_source', {},
+                 '''Updating mimetype extension.''')
+        self.update_mimetype(commit)
         self.log(logging.INFO, 'update_readme', {},
                  '''Updating README_MOZILLA.''')
         self.update_readme(commit, timestamp, glue_dir)
         self.log(logging.INFO, 'add_remove_files', {},
                  '''Registering changes with version control.''')