2013-05-21 20:14:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 et tw=78: */
|
|
|
|
/* 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_TextTrack_h
|
|
|
|
#define mozilla_dom_TextTrack_h
|
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-05-21 20:14:00 +04:00
|
|
|
#include "mozilla/dom/TextTrackBinding.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-01-27 22:10:06 +04:00
|
|
|
class TextTrackList;
|
2013-05-21 20:14:00 +04:00
|
|
|
class TextTrackCue;
|
|
|
|
class TextTrackCueList;
|
2013-09-14 03:44:33 +04:00
|
|
|
class TextTrackRegion;
|
2014-02-27 23:07:39 +04:00
|
|
|
class HTMLTrackElement;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2014-02-27 21:47:23 +04:00
|
|
|
enum TextTrackSource {
|
|
|
|
Track,
|
|
|
|
AddTextTrack,
|
|
|
|
MediaResourceSpecific
|
|
|
|
};
|
|
|
|
|
2014-03-13 22:29:32 +04:00
|
|
|
// Constants for numeric readyState property values.
|
|
|
|
enum TextTrackReadyState {
|
|
|
|
NotLoaded = 0U,
|
|
|
|
Loading = 1U,
|
|
|
|
Loaded = 2U,
|
|
|
|
FailedToLoad = 3U
|
|
|
|
};
|
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
class TextTrack MOZ_FINAL : public DOMEventTargetHelper
|
2013-05-21 20:14:00 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrack, DOMEventTargetHelper)
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
TextTrack(nsISupports* aParent,
|
2014-01-28 00:17:20 +04:00
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
2014-02-27 21:47:23 +04:00
|
|
|
const nsAString& aLanguage,
|
2014-03-13 21:18:06 +04:00
|
|
|
TextTrackMode aMode,
|
2014-03-13 22:41:21 +04:00
|
|
|
TextTrackReadyState aReadyState,
|
2014-02-27 21:47:23 +04:00
|
|
|
TextTrackSource aTextTrackSource);
|
2013-06-15 00:10:36 +04:00
|
|
|
TextTrack(nsISupports* aParent,
|
2014-01-28 00:17:20 +04:00
|
|
|
TextTrackList* aTextTrackList,
|
2013-05-21 20:14:00 +04:00
|
|
|
TextTrackKind aKind,
|
|
|
|
const nsAString& aLabel,
|
2014-02-27 21:47:23 +04:00
|
|
|
const nsAString& aLanguage,
|
2014-03-13 21:18:06 +04:00
|
|
|
TextTrackMode aMode,
|
2014-03-13 22:41:21 +04:00
|
|
|
TextTrackReadyState aReadyState,
|
2014-02-27 21:47:23 +04:00
|
|
|
TextTrackSource aTextTrackSource);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2013-06-15 00:10:36 +04:00
|
|
|
void SetDefaultSettings();
|
|
|
|
|
2014-04-09 02:27:18 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
nsISupports* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextTrackKind Kind() const
|
|
|
|
{
|
|
|
|
return mKind;
|
|
|
|
}
|
|
|
|
void GetLabel(nsAString& aLabel) const
|
|
|
|
{
|
|
|
|
aLabel = mLabel;
|
|
|
|
}
|
|
|
|
void GetLanguage(nsAString& aLanguage) const
|
|
|
|
{
|
|
|
|
aLanguage = mLanguage;
|
|
|
|
}
|
|
|
|
void GetInBandMetadataTrackDispatchType(nsAString& aType) const
|
|
|
|
{
|
|
|
|
aType = mType;
|
|
|
|
}
|
2014-03-19 19:27:39 +04:00
|
|
|
void GetId(nsAString& aId) const;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
TextTrackMode Mode() const
|
|
|
|
{
|
|
|
|
return mMode;
|
|
|
|
}
|
|
|
|
void SetMode(TextTrackMode aValue);
|
|
|
|
|
|
|
|
TextTrackCueList* GetCues() const
|
|
|
|
{
|
|
|
|
if (mMode == TextTrackMode::Disabled) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mCueList;
|
|
|
|
}
|
|
|
|
|
2013-06-15 00:10:36 +04:00
|
|
|
TextTrackCueList* GetActiveCues();
|
2014-02-27 19:02:40 +04:00
|
|
|
void UpdateActiveCueList();
|
2013-12-12 19:57:21 +04:00
|
|
|
void GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues);
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2014-03-13 22:29:32 +04:00
|
|
|
TextTrackReadyState ReadyState() const;
|
|
|
|
void SetReadyState(TextTrackReadyState aState);
|
2014-03-14 20:13:41 +04:00
|
|
|
void SetReadyState(uint32_t aReadyState);
|
2013-10-25 08:14:36 +04:00
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
void AddCue(TextTrackCue& aCue);
|
2013-06-28 21:31:43 +04:00
|
|
|
void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv);
|
2013-06-15 00:10:36 +04:00
|
|
|
void SetDirty() { mDirty = true; }
|
2013-05-21 20:14:00 +04:00
|
|
|
|
2014-01-27 22:10:06 +04:00
|
|
|
TextTrackList* GetTextTrackList();
|
|
|
|
void SetTextTrackList(TextTrackList* aTextTrackList);
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
IMPL_EVENT_HANDLER(cuechange)
|
|
|
|
|
2014-02-27 23:07:39 +04:00
|
|
|
HTMLTrackElement* GetTrackElement();
|
|
|
|
void SetTrackElement(HTMLTrackElement* aTrackElement);
|
|
|
|
|
2014-02-27 21:47:23 +04:00
|
|
|
TextTrackSource GetTextTrackSource() {
|
|
|
|
return mTextTrackSource;
|
|
|
|
}
|
|
|
|
|
2013-05-21 20:14:00 +04:00
|
|
|
private:
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
2014-01-27 22:10:06 +04:00
|
|
|
nsRefPtr<TextTrackList> mTextTrackList;
|
2013-05-21 20:14:00 +04:00
|
|
|
|
|
|
|
TextTrackKind mKind;
|
|
|
|
nsString mLabel;
|
|
|
|
nsString mLanguage;
|
|
|
|
nsString mType;
|
|
|
|
TextTrackMode mMode;
|
|
|
|
|
|
|
|
nsRefPtr<TextTrackCueList> mCueList;
|
|
|
|
nsRefPtr<TextTrackCueList> mActiveCueList;
|
2014-02-27 23:07:39 +04:00
|
|
|
nsRefPtr<HTMLTrackElement> mTrackElement;
|
2013-06-15 00:10:36 +04:00
|
|
|
|
|
|
|
uint32_t mCuePos;
|
2014-03-13 22:29:32 +04:00
|
|
|
TextTrackReadyState mReadyState;
|
2013-06-15 00:10:36 +04:00
|
|
|
bool mDirty;
|
2014-02-27 21:47:23 +04:00
|
|
|
|
|
|
|
// An enum that represents where the track was sourced from.
|
|
|
|
TextTrackSource mTextTrackSource;
|
2013-05-21 20:14:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_TextTrack_h
|