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_
|
|
|
|
|
2014-08-13 16:22:00 +04:00
|
|
|
#include "MediaDecoder.h"
|
2017-08-15 07:13:00 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-09-27 09:22:37 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class MediaDecoderStateMachine;
|
2015-06-12 02:26:57 +03:00
|
|
|
class MediaSourceDemuxer;
|
2017-08-03 10:38:28 +03:00
|
|
|
class MediaSourceResource;
|
2013-09-27 09:22:37 +04:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class MediaSource;
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
|
|
|
|
class MediaSourceDecoder : public MediaDecoder
|
|
|
|
{
|
|
|
|
public:
|
2017-06-07 07:14:11 +03:00
|
|
|
explicit MediaSourceDecoder(MediaDecoderInit& aInit);
|
2013-09-27 09:22:37 +04:00
|
|
|
|
2017-08-03 10:38:28 +03:00
|
|
|
MediaResource* GetResource() const override final;
|
|
|
|
|
2017-08-17 09:35:38 +03:00
|
|
|
MediaDecoderStateMachine* CreateStateMachine() override;
|
2017-06-23 10:39:57 +03:00
|
|
|
nsresult Load(nsIPrincipal* aPrincipal);
|
2016-01-18 06:46:10 +03:00
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
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);
|
2017-08-04 12:38:20 +03:00
|
|
|
bool CanPlayThroughImpl() override;
|
2015-01-16 15:49:02 +03:00
|
|
|
|
2017-08-03 10:38:28 +03:00
|
|
|
RefPtr<MediaSourceResource> mResource;
|
|
|
|
|
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;
|
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_ */
|