Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | #ifndef MediaDecoderOwner_h_ |
michael@0 | 7 | #define MediaDecoderOwner_h_ |
michael@0 | 8 | #include "AbstractMediaDecoder.h" |
michael@0 | 9 | |
michael@0 | 10 | namespace mozilla { |
michael@0 | 11 | |
michael@0 | 12 | class VideoFrameContainer; |
michael@0 | 13 | |
michael@0 | 14 | namespace dom { |
michael@0 | 15 | class HTMLMediaElement; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | class MediaDecoderOwner |
michael@0 | 19 | { |
michael@0 | 20 | public: |
michael@0 | 21 | // Called by the media decoder to indicate that the download has stalled |
michael@0 | 22 | // (no data has arrived for a while). |
michael@0 | 23 | virtual void DownloadStalled() = 0; |
michael@0 | 24 | |
michael@0 | 25 | // Dispatch a synchronous event to the decoder owner |
michael@0 | 26 | virtual nsresult DispatchEvent(const nsAString& aName) = 0; |
michael@0 | 27 | |
michael@0 | 28 | // Dispatch an asynchronous event to the decoder owner |
michael@0 | 29 | virtual nsresult DispatchAsyncEvent(const nsAString& aName) = 0; |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * Fires a timeupdate event. If aPeriodic is true, the event will only |
michael@0 | 33 | * be fired if we've not fired a timeupdate event (for any reason) in the |
michael@0 | 34 | * last 250ms, as required by the spec when the current time is periodically |
michael@0 | 35 | * increasing during playback. |
michael@0 | 36 | */ |
michael@0 | 37 | virtual void FireTimeUpdate(bool aPeriodic) = 0; |
michael@0 | 38 | |
michael@0 | 39 | // Get the HTMLMediaElement object if the decoder is being used from an |
michael@0 | 40 | // HTML media element, and null otherwise. |
michael@0 | 41 | virtual dom::HTMLMediaElement* GetMediaElement() |
michael@0 | 42 | { |
michael@0 | 43 | return nullptr; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | // Return true if decoding should be paused |
michael@0 | 47 | virtual bool GetPaused() = 0; |
michael@0 | 48 | |
michael@0 | 49 | // Called by the video decoder object, on the main thread, |
michael@0 | 50 | // when it has read the metadata containing video dimensions, |
michael@0 | 51 | // etc. |
michael@0 | 52 | virtual void MetadataLoaded(int aChannels, |
michael@0 | 53 | int aRate, |
michael@0 | 54 | bool aHasAudio, |
michael@0 | 55 | bool aHasVideo, |
michael@0 | 56 | const MetadataTags* aTags) = 0; |
michael@0 | 57 | |
michael@0 | 58 | // Called by the video decoder object, on the main thread, |
michael@0 | 59 | // when it has read the first frame of the video |
michael@0 | 60 | // aResourceFullyLoaded should be true if the resource has been |
michael@0 | 61 | // fully loaded and the caller will call ResourceLoaded next. |
michael@0 | 62 | virtual void FirstFrameLoaded(bool aResourceFullyLoaded) = 0; |
michael@0 | 63 | |
michael@0 | 64 | // Called by the video decoder object, on the main thread, |
michael@0 | 65 | // when the resource has completed downloading. |
michael@0 | 66 | virtual void ResourceLoaded() = 0; |
michael@0 | 67 | |
michael@0 | 68 | // Called by the video decoder object, on the main thread, |
michael@0 | 69 | // when the resource has a network error during loading. |
michael@0 | 70 | virtual void NetworkError() = 0; |
michael@0 | 71 | |
michael@0 | 72 | // Called by the video decoder object, on the main thread, when the |
michael@0 | 73 | // resource has a decode error during metadata loading or decoding. |
michael@0 | 74 | virtual void DecodeError() = 0; |
michael@0 | 75 | |
michael@0 | 76 | // Called by the video decoder object, on the main thread, when the |
michael@0 | 77 | // resource load has been cancelled. |
michael@0 | 78 | virtual void LoadAborted() = 0; |
michael@0 | 79 | |
michael@0 | 80 | // Called by the video decoder object, on the main thread, |
michael@0 | 81 | // when the video playback has ended. |
michael@0 | 82 | virtual void PlaybackEnded() = 0; |
michael@0 | 83 | |
michael@0 | 84 | // Called by the video decoder object, on the main thread, |
michael@0 | 85 | // when the resource has started seeking. |
michael@0 | 86 | virtual void SeekStarted() = 0; |
michael@0 | 87 | |
michael@0 | 88 | // Called by the video decoder object, on the main thread, |
michael@0 | 89 | // when the resource has completed seeking. |
michael@0 | 90 | virtual void SeekCompleted() = 0; |
michael@0 | 91 | |
michael@0 | 92 | // Called by the media stream, on the main thread, when the download |
michael@0 | 93 | // has been suspended by the cache or because the element itself |
michael@0 | 94 | // asked the decoder to suspend the download. |
michael@0 | 95 | virtual void DownloadSuspended() = 0; |
michael@0 | 96 | |
michael@0 | 97 | // Called by the media stream, on the main thread, when the download |
michael@0 | 98 | // has been resumed by the cache or because the element itself |
michael@0 | 99 | // asked the decoder to resumed the download. |
michael@0 | 100 | // If aForceNetworkLoading is True, ignore the fact that the download has |
michael@0 | 101 | // previously finished. We are downloading the middle of the media after |
michael@0 | 102 | // having downloaded the end, we need to notify the element a download in |
michael@0 | 103 | // ongoing. |
michael@0 | 104 | virtual void DownloadResumed(bool aForceNetworkLoading = false) = 0; |
michael@0 | 105 | |
michael@0 | 106 | // Called by the media decoder to indicate whether the media cache has |
michael@0 | 107 | // suspended the channel. |
michael@0 | 108 | virtual void NotifySuspendedByCache(bool aIsSuspended) = 0; |
michael@0 | 109 | |
michael@0 | 110 | // called to notify that the principal of the decoder's media resource has changed. |
michael@0 | 111 | virtual void NotifyDecoderPrincipalChanged() = 0; |
michael@0 | 112 | |
michael@0 | 113 | // The status of the next frame which might be available from the decoder |
michael@0 | 114 | enum NextFrameStatus { |
michael@0 | 115 | // The next frame of audio/video is available |
michael@0 | 116 | NEXT_FRAME_AVAILABLE, |
michael@0 | 117 | // The next frame of audio/video is unavailable because the decoder |
michael@0 | 118 | // is paused while it buffers up data |
michael@0 | 119 | NEXT_FRAME_UNAVAILABLE_BUFFERING, |
michael@0 | 120 | // The next frame of audio/video is unavailable for some other reasons |
michael@0 | 121 | NEXT_FRAME_UNAVAILABLE, |
michael@0 | 122 | // Sentinel value |
michael@0 | 123 | NEXT_FRAME_UNINITIALIZED |
michael@0 | 124 | }; |
michael@0 | 125 | |
michael@0 | 126 | // Called by the decoder when some data has been downloaded or |
michael@0 | 127 | // buffering/seeking has ended. aNextFrameAvailable is true when |
michael@0 | 128 | // the data for the next frame is available. This method will |
michael@0 | 129 | // decide whether to set the ready state to HAVE_CURRENT_DATA, |
michael@0 | 130 | // HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA. |
michael@0 | 131 | virtual void UpdateReadyStateForData(NextFrameStatus aNextFrame) = 0; |
michael@0 | 132 | |
michael@0 | 133 | // Called by the media decoder and the video frame to get the |
michael@0 | 134 | // ImageContainer containing the video data. |
michael@0 | 135 | virtual VideoFrameContainer* GetVideoFrameContainer() = 0; |
michael@0 | 136 | |
michael@0 | 137 | // Called by the media decoder object, on the main thread, |
michael@0 | 138 | // when the connection between Rtsp server and client gets lost. |
michael@0 | 139 | virtual void ResetConnectionState() = 0; |
michael@0 | 140 | }; |
michael@0 | 141 | |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | #endif |
michael@0 | 145 |