Commit 243e33e9 authored by eric.carlson@apple.com's avatar eric.carlson@apple.com
Browse files

In-band text tracks infrastructure

https://bugs.webkit.org/show_bug.cgi?id=102830

Reviewed by Philippe Normand.

Add the infrastructure necessary to allow a port-specific media engine to expose in-band text
tracks.

No new tests, this patch only adds plumbing. Existing tests verify that these changes don't
break existing functionality.

* CMakeLists.txt: Add new project files.
* GNUmakefile.list.am: Ditto.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState): Call processInbandTextTracks when readyState reaches
    HAVE_METADATA
(WebCore::HTMLMediaElement::processInbandTextTracks): Fetch the in-band text tracks from the 
    media player and processes them.
* html/HTMLMediaElement.h:

* html/track/InbandTextTrack.cpp: Added.
* html/track/InbandTextTrack.h: Added.
* html/track/InbandTextTrackPrivate.h: Added.

* html/track/TextTrack.h:
(TextTrack):
(WebCore::TextTrack::clearClient): Remove virtual, it is unnecessary
(WebCore::TextTrack::mode): Make virtual so derived classes can override.
(WebCore::TextTrack::setMode): Ditto.

* html/track/TextTrackList.cpp:
(TextTrackList::length): Update to deal with in-band tracks.
(TextTrackList::getTrackIndex): Ditto.
(TextTrackList::getTrackIndexRelativeToRenderedTracks): Ditto.
(TextTrackList::item): Ditto.
(TextTrackList::invalidateTrackIndexesAfterTrack): New, invalidate the cached track indexes of
    all tracks after another.
(TextTrackList::append): Update to deal with in-band tracks.
(TextTrackList::remove): Update to deal with in-band tracks.
(TextTrackList::scheduleAddTrackEvent): Remove typo.
* html/track/TextTrackList.h:

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::getTextTracks): New, pass through to the media engine.
(WebCore::MediaPlayer::setTextTrackClient):
* platform/graphics/MediaPlayer.h:

* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setPreload): Cleanup.
(WebCore::MediaPlayerPrivateInterface::sourceEndOfStream): Ditto.
(WebCore::MediaPlayerPrivateInterface::getTextTracks): New client method.
(WebCore::MediaPlayerPrivateInterface::setTextTrackClient): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135410 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a330ad87
......@@ -1549,6 +1549,7 @@ SET(WebCore_SOURCES
html/shadow/SpinButtonElement.cpp
html/shadow/TextControlInnerElements.cpp
html/track/InbandTextTrack.cpp
html/track/LoadableTextTrack.cpp
html/track/TextTrack.cpp
html/track/TextTrackCue.cpp
......
2012-11-21 Eric Carlson <eric.carlson@apple.com>
In-band text tracks infrastructure
https://bugs.webkit.org/show_bug.cgi?id=102830
Reviewed by Philippe Normand.
Add the infrastructure necessary to allow a port-specific media engine to expose in-band text
tracks.
No new tests, this patch only adds plumbing. Existing tests verify that these changes don't
break existing functionality.
* CMakeLists.txt: Add new project files.
* GNUmakefile.list.am: Ditto.
* Target.pri: Ditto.
* WebCore.gypi: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState): Call processInbandTextTracks when readyState reaches
HAVE_METADATA
(WebCore::HTMLMediaElement::processInbandTextTracks): Fetch the in-band text tracks from the
media player and processes them.
* html/HTMLMediaElement.h:
* html/track/InbandTextTrack.cpp: Added.
* html/track/InbandTextTrack.h: Added.
* html/track/InbandTextTrackPrivate.h: Added.
* html/track/TextTrack.h:
(TextTrack):
(WebCore::TextTrack::clearClient): Remove virtual, it is unnecessary
(WebCore::TextTrack::mode): Make virtual so derived classes can override.
(WebCore::TextTrack::setMode): Ditto.
* html/track/TextTrackList.cpp:
(TextTrackList::length): Update to deal with in-band tracks.
(TextTrackList::getTrackIndex): Ditto.
(TextTrackList::getTrackIndexRelativeToRenderedTracks): Ditto.
(TextTrackList::item): Ditto.
(TextTrackList::invalidateTrackIndexesAfterTrack): New, invalidate the cached track indexes of
all tracks after another.
(TextTrackList::append): Update to deal with in-band tracks.
(TextTrackList::remove): Update to deal with in-band tracks.
(TextTrackList::scheduleAddTrackEvent): Remove typo.
* html/track/TextTrackList.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::getTextTracks): New, pass through to the media engine.
(WebCore::MediaPlayer::setTextTrackClient):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setPreload): Cleanup.
(WebCore::MediaPlayerPrivateInterface::sourceEndOfStream): Ditto.
(WebCore::MediaPlayerPrivateInterface::getTextTracks): New client method.
(WebCore::MediaPlayerPrivateInterface::setTextTrackClient): Ditto.
2012-11-21 Kai Koehne <kai.koehne@digia.com>
 
[Qt] MinGW: Explicitly add OpenGL library dependencies
......@@ -3601,6 +3601,9 @@ webcore_sources += \
Source/WebCore/html/TimeInputType.h \
Source/WebCore/html/TimeRanges.cpp \
Source/WebCore/html/TimeRanges.h \
Source/WebCore/html/track/InbandTextTrack.cpp \
Source/WebCore/html/track/InbandTextTrack.h \
Source/WebCore/html/track/InbandTextTrackPrivate.h \
Source/WebCore/html/track/LoadableTextTrack.cpp \
Source/WebCore/html/track/LoadableTextTrack.h \
Source/WebCore/html/track/TextTrack.cpp \
......
......@@ -1868,6 +1868,8 @@ HEADERS += \
html/shadow/HTMLShadowElement.h \
html/shadow/MediaControlElements.h \
html/shadow/DetailsMarkerControl.h \
html/track/InbandTextTrack.h \
html/track/InbandTextTrackPrivate.h \
html/track/LoadableTextTrack.h \
html/track/TextTrack.h \
html/track/TextTrackCue.h \
......
......@@ -4461,6 +4461,9 @@
'html/shadow/TextControlInnerElements.h',
'html/shadow/TextFieldDecorationElement.cpp',
'html/shadow/TextFieldDecorationElement.h',
'html/track/InbandTextTrack.cpp',
'html/track/InbandTextTrack.h',
'html/track/InbandTextTrackPrivate.h',
'html/track/LoadableTextTrack.cpp',
'html/track/LoadableTextTrack.h',
'html/track/TextTrack.cpp',
......
......@@ -108,6 +108,9 @@
070756DF14239B4E00414161 /* JSTextTrackCueList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 070756D914239B4C00414161 /* JSTextTrackCueList.cpp */; };
070756E014239B4E00414161 /* JSTextTrackCueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 070756DA14239B4E00414161 /* JSTextTrackCueList.h */; };
0709FC4E1025DEE30059CDBA /* AccessibilitySlider.h in Headers */ = {isa = PBXBuildFile; fileRef = 0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */; };
0711BF8E1642D9D100419E36 /* InbandTextTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0711BF8D1642D9D100419E36 /* InbandTextTrack.cpp */; };
0711BF8F1642D9F400419E36 /* InbandTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = 0711BF8C1642D81100419E36 /* InbandTextTrack.h */; };
0711BF9116430C9100419E36 /* InbandTextTrackPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 0711BF9016430C9000419E36 /* InbandTextTrackPrivate.h */; };
0720B0A014D3323500642955 /* GenericEventQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0720B09E14D3323500642955 /* GenericEventQueue.cpp */; };
0720B0A014D3323500642956 /* GestureEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642956 /* GestureEvent.cpp */; };
0720B0A114D3323500642955 /* GenericEventQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 0720B09F14D3323500642955 /* GenericEventQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -7182,6 +7185,9 @@
070756DA14239B4E00414161 /* JSTextTrackCueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueList.h; sourceTree = "<group>"; };
0709FC4D1025DEE30059CDBA /* AccessibilitySlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilitySlider.h; sourceTree = "<group>"; };
070DD8F50F01868000727DEB /* mediaControls.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mediaControls.css; sourceTree = "<group>"; };
0711BF8C1642D81100419E36 /* InbandTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrack.h; sourceTree = "<group>"; };
0711BF8D1642D9D100419E36 /* InbandTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandTextTrack.cpp; sourceTree = "<group>"; };
0711BF9016430C9000419E36 /* InbandTextTrackPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivate.h; sourceTree = "<group>"; };
0720B09E14D3323500642955 /* GenericEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericEventQueue.cpp; sourceTree = "<group>"; };
0720B09F14D3323500642955 /* GenericEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericEventQueue.h; sourceTree = "<group>"; };
0720B09F14D3323500642956 /* GestureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GestureEvent.cpp; sourceTree = "<group>"; };
......@@ -19367,6 +19373,9 @@
B1AD4E7713A12A7200846B27 /* track */ = {
isa = PBXGroup;
children = (
0711BF9016430C9000419E36 /* InbandTextTrackPrivate.h */,
0711BF8D1642D9D100419E36 /* InbandTextTrack.cpp */,
0711BF8C1642D81100419E36 /* InbandTextTrack.h */,
9759E93414EF1CF80026A2DD /* LoadableTextTrack.cpp */,
9759E94814EF1D490026A2DD /* LoadableTextTrack.h */,
9759E93514EF1CF80026A2DD /* TextTrack.cpp */,
......@@ -23943,6 +23952,8 @@
B27535710B053814002CE64F /* ImageSource.h in Headers */,
4B3480940EEF50D400AC1B41 /* ImageSourceCG.h in Headers */,
316FE1180E6E1DA700BF6088 /* ImplicitAnimation.h in Headers */,
0711BF8F1642D9F400419E36 /* InbandTextTrack.h in Headers */,
0711BF9116430C9100419E36 /* InbandTextTrackPrivate.h in Headers */,
DB23C2CC0A508D29002489EB /* IndentOutdentCommand.h in Headers */,
F3644B001119805900E0D537 /* InjectedScript.h in Headers */,
AAB6054F15874C58007B5031 /* InjectedScriptBase.h in Headers */,
......@@ -27149,6 +27160,7 @@
B275355F0B053814002CE64F /* ImageSourceCG.cpp in Sources */,
4B3480930EEF50D400AC1B41 /* ImageSourceCGMac.mm in Sources */,
316FE1170E6E1DA700BF6088 /* ImplicitAnimation.cpp in Sources */,
0711BF8E1642D9D100419E36 /* InbandTextTrack.cpp in Sources */,
DB23C2CB0A508D29002489EB /* IndentOutdentCommand.cpp in Sources */,
F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */,
AAB6054E15874C58007B5031 /* InjectedScriptBase.cpp in Sources */,
......@@ -100,6 +100,8 @@
#if ENABLE(VIDEO_TRACK)
#include "HTMLTrackElement.h"
#include "InbandTextTrack.h"
#include "InbandTextTrackPrivate.h"
#include "RuntimeEnabledFeatures.h"
#include "TextTrackCueList.h"
#include "TextTrackList.h"
......@@ -1740,6 +1742,10 @@ void HTMLMediaElement::setReadyState(MediaPlayer::ReadyState state)
prepareMediaFragmentURI();
scheduleEvent(eventNames().durationchangeEvent);
scheduleEvent(eventNames().loadedmetadataEvent);
#if ENABLE(VIDEO_TRACK)
if (m_player && m_player->hasClosedCaptions())
processInbandTextTracks();
#endif
if (hasMediaControls())
mediaControls()->loadedMetadata();
if (renderer())
......@@ -2718,6 +2724,50 @@ float HTMLMediaElement::percentLoaded() const
}
#if ENABLE(VIDEO_TRACK)
void HTMLMediaElement::processInbandTextTracks()
{
if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())
return;
Vector<RefPtr<InbandTextTrackPrivate> > privateTextTracks;
m_player->getTextTracks(privateTextTracks);
if (!privateTextTracks.size())
return;
for (size_t i = 0; i < privateTextTracks.size(); ++i) {
// 4.8.10.12.2 Sourcing in-band text tracks
// 1. Associate the relevant data with a new text track and its corresponding new TextTrack object.
// 2. Set the new text track's kind, label, and language based on the semantics of the relevant data,
// as defined by the relevant specification. If there is no label in that data, then the label must
// be set to the empty string.
// - This is done by the media engine when it creates the InbandTextTrackPrivate.
RefPtr<TextTrack> textTrack = InbandTextTrack::create(ActiveDOMObject::scriptExecutionContext(), this, privateTextTracks[i]);
// 5. Populate the new text track's list of cues with the cues parsed so far, folllowing the guidelines for exposing
// cues, and begin updating it dynamically as necessary.
// - This will happen automatically as the media engine loads the cues
// 6. Set the new text track's readiness state to loaded.
textTrack->setReadinessState(TextTrack::Loaded);
// 7. Set the new text track's mode to the mode consistent with the user's preferences and the requirements of
// the relevant specification for the data.
// - This will happen in configureTextTracks()
// 8. Add the new text track to the media element's list of text tracks.
textTracks()->append(textTrack);
// 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
// interface, with the track attribute initialized to the text track's TextTrack object, at the media element's
// textTracks attribute's TextTrackList object.
// - This was done in TextTrackList::append
}
configureTextTracks();
}
PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const String& label, const String& language, ExceptionCode& ec)
{
if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())
......@@ -2812,7 +2862,6 @@ void HTMLMediaElement::willRemoveTrack(HTMLTrackElement* trackElement)
if (!m_textTracks)
return;
// 4.8.10.12.3 Sourcing out-of-band text tracks
// When a track element's parent element changes and the old parent was a media element,
// then the user agent must remove the track element's corresponding text track from the
......
......@@ -69,6 +69,8 @@ class DisplaySleepDisabler;
#endif
#if ENABLE(VIDEO_TRACK)
class InbandTextTrackPrivate;
typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
typedef Vector<CueIntervalTree::IntervalType> CueList;
#endif
......@@ -213,6 +215,8 @@ public:
PassRefPtr<TextTrack> addTextTrack(const String& kind, const String& label, ExceptionCode& ec) { return addTextTrack(kind, label, emptyString(), ec); }
PassRefPtr<TextTrack> addTextTrack(const String& kind, ExceptionCode& ec) { return addTextTrack(kind, emptyString(), emptyString(), ec); }
void processInbandTextTracks();
TextTrackList* textTracks();
CueList currentlyActiveCues() const { return m_currentlyActiveCues; }
......
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#if ENABLE(VIDEO_TRACK)
#include "InbandTextTrack.h"
#include "Document.h"
#include "Event.h"
#include "InbandTextTrackPrivate.h"
#include "MediaPlayer.h"
#include "TextTrackCueList.h"
namespace WebCore {
InbandTextTrack::InbandTextTrack(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate> tracksPrivate)
: TextTrack(context, client, emptyString(), tracksPrivate->label(), tracksPrivate->language(), InBand)
, m_private(tracksPrivate)
{
m_private->setClient(this);
switch (tracksPrivate->kind()) {
case InbandTextTrackPrivate::subtitles:
setKind(TextTrack::subtitlesKeyword());
break;
case InbandTextTrackPrivate::captions:
setKind(TextTrack::captionsKeyword());
break;
case InbandTextTrackPrivate::descriptions:
setKind(TextTrack::descriptionsKeyword());
break;
case InbandTextTrackPrivate::chapters:
setKind(TextTrack::chaptersKeyword());
break;
case InbandTextTrackPrivate::metadata:
setKind(TextTrack::metadataKeyword());
break;
case InbandTextTrackPrivate::none:
default:
ASSERT_NOT_REACHED();
break;
}
}
InbandTextTrack::~InbandTextTrack()
{
m_private->setClient(0);
}
void InbandTextTrack::setMode(const AtomicString& mode)
{
TextTrack::setMode(mode);
if (mode == TextTrack::disabledKeyword())
m_private->setMode(InbandTextTrackPrivate::disabled);
else if (mode == TextTrack::hiddenKeyword())
m_private->setMode(InbandTextTrackPrivate::hidden);
else if (mode == TextTrack::showingKeyword())
m_private->setMode(InbandTextTrackPrivate::showing);
else
ASSERT_NOT_REACHED();
}
size_t InbandTextTrack::inbandTrackIndex()
{
ASSERT(m_private);
return m_private->textTrackIndex();
}
void InbandTextTrack::addCue(InbandTextTrackPrivate* trackPrivate, double start, double end, const String& id, const String& content, const String& settings)
{
ASSERT(trackPrivate == m_private);
RefPtr<TextTrackCue> cue = TextTrackCue::create(scriptExecutionContext(), start, end, content);
cue->setId(id);
cue->setCueSettings(settings);
cue->setTrack(this);
if (!m_cues)
m_cues = TextTrackCueList::create();
m_cues->add(cue);
if (client())
client()->textTrackAddCues(this, m_cues.get());
}
} // namespace WebCore
#endif
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef InbandTextTrack_h
#define InbandTextTrack_h
#if ENABLE(VIDEO_TRACK)
#include "TextTrack.h"
#include <wtf/RefPtr.h>
namespace WebCore {
class Document;
class InbandTextTrackPrivate;
class MediaPlayer;
class TextTrackCue;
class InbandTextTrackClient {
public:
virtual ~InbandTextTrackClient() { }
virtual void addCue(InbandTextTrackPrivate*, double /*start*/, double /*end*/, const String& /*id*/, const String& /*content*/, const String& /*settings*/) { }
};
class InbandTextTrack : public TextTrack, public InbandTextTrackClient {
public:
static PassRefPtr<InbandTextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate> playerPrivate)
{
return adoptRef(new InbandTextTrack(context, client, playerPrivate));
}
virtual ~InbandTextTrack();
virtual void setMode(const AtomicString&) OVERRIDE;
size_t inbandTrackIndex();
private:
InbandTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
virtual void addCue(InbandTextTrackPrivate*, double, double, const String&, const String&, const String&);
RefPtr<InbandTextTrackPrivate> m_private;
};
} // namespace WebCore
#endif
#endif
/*
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef InbandTextTrackPrivate_h
#define InbandTextTrackPrivate_h
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefCounted.h>
#include <wtf/text/AtomicString.h>
#if ENABLE(VIDEO_TRACK)
namespace WebCore {
class InbandTextTrackClient;
class InbandTextTrackPrivate : public RefCounted<InbandTextTrackPrivate> {
WTF_MAKE_NONCOPYABLE(InbandTextTrackPrivate); WTF_MAKE_FAST_ALLOCATED;
public:
static PassRefPtr<InbandTextTrackPrivate> create()
{
return adoptRef(new InbandTextTrackPrivate());
}
virtual ~InbandTextTrackPrivate() { }
void setClient(InbandTextTrackClient* client) { m_client = client; }
InbandTextTrackClient* client() { return m_client; }
enum Mode { disabled, hidden, showing };
virtual void setMode(Mode mode) { m_mode = mode; };
virtual InbandTextTrackPrivate::Mode mode() const { return m_mode; }
enum Kind { subtitles, captions, descriptions, chapters, metadata, none };
virtual Kind kind() const { return subtitles; }
virtual AtomicString label() const { return emptyString(); }
virtual AtomicString language() const { return emptyString(); }
virtual bool isDefault() const { return false; }
virtual int textTrackIndex() const { return 0; }
protected:
InbandTextTrackPrivate()
: m_client(0)
, m_mode(disabled)
{
}
private:
InbandTextTrackClient* m_client;
Mode m_mode;
};
} // namespace WebCore
#endif
#endif
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
* Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -83,8 +84,8 @@ public:
static const AtomicString& hiddenKeyword();
static const AtomicString& showingKeyword();
AtomicString mode() const;
void setMode(const AtomicString&);
virtual AtomicString mode() const;
virtual void setMode(const AtomicString&);
bool showingByDefault() const { return m_showingByDefault; }
void setShowingByDefault(bool showing) { m_showingByDefault = showing; }
......@@ -96,7 +97,7 @@ public:
TextTrackCueList* cues();
TextTrackCueList* activeCues() const;
virtual void clearClient() { m_client = 0; }
void clearClient() { m_client = 0; }
TextTrackClient* client() { return m_client; }
void addCue(PassRefPtr<TextTrackCue>, ExceptionCode&);
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
* Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -31,6 +31,8 @@
#include "EventNames.h"
#include "HTMLMediaElement.h"
#include "InbandTextTrack.h"
#include "InbandTextTrackPrivate.h"
#include "LoadableTextTrack.h"
#include "ScriptExecutionContext.h"
#include "TextTrack.h"
......@@ -53,7 +55,7 @@ TextTrackList::~TextTrackList()
unsigned TextTrackList::length() const
{
return m_addTrackTracks.size() + m_elementTracks.size();
return m_addTrackTracks.size() + m_elementTracks.size() + m_inbandTracks.size();
}
int TextTrackList::getTrackIndex(TextTrack *textTrack)
......@@ -64,6 +66,9 @@ int TextTrackList::getTrackIndex(TextTrack *textTrack)
if (textTrack->trackType() == TextTrack::AddTrack)
return m_elementTracks.size() + m_addTrackTracks.find(textTrack);
if (textTrack->trackType() == TextTrack::InBand)
return m_elementTracks.size() + m_addTrackTracks.size() + m_inbandTracks.find(textTrack);
ASSERT_NOT_REACHED();
return -1;
......@@ -82,7 +87,7 @@ int TextTrackList::getTrackIndexRelativeToRenderedTracks(TextTrack *textTrack)
return trackIndex;
++trackIndex;
}
for (size_t i = 0; i < m_addTrackTracks.size(); ++i) {
if (!m_addTrackTracks[i]->isRendered())
continue;
......@@ -91,9 +96,18 @@ int TextTrackList::getTrackIndexRelativeToRenderedTracks(TextTrack *textTrack)
return trackIndex;
++trackIndex;
}
for (size_t i = 0; i < m_inbandTracks.size(); ++i) {
if (!m_inbandTracks[i]->isRendered())
continue;
if (m_inbandTracks[i] == textTrack)
return trackIndex;
++trackIndex;
}
ASSERT_NOT_REACHED();
return -1;
}
......@@ -113,9 +127,40 @@ TextTrack* TextTrackList::item(unsigned index)
if (index < m_addTrackTracks.size())
return m_addTrackTracks[index].get();
index -= m_addTrackTracks.size();
if (index < m_inbandTracks.size())
return m_inbandTracks[index].get();
return 0;