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_
|
|
|
|
|
|
|
|
#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-17 15:29:00 +04:00
|
|
|
class MediaSourceReader;
|
2014-08-22 06:14:36 +04:00
|
|
|
class SourceBufferDecoder;
|
2014-09-04 05:57:06 +04:00
|
|
|
class TrackBuffer;
|
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
|
|
|
|
2013-09-27 09:22:38 +04:00
|
|
|
virtual MediaDecoder* Clone() MOZ_OVERRIDE;
|
|
|
|
virtual MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE;
|
|
|
|
virtual nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE;
|
2013-11-18 08:22:47 +04:00
|
|
|
virtual nsresult GetSeekable(dom::TimeRanges* aSeekable) MOZ_OVERRIDE;
|
2013-09-27 09:22:37 +04:00
|
|
|
|
2014-08-25 08:09:44 +04:00
|
|
|
virtual void Shutdown() MOZ_OVERRIDE;
|
|
|
|
|
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();
|
|
|
|
|
2014-08-22 06:14:36 +04:00
|
|
|
already_AddRefed<SourceBufferDecoder> CreateSubDecoder(const nsACString& aType);
|
2014-09-04 05:57:06 +04:00
|
|
|
void AddTrackBuffer(TrackBuffer* aTrackBuffer);
|
|
|
|
void RemoveTrackBuffer(TrackBuffer* aTrackBuffer);
|
|
|
|
void OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo);
|
2014-02-28 04:54:48 +04:00
|
|
|
|
2014-08-26 11:25:09 +04:00
|
|
|
void Ended();
|
2014-11-12 07:50:20 +03:00
|
|
|
bool IsExpectingMoreData() MOZ_OVERRIDE;
|
2014-08-26 11:25:09 +04:00
|
|
|
|
2014-11-12 07:11:33 +03:00
|
|
|
void SetDecodedDuration(int64_t aDuration);
|
2014-08-25 08:09:44 +04:00
|
|
|
void SetMediaSourceDuration(double aDuration);
|
2014-11-12 07:11:33 +03:00
|
|
|
double GetMediaSourceDuration();
|
|
|
|
void DurationChanged(double aOldDuration, double aNewDuration);
|
2014-08-25 08:09:44 +04:00
|
|
|
|
2014-09-07 15:54:00 +04:00
|
|
|
// Called whenever a TrackBuffer has new data appended or a new decoder
|
|
|
|
// initializes. Safe to call from any thread.
|
|
|
|
void NotifyTimeRangesChanged();
|
2014-08-25 08:09:44 +04:00
|
|
|
|
2014-09-05 04:04:54 +04:00
|
|
|
// Indicates the point in time at which the reader should consider
|
|
|
|
// registered TrackBuffers essential for initialization.
|
|
|
|
void PrepareReaderInitialization();
|
|
|
|
|
2014-10-14 02:05:00 +04:00
|
|
|
#ifdef MOZ_EME
|
|
|
|
virtual nsresult SetCDMProxy(CDMProxy* aProxy) MOZ_OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
2013-09-27 09:22:37 +04:00
|
|
|
private:
|
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;
|
2014-08-17 15:29:00 +04:00
|
|
|
nsRefPtr<MediaSourceReader> mReader;
|
2014-11-12 07:11:33 +03:00
|
|
|
|
|
|
|
// Protected by GetReentrantMonitor()
|
|
|
|
double mMediaSourceDuration;
|
2013-09-27 09:22:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASOURCEDECODER_H_ */
|