2013-09-27 09:22:37 +04: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 MOZILLA_MEDIASOURCEDECODER_H_
|
|
|
|
#define MOZILLA_MEDIASOURCEDECODER_H_
|
|
|
|
|
2015-06-12 02:26:57 +03:00
|
|
|
#include "mozilla/Atomics.h"
|
2013-09-27 09:22:37 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsError.h"
|
2014-08-13 16:22:00 +04:00
|
|
|
#include "MediaDecoder.h"
|
2013-09-27 09:22:37 +04:00
|
|
|
|
|
|
|
class nsIStreamListener;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-04-14 15:24:00 +04:00
|
|
|
class MediaResource;
|
2013-09-27 09:22:37 +04:00
|
|
|
class MediaDecoderStateMachine;
|
2014-08-22 06:14:36 +04:00
|
|
|
class SourceBufferDecoder;
|
2014-09-04 05:57:06 +04:00
|
|
|
class TrackBuffer;
|
2015-01-16 15:49:02 +03:00
|
|
|
enum MSRangeRemovalAction : uint8_t;
|
2015-06-12 02:26:57 +03:00
|
|
|
class MediaSourceDemuxer;
|
2013-09-27 09:22:37 +04:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class HTMLMediaElement;
|
|
|
|
class MediaSource;
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
|
|
|
|
class MediaSourceDecoder : public MediaDecoder
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:50:23 +04:00
|
|
|
explicit MediaSourceDecoder(dom::HTMLMediaElement* aElement);
|
2013-09-27 09:22:37 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual MediaDecoder* Clone() override;
|
|
|
|
virtual MediaDecoderStateMachine* CreateStateMachine() override;
|
|
|
|
virtual nsresult Load(nsIStreamListener**, MediaDecoder*) override;
|
2015-05-18 09:15:47 +03:00
|
|
|
virtual media::TimeIntervals GetSeekable() override;
|
2015-06-18 00:22:10 +03:00
|
|
|
media::TimeIntervals GetBuffered() override;
|
2013-09-27 09:22:37 +04:00
|
|
|
|
2015-06-30 01:01:50 +03:00
|
|
|
// We can't do this in the constructor because we don't know what type of
|
|
|
|
// media we're dealing with by that point.
|
|
|
|
void NotifyDormantSupported(bool aSupported)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
mDormantSupported = aSupported;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Shutdown() override;
|
2014-08-25 08:09:44 +04:00
|
|
|
|
2014-10-15 05:17:03 +04:00
|
|
|
static already_AddRefed<MediaResource> CreateResource(nsIPrincipal* aPrincipal = nullptr);
|
2014-04-14 15:24:00 +04:00
|
|
|
|
2013-11-18 08:22:47 +04:00
|
|
|
void AttachMediaSource(dom::MediaSource* aMediaSource);
|
2013-09-27 09:22:37 +04:00
|
|
|
void DetachMediaSource();
|
|
|
|
|
2015-03-23 13:08:05 +03:00
|
|
|
void Ended(bool aEnded);
|
2014-08-26 11:25:09 +04:00
|
|
|
|
2015-02-12 10:52:12 +03:00
|
|
|
// Return the duration of the video in seconds.
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual double GetDuration() override;
|
2015-02-12 10:52:12 +03:00
|
|
|
|
2015-02-04 12:20:15 +03:00
|
|
|
void SetInitialDuration(int64_t aDuration);
|
2015-01-16 15:49:02 +03:00
|
|
|
void SetMediaSourceDuration(double aDuration, MSRangeRemovalAction aAction);
|
2014-11-12 07:11:33 +03:00
|
|
|
double GetMediaSourceDuration();
|
2014-08-25 08:09:44 +04:00
|
|
|
|
2015-06-12 02:26:57 +03:00
|
|
|
MediaSourceDemuxer* GetDemuxer()
|
|
|
|
{
|
|
|
|
return mDemuxer;
|
|
|
|
}
|
2014-12-09 22:43:21 +03:00
|
|
|
|
2015-01-29 05:35:58 +03:00
|
|
|
// Returns a string describing the state of the MediaSource internal
|
|
|
|
// buffered data. Used for debugging purposes.
|
|
|
|
void GetMozDebugReaderData(nsAString& aString);
|
|
|
|
|
2013-09-27 09:22:37 +04:00
|
|
|
private:
|
2015-01-16 15:49:02 +03:00
|
|
|
void DoSetMediaSourceDuration(double aDuration);
|
|
|
|
|
2014-04-21 17:30:00 +04:00
|
|
|
// The owning MediaSource holds a strong reference to this decoder, and
|
|
|
|
// calls Attach/DetachMediaSource on this decoder to set and clear
|
|
|
|
// mMediaSource.
|
2013-11-18 08:22:47 +04:00
|
|
|
dom::MediaSource* mMediaSource;
|
2015-06-12 02:26:57 +03:00
|
|
|
nsRefPtr<MediaSourceDemuxer> mDemuxer;
|
|
|
|
|
|
|
|
Atomic<bool> mEnded;
|
2013-09-27 09:22:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASOURCEDECODER_H_ */
|