Bug 1350246 - [Part7] Create HLSResource if the mimetype is HLS. draft
authorJames Cheng <jacheng@mozilla.com>
Fri, 05 May 2017 16:03:39 +0800
changeset 592559 bcb1f3426052aa24ddd031cb1e12b363bb3727dd
parent 592558 5b20044cb06dafb2064d19f151e5d20ed8a20986
child 592560 cd62559f10b5a7aaa4ed423b2c9c82f4ba8f22e9
push id63431
push userbmo:jacheng@mozilla.com
push dateMon, 12 Jun 2017 12:38:14 +0000
bugs1350246
milestone55.0a1
Bug 1350246 - [Part7] Create HLSResource if the mimetype is HLS. MozReview-Commit-ID: HTUaA2zwYVH
dom/media/MediaResource.cpp
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "mozilla/DebugOnly.h"
 
+#include "DecoderTraits.h"
 #include "MediaResource.h"
 #include "MediaResourceCallback.h"
 
 #include "mozilla/Mutex.h"
 #include "nsDebug.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
 #include "nsIFile.h"
@@ -27,16 +28,20 @@
 #include "nsICachingChannel.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsContentUtils.h"
 #include "nsHostObjectProtocolHandler.h"
 #include <algorithm>
 #include "nsProxyRelease.h"
 #include "nsIContentPolicy.h"
 
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+#include "HLSResource.h"
+#endif
+
 using mozilla::media::TimeUnit;
 
 #undef LOG
 #undef ILOG
 
 mozilla::LazyLogModule gMediaResourceLog("MediaResource");
 // Debug logging macro with object pointer and class name.
 #define LOG(msg, ...) MOZ_LOG(gMediaResourceLog, mozilla::LogLevel::Debug, \
@@ -1542,16 +1547,23 @@ MediaResource::Create(MediaResourceCallb
   aChannel->GetContentType(contentTypeString);
   Maybe<MediaContainerType> containerType = MakeMediaContainerType(contentTypeString);
   if (!containerType) {
     return nullptr;
   }
 
   RefPtr<MediaResource> resource;
 
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+  if (DecoderTraits::IsHttpLiveStreamingType(containerType.value())) {
+    resource = new HLSResource(aCallback, aChannel, uri, *containerType);
+    return resource.forget();
+  }
+#endif
+
   // Let's try to create a FileMediaResource in case the channel is a nsIFile
   nsCOMPtr<nsIFileChannel> fc = do_QueryInterface(aChannel);
   if (fc) {
     resource = new FileMediaResource(aCallback, aChannel, uri, *containerType);
   }
 
   // If the URL is blobURL with a seekable inputStream, we can still use a
   // FileMediaResource. This basically means that the blobURL and its Blob have