tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MediaResourceCallback.h (2179B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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 
      7 #ifndef MediaResourceCallback_h_
      8 #define MediaResourceCallback_h_
      9 
     10 #include "DecoderDoctorLogger.h"
     11 #include "MediaResult.h"
     12 #include "nsError.h"
     13 #include "nsISupportsImpl.h"
     14 
     15 namespace mozilla {
     16 
     17 class AbstractThread;
     18 class MediaDecoderOwner;
     19 class MediaResource;
     20 
     21 DDLoggedTypeDeclName(MediaResourceCallback);
     22 
     23 /**
     24 * A callback used by MediaResource (sub-classes like FileMediaResource,
     25 * RtspMediaResource, and ChannelMediaResource) to notify various events.
     26 * Currently this is implemented by MediaDecoder only.
     27 *
     28 * Since this class has no pure virtual function, it is convenient to write
     29 * gtests for the readers without using a mock MediaResource when you don't
     30 * care about the events notified by the MediaResource.
     31 */
     32 class MediaResourceCallback
     33    : public DecoderDoctorLifeLogger<MediaResourceCallback> {
     34 public:
     35  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaResourceCallback);
     36 
     37  // Return an abstract thread on which to run main thread runnables.
     38  virtual AbstractThread* AbstractMainThread() const { return nullptr; }
     39 
     40  // Returns a weak reference to the media decoder owner.
     41  virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; }
     42 
     43  // Notify that a network error is encountered.
     44  virtual void NotifyNetworkError(const MediaResult& aError) {}
     45 
     46  // Notify that data arrives on the stream and is read into the cache.
     47  virtual void NotifyDataArrived() {}
     48 
     49  // Notify download is ended.
     50  virtual void NotifyDataEnded(nsresult aStatus) {}
     51 
     52  // Notify that the principal of MediaResource has changed.
     53  virtual void NotifyPrincipalChanged() {}
     54 
     55  // Notify that the "cache suspended" status of MediaResource changes.
     56  virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {}
     57 
     58 protected:
     59  virtual ~MediaResourceCallback() = default;
     60 };
     61 
     62 }  // namespace mozilla
     63 
     64 #endif  // MediaResourceCallback_h_