2014-06-07 08:52:15 +12: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 mozilla_dom_MediaKeySession_h
|
|
|
|
#define mozilla_dom_MediaKeySession_h
|
|
|
|
|
2018-03-19 10:53:13 -07:00
|
|
|
#include "DecoderDoctorLogger.h"
|
2014-06-07 08:52:15 +12:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "mozilla/dom/Promise.h"
|
2015-06-08 11:34:23 +08:00
|
|
|
#include "mozilla/DetailedPromise.h"
|
2014-06-07 08:52:15 +12:00
|
|
|
#include "mozilla/dom/MediaKeySessionBinding.h"
|
|
|
|
#include "mozilla/dom/MediaKeysBinding.h"
|
2015-01-15 11:25:47 +13:00
|
|
|
#include "mozilla/dom/MediaKeyMessageEventBinding.h"
|
2014-06-07 08:52:15 +12:00
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
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 17:55:27 +11:00
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
class MediaKeySession;
|
|
|
|
} // namespace dom
|
|
|
|
DDLoggedTypeName(dom::MediaKeySession);
|
|
|
|
|
2014-06-07 08:52:15 +12:00
|
|
|
namespace dom {
|
|
|
|
|
2014-10-01 20:43:26 +02:00
|
|
|
class ArrayBufferViewOrArrayBuffer;
|
2014-06-07 08:52:15 +12:00
|
|
|
class MediaKeyError;
|
2015-01-31 13:23:07 +13:00
|
|
|
class MediaKeyStatusMap;
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2017-03-09 12:19:58 +13:00
|
|
|
nsCString ToCString(MediaKeySessionType aType);
|
|
|
|
|
|
|
|
nsString ToString(MediaKeySessionType aType);
|
|
|
|
|
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 17:55:27 +11:00
|
|
|
class MediaKeySession final : public DOMEventTargetHelper,
|
|
|
|
public DecoderDoctorLifeLogger<MediaKeySession> {
|
2014-06-07 08:52:15 +12:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaKeySession,
|
|
|
|
DOMEventTargetHelper)
|
|
|
|
public:
|
2015-02-01 19:12:00 +01:00
|
|
|
MediaKeySession(JSContext* aCx, nsPIDOMWindowInner* aParent, MediaKeys* aKeys,
|
2016-07-04 14:14:01 +12:00
|
|
|
const nsAString& aKeySystem, MediaKeySessionType aSessionType,
|
2014-07-18 21:31:11 -04:00
|
|
|
ErrorResult& aRv);
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2015-01-09 14:30:07 +13:00
|
|
|
void SetSessionId(const nsAString& aSessionId);
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2016-01-18 14:29:21 +11:00
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2014-06-07 08:52:15 +12:00
|
|
|
|
|
|
|
// Mark this as resultNotAddRefed to return raw pointers
|
|
|
|
MediaKeyError* GetError() const;
|
|
|
|
|
2015-01-31 13:23:07 +13:00
|
|
|
MediaKeyStatusMap* KeyStatuses() const;
|
|
|
|
|
2014-06-07 08:52:15 +12:00
|
|
|
void GetSessionId(nsString& aRetval) const;
|
|
|
|
|
2014-07-30 18:53:28 +12:00
|
|
|
const nsString& GetSessionId() const;
|
|
|
|
|
2014-06-07 08:52:15 +12:00
|
|
|
// Number of ms since epoch at which expiration occurs, or NaN if unknown.
|
|
|
|
// TODO: The type of this attribute is still under contention.
|
|
|
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=25902
|
|
|
|
double Expiration() const;
|
|
|
|
|
|
|
|
Promise* Closed() const;
|
|
|
|
|
2014-09-24 10:04:49 +12:00
|
|
|
already_AddRefed<Promise> GenerateRequest(
|
|
|
|
const nsAString& aInitDataType,
|
|
|
|
const ArrayBufferViewOrArrayBuffer& aInitData, ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<Promise> Load(const nsAString& aSessionId, ErrorResult& aRv);
|
|
|
|
|
2014-08-27 20:46:56 +12:00
|
|
|
already_AddRefed<Promise> Update(const ArrayBufferViewOrArrayBuffer& response,
|
2014-07-18 21:31:11 -04:00
|
|
|
ErrorResult& aRv);
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2014-07-18 21:31:11 -04:00
|
|
|
already_AddRefed<Promise> Close(ErrorResult& aRv);
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2014-07-18 21:31:11 -04:00
|
|
|
already_AddRefed<Promise> Remove(ErrorResult& aRv);
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2015-01-15 11:25:47 +13:00
|
|
|
void DispatchKeyMessage(MediaKeyMessageType aMessageType,
|
|
|
|
const nsTArray<uint8_t>& aMessage);
|
2014-06-07 08:52:15 +12:00
|
|
|
|
|
|
|
void DispatchKeyError(uint32_t system_code);
|
|
|
|
|
2015-02-03 16:53:36 +08:00
|
|
|
void DispatchKeyStatusesChange();
|
2014-10-15 21:33:18 +13:00
|
|
|
|
2014-06-07 08:52:15 +12:00
|
|
|
void OnClosed();
|
|
|
|
|
|
|
|
bool IsClosed() const;
|
|
|
|
|
2015-11-10 07:59:15 +13:00
|
|
|
void SetExpiration(double aExpiry);
|
|
|
|
|
2016-09-21 14:31:15 +12:00
|
|
|
mozilla::dom::EventHandlerNonNull* GetOnkeystatuseschange();
|
|
|
|
void SetOnkeystatuseschange(mozilla::dom::EventHandlerNonNull* aCallback);
|
|
|
|
|
2016-09-21 14:56:20 +12:00
|
|
|
mozilla::dom::EventHandlerNonNull* GetOnmessage();
|
|
|
|
void SetOnmessage(mozilla::dom::EventHandlerNonNull* aCallback);
|
|
|
|
|
2015-01-09 14:30:07 +13:00
|
|
|
// Process-unique identifier.
|
|
|
|
uint32_t Token() const;
|
|
|
|
|
2014-06-07 08:52:15 +12:00
|
|
|
private:
|
2014-07-08 17:23:17 -04:00
|
|
|
~MediaKeySession();
|
|
|
|
|
2015-01-31 13:23:07 +13:00
|
|
|
void UpdateKeyStatusMap();
|
2015-11-10 07:59:28 +13:00
|
|
|
|
|
|
|
bool IsCallable() const {
|
|
|
|
// The EME spec sets the "callable value" to true whenever the CDM sets
|
|
|
|
// the sessionId. When the session is initialized, sessionId is empty and
|
|
|
|
// callable is thus false.
|
|
|
|
return !mSessionId.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2015-07-27 11:52:19 +12:00
|
|
|
already_AddRefed<DetailedPromise> MakePromise(ErrorResult& aRv,
|
|
|
|
const nsACString& aName);
|
2015-01-31 13:23:07 +13:00
|
|
|
|
2015-10-18 01:24:48 -04:00
|
|
|
RefPtr<DetailedPromise> mClosed;
|
2014-06-07 08:52:15 +12:00
|
|
|
|
2015-10-18 01:24:48 -04:00
|
|
|
RefPtr<MediaKeyError> mMediaKeyError;
|
|
|
|
RefPtr<MediaKeys> mKeys;
|
2014-06-07 08:52:15 +12:00
|
|
|
const nsString mKeySystem;
|
|
|
|
nsString mSessionId;
|
2016-07-04 14:14:01 +12:00
|
|
|
const MediaKeySessionType mSessionType;
|
2015-01-09 14:30:07 +13:00
|
|
|
const uint32_t mToken;
|
2014-06-07 08:52:15 +12:00
|
|
|
bool mIsClosed;
|
2014-09-24 10:04:49 +12:00
|
|
|
bool mUninitialized;
|
2015-10-18 01:24:48 -04:00
|
|
|
RefPtr<MediaKeyStatusMap> mKeyStatusMap;
|
2015-11-10 07:59:15 +13:00
|
|
|
double mExpiration;
|
2014-06-07 08:52:15 +12:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|