michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef MediaDecoderOwner_h_ michael@0: #define MediaDecoderOwner_h_ michael@0: #include "AbstractMediaDecoder.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class VideoFrameContainer; michael@0: michael@0: namespace dom { michael@0: class HTMLMediaElement; michael@0: } michael@0: michael@0: class MediaDecoderOwner michael@0: { michael@0: public: michael@0: // Called by the media decoder to indicate that the download has stalled michael@0: // (no data has arrived for a while). michael@0: virtual void DownloadStalled() = 0; michael@0: michael@0: // Dispatch a synchronous event to the decoder owner michael@0: virtual nsresult DispatchEvent(const nsAString& aName) = 0; michael@0: michael@0: // Dispatch an asynchronous event to the decoder owner michael@0: virtual nsresult DispatchAsyncEvent(const nsAString& aName) = 0; michael@0: michael@0: /** michael@0: * Fires a timeupdate event. If aPeriodic is true, the event will only michael@0: * be fired if we've not fired a timeupdate event (for any reason) in the michael@0: * last 250ms, as required by the spec when the current time is periodically michael@0: * increasing during playback. michael@0: */ michael@0: virtual void FireTimeUpdate(bool aPeriodic) = 0; michael@0: michael@0: // Get the HTMLMediaElement object if the decoder is being used from an michael@0: // HTML media element, and null otherwise. michael@0: virtual dom::HTMLMediaElement* GetMediaElement() michael@0: { michael@0: return nullptr; michael@0: } michael@0: michael@0: // Return true if decoding should be paused michael@0: virtual bool GetPaused() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when it has read the metadata containing video dimensions, michael@0: // etc. michael@0: virtual void MetadataLoaded(int aChannels, michael@0: int aRate, michael@0: bool aHasAudio, michael@0: bool aHasVideo, michael@0: const MetadataTags* aTags) = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when it has read the first frame of the video michael@0: // aResourceFullyLoaded should be true if the resource has been michael@0: // fully loaded and the caller will call ResourceLoaded next. michael@0: virtual void FirstFrameLoaded(bool aResourceFullyLoaded) = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when the resource has completed downloading. michael@0: virtual void ResourceLoaded() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when the resource has a network error during loading. michael@0: virtual void NetworkError() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, when the michael@0: // resource has a decode error during metadata loading or decoding. michael@0: virtual void DecodeError() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, when the michael@0: // resource load has been cancelled. michael@0: virtual void LoadAborted() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when the video playback has ended. michael@0: virtual void PlaybackEnded() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when the resource has started seeking. michael@0: virtual void SeekStarted() = 0; michael@0: michael@0: // Called by the video decoder object, on the main thread, michael@0: // when the resource has completed seeking. michael@0: virtual void SeekCompleted() = 0; michael@0: michael@0: // Called by the media stream, on the main thread, when the download michael@0: // has been suspended by the cache or because the element itself michael@0: // asked the decoder to suspend the download. michael@0: virtual void DownloadSuspended() = 0; michael@0: michael@0: // Called by the media stream, on the main thread, when the download michael@0: // has been resumed by the cache or because the element itself michael@0: // asked the decoder to resumed the download. michael@0: // If aForceNetworkLoading is True, ignore the fact that the download has michael@0: // previously finished. We are downloading the middle of the media after michael@0: // having downloaded the end, we need to notify the element a download in michael@0: // ongoing. michael@0: virtual void DownloadResumed(bool aForceNetworkLoading = false) = 0; michael@0: michael@0: // Called by the media decoder to indicate whether the media cache has michael@0: // suspended the channel. michael@0: virtual void NotifySuspendedByCache(bool aIsSuspended) = 0; michael@0: michael@0: // called to notify that the principal of the decoder's media resource has changed. michael@0: virtual void NotifyDecoderPrincipalChanged() = 0; michael@0: michael@0: // The status of the next frame which might be available from the decoder michael@0: enum NextFrameStatus { michael@0: // The next frame of audio/video is available michael@0: NEXT_FRAME_AVAILABLE, michael@0: // The next frame of audio/video is unavailable because the decoder michael@0: // is paused while it buffers up data michael@0: NEXT_FRAME_UNAVAILABLE_BUFFERING, michael@0: // The next frame of audio/video is unavailable for some other reasons michael@0: NEXT_FRAME_UNAVAILABLE, michael@0: // Sentinel value michael@0: NEXT_FRAME_UNINITIALIZED michael@0: }; michael@0: michael@0: // Called by the decoder when some data has been downloaded or michael@0: // buffering/seeking has ended. aNextFrameAvailable is true when michael@0: // the data for the next frame is available. This method will michael@0: // decide whether to set the ready state to HAVE_CURRENT_DATA, michael@0: // HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA. michael@0: virtual void UpdateReadyStateForData(NextFrameStatus aNextFrame) = 0; michael@0: michael@0: // Called by the media decoder and the video frame to get the michael@0: // ImageContainer containing the video data. michael@0: virtual VideoFrameContainer* GetVideoFrameContainer() = 0; michael@0: michael@0: // Called by the media decoder object, on the main thread, michael@0: // when the connection between Rtsp server and client gets lost. michael@0: virtual void ResetConnectionState() = 0; michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif michael@0: