Bug 1330284 - Use MediaCodecs::Range() in DecoderTraits:CanHandleCodecsType() - r?jya draft
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 22 Dec 2016 10:12:42 +1100
changeset 460043 8de4988b0fe4adadcf73680819175768883d3d81
parent 460042 f4819fa9c01f6cdb870e868511b201b8af0621c0
child 460044 9c8e146cb88ce0e03cf2824120312c944e2ea90e
push id41348
push usergsquelart@mozilla.com
push dateThu, 12 Jan 2017 20:50:49 +0000
reviewersjya
bugs1330284
milestone53.0a1
Bug 1330284 - Use MediaCodecs::Range() in DecoderTraits:CanHandleCodecsType() - r?jya MozReview-Commit-ID: EFiDpSKw2JN
dom/media/DecoderTraits.cpp
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -2,17 +2,16 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DecoderTraits.h"
 #include "MediaContentType.h"
 #include "MediaDecoder.h"
-#include "nsCharSeparatedTokenizer.h"
 #include "nsMimeTypes.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 
 #include "OggDecoder.h"
 #include "OggDemuxer.h"
 
 #include "WebMDecoder.h"
@@ -175,31 +174,21 @@ CanHandleCodecsType(const MediaContentTy
   }
 #endif
   if (!codecList) {
     return CANPLAY_MAYBE;
   }
 
   // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description
   // of the 'codecs' parameter
-  nsCharSeparatedTokenizer
-    tokenizer(aType.ExtendedType().Codecs().AsString(), ',');
-  bool expectMoreTokens = false;
-  while (tokenizer.hasMoreTokens()) {
-    const nsSubstring& token = tokenizer.nextToken();
-
+  for (const auto& token : aType.ExtendedType().Codecs().Range()) {
     if (!CodecListContains(codecList, token)) {
       // Totally unsupported codec
       return CANPLAY_NO;
     }
-    expectMoreTokens = tokenizer.separatorAfterCurrentToken();
-  }
-  if (expectMoreTokens) {
-    // Last codec name was empty
-    return CANPLAY_NO;
   }
 
   return CANPLAY_YES;
 }
 
 static
 CanPlayStatus
 CanHandleMediaType(const MediaContentType& aType,