2015-10-27 05:28:26 +03:00
|
|
|
/* -*- 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_
|
|
|
|
|
Bug 1407810 - Use DDLogger in media stack - r=jwwang
Mostly-mechanical additions:
- Log constructions&destructions, usually by just inheriting from
DecoderDoctorLifeLogger, otherwise with explicit log commands (for internal
classes for which DecoderDoctorTraits can't be specialized),
- Log links between most objects, e.g.: Media element -> decoder -> state
machine -> reader -> demuxer -> resource, etc.
And logging some important properties and events (JS events, duration change,
frames being decoded, etc.)
More will be added later on, from just converting MOZ_LOGs, and as needed.
MozReview-Commit-ID: KgNhHSz35t0
--HG--
extra : rebase_source : dd7206e350e32671adc6f3b9e54ebf777251de2c
2017-10-10 09:55:27 +03:00
|
|
|
#include "DecoderDoctorLogger.h"
|
2015-10-27 05:28:26 +03:00
|
|
|
#include "nsError.h"
|
2015-11-16 02:50:55 +03:00
|
|
|
#include "nsISupportsImpl.h"
|
2017-11-17 06:07:30 +03:00
|
|
|
#include "MediaResult.h"
|
2015-10-27 05:28:26 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-09-06 10:12:34 +03:00
|
|
|
class AbstractThread;
|
2015-11-16 02:50:55 +03:00
|
|
|
class MediaDecoderOwner;
|
2015-10-27 05:28:26 +03:00
|
|
|
class MediaResource;
|
|
|
|
|
Bug 1407810 - Use DDLogger in media stack - r=jwwang
Mostly-mechanical additions:
- Log constructions&destructions, usually by just inheriting from
DecoderDoctorLifeLogger, otherwise with explicit log commands (for internal
classes for which DecoderDoctorTraits can't be specialized),
- Log links between most objects, e.g.: Media element -> decoder -> state
machine -> reader -> demuxer -> resource, etc.
And logging some important properties and events (JS events, duration change,
frames being decoded, etc.)
More will be added later on, from just converting MOZ_LOGs, and as needed.
MozReview-Commit-ID: KgNhHSz35t0
--HG--
extra : rebase_source : dd7206e350e32671adc6f3b9e54ebf777251de2c
2017-10-10 09:55:27 +03:00
|
|
|
DDLoggedTypeDeclName(MediaResourceCallback);
|
|
|
|
|
2015-10-27 05:28:26 +03:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
Bug 1407810 - Use DDLogger in media stack - r=jwwang
Mostly-mechanical additions:
- Log constructions&destructions, usually by just inheriting from
DecoderDoctorLifeLogger, otherwise with explicit log commands (for internal
classes for which DecoderDoctorTraits can't be specialized),
- Log links between most objects, e.g.: Media element -> decoder -> state
machine -> reader -> demuxer -> resource, etc.
And logging some important properties and events (JS events, duration change,
frames being decoded, etc.)
More will be added later on, from just converting MOZ_LOGs, and as needed.
MozReview-Commit-ID: KgNhHSz35t0
--HG--
extra : rebase_source : dd7206e350e32671adc6f3b9e54ebf777251de2c
2017-10-10 09:55:27 +03:00
|
|
|
class MediaResourceCallback
|
|
|
|
: public DecoderDoctorLifeLogger<MediaResourceCallback>
|
|
|
|
{
|
2015-10-27 05:28:26 +03:00
|
|
|
public:
|
2015-11-16 02:50:55 +03:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaResourceCallback);
|
|
|
|
|
2017-09-06 10:12:34 +03:00
|
|
|
// Return an abstract thread on which to run main thread runnables.
|
|
|
|
virtual AbstractThread* AbstractMainThread() const { return nullptr; }
|
|
|
|
|
2015-10-27 05:28:26 +03:00
|
|
|
// Returns a weak reference to the media decoder owner.
|
|
|
|
virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; }
|
|
|
|
|
|
|
|
// Notify that a network error is encountered.
|
2017-11-17 06:07:30 +03:00
|
|
|
virtual void NotifyNetworkError(const MediaResult& aError) {}
|
2015-10-27 05:28:26 +03:00
|
|
|
|
|
|
|
// Notify that data arrives on the stream and is read into the cache.
|
2015-11-11 12:59:16 +03:00
|
|
|
virtual void NotifyDataArrived() {}
|
2015-10-27 05:28:26 +03:00
|
|
|
|
|
|
|
// 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.
|
2017-08-23 09:32:51 +03:00
|
|
|
virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {}
|
2015-10-27 05:28:26 +03:00
|
|
|
|
2015-11-16 02:50:55 +03:00
|
|
|
protected:
|
|
|
|
virtual ~MediaResourceCallback() {}
|
2015-10-27 05:28:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif //MediaResourceCallback_h_
|