Bug 1839170 - Refactor Snap pulling, Add Firefox Snap Core22 and GNOME 42 SDK symbols...
[gecko.git] / dom / media / hls / HLSDecoder.h
blob0f6545776566f7531ee38753c108de3cb774c953
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/. */
7 #ifndef HLSDecoder_h_
8 #define HLSDecoder_h_
10 #include "MediaDecoder.h"
11 #include "mozilla/java/GeckoHLSResourceWrapperWrappers.h"
13 namespace mozilla {
15 class HLSResourceCallbacksSupport;
17 class HLSDecoder final : public MediaDecoder {
18 public:
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.
32 void Play() override;
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);
50 private:
51 friend class HLSResourceCallbacksSupport;
53 explicit HLSDecoder(MediaDecoderInit& aInit);
54 ~HLSDecoder();
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.
61 return true;
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_ */