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