2017-05-05 11:40:29 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef HLSDecoder_h_
|
|
|
|
#define HLSDecoder_h_
|
|
|
|
|
2017-07-26 21:52:07 +03:00
|
|
|
#include "MediaDecoder.h"
|
2017-10-05 10:27:15 +03:00
|
|
|
#include "GeneratedJNIWrappers.h"
|
2017-05-05 11:40:29 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-08-30 09:14:32 +03:00
|
|
|
class HLSResourceCallbacksSupport;
|
|
|
|
|
2017-07-26 21:52:07 +03:00
|
|
|
class HLSDecoder final : public MediaDecoder {
|
2017-05-05 11:40:29 +03:00
|
|
|
public:
|
2019-02-21 04:22:02 +03:00
|
|
|
static RefPtr<HLSDecoder> Create(MediaDecoderInit& aInit);
|
2017-07-26 18:26:17 +03:00
|
|
|
|
2017-06-19 10:50:09 +03:00
|
|
|
// Returns true if the HLS backend is pref'ed on.
|
|
|
|
static bool IsEnabled();
|
2017-05-05 11:40:29 +03:00
|
|
|
|
2017-06-19 10:50:09 +03:00
|
|
|
// Returns true if aContainerType is an HLS type that we think we can render
|
|
|
|
// with the a platform decoder backend.
|
|
|
|
// If provided, codecs are checked for support.
|
|
|
|
static bool IsSupportedType(const MediaContainerType& aContainerType);
|
2017-05-05 11:40:29 +03:00
|
|
|
|
2017-07-26 21:54:53 +03:00
|
|
|
nsresult Load(nsIChannel* aChannel);
|
2017-07-20 12:47:54 +03:00
|
|
|
|
2019-02-21 04:22:02 +03:00
|
|
|
// MediaDecoder interface.
|
2018-05-02 18:27:27 +03:00
|
|
|
void Play() override;
|
2017-07-20 12:47:54 +03:00
|
|
|
|
|
|
|
void Pause() override;
|
2017-08-03 10:38:28 +03:00
|
|
|
|
2017-08-24 12:35:24 +03:00
|
|
|
void AddSizeOfResources(ResourceSizes* aSizes) override;
|
2017-08-24 11:58:06 +03:00
|
|
|
already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
|
2019-06-04 09:32:37 +03:00
|
|
|
bool HadCrossOriginRedirects() override;
|
2017-08-23 19:06:23 +03:00
|
|
|
bool IsTransportSeekable() override { return true; }
|
2017-08-07 13:09:56 +03:00
|
|
|
void Suspend() override;
|
|
|
|
void Resume() override;
|
2017-08-30 09:14:32 +03:00
|
|
|
void Shutdown() override;
|
2017-08-07 13:09:56 +03:00
|
|
|
|
2017-11-30 06:07:13 +03:00
|
|
|
// Called as data arrives on the underlying HLS player. Main thread only.
|
|
|
|
void NotifyDataArrived();
|
|
|
|
|
2017-08-03 10:38:28 +03:00
|
|
|
private:
|
2017-08-30 09:14:32 +03:00
|
|
|
friend class HLSResourceCallbacksSupport;
|
|
|
|
|
2019-02-21 04:22:02 +03:00
|
|
|
explicit HLSDecoder(MediaDecoderInit& aInit);
|
|
|
|
~HLSDecoder();
|
2017-08-15 08:52:17 +03:00
|
|
|
MediaDecoderStateMachine* CreateStateMachine();
|
|
|
|
|
2018-02-06 09:50:00 +03:00
|
|
|
bool CanPlayThroughImpl() final {
|
2017-08-07 06:48:43 +03:00
|
|
|
// TODO: We don't know how to estimate 'canplaythrough' for this decoder.
|
|
|
|
// For now we just return true for 'autoplay' can work.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-02-21 04:22:02 +03:00
|
|
|
static size_t sAllocatedInstances; // Access only in the main thread.
|
|
|
|
|
2017-08-30 09:14:32 +03:00
|
|
|
nsCOMPtr<nsIChannel> mChannel;
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
java::GeckoHLSResourceWrapper::GlobalRef mHLSResourceWrapper;
|
|
|
|
java::GeckoHLSResourceWrapper::Callbacks::GlobalRef mJavaCallbacks;
|
|
|
|
RefPtr<HLSResourceCallbacksSupport> mCallbackSupport;
|
2017-05-05 11:40:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* HLSDecoder_h_ */
|