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"
|
2016-01-18 02:21:59 +03:00
|
|
|
#include "MediaFormatReader.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
|
|
|
|
2016-01-18 06:46:10 +03:00
|
|
|
MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
|
|
|
|
MediaDecoderStateMachine* CreateStateMachine() override;
|
|
|
|
nsresult Load(nsIStreamListener**) override;
|
|
|
|
media::TimeIntervals GetSeekable() override;
|
2015-06-18 00:22:10 +03:00
|
|
|
media::TimeIntervals GetBuffered() override;
|
2013-09-27 09:22:37 +04:00
|
|
|
|
2016-05-04 11:13:25 +03:00
|
|
|
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.
|
2016-01-18 06:46:10 +03:00
|
|
|
double GetDuration() override;
|
2015-02-12 10:52:12 +03:00
|
|
|
|
2015-02-04 12:20:15 +03:00
|
|
|
void SetInitialDuration(int64_t aDuration);
|
2016-07-15 16:38:33 +03:00
|
|
|
void SetMediaSourceDuration(double aDuration);
|
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.
|
2017-01-18 11:51:31 +03:00
|
|
|
void GetMozDebugReaderData(nsACString& aString) override;
|
2015-01-29 05:35:58 +03:00
|
|
|
|
2015-08-21 01:10:33 +03:00
|
|
|
void AddSizeOfResources(ResourceSizes* aSizes) override;
|
|
|
|
|
2015-12-02 05:01:40 +03:00
|
|
|
MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
|
2015-12-02 07:09:47 +03:00
|
|
|
bool CanPlayThrough() override;
|
2015-12-02 05:01:40 +03:00
|
|
|
|
2016-08-21 23:51:01 +03:00
|
|
|
void NotifyWaitingForKey() override;
|
|
|
|
|
|
|
|
MediaEventSource<void>* WaitingForKeyEvent() override;
|
|
|
|
|
2017-02-08 13:15:28 +03:00
|
|
|
bool IsMSE() const override { return true; }
|
|
|
|
|
2017-04-27 20:53:53 +03:00
|
|
|
void NotifyInitDataArrived();
|
|
|
|
|
2013-09-27 09:22:37 +04:00
|
|
|
private:
|
2015-01-16 15:49:02 +03:00
|
|
|
void DoSetMediaSourceDuration(double aDuration);
|
2016-05-02 08:21:40 +03:00
|
|
|
media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
|
2015-01-16 15:49:02 +03:00
|
|
|
|
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-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaSourceDemuxer> mDemuxer;
|
2016-01-18 02:21:59 +03:00
|
|
|
RefPtr<MediaFormatReader> mReader;
|
2016-08-21 23:51:01 +03:00
|
|
|
MediaEventProducer<void> mWaitingForKeyEvent;
|
2015-06-12 02:26:57 +03:00
|
|
|
|
2016-08-08 06:56:38 +03:00
|
|
|
bool mEnded;
|
2013-09-27 09:22:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASOURCEDECODER_H_ */
|