summaryrefslogtreecommitdiffstats
path: root/dom/media/MediaResourceCallback.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/MediaResourceCallback.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/MediaResourceCallback.h')
-rw-r--r--dom/media/MediaResourceCallback.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/media/MediaResourceCallback.h b/dom/media/MediaResourceCallback.h
new file mode 100644
index 000000000..9c126f400
--- /dev/null
+++ b/dom/media/MediaResourceCallback.h
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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 MediaResourceCallback_h_
+#define MediaResourceCallback_h_
+
+#include "nsError.h"
+#include "nsISupportsImpl.h"
+
+namespace mozilla {
+
+class MediaDecoderOwner;
+class MediaResource;
+
+/**
+ * A callback used by MediaResource (sub-classes like FileMediaResource,
+ * RtspMediaResource, and ChannelMediaResource) to notify various events.
+ * Currently this is implemented by MediaDecoder only.
+ *
+ * Since this class has no pure virtual function, it is convenient to write
+ * gtests for the readers without using a mock MediaResource when you don't
+ * care about the events notified by the MediaResource.
+ */
+class MediaResourceCallback {
+public:
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaResourceCallback);
+
+ // Returns a weak reference to the media decoder owner.
+ virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; }
+
+ // Notify is duration is known to this MediaResource.
+ virtual void SetInfinite(bool aInfinite) {}
+
+ // Notify that a network error is encountered.
+ virtual void NotifyNetworkError() {}
+
+ // Notify that decoding has failed.
+ virtual void NotifyDecodeError() {}
+
+ // Notify that data arrives on the stream and is read into the cache.
+ virtual void NotifyDataArrived() {}
+
+ // Notify that MediaResource has received some data.
+ virtual void NotifyBytesDownloaded() {}
+
+ // Notify download is ended.
+ // NOTE: this can be called with the media cache lock held, so don't
+ // block or do anything which might try to acquire a lock!
+ virtual void NotifyDataEnded(nsresult aStatus) {}
+
+ // Notify that the principal of MediaResource has changed.
+ virtual void NotifyPrincipalChanged() {}
+
+ // Notify that the "cache suspended" status of MediaResource changes.
+ virtual void NotifySuspendedStatusChanged() {}
+
+ // Notify the number of bytes read from the resource.
+ virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) {}
+
+protected:
+ virtual ~MediaResourceCallback() {}
+};
+
+} // namespace mozilla
+
+#endif //MediaResourceCallback_h_