platform/graphics/IntPoint.cpp
platform/graphics/IntRect.cpp
platform/graphics/IntSize.cpp
- platform/graphics/ISOVTTCue.cpp
platform/graphics/LayoutBoxExtent.cpp
platform/graphics/LayoutRect.cpp
platform/graphics/MediaPlayer.cpp
+2014-06-23 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r170323.
+ https://bugs.webkit.org/show_bug.cgi?id=134224
+
+ lots of build breakage (Requested by bradeeoh on #webkit).
+
+ Reverted changeset:
+
+ "[Mac] process raw VTT in-band captions"
+ https://bugs.webkit.org/show_bug.cgi?id=134178
+ http://trac.webkit.org/changeset/170323
+
2014-06-23 Jeffrey Pfau <jpfau@apple.com>
Fix release build
if (this.hideTimer)
clearTimeout(this.hideTimer);
this.hideTimer = setTimeout(this.hideControls.bind(this), this.HideControlsDelay);
- } else if (this.canPlay())
+ } else if (!this.canPlay())
this.hideControls();
},
<ClCompile Include="..\platform\FileChooser.cpp" />
<ClCompile Include="..\platform\FileStream.cpp" />
<ClCompile Include="..\platform\FileSystem.cpp" />
- <ClCompile Include="..\platform\graphics\ISOVTTCue.cpp" />
<ClCompile Include="..\platform\audio\AudioSession.cpp" />
<ClCompile Include="..\platform\audio\MediaSession.cpp" />
<ClCompile Include="..\platform\audio\MediaSessionManager.cpp" />
<ClInclude Include="..\platform\graphics\IntRect.h" />
<ClInclude Include="..\platform\graphics\IntSize.h" />
<ClInclude Include="..\platform\graphics\IntSizeHash.h" />
- <ClInclude Include="..\platform\graphics\ISOVTTCue.h" />
<ClInclude Include="..\platform\graphics\LayoutBoxExtent.h" />
<ClInclude Include="..\platform\graphics\LayoutPoint.h" />
<ClInclude Include="..\platform\graphics\LayoutRect.h" />
07AB996B18DA3C010018771E /* RTCIceServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996718DA3C010018771E /* RTCIceServer.h */; };
07AB996F18DA3C740018771E /* RTCConfigurationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996D18DA3C740018771E /* RTCConfigurationPrivate.h */; };
07AB997018DA3C740018771E /* RTCIceServerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996E18DA3C740018771E /* RTCIceServerPrivate.h */; };
- 07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */; };
- 07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AC47001952102100EE9723 /* ISOVTTCue.h */; };
07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */; };
07B442D6166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */; };
07B442D7166C70B000556CAD /* InbandTextTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */; settings = {ATTRIBUTES = (Private, ); }; };
07AB996818DA3C010018771E /* RTCIceServer.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCIceServer.idl; sourceTree = "<group>"; };
07AB996D18DA3C740018771E /* RTCConfigurationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCConfigurationPrivate.h; sourceTree = "<group>"; };
07AB996E18DA3C740018771E /* RTCIceServerPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceServerPrivate.h; sourceTree = "<group>"; };
- 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOVTTCue.cpp; path = ISOVTTCue.cpp; sourceTree = "<group>"; };
- 07AC47001952102100EE9723 /* ISOVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOVTTCue.h; path = ISOVTTCue.h; sourceTree = "<group>"; };
07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMediaControls.h; sourceTree = "<group>"; };
07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandTextTrackPrivateAVF.cpp; sourceTree = "<group>"; };
07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateAVF.h; sourceTree = "<group>"; };
2D46F04F17B96FD2005647F0 /* IntSize.cpp */,
B27535470B053814002CE64F /* IntSize.h */,
B27535480B053814002CE64F /* IntSizeHash.h */,
- 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */,
- 07AC47001952102100EE9723 /* ISOVTTCue.h */,
65CC6BED16014EC0000ED27D /* Latin1TextIterator.h */,
141DC049164834B900371E5A /* LayoutBoxExtent.cpp */,
141DC04A164834B900371E5A /* LayoutBoxExtent.h */,
E1FF8F65180745D800132674 /* JSSubtleCrypto.h in Headers */,
B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */,
24D9129213CA951E00D21915 /* JSSVGAltGlyphDefElement.h in Headers */,
- 07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */,
6515EC920D9723FF0063D49A /* JSSVGAltGlyphElement.h in Headers */,
24D9129613CA956100D21915 /* JSSVGAltGlyphItemElement.h in Headers */,
B222F6990AB771950022EFAD /* JSSVGAngle.h in Headers */,
B2227A530D00BF220071B782 /* SVGPaint.cpp in Sources */,
B2227A560D00BF220071B782 /* SVGParserUtilities.cpp in Sources */,
84C6784C1214814700A92902 /* SVGPathBlender.cpp in Sources */,
- 07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */,
8476C9EA11DF6A2900555B02 /* SVGPathBuilder.cpp in Sources */,
8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */,
8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */,
// Returns true if EOS has been reached proper.
bool isAtEndOfStream() const { return m_endOfStream && m_buffer.isEmpty(); }
- void reset() { m_buffer.clear(); }
-
private:
// Consume the next character the buffer if it is the character |c|.
void scanCharacter(UChar c)
/*
- * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
+ * 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
#include <math.h>
#include <wtf/text/CString.h>
-#if ENABLE(WEBVTT_REGIONS)
-#include "VTTRegionList.h"
-#endif
-
namespace WebCore {
GenericTextTrackCueMap::GenericTextTrackCueMap()
TextTrack::removeCue(cue, ec);
}
-WebVTTParser& InbandGenericTextTrack::parser()
-{
- if (!m_webVTTParser)
- m_webVTTParser = std::make_unique<WebVTTParser>(static_cast<WebVTTParserClient*>(this), scriptExecutionContext());
- return *m_webVTTParser;
-}
-
-void InbandGenericTextTrack::parseWebVTTCueData(InbandTextTrackPrivate* trackPrivate, const ISOWebVTTCue& cueData)
-{
- ASSERT_UNUSED(trackPrivate, trackPrivate == m_private);
- parser().parseCueData(cueData);
-}
-
-void InbandGenericTextTrack::parseWebVTTFileHeader(InbandTextTrackPrivate* trackPrivate, String header)
-{
- ASSERT_UNUSED(trackPrivate, trackPrivate == m_private);
- parser().parseFileHeader(header);
-}
-
-void InbandGenericTextTrack::newCuesParsed()
-{
- Vector<RefPtr<WebVTTCueData>> cues;
- parser().getNewCues(cues);
-
- for (auto& cueData : cues) {
- RefPtr<VTTCue> vttCue = VTTCue::create(*scriptExecutionContext(), *cueData);
-
- if (hasCue(vttCue.get(), TextTrackCue::IgnoreDuration)) {
- LOG(Media, "InbandGenericTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data());
- return;
- }
- addCue(vttCue.release(), ASSERT_NO_EXCEPTION);
- }
-}
-
-#if ENABLE(WEBVTT_REGIONS)
-void InbandGenericTextTrack::newRegionsParsed()
-{
- Vector<RefPtr<VTTRegion>> newRegions;
- parser().getNewRegions(newRegions);
-
- for (auto& region : newRegions) {
- region->setTrack(this);
- regions()->add(region);
- }
-}
-#endif
-
-void InbandGenericTextTrack::fileFailedToParse()
-{
- LOG(Media, "Error parsing WebVTT stream.");
-}
-
} // namespace WebCore
#endif
/*
- * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "InbandTextTrack.h"
#include "TextTrackCueGeneric.h"
-#include "WebVTTParser.h"
#include <wtf/RefPtr.h>
namespace WebCore {
CueDataToCueMap m_dataToCueMap;
};
-class InbandGenericTextTrack : public InbandTextTrack, private WebVTTParserClient {
+class InbandGenericTextTrack : public InbandTextTrack {
public:
static PassRefPtr<InbandGenericTextTrack> create(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
virtual ~InbandGenericTextTrack();
PassRefPtr<TextTrackCueGeneric> createCue(PassRefPtr<GenericCueData>);
void updateCueFromCueData(TextTrackCueGeneric*, GenericCueData*);
- WebVTTParser& parser();
- virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override;
- virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) override;
-
- virtual void newCuesParsed() override;
-#if ENABLE(WEBVTT_REGIONS)
- virtual void newRegionsParsed() override;
-#endif
- virtual void fileFailedToParse() override;
-
GenericTextTrackCueMap m_cueMap;
- std::unique_ptr<WebVTTParser> m_webVTTParser;
};
} // namespace WebCore
virtual void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) override { ASSERT_NOT_REACHED(); }
virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) override { ASSERT_NOT_REACHED(); }
- virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) override { ASSERT_NOT_REACHED(); }
virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char*, unsigned) override { ASSERT_NOT_REACHED(); }
- virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override { ASSERT_NOT_REACHED(); }
-
virtual double startTimeVariance() const;
#if USE(PLATFORM_TEXT_TRACK_MENU)
#include "NotImplemented.h"
#include <wtf/text/CString.h>
-#if ENABLE(WEBVTT_REGIONS)
-#include "VTTRegionList.h"
-#endif
-
namespace WebCore {
PassRefPtr<InbandTextTrack> InbandWebVTTTextTrack::create(ScriptExecutionContext* context, TextTrackClient* client, PassRefPtr<InbandTextTrackPrivate> playerPrivate)
{
}
-WebVTTParser& InbandWebVTTTextTrack::parser()
-{
- if (!m_webVTTParser)
- m_webVTTParser = std::make_unique<WebVTTParser>(static_cast<WebVTTParserClient*>(this), scriptExecutionContext());
- return *m_webVTTParser;
-}
-
void InbandWebVTTTextTrack::parseWebVTTCueData(InbandTextTrackPrivate* trackPrivate, const char* data, unsigned length)
{
ASSERT_UNUSED(trackPrivate, trackPrivate == m_private);
- parser().parseBytes(data, length);
-}
-
-void InbandWebVTTTextTrack::parseWebVTTCueData(InbandTextTrackPrivate* trackPrivate, const ISOWebVTTCue& cueData)
-{
- ASSERT_UNUSED(trackPrivate, trackPrivate == m_private);
- parser().parseCueData(cueData);
+ if (!m_webVTTParser)
+ m_webVTTParser = std::make_unique<WebVTTParser>(static_cast<WebVTTParserClient*>(this), scriptExecutionContext());
+ m_webVTTParser->parseBytes(data, length);
}
void InbandWebVTTTextTrack::newCuesParsed()
{
Vector<RefPtr<WebVTTCueData>> cues;
- parser().getNewCues(cues);
-
- for (auto& cueData : cues) {
- RefPtr<VTTCue> vttCue = VTTCue::create(*scriptExecutionContext(), *cueData);
-
- if (hasCue(vttCue.get(), TextTrackCue::IgnoreDuration)) {
- LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data());
+ m_webVTTParser->getNewCues(cues);
+ for (size_t i = 0; i < cues.size(); ++i) {
+ RefPtr<WebVTTCueData> cueData = cues[i];
+ RefPtr<VTTCue> cue = VTTCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
+ cue->setId(cueData->id());
+ cue->setCueSettings(cueData->settings());
+
+ if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
+ LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data());
return;
}
- addCue(vttCue.release(), ASSERT_NO_EXCEPTION);
+ addCue(cue.release(), ASSERT_NO_EXCEPTION);
}
}
#if ENABLE(WEBVTT_REGIONS)
void InbandWebVTTTextTrack::newRegionsParsed()
{
- Vector<RefPtr<VTTRegion>> newRegions;
- parser().getNewRegions(newRegions);
-
- for (auto& region : newRegions) {
- region->setTrack(this);
- regions()->add(region);
- }
+ notImplemented();
}
#endif
void InbandWebVTTTextTrack::fileFailedToParse()
{
- LOG(Media, "Error parsing WebVTT stream.");
+ LOG(Media, "Unable to parse WebVTT stream.");
}
} // namespace WebCore
private:
InbandWebVTTTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>);
- WebVTTParser& parser();
virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char* data, unsigned length) override;
- virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override;
virtual void newCuesParsed() override;
#if ENABLE(WEBVTT_REGIONS)
class TextTrackCueGenericBoxElement final : public VTTCueBox {
public:
- static PassRefPtr<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric& cue)
+ static PassRefPtr<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric* cue)
{
return adoptRef(new TextTrackCueGenericBoxElement(document, cue));
}
virtual void applyCSSProperties(const IntSize&) override;
private:
- TextTrackCueGenericBoxElement(Document&, VTTCue&);
+ TextTrackCueGenericBoxElement(Document&, VTTCue*);
};
-TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue& cue)
+TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue* cue)
: VTTCueBox(document, cue)
{
}
PassRefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree()
{
- return TextTrackCueGenericBoxElement::create(ownerDocument(), *this);
+ return TextTrackCueGenericBoxElement::create(ownerDocument(), this);
}
void TextTrackCueGeneric::setLine(int line, ExceptionCode& ec)
// ----------------------------
-PassRefPtr<VTTCueBox> VTTCueBox::create(Document& document, VTTCue& cue)
-{
- VTTCueBox* cueBox = new VTTCueBox(document, cue);
- cueBox->setPseudo(VTTCueBox::vttCueBoxShadowPseudoId());
- return adoptRef(cueBox);
-}
-
-VTTCueBox::VTTCueBox(Document& document, VTTCue& cue)
+VTTCueBox::VTTCueBox(Document& document, VTTCue* cue)
: HTMLElement(divTag, document)
, m_cue(cue)
{
VTTCue* VTTCueBox::getCue() const
{
- return &m_cue;
+ return m_cue;
}
void VTTCueBox::applyCSSProperties(const IntSize&)
{
// FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
#if ENABLE(WEBVTT_REGIONS)
- if (!m_cue.regionId().isEmpty()) {
+ if (!m_cue->regionId().isEmpty()) {
setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative);
return;
}
setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueWebkitPlaintext);
// the 'direction' property must be set to direction
- setInlineStyleProperty(CSSPropertyDirection, m_cue.getCSSWritingDirection());
+ setInlineStyleProperty(CSSPropertyDirection, m_cue->getCSSWritingDirection());
// the 'writing-mode' property must be set to writing-mode
- setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue.getCSSWritingMode(), false);
+ setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue->getCSSWritingMode(), false);
- std::pair<float, float> position = m_cue.getCSSPosition();
+ std::pair<float, float> position = m_cue->getCSSPosition();
// the 'top' property must be set to top,
setInlineStyleProperty(CSSPropertyTop, static_cast<double>(position.second), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
// the 'width' property must be set to width, and the 'height' property must be set to height
- if (m_cue.vertical() == horizontalKeyword()) {
- setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ if (m_cue->vertical() == horizontalKeyword()) {
+ setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
} else {
setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
- setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
}
// The 'text-align' property on the (root) List of WebVTT Node Objects must
// be set to the value in the second cell of the row of the table below
// whose first cell is the value of the corresponding cue's text track cue
// alignment:
- setInlineStyleProperty(CSSPropertyTextAlign, m_cue.getCSSAlignment());
+ setInlineStyleProperty(CSSPropertyTextAlign, m_cue->getCSSAlignment());
- if (!m_cue.snapToLines()) {
+ if (!m_cue->snapToLines()) {
// 10.13.1 Set up x and y:
// Note: x and y are set through the CSS left and top above.
// ----------------------------
-PassRefPtr<VTTCue> VTTCue::create(ScriptExecutionContext& context, double start, double end, const String& content)
-{
- return adoptRef(new VTTCue(context, start, end, content));
-}
-
-PassRefPtr<VTTCue> VTTCue::create(ScriptExecutionContext& context, const WebVTTCueData& data)
-{
- return adoptRef(new VTTCue(context, data));
-}
-
VTTCue::VTTCue(ScriptExecutionContext& context, double start, double end, const String& content)
: TextTrackCue(context, start, end)
, m_content(content)
+ , m_linePosition(undefinedPosition)
+ , m_computedLinePosition(undefinedPosition)
+ , m_textPosition(50)
+ , m_cueSize(100)
+ , m_writingDirection(Horizontal)
+ , m_cueAlignment(Middle)
+ , m_webVTTNodeTree(nullptr)
+ , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))
+ , m_displayDirection(CSSValueLtr)
+ , m_displaySize(0)
+ , m_snapToLines(true)
+ , m_displayTreeShouldChange(true)
+ , m_notifyRegion(true)
{
- initialize(context);
-}
-
-VTTCue::VTTCue(ScriptExecutionContext& context, const WebVTTCueData& cueData)
- : TextTrackCue(context, 0, 0)
-{
- initialize(context);
- setText(cueData.content());
- setStartTime(cueData.startTime(), IGNORE_EXCEPTION);
- setEndTime(cueData.endTime(), IGNORE_EXCEPTION);
- setId(cueData.id());
- setCueSettings(cueData.settings());
- m_originalStartTime = cueData.originalStartTime();
}
VTTCue::~VTTCue()
displayTreeInternal()->remove(ASSERT_NO_EXCEPTION);
}
-void VTTCue::initialize(ScriptExecutionContext& context)
-{
- m_linePosition = undefinedPosition;
- m_computedLinePosition = undefinedPosition;
- m_textPosition = 50;
- m_cueSize = 100;
- m_writingDirection = Horizontal;
- m_cueAlignment = Middle;
- m_webVTTNodeTree = nullptr;
- m_cueBackgroundBox = HTMLSpanElement::create(spanTag, toDocument(context));
- m_displayDirection = CSSValueLtr;
- m_displaySize = 0;
- m_snapToLines = true;
- m_displayTreeShouldChange = true;
- m_notifyRegion = true;
- m_originalStartTime = 0;
-}
-
PassRefPtr<VTTCueBox> VTTCue::createDisplayTree()
{
- return VTTCueBox::create(ownerDocument(), *this);
+ return VTTCueBox::create(ownerDocument(), this);
}
VTTCueBox* VTTCue::displayTreeInternal()
bool check = WebVTTParser::collectTimeStamp(child->nodeValue(), currentTimestamp);
ASSERT_UNUSED(check, check);
- currentTimestamp += m_originalStartTime;
if (currentTimestamp > movieTime)
isPastNode = false;
}
void VTTCue::setCueSettings(const String& inputString)
{
- if (inputString.isEmpty())
- return;
-
VTTScanner input(inputString);
while (!input.isAtEnd()) {
class ScriptExecutionContext;
class VTTCue;
class VTTScanner;
-class WebVTTCueData;
// ----------------------------
class VTTCueBox : public HTMLElement {
public:
- static PassRefPtr<VTTCueBox> create(Document&, VTTCue&);
+ static PassRefPtr<VTTCueBox> create(Document& document, VTTCue* cue)
+ {
+ return adoptRef(new VTTCueBox(document, cue));
+ }
VTTCue* getCue() const;
virtual void applyCSSProperties(const IntSize& videoSize);
static const AtomicString& vttCueBoxShadowPseudoId();
protected:
- VTTCueBox(Document&, VTTCue&);
+ VTTCueBox(Document&, VTTCue*);
virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
- VTTCue& m_cue;
+ VTTCue* m_cue;
};
// ----------------------------
class VTTCue : public TextTrackCue {
public:
- static PassRefPtr<VTTCue> create(ScriptExecutionContext&, double start, double end, const String&);
- static PassRefPtr<VTTCue> create(ScriptExecutionContext&, const WebVTTCueData&);
+ static PassRefPtr<VTTCue> create(ScriptExecutionContext& context, double start, double end, const String& content)
+ {
+ return adoptRef(new VTTCue(context, start, end, content));
+ }
virtual ~VTTCue();
protected:
VTTCue(ScriptExecutionContext&, double start, double end, const String& content);
- VTTCue(ScriptExecutionContext&, const WebVTTCueData&);
virtual PassRefPtr<VTTCueBox> createDisplayTree();
VTTCueBox* displayTreeInternal();
private:
- void initialize(ScriptExecutionContext&);
void createWebVTTNodeTree();
void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root);
int m_displaySize;
std::pair<float, float> m_displayPosition;
- double m_originalStartTime;
-
bool m_snapToLines : 1;
bool m_displayTreeShouldChange : 1;
bool m_notifyRegion : 1;
/*
* Copyright (C) 2011, 2013 Google Inc. All rights reserved.
* Copyright (C) 2013 Cable Television Labs, Inc.
- * Copyright (C) 2011-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 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
#include "WebVTTParser.h"
-#include "ISOVTTCue.h"
#include "ProcessingInstruction.h"
#include "Text.h"
#include "VTTScanner.h"
}
#endif
-void WebVTTParser::parseFileHeader(const String& data)
-{
- m_state = Initial;
- m_lineReader.reset();
- m_lineReader.append(data);
- parse();
-}
-
void WebVTTParser::parseBytes(const char* data, unsigned length)
{
String textData = m_decoder->decode(data, length);
parse();
}
-void WebVTTParser::parseCueData(const ISOWebVTTCue& data)
-{
- RefPtr<WebVTTCueData> cue = WebVTTCueData::create();
-
- double startTime = data.presentationTime().toDouble();
- cue->setStartTime(startTime);
- cue->setEndTime(startTime + data.duration().toDouble());
-
- cue->setContent(data.cueText());
- cue->setId(data.id());
- cue->setSettings(data.settings());
-
- double originalStartTime;
- if (WebVTTParser::collectTimeStamp(data.originalStartTime(), originalStartTime))
- cue->setOriginalStartTime(originalStartTime);
-
- m_cuelist.append(cue);
- if (m_client)
- m_client->newCuesParsed();
-}
-
void WebVTTParser::flush()
{
String textData = m_decoder->flush();
WebVTTParser::ParseState WebVTTParser::collectTimingsAndSettings(const String& line)
{
- if (line.isEmpty())
- return BadCue;
-
VTTScanner input(line);
// Collect WebVTT cue timings and settings. (5.3 WebVTT cue timings and settings parsing.)
bool WebVTTParser::collectTimeStamp(const String& line, double& timeStamp)
{
- if (line.isEmpty())
- return false;
-
VTTScanner input(line);
return collectTimeStamp(input, timeStamp);
}
using namespace HTMLNames;
class Document;
-class ISOWebVTTCue;
class VTTScanner;
class WebVTTParserClient {
String settings() const { return m_settings; }
void setSettings(String settings) { m_settings = settings; }
- double originalStartTime() const { return m_originalStartTime; }
- void setOriginalStartTime(double time) { m_originalStartTime = time; }
-
private:
WebVTTCueData()
: m_startTime(0)
, m_endTime(0)
- , m_originalStartTime(0)
{
}
double m_startTime;
double m_endTime;
- double m_originalStartTime;
String m_id;
String m_content;
String m_settings;
#endif
// Input data to the parser to parse.
- void parseBytes(const char*, unsigned);
- void parseFileHeader(const String&);
- void parseCueData(const ISOWebVTTCue&);
+ void parseBytes(const char* data, unsigned length);
void flush();
void fileFinished();
double m_currentEndTime;
StringBuilder m_currentContent;
String m_currentSettings;
-
+
WebVTTParserClient* m_client;
Vector<RefPtr<WebVTTCueData>> m_cuelist;
if (m_cueParser) {
Vector<RefPtr<WebVTTCueData>> newCues;
m_cueParser->getNewCues(newCues);
-
- for (auto& cueData : newCues)
- outputCues.append(VTTCue::create(*m_scriptExecutionContext, *cueData));
+ for (size_t i = 0; i < newCues.size(); ++i) {
+ RefPtr<WebVTTCueData> data = newCues[i];
+ RefPtr<VTTCue> cue = VTTCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content());
+ cue->setId(data->id());
+ cue->setCueSettings(data->settings());
+ outputCues.append(cue);
+ }
}
}
+++ /dev/null
-/*
- * Copyright (C) 2014 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 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 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"
-#include "ISOVTTCue.h"
-
-#include "Logging.h"
-#include <runtime/ArrayBuffer.h>
-#include <runtime/DataView.h>
-#include <runtime/Int8Array.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-
-namespace JSC {
-class ArrayBuffer;
-}
-
-namespace WebCore {
-
-ISOBox::ISOBox(ArrayBuffer* data)
-{
- m_type = peekType(data);
- m_length = peekLength(data);
- ASSERT(m_length >= 8);
-}
-
-String ISOBox::peekType(ArrayBuffer* data)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(data->byteLength() >= 2 * sizeof(uint32_t));
- if (data->byteLength() < 2 * sizeof(uint32_t))
- return emptyString();
-
- StringBuilder builder;
- RefPtr<Int8Array> array = JSC::Int8Array::create(data, 4, sizeof(uint32_t));
- for (int i = 0; i < 4; ++i)
- builder.append(array->item(i));
- return builder.toString();
-}
-
-size_t ISOBox::peekLength(ArrayBuffer* data)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(data->byteLength() >= sizeof(uint32_t));
- if (data->byteLength() < sizeof(uint32_t))
- return 0;
-
- return JSC::DataView::create(data, 0, sizeof(uint32_t))->get<uint32_t>(0, false);
-}
-
-String ISOBox::peekString(ArrayBuffer* data, unsigned offset, unsigned length)
-{
- ASSERT_WITH_SECURITY_IMPLICATION(offset + length <= data->byteLength());
- if (data->byteLength() < offset + length)
- return emptyString();
-
- return String(JSC::Uint8Array::create(data, offset, length)->data(), length);
-}
-
-static const AtomicString& vttCueBoxType()
-{
- static NeverDestroyed<AtomicString> vttc("vttc", AtomicString::ConstructFromLiteral);
- return vttc;
-}
-
-static const AtomicString& vttIdBoxType()
-{
- static NeverDestroyed<AtomicString> iden("iden", AtomicString::ConstructFromLiteral);
- return iden;
-}
-
-static const AtomicString& vttSettingsBoxType()
-{
- static NeverDestroyed<AtomicString> sttg("sttg", AtomicString::ConstructFromLiteral);
- return sttg;
-}
-
-static const AtomicString& vttPayloadBoxType()
-{
- static NeverDestroyed<AtomicString> payl("payl", AtomicString::ConstructFromLiteral);
- return payl;
-}
-
-static const AtomicString& vttCurrentTimeBoxType()
-{
- static NeverDestroyed<AtomicString> ctim("ctim", AtomicString::ConstructFromLiteral);
- return ctim;
-}
-
-static const AtomicString& vttCueSourceIDBoxType()
-{
- static NeverDestroyed<AtomicString> vsid("vsid", AtomicString::ConstructFromLiteral);
- return vsid;
-}
-
-const AtomicString& ISOWebVTTCue::boxType()
-{
- return vttCueBoxType();
-}
-
-ISOWebVTTCue::ISOWebVTTCue(const MediaTime& presentationTime, const MediaTime& duration, JSC::ArrayBuffer* buffer)
- : ISOBox(buffer)
- , m_presentationTime(presentationTime)
- , m_duration(duration)
-{
- size_t offset = ISOBox::boxHeaderSize();
- while (offset < length() && length() - offset > ISOBox::boxHeaderSize()) {
- RefPtr<ArrayBuffer> subBuffer = buffer->slice(offset);
- String boxType = ISOBox::peekType(subBuffer.get());
- size_t boxSize = ISOBox::peekLength(subBuffer.get());
- size_t boxDataSize = boxSize - ISOBox::boxHeaderSize();
-
- if (boxType == vttCueSourceIDBoxType())
- m_sourceID = peekString(subBuffer.get(), ISOBox::boxHeaderSize(), boxDataSize);
- else if (boxType == vttIdBoxType())
- m_identifer = peekString(subBuffer.get(), ISOBox::boxHeaderSize(), boxDataSize);
- else if (boxType == vttCurrentTimeBoxType())
- m_originalStartTime = peekString(subBuffer.get(), ISOBox::boxHeaderSize(), boxDataSize);
- else if (boxType == vttSettingsBoxType())
- m_settings = peekString(subBuffer.get(), ISOBox::boxHeaderSize(), boxDataSize);
- else if (boxType == vttPayloadBoxType())
- m_cueText = peekString(subBuffer.get(), ISOBox::boxHeaderSize(), boxDataSize);
- else
- LOG(Media, "ISOWebVTTCue::ISOWebVTTCue - skipping box id = \"%s\", size = %zu", boxType.utf8().data(), boxSize);
-
- offset += boxSize;
- }
-}
-
-} // namespace WebCore
+++ /dev/null
-/*
- * Copyright (C) 2014 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 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 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 ISOVTTCue_h
-#define ISOVTTCue_h
-
-#include <wtf/MediaTime.h>
-#include <wtf/text/WTFString.h>
-
-namespace JSC {
-class ArrayBuffer;
-}
-
-namespace WebCore {
-
-// An ISOBox represents a ISO-BMFF box. Data in the structure is big-endian. The layout of the data structure as follows:
-// 4 bytes : 4CC : identifier
-// 4 bytes : unsigned : length
-class ISOBox {
-public:
- static String peekType(JSC::ArrayBuffer*);
- static size_t peekLength(JSC::ArrayBuffer*);
- static String peekString(JSC::ArrayBuffer*, unsigned offset, unsigned length);
- static unsigned boxHeaderSize() { return 2 * sizeof(uint32_t); }
-
- size_t length() const { return m_length; }
- const AtomicString& type() const { return m_type; }
-
-protected:
- ISOBox(JSC::ArrayBuffer*);
-
-private:
- size_t m_length;
- AtomicString m_type;
-};
-
-// 4 bytes : 4CC : identifier = 'vttc'
-// 4 bytes : unsigned : length
-// N bytes :CueSourceIDBox : box : optional
-// N bytes :CueIDBox : box : optional
-// N bytes :CueTimeBox : box : optional
-// N bytes :CueSettingsBox : box : optional
-// N bytes :CuePayloadBox : box : required
-class ISOWebVTTCue : public ISOBox {
-public:
- ISOWebVTTCue(const MediaTime& presentationTime, const MediaTime& duration, JSC::ArrayBuffer*);
-
- static const AtomicString& boxType();
-
- const MediaTime& presentationTime() const { return m_presentationTime; }
- const MediaTime& duration() const { return m_duration; }
-
- const String& sourceID() const { return m_sourceID; }
- const String& id() const { return m_identifer; }
- const String& originalStartTime() const { return m_originalStartTime; }
- const String& settings() const { return m_settings; }
- const String& cueText() const { return m_cueText; }
-
-private:
- MediaTime m_presentationTime;
- MediaTime m_duration;
-
- String m_sourceID;
- String m_identifer;
- String m_originalStartTime;
- String m_settings;
- String m_cueText;
-};
-
-}
-
-#endif // ISOVTTCue_h
/*
- * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
namespace WebCore {
class InbandTextTrackPrivate;
-class ISOWebVTTCue;
class GenericCueData : public RefCounted<GenericCueData> {
public:
virtual void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0;
virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0;
- virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) { ASSERT_NOT_REACHED(); }
virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char* data, unsigned length) = 0;
- virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) = 0;
};
} // namespace WebCore
/*
- * Copyright (C) 2012-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "InbandTextTrackPrivateAVF.h"
-#include "ISOVTTCue.h"
#include "InbandTextTrackPrivateClient.h"
#include "Logging.h"
#include "SoftLinking.h"
#include <CoreMedia/CoreMedia.h>
-#include <runtime/ArrayBuffer.h>
-#include <runtime/DataView.h>
-#include <runtime/Int8Array.h>
-#include <wtf/MediaTime.h>
-#include <wtf/NeverDestroyed.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
#include <wtf/text/WTFString.h>
#include <wtf/unicode/CharacterNames.h>
#if !PLATFORM(WIN)
-#include "MediaTimeMac.h"
-#endif
-
-#if !PLATFORM(WIN)
#define SOFT_LINK_AVF_FRAMEWORK(Lib) SOFT_LINK_FRAMEWORK_OPTIONAL(Lib)
#define SOFT_LINK_AVF_POINTER(Lib, Name, Type) SOFT_LINK_POINTER_OPTIONAL(Lib, Name, Type)
#else
SOFT_LINK_AVF_FRAMEWORK(CoreMedia)
-#if !PLATFORM(WIN)
-SOFT_LINK(CoreMedia, CMSampleBufferGetDataBuffer, CMBlockBufferRef, (CMSampleBufferRef sbuf), (sbuf))
-SOFT_LINK(CoreMedia, CMBlockBufferCopyDataBytes, OSStatus, (CMBlockBufferRef theSourceBuffer, size_t offsetToData, size_t dataLength, void* destination), (theSourceBuffer, offsetToData, dataLength, destination))
-SOFT_LINK(CoreMedia, CMBlockBufferGetDataLength, size_t, (CMBlockBufferRef theBuffer), (theBuffer))
-SOFT_LINK(CoreMedia, CMSampleBufferGetSampleTimingInfo, OSStatus, (CMSampleBufferRef sbuf, CMItemIndex sampleIndex, CMSampleTimingInfo* timingInfoOut), (sbuf, sampleIndex, timingInfoOut))
-SOFT_LINK(CoreMedia, CMFormatDescriptionGetExtensions, CFDictionaryRef, (CMFormatDescriptionRef desc), (desc))
-SOFT_LINK(CoreMedia, CMSampleBufferGetFormatDescription, CMFormatDescriptionRef, (CMSampleBufferRef sbuf), (sbuf))
-#else
-
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMTimeGetSeconds, Float64, __cdecl, (CMTime time), (time))
-#define CMTimeGetSeconds softLink_CMTimeGetSeconds
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMSampleBufferGetDataBuffer, CMBlockBufferRef, __cdecl, (CMSampleBufferRef sbuf), (sbuf))
-#define CMSampleBufferGetDataBuffer softLink_CMSampleBufferGetDataBuffer
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMBlockBufferCopyDataBytes, OSStatus, __cdecl, (CMBlockBufferRef theSourceBuffer, size_t offsetToData, size_t dataLength, void* destination), (theSourceBuffer, offsetToData, dataLength, destination))
-#define CMBlockBufferCopyDataBytes softLink_CMBlockBufferCopyDataBytes
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMBlockBufferGetDataLength, size_t, __cdecl, (CMBlockBufferRef theBuffer), (theBuffer))
-#define CMBlockBufferGetDataLength softLink_CMBlockBufferGetDataLength
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMSampleBufferGetSampleTimingInfo, OSStatus, __cdecl, (CMSampleBufferRef sbuf, CMItemIndex sampleIndex, CMSampleTimingInfo* timingInfoOut), (sbuf, sampleIndex, timingInfoOut))
-#define CMSampleBufferGetSampleTimingInfo softLink_CMSampleBufferGetSampleTimingInfo
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMFormatDescriptionGetExtensions, CFDictionaryRef, __cdecl, (CMFormatDescriptionRef desc), (desc))
-#define CMFormatDescriptionGetExtensions softLink_CMFormatDescriptionGetExtensions
-SOFT_LINK_DLL_IMPORT(CoreMedia, CMSampleBufferGetFormatDescription, CMFormatDescriptionRef, __cdecl, (CMSampleBufferRef sbuf), (sbuf))
-#define CMSampleBufferGetFormatDescription softLink_CMSampleBufferGetFormatDescription
-
-#endif
-
SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_Alignment, CFStringRef)
SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAlignmentType_Start, CFStringRef)
SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAlignmentType_Middle, CFStringRef)
SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_ForegroundColorARGB, CFStringRef)
SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_BackgroundColorARGB, CFStringRef)
SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_CharacterBackgroundColorARGB, CFStringRef)
-SOFT_LINK_AVF_POINTER(CoreMedia, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, CFStringRef)
#define kCMTextMarkupAttribute_Alignment getkCMTextMarkupAttribute_Alignment()
#define kCMTextMarkupAlignmentType_Start getkCMTextMarkupAlignmentType_Start()
#define kCMTextMarkupAttribute_ForegroundColorARGB getkCMTextMarkupAttribute_ForegroundColorARGB()
#define kCMTextMarkupAttribute_BackgroundColorARGB getkCMTextMarkupAttribute_BackgroundColorARGB()
#define kCMTextMarkupAttribute_CharacterBackgroundColorARGB getkCMTextMarkupAttribute_CharacterBackgroundColorARGB()
-#define kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms getkCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms()
-
-namespace JSC {
-class ArrayBuffer;
-}
namespace WebCore {
{
}
-InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF(AVFInbandTrackParent* owner, CueFormat format)
- : InbandTextTrackPrivate(format)
+InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF(AVFInbandTrackParent* owner)
+ : InbandTextTrackPrivate(Generic)
, m_owner(owner)
, m_pendingCueStatus(None)
, m_index(0)
, m_hasBeenReported(false)
, m_seeking(false)
- , m_haveReportedVTTHeader(false)
{
}
cueData->setContent(content.toString());
}
-void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, CFArrayRef nativeSamples, double time)
+void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)
{
if (!client())
return;
- processAttributedStrings(attributedStrings, time);
- processNativeSamples(nativeSamples, time);
-}
-
-void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedStrings, double time)
-{
- LOG(Media, "InbandTextTrackPrivateAVF::processAttributedStrings - %li attributed strings at time %.2f\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, time);
+ LOG(Media, "InbandTextTrackPrivateAVF::processCue - %li cues at time %.2f\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, time);
Vector<RefPtr<GenericCueData>> arrivingCues;
if (attributedStrings) {
LOG(Media, "InbandTextTrackPrivateAVF::processCue(%p) - adding cue for time = %.2f, position = %.2f, line = %.2f", this, cueData->startTime(), cueData->position(), cueData->line());
client()->addGenericCue(this, cueData.release());
- }
- m_pendingCueStatus = seeking() ? DeliveredDuringSeek : Valid;
+ m_pendingCueStatus = seeking() ? DeliveredDuringSeek : Valid;
+ }
}
void InbandTextTrackPrivateAVF::beginSeeking()
m_owner->trackModeChanged();
}
-void InbandTextTrackPrivateAVF::processNativeSamples(CFArrayRef nativeSamples, double presentationTime)
-{
- if (!nativeSamples)
- return;
-
- CFIndex count = CFArrayGetCount(nativeSamples);
- if (!count)
- return;
-
- LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples - %li sample buffers at time %.2f\n", count, presentationTime);
-
- for (CFIndex i = 0; i < count; i++) {
-
- CMSampleBufferRef sampleBuffer = (CMSampleBufferRef)CFArrayGetValueAtIndex(nativeSamples, i);
- if (!sampleBuffer)
- continue;
-
- CMSampleTimingInfo timingInfo;
- OSStatus status = CMSampleBufferGetSampleTimingInfo(sampleBuffer, i, &timingInfo);
- if (status) {
- LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - CMSampleBufferGetSampleTimingInfo returned error %x for sample %li", this, status, i);
- continue;
- }
-
- CMBlockBufferRef blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer);
- size_t bufferLength = CMBlockBufferGetDataLength(blockBuffer);
- if (bufferLength < ISOBox::boxHeaderSize()) {
- LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - ERROR: CMSampleBuffer size length unexpectedly small (%zu)!!", this, bufferLength);
- continue;
- }
-
- m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength);
- CMBlockBufferCopyDataBytes(blockBuffer, 0, bufferLength, m_sampleInputBuffer.data() + m_sampleInputBuffer.size() - bufferLength);
-
- RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());
-
- String type = ISOBox::peekType(buffer.get());
- size_t boxLength = ISOBox::peekLength(buffer.get());
- if (boxLength > buffer->byteLength()) {
- LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - ERROR: chunk '%s' size (%zu) larger than buffer length (%u)!!", this, type.utf8().data(), boxLength, buffer->byteLength());
- continue;
- }
-
- LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - chunk type = '%s', size = %zu", this, type.utf8().data(), boxLength);
-
- if (type == ISOWebVTTCue::boxType()) {
-#if !PLATFORM(WIN)
- ISOWebVTTCue cueData = ISOWebVTTCue(MediaTime::createWithDouble(presentationTime), toMediaTime(timingInfo.duration), buffer.get());
-#else
- ISOWebVTTCue cueData = ISOWebVTTCue(MediaTime::createWithDouble(presentationTime), MediaTime::createWithDouble(CMTimeGetSeconds(timingInfo.duration)), buffer.get());
-#endif
- LOG(Media, " sample presentation time = %.2f, duration = %.2f", cueData.presentationTime().toDouble(), cueData.duration().toDouble());
- LOG(Media, " id = \"%s\", settings = \"%s\", cue text = \"%s\"", cueData.id().utf8().data(), cueData.settings().utf8().data(), cueData.cueText().utf8().data());
- LOG(Media, " sourceID = \"%s\", originalStartTime = \"%s\"", cueData.sourceID().utf8().data(), cueData.originalStartTime().utf8().data());
-
- client()->parseWebVTTCueData(this, cueData);
- }
-
- do {
- if (m_haveReportedVTTHeader)
- break;
-
- CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
- if (!formatDescription)
- break;
-
- CFDictionaryRef extensions = CMFormatDescriptionGetExtensions(formatDescription);
- if (!extensions)
- break;
-
- CFDictionaryRef sampleDescriptionExtensions = static_cast<CFDictionaryRef>(CFDictionaryGetValue(extensions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms));
- if (!sampleDescriptionExtensions)
- break;
-
- CFDataRef webvttHeaderData = static_cast<CFDataRef>(CFDictionaryGetValue(sampleDescriptionExtensions, CFSTR("vttC")));
- if (!webvttHeaderData)
- break;
-
- unsigned length = CFDataGetLength(webvttHeaderData);
- if (!length)
- break;
-
- // A WebVTT header is terminated by "One or more WebVTT line terminators" so append two line feeds to make sure the parser
- // reccognized this string as a full header.
- StringBuilder header;
- header.append(reinterpret_cast<const unsigned char*>(CFDataGetBytePtr(webvttHeaderData)), length);
- header.append("\n\n");
-
- LOG(Media, " vtt header = \n%s", header.toString().utf8().data());
- client()->parseWebVTTFileHeader(this, header.toString());
- m_haveReportedVTTHeader = true;
- } while (0);
-
- m_sampleInputBuffer.remove(0, boxLength);
- }
-}
-
} // namespace WebCore
#endif // ENABLE(VIDEO) && (USE(AVFOUNDATION) || PLATFORM(IOS))
bool hasBeenReported() const { return m_hasBeenReported; }
void setHasBeenReported(bool reported) { m_hasBeenReported = reported; }
- virtual void processCue(CFArrayRef attributedStrings, CFArrayRef nativeSamples, double);
+ virtual void processCue(CFArrayRef, double);
virtual void resetCueValues();
void beginSeeking();
InBand
};
virtual Category textTrackCategory() const = 0;
-
+
virtual double startTimeVariance() const override { return 0.25; }
-
+
protected:
- InbandTextTrackPrivateAVF(AVFInbandTrackParent*, CueFormat);
+ InbandTextTrackPrivateAVF(AVFInbandTrackParent*);
void processCueAttributes(CFAttributedStringRef, GenericCueData*);
- void processAttributedStrings(CFArrayRef, double);
- void processNativeSamples(CFArrayRef, double);
void removeCompletedCues();
double m_currentCueStartTime;
Vector<RefPtr<GenericCueData>> m_cues;
AVFInbandTrackParent* m_owner;
- Vector<char> m_sampleInputBuffer;
-
enum PendingCueStatus {
None,
DeliveredDuringSeek,
int m_index;
bool m_hasBeenReported;
bool m_seeking;
- bool m_haveReportedVTTHeader;
};
} // namespace WebCore
namespace WebCore {
-InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection, InbandTextTrackPrivate::CueFormat format)
- : InbandTextTrackPrivateAVF(player, format)
+InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection)
+ : InbandTextTrackPrivateAVF(player)
, m_mediaSelectionOption(selection)
{
}
class InbandTextTrackPrivateAVCF : public InbandTextTrackPrivateAVF {
public:
- static PassRefPtr<InbandTextTrackPrivateAVCF> create(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection, InbandTextTrackPrivate::CueFormat format)
+ static PassRefPtr<InbandTextTrackPrivateAVCF> create(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection)
{
- return adoptRef(new InbandTextTrackPrivateAVCF(player, selection, format));
+ return adoptRef(new InbandTextTrackPrivateAVCF(player, selection));
}
~InbandTextTrackPrivateAVCF() { }
AVCFMediaSelectionOptionRef mediaSelectionOption() const { return m_mediaSelectionOption.get(); }
protected:
- InbandTextTrackPrivateAVCF(AVFInbandTrackParent*, AVCFMediaSelectionOptionRef, InbandTextTrackPrivate::CueFormat);
+ InbandTextTrackPrivateAVCF(AVFInbandTrackParent*, AVCFMediaSelectionOptionRef);
RetainPtr<AVCFMediaSelectionOptionRef> m_mediaSelectionOption;
};
if (!newTrack)
continue;
- m_textTracks.append(InbandTextTrackPrivateAVCF::create(this, option, InbandTextTrackPrivate::Generic));
+ m_textTracks.append(InbandTextTrackPrivateAVCF::create(this, option));
}
processNewAndRemovedTextTracks(removedTextTracks);
#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
struct LegibleOutputData {
RetainPtr<CFArrayRef> m_attributedStrings;
- RetainPtr<CFArrayRef> m_samples;
double m_time;
void* m_context;
- LegibleOutputData(CFArrayRef strings, CFArrayRef samples, double time, void* context)
- : m_attributedStrings(strings), m_samples(samples), m_time(time), m_context(context)
+ LegibleOutputData(CFArrayRef strings, double time, void* context)
+ : m_attributedStrings(strings), m_time(time), m_context(context)
{
}
};
if (!self->m_currentTextTrack)
return;
- self->m_currentTextTrack->processCue(legibleOutputData->m_attributedStrings.get(), legibleOutputData->m_samples.get(), legibleOutputData->m_time);
+ self->m_currentTextTrack->processCue(legibleOutputData->m_attributedStrings.get(), legibleOutputData->m_time);
}
-void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef legibleOutput, CFArrayRef attributedStrings, CFArrayRef nativeSampleBuffers, CMTime itemTime)
+void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef legibleOutput, CFArrayRef attributedStrings, CFArrayRef /*nativeSampleBuffers*/, CMTime itemTime)
{
ASSERT(dispatch_get_main_queue() != dispatch_get_current_queue());
MutexLocker locker(mapLock());
ASSERT(legibleOutput == self->m_legibleOutput);
- OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(new LegibleOutputData(attributedStrings, nativeSampleBuffers, CMTimeGetSeconds(itemTime), context));
+ OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(new LegibleOutputData(attributedStrings, CMTimeGetSeconds(itemTime), context));
dispatch_async_f(dispatch_get_main_queue(), legibleOutputData.leakPtr(), processCue);
}
#include "InbandTextTrackPrivateAVF.h"
#include <wtf/RetainPtr.h>
-OBJC_CLASS AVAsset;
OBJC_CLASS AVMediaSelectionOption;
namespace WebCore {
class InbandTextTrackPrivateAVFObjC : public InbandTextTrackPrivateAVF {
public:
- static PassRefPtr<InbandTextTrackPrivateAVFObjC> create(AVFInbandTrackParent* player, AVMediaSelectionOption *selection, InbandTextTrackPrivate::CueFormat format)
+ static PassRefPtr<InbandTextTrackPrivateAVFObjC> create(AVFInbandTrackParent* player, AVMediaSelectionOption *selection)
{
- return adoptRef(new InbandTextTrackPrivateAVFObjC(player, selection, format));
+ return adoptRef(new InbandTextTrackPrivateAVFObjC(player, selection));
}
~InbandTextTrackPrivateAVFObjC() { }
AVMediaSelectionOption *mediaSelectionOption() const { return m_mediaSelectionOption.get(); }
protected:
- InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent*, AVMediaSelectionOption *, InbandTextTrackPrivate::CueFormat);
+ InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent*, AVMediaSelectionOption *);
RetainPtr<AVMediaSelectionOption> m_mediaSelectionOption;
};
namespace WebCore {
-InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent* player, AVMediaSelectionOption *selection, InbandTextTrackPrivate::CueFormat format)
- : InbandTextTrackPrivateAVF(player, format)
+InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent* player, AVMediaSelectionOption *selection)
+ : InbandTextTrackPrivateAVF(player)
, m_mediaSelectionOption(selection)
{
}
namespace WebCore {
InbandTextTrackPrivateLegacyAVFObjC::InbandTextTrackPrivateLegacyAVFObjC(MediaPlayerPrivateAVFoundationObjC* player, AVPlayerItemTrack* track)
- : InbandTextTrackPrivateAVF(player, InbandTextTrackPrivate::Generic)
+ : InbandTextTrackPrivateAVF(player)
, m_playerItemTrack(track)
{
}
#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
RetainPtr<AVPlayerItem> playerItem() const { return m_avPlayerItem; }
- void processCue(NSArray *, NSArray *, double);
+ void processCue(NSArray *, double);
void flushCues();
#endif
if (m_avAsset)
return;
- LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(%p) - url = %s", this, url.utf8().data());
+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(%p)", this);
setDelayCallbacks(true);
#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) && HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
const NSTimeInterval legibleOutputAdvanceInterval = 2;
- RetainPtr<NSArray> subtypes = adoptNS([[NSArray alloc] initWithObjects:[NSNumber numberWithUnsignedInt:kCMSubtitleFormatType_WebVTT], nil]);
- m_legibleOutput = adoptNS([[AVPlayerItemLegibleOutput alloc] initWithMediaSubtypesForNativeRepresentation:subtypes.get()]);
+ m_legibleOutput = adoptNS([[AVPlayerItemLegibleOutput alloc] initWithMediaSubtypesForNativeRepresentation:[NSArray array]]);
[m_legibleOutput.get() setSuppressesPlayerRendering:YES];
[m_legibleOutput.get() setDelegate:m_objcObserver.get() queue:dispatch_get_main_queue()];
}
#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
- AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia();
- if (legibleGroup && m_cachedTracks) {
+ if (AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia()) {
hasCaptions = [[AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]] count];
if (hasCaptions)
processMediaSelectionOptions();
}
#endif
- m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option, InbandTextTrackPrivate::Generic));
+ m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option));
}
processNewAndRemovedTextTracks(removedTextTracks);
player()->addTextTrack(m_metadataTrack);
}
-void MediaPlayerPrivateAVFoundationObjC::processCue(NSArray *attributedStrings, NSArray *nativeSamples, double time)
+void MediaPlayerPrivateAVFoundationObjC::processCue(NSArray *attributedStrings, double time)
{
if (!m_currentTextTrack)
return;
- m_currentTextTrack->processCue(reinterpret_cast<CFArrayRef>(attributedStrings), reinterpret_cast<CFArrayRef>(nativeSamples), time);
+ m_currentTextTrack->processCue(reinterpret_cast<CFArrayRef>(attributedStrings), time);
}
void MediaPlayerPrivateAVFoundationObjC::flushCues()
RetainPtr<WebCoreAVFMovieObserver> strongSelf = self;
RetainPtr<NSArray> strongStrings = strings;
- RetainPtr<NSArray> strongSamples = nativeSamples;
- callOnMainThread([strongSelf, strongStrings, strongSamples, itemTime] {
+ callOnMainThread([strongSelf, strongStrings, itemTime] {
MediaPlayerPrivateAVFoundationObjC* callback = strongSelf->m_callback;
if (!callback)
return;
- callback->processCue(strongStrings.get(), strongSamples.get(), CMTimeGetSeconds(itemTime));
+ callback->processCue(strongStrings.get(), CMTimeGetSeconds(itemTime));
});
}
return adoptRef(new OutOfBandTextTrackPrivateAVF(player, selection));
}
- virtual void processCue(CFArrayRef, CFArrayRef, double) override { }
+ virtual void processCue(CFArrayRef, double) override { }
virtual void resetCueValues() override { }
virtual Category textTrackCategory() const override { return OutOfBand; }
protected:
OutOfBandTextTrackPrivateAVF(AVFInbandTrackParent* player, AVMediaSelectionOption* selection)
- : InbandTextTrackPrivateAVF(player, InbandTextTrackPrivate::Generic)
+ : InbandTextTrackPrivateAVF(player)
, m_mediaSelectionOption(selection)
{
}