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_
|
2012-11-30 17:17:54 +04:00
|
|
|
#include "AbstractMediaDecoder.h"
|
2012-11-09 09:52:53 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2012-11-14 23:45:31 +04:00
|
|
|
class VideoFrameContainer;
|
|
|
|
|
2013-03-19 16:23:54 +04:00
|
|
|
namespace dom {
|
|
|
|
class HTMLMediaElement;
|
|
|
|
}
|
|
|
|
|
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 a synchronous event to the decoder owner
|
|
|
|
virtual nsresult DispatchEvent(const nsAString& aName) = 0;
|
|
|
|
|
|
|
|
// Dispatch an asynchronous event to the decoder owner
|
|
|
|
virtual nsresult DispatchAsyncEvent(const nsAString& aName) = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
|
2013-03-19 16:23:54 +04:00
|
|
|
// Get the HTMLMediaElement object if the decoder is being used from an
|
2012-11-09 09:52:53 +04:00
|
|
|
// HTML media element, and null otherwise.
|
2013-03-19 16:23:54 +04:00
|
|
|
virtual dom::HTMLMediaElement* GetMediaElement()
|
2012-11-09 09:52:53 +04:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
2014-11-06 11:17:05 +03:00
|
|
|
nsAutoPtr<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
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread,
|
|
|
|
// when the resource has a network error during loading.
|
|
|
|
virtual void NetworkError() = 0;
|
|
|
|
|
|
|
|
// Called by the video decoder object, on the main thread, when the
|
|
|
|
// resource has a decode error during metadata loading or decoding.
|
|
|
|
virtual void DecodeError() = 0;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
// 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 stream, on the main thread, when the download
|
|
|
|
// has been resumed by the cache or because the element itself
|
|
|
|
// asked the decoder to resumed the download.
|
|
|
|
// If aForceNetworkLoading is True, ignore the fact that the download has
|
|
|
|
// previously finished. We are downloading the middle of the media after
|
|
|
|
// having downloaded the end, we need to notify the element a download in
|
|
|
|
// ongoing.
|
|
|
|
virtual void DownloadResumed(bool aForceNetworkLoading = false) = 0;
|
|
|
|
|
|
|
|
// Called by the media decoder to indicate whether the media cache has
|
|
|
|
// suspended the channel.
|
|
|
|
virtual void NotifySuspendedByCache(bool aIsSuspended) = 0;
|
|
|
|
|
|
|
|
// 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
|
|
|
};
|
|
|
|
|
2012-11-09 09:52:53 +04:00
|
|
|
// Called by the decoder when some data has been downloaded or
|
|
|
|
// buffering/seeking has ended. aNextFrameAvailable is true when
|
|
|
|
// the data for the next frame is available. This method will
|
|
|
|
// decide whether to set the ready state to HAVE_CURRENT_DATA,
|
|
|
|
// HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA.
|
2012-11-14 23:45:31 +04:00
|
|
|
virtual void UpdateReadyStateForData(NextFrameStatus aNextFrame) = 0;
|
2012-11-09 09:52:53 +04:00
|
|
|
|
|
|
|
// Called by the media decoder and the video frame to get the
|
|
|
|
// ImageContainer containing the video data.
|
2012-11-14 23:45:31 +04:00
|
|
|
virtual VideoFrameContainer* GetVideoFrameContainer() = 0;
|
2013-11-20 07:08:10 +04:00
|
|
|
|
|
|
|
// Called by the media decoder object, on the main thread,
|
|
|
|
// when the connection between Rtsp server and client gets lost.
|
|
|
|
virtual void ResetConnectionState() = 0;
|
2014-07-30 10:53:34 +04:00
|
|
|
|
2014-08-08 06:44:04 +04:00
|
|
|
#ifdef MOZ_EME
|
2014-08-27 12:46:56 +04:00
|
|
|
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
|
2014-07-30 10:53:34 +04:00
|
|
|
// provided init data.
|
|
|
|
// Main thread only.
|
2014-08-27 12:46:56 +04:00
|
|
|
virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
|
|
|
|
const nsAString& aInitDataType) = 0;
|
2014-08-08 06:44:04 +04:00
|
|
|
#endif
|
2012-11-09 09:52:53 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|