1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include "MediaDecoder.h"
11 #include "mozilla/java/GeckoHLSResourceWrapperWrappers.h"
15 class HLSResourceCallbacksSupport
;
17 class HLSDecoder final
: public MediaDecoder
{
19 static RefPtr
<HLSDecoder
> Create(MediaDecoderInit
& aInit
);
21 // Returns true if the HLS backend is pref'ed on.
22 static bool IsEnabled();
24 // Returns true if aContainerType is an HLS type that we think we can render
25 // with the a platform decoder backend.
26 // If provided, codecs are checked for support.
27 static bool IsSupportedType(const MediaContainerType
& aContainerType
);
29 nsresult
Load(nsIChannel
* aChannel
);
31 // MediaDecoder interface.
34 void Pause() override
;
36 void AddSizeOfResources(ResourceSizes
* aSizes
) override
;
37 already_AddRefed
<nsIPrincipal
> GetCurrentPrincipal() override
;
38 bool HadCrossOriginRedirects() override
;
39 bool IsTransportSeekable() override
{ return true; }
40 void Suspend() override
;
41 void Resume() override
;
42 void Shutdown() override
;
44 // Called as data arrives on the underlying HLS player. Main thread only.
45 void NotifyDataArrived();
47 // Called when Exoplayer start to load media. Main thread only.
48 void NotifyLoad(nsCString aMediaUrl
);
51 friend class HLSResourceCallbacksSupport
;
53 explicit HLSDecoder(MediaDecoderInit
& aInit
);
55 MediaDecoderStateMachineBase
* CreateStateMachine(
56 bool aDisableExternalEngine
) override
;
58 bool CanPlayThroughImpl() final
{
59 // TODO: We don't know how to estimate 'canplaythrough' for this decoder.
60 // For now we just return true for 'autoplay' can work.
64 void UpdateCurrentPrincipal(nsCString aMediaUrl
);
65 already_AddRefed
<nsIPrincipal
> GetContentPrincipal(nsCString aMediaUrl
);
67 static size_t sAllocatedInstances
; // Access only in the main thread.
69 nsCOMPtr
<nsIChannel
> mChannel
;
70 nsCOMPtr
<nsIURI
> mURI
;
71 java::GeckoHLSResourceWrapper::GlobalRef mHLSResourceWrapper
;
72 java::GeckoHLSResourceWrapper::Callbacks::GlobalRef mJavaCallbacks
;
73 RefPtr
<HLSResourceCallbacksSupport
> mCallbackSupport
;
74 nsCOMPtr
<nsIPrincipal
> mContentPrincipal
;
77 } // namespace mozilla
79 #endif /* HLSDecoder_h_ */