2012-11-09 09:52:53 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* 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 MediaDecoderOwner_h_
|
|
|
|
#define MediaDecoderOwner_h_
|
2017-07-13 12:39:42 +03:00
|
|
|
|
2017-08-28 09:10:35 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2017-07-13 12:39:42 +03:00
|
|
|
#include "MediaInfo.h"
|
2017-11-13 06:09:23 +03:00
|
|
|
#include "MediaSegment.h"
|
|
|
|
#include "nsSize.h"
|
|
|
|
|
2012-11-09 09:52:53 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2016-11-29 08:03:36 +03:00
|
|
|
class AbstractThread;
|
2017-03-16 06:16:15 +03:00
|
|
|
class GMPCrashHelper;
|
2012-11-14 23:45:31 +04:00
|
|
|
class VideoFrameContainer;
|
2017-03-15 12:33:21 +03:00
|
|
|
class MediaInfo;
|
2016-09-10 17:56:09 +03:00
|
|
|
class MediaResult;
|
2012-11-14 23:45:31 +04:00
|
|
|
|
2013-03-19 16:23:54 +04:00
|
|
|
namespace dom {
|
2019-01-02 16:05:23 +03:00
|
|
|
class Document;
|
2013-03-19 16:23:54 +04:00
|
|
|
class HTMLMediaElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2013-03-19 16:23:54 +04:00
|
|
|
|
2012-11-09 09:52:53 +04:00
|
|
|
class MediaDecoderOwner {
|
|
|
|
public:
|
2014-09-24 11:26:00 +04:00
|
|
|
// Called by the media decoder to indicate that the download is progressing.
|
|
|
|
virtual void DownloadProgressed() = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
|
|
|
// Dispatch an asynchronous event to the decoder owner
|
2017-11-05 11:12:44 +03:00
|
|
|
virtual void DispatchAsyncEvent(const nsAString& aName) = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
2015-04-29 05:02:31 +03:00
|
|
|
// Triggers a recomputation of readyState.
|
|
|
|
virtual void UpdateReadyState() = 0;
|
|
|
|
|
2012-11-09 09:52:53 +04:00
|
|
|
/**
|
|
|
|
* Fires a timeupdate event. If aPeriodic is true, the event will only
|
|
|
|
* be fired if we've not fired a timeupdate event (for any reason) in the
|
|
|
|
* last 250ms, as required by the spec when the current time is periodically
|
|
|
|
* increasing during playback.
|
|
|
|
*/
|
|
|
|
virtual void FireTimeUpdate(bool aPeriodic) = 0;
|
|
|
|
|
|
|
|
// Return true if decoding should be paused
|
|
|
|
virtual bool GetPaused() = 0;
|
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when it has read the metadata containing video dimensions,
|
|
|
|
// etc.
|
2014-11-06 11:17:05 +03:00
|
|
|
// Must take ownership of MetadataTags aTags argument.
|
2014-07-04 07:54:54 +04:00
|
|
|
virtual void MetadataLoaded(const MediaInfo* aInfo,
|
2017-08-28 09:10:35 +03:00
|
|
|
UniquePtr<const MetadataTags> aTags) = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
2014-09-24 11:25:00 +04:00
|
|
|
// Called by the decoder object, on the main thread,
|
|
|
|
// when it has read the first frame of the video or audio.
|
|
|
|
virtual void FirstFrameLoaded() = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
2016-07-26 09:33:16 +03:00
|
|
|
// Called by the decoder object, on the main thread,
|
2012-11-09 09:52:53 +04:00
|
|
|
// when the resource has a network error during loading.
|
2016-07-26 09:33:16 +03:00
|
|
|
// The decoder owner should call Shutdown() on the decoder and drop the
|
|
|
|
// reference to the decoder to prevent further calls into the decoder.
|
2017-11-17 06:07:30 +03:00
|
|
|
virtual void NetworkError(const MediaResult& aError) = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
2016-07-26 09:18:47 +03:00
|
|
|
// Called by the decoder object, on the main thread, when the
|
2012-11-09 09:52:53 +04:00
|
|
|
// resource has a decode error during metadata loading or decoding.
|
2016-07-26 09:18:47 +03:00
|
|
|
// The decoder owner should call Shutdown() on the decoder and drop the
|
|
|
|
// reference to the decoder to prevent further calls into the decoder.
|
2016-09-10 17:56:09 +03:00
|
|
|
virtual void DecodeError(const MediaResult& aError) = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
2017-02-27 04:12:37 +03:00
|
|
|
// Called by the decoder object, on the main thread, when the
|
|
|
|
// resource has a decode issue during metadata loading or decoding, but can
|
|
|
|
// continue decoding.
|
|
|
|
virtual void DecodeWarning(const MediaResult& aError) = 0;
|
|
|
|
|
2016-02-08 07:27:14 +03:00
|
|
|
// Return true if media element error attribute is not null.
|
|
|
|
virtual bool HasError() const = 0;
|
|
|
|
|
2012-11-09 09:52:53 +04:00
|
|
|
// Called by the video decoder object, on the main thread, when the
|
|
|
|
// resource load has been cancelled.
|
|
|
|
virtual void LoadAborted() = 0;
|
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the video playback has ended.
|
|
|
|
virtual void PlaybackEnded() = 0;
|
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has started seeking.
|
|
|
|
virtual void SeekStarted() = 0;
|
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has completed seeking.
|
|
|
|
virtual void SeekCompleted() = 0;
|
|
|
|
|
2019-08-29 17:30:06 +03:00
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has aborted seeking.
|
|
|
|
virtual void SeekAborted() = 0;
|
|
|
|
|
2012-11-09 09:52:53 +04:00
|
|
|
// Called by the media stream, on the main thread, when the download
|
|
|
|
// has been suspended by the cache or because the element itself
|
|
|
|
// asked the decoder to suspend the download.
|
|
|
|
virtual void DownloadSuspended() = 0;
|
|
|
|
|
|
|
|
// Called by the media decoder to indicate whether the media cache has
|
|
|
|
// suspended the channel.
|
2017-08-23 09:42:25 +03:00
|
|
|
virtual void NotifySuspendedByCache(bool aSuspendedByCache) = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
|
|
|
// called to notify that the principal of the decoder's media resource has
|
|
|
|
// changed.
|
|
|
|
virtual void NotifyDecoderPrincipalChanged() = 0;
|
|
|
|
|
2012-11-14 23:45:31 +04:00
|
|
|
// The status of the next frame which might be available from the decoder
|
|
|
|
enum NextFrameStatus {
|
|
|
|
// The next frame of audio/video is available
|
|
|
|
NEXT_FRAME_AVAILABLE,
|
|
|
|
// The next frame of audio/video is unavailable because the decoder
|
|
|
|
// is paused while it buffers up data
|
|
|
|
NEXT_FRAME_UNAVAILABLE_BUFFERING,
|
2014-09-24 11:25:00 +04:00
|
|
|
// The next frame of audio/video is unavailable for the decoder is seeking.
|
|
|
|
NEXT_FRAME_UNAVAILABLE_SEEKING,
|
2012-11-14 23:45:31 +04:00
|
|
|
// The next frame of audio/video is unavailable for some other reasons
|
2012-12-19 08:48:32 +04:00
|
|
|
NEXT_FRAME_UNAVAILABLE,
|
|
|
|
// Sentinel value
|
|
|
|
NEXT_FRAME_UNINITIALIZED
|
2012-11-14 23:45:31 +04:00
|
|
|
};
|
|
|
|
|
2016-01-21 05:27:38 +03:00
|
|
|
// Called by media decoder when the audible state changed
|
2016-05-03 12:59:43 +03:00
|
|
|
virtual void SetAudibleState(bool aAudible) = 0;
|
2016-01-21 05:27:38 +03:00
|
|
|
|
2017-02-03 12:12:38 +03:00
|
|
|
// Notified by the decoder that XPCOM shutdown has begun.
|
2016-07-27 05:26:21 +03:00
|
|
|
// The decoder owner should call Shutdown() on the decoder and drop the
|
|
|
|
// reference to the decoder to prevent further calls into the decoder.
|
|
|
|
virtual void NotifyXPCOMShutdown() = 0;
|
|
|
|
|
2014-08-27 12:46:56 +04:00
|
|
|
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
|
2015-04-01 10:36:00 +03:00
|
|
|
// provided init data. Actual dispatch may be delayed until HAVE_METADATA.
|
2014-07-30 10:53:34 +04:00
|
|
|
// Main thread only.
|
2014-08-27 12:46:56 +04:00
|
|
|
virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
|
|
|
|
const nsAString& aInitDataType) = 0;
|
2017-03-15 06:40:37 +03:00
|
|
|
|
2017-07-13 09:41:09 +03:00
|
|
|
// Notified by the decoder that a decryption key is required before emitting
|
|
|
|
// further output.
|
|
|
|
virtual void NotifyWaitingForKey() {}
|
2017-08-28 09:36:00 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Methods that are used only in Gecko go here. We provide defaul
|
|
|
|
* implementations so they can compile in Servo without modification.
|
|
|
|
*/
|
|
|
|
// Return an abstract thread on which to run main thread runnables.
|
|
|
|
virtual AbstractThread* AbstractMainThread() const { return nullptr; }
|
|
|
|
|
|
|
|
// Get the HTMLMediaElement object if the decoder is being used from an
|
|
|
|
// HTML media element, and null otherwise.
|
|
|
|
virtual dom::HTMLMediaElement* GetMediaElement() { return nullptr; }
|
|
|
|
|
|
|
|
// Called by the media decoder and the video frame to get the
|
|
|
|
// ImageContainer containing the video data.
|
|
|
|
virtual VideoFrameContainer* GetVideoFrameContainer() { return nullptr; }
|
|
|
|
|
|
|
|
// Return the decoder owner's owner document.
|
2019-01-02 16:05:23 +03:00
|
|
|
virtual mozilla::dom::Document* GetDocument() const { return nullptr; }
|
2017-08-28 09:36:00 +03:00
|
|
|
|
|
|
|
// Called by the media decoder to create a GMPCrashHelper.
|
|
|
|
virtual already_AddRefed<GMPCrashHelper> CreateGMPCrashHelper() {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:09:23 +03:00
|
|
|
// Called by the frame container to notify the layout engine that the
|
|
|
|
// size of the image has changed, or the video needs to be be repainted
|
|
|
|
// for some other reason.
|
|
|
|
virtual void Invalidate(bool aImageSizeChanged,
|
|
|
|
Maybe<nsIntSize>& aNewIntrinsicSize,
|
|
|
|
bool aForceInvalidate) {}
|
|
|
|
|
|
|
|
// Called after the MediaStream we're playing rendered a frame to aContainer
|
|
|
|
// with a different principalHandle than the previous frame.
|
|
|
|
virtual void PrincipalHandleChangedForVideoFrameContainer(
|
|
|
|
VideoFrameContainer* aContainer,
|
|
|
|
const PrincipalHandle& aNewPrincipalHandle) {}
|
|
|
|
|
2019-11-22 15:52:48 +03:00
|
|
|
// Called after the MediaDecoder has installed the given secondary video
|
|
|
|
// container and render potential frames to it.
|
|
|
|
virtual void OnSecondaryVideoContainerInstalled(
|
|
|
|
const RefPtr<VideoFrameContainer>& aSecondaryContainer) {}
|
|
|
|
|
2017-08-28 09:36:00 +03:00
|
|
|
/*
|
|
|
|
* Servo only methods go here. Please provide default implementations so they
|
|
|
|
* can build in Gecko without any modification.
|
|
|
|
*/
|
2012-11-09 09:52:53 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2012-11-09 09:52:53 +04:00
|
|
|
|
|
|
|
#endif
|