2013-09-27 05:22:37 +00: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 12:22:00 +00:00
|
|
|
#include "MediaDecoder.h"
|
2013-09-27 05:22:37 +00:00
|
|
|
|
|
|
|
class nsIStreamListener;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-04-14 11:24:00 +00:00
|
|
|
class MediaResource;
|
2013-09-27 05:22:37 +00:00
|
|
|
class MediaDecoderStateMachine;
|
2014-08-17 11:29:00 +00:00
|
|
|
class MediaSourceReader;
|
2014-08-22 02:14:36 +00:00
|
|
|
class SourceBufferDecoder;
|
2014-09-04 01:57:06 +00:00
|
|
|
class TrackBuffer;
|
2013-09-27 05:22:37 +00:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class HTMLMediaElement;
|
|
|
|
class MediaSource;
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
|
|
|
|
class MediaSourceDecoder : public MediaDecoder
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 03:50:23 +00:00
|
|
|
explicit MediaSourceDecoder(dom::HTMLMediaElement* aElement);
|
2013-09-27 05:22:37 +00:00
|
|
|
|
2013-09-27 05:22:38 +00:00
|
|
|
virtual MediaDecoder* Clone() MOZ_OVERRIDE;
|
|
|
|
virtual MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE;
|
|
|
|
virtual nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE;
|
2013-11-18 04:22:47 +00:00
|
|
|
virtual nsresult GetSeekable(dom::TimeRanges* aSeekable) MOZ_OVERRIDE;
|
2013-09-27 05:22:37 +00:00
|
|
|
|
2014-08-25 04:09:44 +00:00
|
|
|
virtual void Shutdown() MOZ_OVERRIDE;
|
|
|
|
|
2014-04-14 11:24:00 +00:00
|
|
|
static already_AddRefed<MediaResource> CreateResource();
|
|
|
|
|
2013-11-18 04:22:47 +00:00
|
|
|
void AttachMediaSource(dom::MediaSource* aMediaSource);
|
2013-09-27 05:22:37 +00:00
|
|
|
void DetachMediaSource();
|
|
|
|
|
2014-08-22 02:14:36 +00:00
|
|
|
already_AddRefed<SourceBufferDecoder> CreateSubDecoder(const nsACString& aType);
|
2014-09-04 01:57:06 +00:00
|
|
|
void AddTrackBuffer(TrackBuffer* aTrackBuffer);
|
|
|
|
void RemoveTrackBuffer(TrackBuffer* aTrackBuffer);
|
|
|
|
void OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo);
|
2014-02-28 00:54:48 +00:00
|
|
|
|
2014-08-26 07:25:09 +00:00
|
|
|
void Ended();
|
|
|
|
|
2014-08-25 04:09:44 +00:00
|
|
|
void SetMediaSourceDuration(double aDuration);
|
|
|
|
|
|
|
|
// Provide a mechanism for MediaSourceReader to block waiting on data from a SourceBuffer.
|
|
|
|
void WaitForData();
|
|
|
|
|
|
|
|
// Called whenever a SourceBuffer has new data appended.
|
|
|
|
void NotifyGotData();
|
|
|
|
|
2013-09-27 05:22:37 +00:00
|
|
|
private:
|
2014-04-21 13:30:00 +00: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 04:22:47 +00:00
|
|
|
dom::MediaSource* mMediaSource;
|
2014-08-17 11:29:00 +00:00
|
|
|
nsRefPtr<MediaSourceReader> mReader;
|
2013-09-27 05:22:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASOURCEDECODER_H_ */
|