diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/media/MediaResourceCallback.h | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/MediaResourceCallback.h')
-rw-r--r-- | dom/media/MediaResourceCallback.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/dom/media/MediaResourceCallback.h b/dom/media/MediaResourceCallback.h new file mode 100644 index 0000000000..6c4bb08c07 --- /dev/null +++ b/dom/media/MediaResourceCallback.h @@ -0,0 +1,66 @@ +/* -*- 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 "DecoderDoctorLogger.h" +#include "nsError.h" +#include "nsISupportsImpl.h" +#include "MediaResult.h" + +namespace mozilla { + +class AbstractThread; +class MediaDecoderOwner; +class MediaResource; + +DDLoggedTypeDeclName(MediaResourceCallback); + +/** + * 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 DecoderDoctorLifeLogger<MediaResourceCallback> { + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaResourceCallback); + + // Return an abstract thread on which to run main thread runnables. + virtual AbstractThread* AbstractMainThread() const { return nullptr; } + + // Returns a weak reference to the media decoder owner. + virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; } + + // Notify that a network error is encountered. + virtual void NotifyNetworkError(const MediaResult& aError) {} + + // Notify that data arrives on the stream and is read into the cache. + virtual void NotifyDataArrived() {} + + // 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(bool aSuspendedByCache) {} + + protected: + virtual ~MediaResourceCallback() = default; +}; + +} // namespace mozilla + +#endif // MediaResourceCallback_h_ |