Bug 1350246 - [Part7] Create HLSResource if the mimetype is HLS.
MozReview-Commit-ID: HTUaA2zwYVH
--- 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