Changeset 170379 in webkit
- Timestamp:
- Jun 24, 2014, 12:35:47 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 28 edited
-
CMakeLists.txt (modified) (1 diff)
-
ChangeLog (modified) (1 diff)
-
WebCore.vcxproj/WebCore.vcxproj (modified) (2 diffs)
-
WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
html/track/BufferedLineReader.h (modified) (1 diff)
-
html/track/InbandGenericTextTrack.cpp (modified) (3 diffs)
-
html/track/InbandGenericTextTrack.h (modified) (4 diffs)
-
html/track/InbandTextTrack.h (modified) (1 diff)
-
html/track/InbandWebVTTTextTrack.cpp (modified) (5 diffs)
-
html/track/InbandWebVTTTextTrack.h (modified) (1 diff)
-
html/track/TextTrackCueGeneric.cpp (modified) (3 diffs)
-
html/track/VTTCue.cpp (modified) (10 diffs)
-
html/track/VTTCue.h (modified) (7 diffs)
-
html/track/WebVTTParser.cpp (modified) (6 diffs)
-
html/track/WebVTTParser.h (modified) (6 diffs)
-
loader/TextTrackLoader.cpp (modified) (1 diff)
-
platform/graphics/ISOVTTCue.cpp (added)
-
platform/graphics/ISOVTTCue.h (added)
-
platform/graphics/InbandTextTrackPrivateClient.h (modified) (3 diffs)
-
platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (modified) (10 diffs)
-
platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h (modified) (4 diffs)
-
platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp (modified) (1 diff)
-
platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h (modified) (2 diffs)
-
platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (modified) (4 diffs)
-
platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h (modified) (3 diffs)
-
platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm (modified) (1 diff)
-
platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm (modified) (1 diff)
-
platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (modified) (1 diff)
-
platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (6 diffs)
-
platform/graphics/avfoundation/objc/OutOfBandTextTrackPrivateAVF.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r170332 r170379 2091 2091 platform/graphics/IntRect.cpp 2092 2092 platform/graphics/IntSize.cpp 2093 platform/graphics/ISOVTTCue.cpp 2093 2094 platform/graphics/LayoutBoxExtent.cpp 2094 2095 platform/graphics/LayoutRect.cpp -
trunk/Source/WebCore/ChangeLog
r170377 r170379 1 2014-06-24 Eric Carlson <eric.carlson@apple.com> 2 3 [Mac] process raw VTT in-band captions 4 https://bugs.webkit.org/show_bug.cgi?id=134178 5 6 Reviewed by Jer Noble. 7 8 * CMakeLists.txt: Add ISOVTTCue.cpp|h. 9 * WebCore.vcxproj/WebCore.vcxproj: Ditto. 10 * WebCore.xcodeproj/project.pbxproj: Ditto. 11 12 * html/track/BufferedLineReader.h: 13 (WebCore::BufferedLineReader::reset): New, empty the input buffer. 14 15 Make it possible to process WebVTT captions. 16 * html/track/InbandGenericTextTrack.cpp: 17 (WebCore::InbandGenericTextTrack::parser): Allocate, if necessary, and return a WebVTT parser. 18 (WebCore::InbandGenericTextTrack::parseWebVTTCueData): Pass a cue to the parser. 19 (WebCore::InbandGenericTextTrack::parseWebVTTFileHeader): Pass a VTT file header to the parser. 20 (WebCore::InbandGenericTextTrack::newCuesParsed): Parser callback. 21 (WebCore::InbandGenericTextTrack::newRegionsParsed): Ditto. 22 (WebCore::InbandGenericTextTrack::fileFailedToParse): Ditto. 23 * html/track/InbandGenericTextTrack.h: 24 25 * html/track/InbandTextTrack.h: 26 27 * html/track/InbandWebVTTTextTrack.cpp: 28 (WebCore::InbandWebVTTTextTrack::parser): New, parser accessor. 29 (WebCore::InbandWebVTTTextTrack::parseWebVTTCueData): New, parse VTT data in an ISOWebVTTCue 30 object. 31 (WebCore::InbandWebVTTTextTrack::newCuesParsed): Cleanup. 32 (WebCore::InbandWebVTTTextTrack::newRegionsParsed): Implement. 33 (WebCore::InbandWebVTTTextTrack::fileFailedToParse): Change the error message. 34 * html/track/InbandWebVTTTextTrack.h: 35 36 * html/track/TextTrackCueGeneric.cpp: 37 (WebCore::TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement): Change cue parameter 38 from a pointer to a reference. 39 (WebCore::TextTrackCueGeneric::createDisplayTree): Ditto. 40 41 * html/track/VTTCue.cpp: 42 (WebCore::VTTCueBox::create): Change cue parameter from a pointer to a reference. 43 (WebCore::VTTCueBox::VTTCueBox): Ditto. 44 (WebCore::VTTCueBox::getCue): Return a reference. 45 (WebCore::VTTCueBox::applyCSSProperties): m_cue is a reference, not a pointer. 46 (WebCore::VTTCue::create): New, create a VTTCue from WebVTTCueData. 47 (WebCore::VTTCue::VTTCue): New, internal constructor that takes a WebVTTCueData. 48 (WebCore::VTTCue::initialize): New, shared constructor initialization. 49 (WebCore::VTTCue::createDisplayTree): m_cue is a reference, not a pointer. 50 (WebCore::VTTCue::markFutureAndPastNodes): Ditto. 51 (WebCore::VTTCue::setCueSettings): Ditto. 52 * html/track/VTTCue.h: 53 (WebCore::VTTCueBox::create): Deleted. 54 (WebCore::VTTCue::create): Deleted. 55 56 * html/track/WebVTTParser.cpp: 57 (WebCore::WebVTTParser::parseFileHeader): New. Reset the line reader buffer and parser state, 58 call the parser. 59 (WebCore::WebVTTParser::parseCueData): Create a cue from ISOWebVTTCue. 60 (WebCore::WebVTTParser::collectTimingsAndSettings): Return immediately if the string is empty. 61 (WebCore::WebVTTParser::collectTimeStamp): Ditto. 62 * html/track/WebVTTParser.h: 63 (WebCore::WebVTTCueData::originalStartTime): New. 64 (WebCore::WebVTTCueData::setOriginalStartTime): New. 65 (WebCore::WebVTTCueData::WebVTTCueData): 66 67 * loader/TextTrackLoader.cpp: 68 (WebCore::TextTrackLoader::getNewCues): Cleanup, use the new VTTCue::create. 69 70 Parse ISO WebVTT cue boxes. 71 * platform/graphics/ISOVTTCue.cpp: Added. 72 (WebCore::ISOBox::ISOBox): 73 (WebCore::ISOBox::peekType): 74 (WebCore::ISOBox::peekLength): 75 (WebCore::ISOBox::peekString): 76 (WebCore::vttCueBoxType): 77 (WebCore::vttIdBoxType): 78 (WebCore::vttSettingsBoxType): 79 (WebCore::vttPayloadBoxType): 80 (WebCore::vttCurrentTimeBoxType): 81 (WebCore::vttCueSourceIDBoxType): 82 (WebCore::ISOWebVTTCue::boxType): 83 (WebCore::ISOWebVTTCue::ISOWebVTTCue): 84 * platform/graphics/ISOVTTCue.h: Added. 85 (WebCore::ISOBox::boxHeaderSize): 86 (WebCore::ISOBox::length): 87 (WebCore::ISOBox::type): 88 (WebCore::ISOWebVTTCue::presentationTime): 89 (WebCore::ISOWebVTTCue::duration): 90 (WebCore::ISOWebVTTCue::sourceID): 91 (WebCore::ISOWebVTTCue::id): 92 (WebCore::ISOWebVTTCue::originalStartTime): 93 (WebCore::ISOWebVTTCue::settings): 94 (WebCore::ISOWebVTTCue::cueText): 95 96 * platform/graphics/InbandTextTrackPrivateClient.h: 97 (WebCore::InbandTextTrackPrivateClient::parseWebVTTFileHeader): New. 98 99 * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp: 100 (WebCore::InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF): Add a cue format parameter. 101 (WebCore::InbandTextTrackPrivateAVF::processCue): Call processNativeSamples. 102 (WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Add logging. Minor cleanup. 103 (WebCore::InbandTextTrackPrivateAVF::processNativeSamples): New, process an array of 104 CMSampleBuffers, create ISOWebVTTCue from the sample data. 105 * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h: 106 107 * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp: 108 (WebCore::InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF): 109 * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h: 110 (WebCore::InbandTextTrackPrivateAVCF::create): 111 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: 112 (WebCore::MediaPlayerPrivateAVFoundationCF::processMediaSelectionOptions): 113 (WebCore::LegibleOutputData::LegibleOutputData): 114 (WebCore::AVFWrapper::processCue): 115 (WebCore::AVFWrapper::legibleOutputCallback): 116 117 * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h: 118 (WebCore::InbandTextTrackPrivateAVFObjC::create): Add a cue format parameter. 119 * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm: 120 (WebCore::InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC): Ditto. 121 122 * platform/graphics/avfoundation/InbandTextTrackPrivateLegacyAVFObjC.cpp: 123 (WebCore::InbandTextTrackPrivateLegacyAVFObjC::InbandTextTrackPrivateLegacyAVFObjC): Pass cue 124 format to base class. 125 126 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 127 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 128 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Improve logging. 129 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Don't leak an NSDictionary. 130 (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Don't process media selection 131 options until we have tracks. 132 (WebCore::MediaPlayerPrivateAVFoundationObjC::processMediaSelectionOptions): 133 (WebCore::MediaPlayerPrivateAVFoundationObjC::processCue): Pass native samples as well as 134 attributed strings to track. 135 (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): 136 * platform/graphics/avfoundation/objc/OutOfBandTextTrackPrivateAVF.h: 137 (WebCore::OutOfBandTextTrackPrivateAVF::OutOfBandTextTrackPrivateAVF): 138 139 * platform/graphics/avfoundation/objc/OutOfBandTextTrackPrivateAVF.h: 140 (WebCore::OutOfBandTextTrackPrivateAVF::OutOfBandTextTrackPrivateAVF): 141 1 142 2014-06-24 Antti Koivisto <antti@apple.com> 2 143 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r170332 r170379 7257 7257 <ClCompile Include="..\platform\FileStream.cpp" /> 7258 7258 <ClCompile Include="..\platform\FileSystem.cpp" /> 7259 <ClCompile Include="..\platform\graphics\ISOVTTCue.cpp" /> 7259 7260 <ClCompile Include="..\platform\audio\AudioSession.cpp" /> 7260 7261 <ClCompile Include="..\platform\audio\MediaSession.cpp" /> … … 19438 19439 <ClInclude Include="..\platform\graphics\IntSize.h" /> 19439 19440 <ClInclude Include="..\platform\graphics\IntSizeHash.h" /> 19441 <ClInclude Include="..\platform\graphics\ISOVTTCue.h" /> 19440 19442 <ClInclude Include="..\platform\graphics\LayoutBoxExtent.h" /> 19441 19443 <ClInclude Include="..\platform\graphics\LayoutPoint.h" /> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r170374 r170379 315 315 07AB996F18DA3C740018771E /* RTCConfigurationPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996D18DA3C740018771E /* RTCConfigurationPrivate.h */; }; 316 316 07AB997018DA3C740018771E /* RTCIceServerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AB996E18DA3C740018771E /* RTCIceServerPrivate.h */; }; 317 07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */; }; 318 07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */ = {isa = PBXBuildFile; fileRef = 07AC47001952102100EE9723 /* ISOVTTCue.h */; }; 317 319 07B0113F1032242200FBDC33 /* AccessibilityMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */; }; 318 320 07B442D6166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */; }; … … 7204 7206 07AB996D18DA3C740018771E /* RTCConfigurationPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCConfigurationPrivate.h; sourceTree = "<group>"; }; 7205 7207 07AB996E18DA3C740018771E /* RTCIceServerPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCIceServerPrivate.h; sourceTree = "<group>"; }; 7208 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ISOVTTCue.cpp; path = ISOVTTCue.cpp; sourceTree = "<group>"; }; 7209 07AC47001952102100EE9723 /* ISOVTTCue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ISOVTTCue.h; path = ISOVTTCue.h; sourceTree = "<group>"; }; 7206 7210 07B0113E1032242200FBDC33 /* AccessibilityMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityMediaControls.h; sourceTree = "<group>"; }; 7207 7211 07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandTextTrackPrivateAVF.cpp; sourceTree = "<group>"; }; … … 20404 20408 B27535470B053814002CE64F /* IntSize.h */, 20405 20409 B27535480B053814002CE64F /* IntSizeHash.h */, 20410 07AC46FF1952102100EE9723 /* ISOVTTCue.cpp */, 20411 07AC47001952102100EE9723 /* ISOVTTCue.h */, 20406 20412 65CC6BED16014EC0000ED27D /* Latin1TextIterator.h */, 20407 20413 141DC049164834B900371E5A /* LayoutBoxExtent.cpp */, … … 24908 24914 B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */, 24909 24915 24D9129213CA951E00D21915 /* JSSVGAltGlyphDefElement.h in Headers */, 24916 07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */, 24910 24917 6515EC920D9723FF0063D49A /* JSSVGAltGlyphElement.h in Headers */, 24911 24918 24D9129613CA956100D21915 /* JSSVGAltGlyphItemElement.h in Headers */, … … 29494 29501 B2227A560D00BF220071B782 /* SVGParserUtilities.cpp in Sources */, 29495 29502 84C6784C1214814700A92902 /* SVGPathBlender.cpp in Sources */, 29503 07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */, 29496 29504 8476C9EA11DF6A2900555B02 /* SVGPathBuilder.cpp in Sources */, 29497 29505 8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */, -
trunk/Source/WebCore/html/track/BufferedLineReader.h
r170332 r170379 69 69 bool isAtEndOfStream() const { return m_endOfStream && m_buffer.isEmpty(); } 70 70 71 void reset() { m_buffer.clear(); } 72 71 73 private: 72 74 // Consume the next character the buffer if it is the character |c|. -
trunk/Source/WebCore/html/track/InbandGenericTextTrack.cpp
r170332 r170379 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 #include <wtf/text/CString.h> 38 38 39 #if ENABLE(WEBVTT_REGIONS) 40 #include "VTTRegionList.h" 41 #endif 42 39 43 namespace WebCore { 40 44 … … 191 195 } 192 196 197 WebVTTParser& InbandGenericTextTrack::parser() 198 { 199 if (!m_webVTTParser) 200 m_webVTTParser = std::make_unique<WebVTTParser>(static_cast<WebVTTParserClient*>(this), scriptExecutionContext()); 201 return *m_webVTTParser; 202 } 203 204 void InbandGenericTextTrack::parseWebVTTCueData(InbandTextTrackPrivate* trackPrivate, const ISOWebVTTCue& cueData) 205 { 206 ASSERT_UNUSED(trackPrivate, trackPrivate == m_private); 207 parser().parseCueData(cueData); 208 } 209 210 void InbandGenericTextTrack::parseWebVTTFileHeader(InbandTextTrackPrivate* trackPrivate, String header) 211 { 212 ASSERT_UNUSED(trackPrivate, trackPrivate == m_private); 213 parser().parseFileHeader(header); 214 } 215 216 void InbandGenericTextTrack::newCuesParsed() 217 { 218 Vector<RefPtr<WebVTTCueData>> cues; 219 parser().getNewCues(cues); 220 221 for (auto& cueData : cues) { 222 RefPtr<VTTCue> vttCue = VTTCue::create(*scriptExecutionContext(), *cueData); 223 224 if (hasCue(vttCue.get(), TextTrackCue::IgnoreDuration)) { 225 LOG(Media, "InbandGenericTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data()); 226 return; 227 } 228 addCue(vttCue.release(), ASSERT_NO_EXCEPTION); 229 } 230 } 231 232 #if ENABLE(WEBVTT_REGIONS) 233 void InbandGenericTextTrack::newRegionsParsed() 234 { 235 Vector<RefPtr<VTTRegion>> newRegions; 236 parser().getNewRegions(newRegions); 237 238 for (auto& region : newRegions) { 239 region->setTrack(this); 240 regions()->add(region); 241 } 242 } 243 #endif 244 245 void InbandGenericTextTrack::fileFailedToParse() 246 { 247 LOG(Media, "Error parsing WebVTT stream."); 248 } 249 193 250 } // namespace WebCore 194 251 -
trunk/Source/WebCore/html/track/InbandGenericTextTrack.h
r170332 r170379 1 1 /* 2 * Copyright (C) 2012 , 2013Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "InbandTextTrack.h" 32 32 #include "TextTrackCueGeneric.h" 33 #include "WebVTTParser.h" 33 34 #include <wtf/RefPtr.h> 34 35 … … 60 61 }; 61 62 62 class InbandGenericTextTrack : public InbandTextTrack {63 class InbandGenericTextTrack : public InbandTextTrack, private WebVTTParserClient { 63 64 public: 64 65 static PassRefPtr<InbandGenericTextTrack> create(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>); … … 76 77 void updateCueFromCueData(TextTrackCueGeneric*, GenericCueData*); 77 78 79 WebVTTParser& parser(); 80 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override; 81 virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) override; 82 83 virtual void newCuesParsed() override; 84 #if ENABLE(WEBVTT_REGIONS) 85 virtual void newRegionsParsed() override; 86 #endif 87 virtual void fileFailedToParse() override; 88 78 89 GenericTextTrackCueMap m_cueMap; 90 std::unique_ptr<WebVTTParser> m_webVTTParser; 79 91 }; 80 92 -
trunk/Source/WebCore/html/track/InbandTextTrack.h
r170332 r170379 82 82 virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) override { ASSERT_NOT_REACHED(); } 83 83 84 virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) override { ASSERT_NOT_REACHED(); } 84 85 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char*, unsigned) override { ASSERT_NOT_REACHED(); } 86 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override { ASSERT_NOT_REACHED(); } 87 85 88 virtual double startTimeVariance() const; 86 89 -
trunk/Source/WebCore/html/track/InbandWebVTTTextTrack.cpp
r170332 r170379 35 35 #include <wtf/text/CString.h> 36 36 37 #if ENABLE(WEBVTT_REGIONS) 38 #include "VTTRegionList.h" 39 #endif 40 37 41 namespace WebCore { 38 42 … … 51 55 } 52 56 57 WebVTTParser& InbandWebVTTTextTrack::parser() 58 { 59 if (!m_webVTTParser) 60 m_webVTTParser = std::make_unique<WebVTTParser>(static_cast<WebVTTParserClient*>(this), scriptExecutionContext()); 61 return *m_webVTTParser; 62 } 63 53 64 void InbandWebVTTTextTrack::parseWebVTTCueData(InbandTextTrackPrivate* trackPrivate, const char* data, unsigned length) 54 65 { 55 66 ASSERT_UNUSED(trackPrivate, trackPrivate == m_private); 56 if (!m_webVTTParser) 57 m_webVTTParser = std::make_unique<WebVTTParser>(static_cast<WebVTTParserClient*>(this), scriptExecutionContext()); 58 m_webVTTParser->parseBytes(data, length); 67 parser().parseBytes(data, length); 68 } 69 70 void InbandWebVTTTextTrack::parseWebVTTCueData(InbandTextTrackPrivate* trackPrivate, const ISOWebVTTCue& cueData) 71 { 72 ASSERT_UNUSED(trackPrivate, trackPrivate == m_private); 73 parser().parseCueData(cueData); 59 74 } 60 75 … … 62 77 { 63 78 Vector<RefPtr<WebVTTCueData>> cues; 64 m_webVTTParser->getNewCues(cues); 65 for (size_t i = 0; i < cues.size(); ++i) { 66 RefPtr<WebVTTCueData> cueData = cues[i]; 67 RefPtr<VTTCue> cue = VTTCue::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content()); 68 cue->setId(cueData->id()); 69 cue->setCueSettings(cueData->settings()); 79 parser().getNewCues(cues); 70 80 71 if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) { 72 LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime(), cueData->endTime(), cueData->content().utf8().data()); 81 for (auto& cueData : cues) { 82 RefPtr<VTTCue> vttCue = VTTCue::create(*scriptExecutionContext(), *cueData); 83 84 if (hasCue(vttCue.get(), TextTrackCue::IgnoreDuration)) { 85 LOG(Media, "InbandWebVTTTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data()); 73 86 return; 74 87 } 75 addCue( cue.release(), ASSERT_NO_EXCEPTION);88 addCue(vttCue.release(), ASSERT_NO_EXCEPTION); 76 89 } 77 90 } … … 80 93 void InbandWebVTTTextTrack::newRegionsParsed() 81 94 { 82 notImplemented(); 95 Vector<RefPtr<VTTRegion>> newRegions; 96 parser().getNewRegions(newRegions); 97 98 for (auto& region : newRegions) { 99 region->setTrack(this); 100 regions()->add(region); 101 } 83 102 } 84 103 #endif … … 86 105 void InbandWebVTTTextTrack::fileFailedToParse() 87 106 { 88 LOG(Media, " Unable to parseWebVTT stream.");107 LOG(Media, "Error parsing WebVTT stream."); 89 108 } 90 109 -
trunk/Source/WebCore/html/track/InbandWebVTTTextTrack.h
r170332 r170379 44 44 InbandWebVTTTextTrack(ScriptExecutionContext*, TextTrackClient*, PassRefPtr<InbandTextTrackPrivate>); 45 45 46 WebVTTParser& parser(); 46 47 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char* data, unsigned length) override; 48 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) override; 47 49 48 50 virtual void newCuesParsed() override; -
trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp
r170332 r170379 44 44 class TextTrackCueGenericBoxElement final : public VTTCueBox { 45 45 public: 46 static PassRefPtr<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric *cue)46 static PassRefPtr<TextTrackCueGenericBoxElement> create(Document& document, TextTrackCueGeneric& cue) 47 47 { 48 48 return adoptRef(new TextTrackCueGenericBoxElement(document, cue)); … … 52 52 53 53 private: 54 TextTrackCueGenericBoxElement(Document&, VTTCue *);54 TextTrackCueGenericBoxElement(Document&, VTTCue&); 55 55 }; 56 56 57 TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue *cue)57 TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement(Document& document, VTTCue& cue) 58 58 : VTTCueBox(document, cue) 59 59 { … … 119 119 PassRefPtr<VTTCueBox> TextTrackCueGeneric::createDisplayTree() 120 120 { 121 return TextTrackCueGenericBoxElement::create(ownerDocument(), this);121 return TextTrackCueGenericBoxElement::create(ownerDocument(), *this); 122 122 } 123 123 -
trunk/Source/WebCore/html/track/VTTCue.cpp
r170332 r170379 120 120 // ---------------------------- 121 121 122 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) 122 PassRefPtr<VTTCueBox> VTTCueBox::create(Document& document, VTTCue& cue) 123 { 124 VTTCueBox* cueBox = new VTTCueBox(document, cue); 125 cueBox->setPseudo(VTTCueBox::vttCueBoxShadowPseudoId()); 126 return adoptRef(cueBox); 127 } 128 129 VTTCueBox::VTTCueBox(Document& document, VTTCue& cue) 123 130 : HTMLElement(divTag, document) 124 131 , m_cue(cue) … … 129 136 VTTCue* VTTCueBox::getCue() const 130 137 { 131 return m_cue;138 return &m_cue; 132 139 } 133 140 … … 136 143 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916 137 144 #if ENABLE(WEBVTT_REGIONS) 138 if (!m_cue ->regionId().isEmpty()) {145 if (!m_cue.regionId().isEmpty()) { 139 146 setInlineStyleProperty(CSSPropertyPosition, CSSValueRelative); 140 147 return; … … 151 158 152 159 // the 'direction' property must be set to direction 153 setInlineStyleProperty(CSSPropertyDirection, m_cue ->getCSSWritingDirection());160 setInlineStyleProperty(CSSPropertyDirection, m_cue.getCSSWritingDirection()); 154 161 155 162 // the 'writing-mode' property must be set to writing-mode 156 setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue ->getCSSWritingMode(), false);157 158 std::pair<float, float> position = m_cue ->getCSSPosition();163 setInlineStyleProperty(CSSPropertyWebkitWritingMode, m_cue.getCSSWritingMode(), false); 164 165 std::pair<float, float> position = m_cue.getCSSPosition(); 159 166 160 167 // the 'top' property must be set to top, … … 165 172 166 173 // the 'width' property must be set to width, and the 'height' property must be set to height 167 if (m_cue ->vertical() == horizontalKeyword()) {168 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue ->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);174 if (m_cue.vertical() == horizontalKeyword()) { 175 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); 169 176 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); 170 177 } else { 171 178 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); 172 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue ->getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);179 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE); 173 180 } 174 181 … … 177 184 // whose first cell is the value of the corresponding cue's text track cue 178 185 // alignment: 179 setInlineStyleProperty(CSSPropertyTextAlign, m_cue ->getCSSAlignment());180 181 if (!m_cue ->snapToLines()) {186 setInlineStyleProperty(CSSPropertyTextAlign, m_cue.getCSSAlignment()); 187 188 if (!m_cue.snapToLines()) { 182 189 // 10.13.1 Set up x and y: 183 190 // Note: x and y are set through the CSS left and top above. … … 210 217 // ---------------------------- 211 218 219 PassRefPtr<VTTCue> VTTCue::create(ScriptExecutionContext& context, double start, double end, const String& content) 220 { 221 return adoptRef(new VTTCue(context, start, end, content)); 222 } 223 224 PassRefPtr<VTTCue> VTTCue::create(ScriptExecutionContext& context, const WebVTTCueData& data) 225 { 226 return adoptRef(new VTTCue(context, data)); 227 } 228 212 229 VTTCue::VTTCue(ScriptExecutionContext& context, double start, double end, const String& content) 213 230 : TextTrackCue(context, start, end) 214 231 , m_content(content) 215 , m_linePosition(undefinedPosition) 216 , m_computedLinePosition(undefinedPosition)217 , m_textPosition(50) 218 , m_cueSize(100) 219 , m_writingDirection(Horizontal)220 , m_cueAlignment(Middle)221 , m_webVTTNodeTree(nullptr) 222 , m_cueBackgroundBox(HTMLSpanElement::create(spanTag, toDocument(context)))223 , m_displayDirection(CSSValueLtr)224 , m_displaySize(0)225 , m_snapToLines(true)226 , m_displayTreeShouldChange(true)227 , m_notifyRegion(true)228 { 232 { 233 initialize(context); 234 } 235 236 VTTCue::VTTCue(ScriptExecutionContext& context, const WebVTTCueData& cueData) 237 : TextTrackCue(context, 0, 0) 238 { 239 initialize(context); 240 setText(cueData.content()); 241 setStartTime(cueData.startTime(), IGNORE_EXCEPTION); 242 setEndTime(cueData.endTime(), IGNORE_EXCEPTION); 243 setId(cueData.id()); 244 setCueSettings(cueData.settings()); 245 m_originalStartTime = cueData.originalStartTime(); 229 246 } 230 247 … … 237 254 } 238 255 256 void VTTCue::initialize(ScriptExecutionContext& context) 257 { 258 m_linePosition = undefinedPosition; 259 m_computedLinePosition = undefinedPosition; 260 m_textPosition = 50; 261 m_cueSize = 100; 262 m_writingDirection = Horizontal; 263 m_cueAlignment = Middle; 264 m_webVTTNodeTree = nullptr; 265 m_cueBackgroundBox = HTMLSpanElement::create(spanTag, toDocument(context)); 266 m_displayDirection = CSSValueLtr; 267 m_displaySize = 0; 268 m_snapToLines = true; 269 m_displayTreeShouldChange = true; 270 m_notifyRegion = true; 271 m_originalStartTime = 0; 272 } 273 239 274 PassRefPtr<VTTCueBox> VTTCue::createDisplayTree() 240 275 { 241 return VTTCueBox::create(ownerDocument(), this);276 return VTTCueBox::create(ownerDocument(), *this); 242 277 } 243 278 … … 700 735 ASSERT_UNUSED(check, check); 701 736 737 currentTimestamp += m_originalStartTime; 702 738 if (currentTimestamp > movieTime) 703 739 isPastNode = false; … … 885 921 void VTTCue::setCueSettings(const String& inputString) 886 922 { 923 if (inputString.isEmpty()) 924 return; 925 887 926 VTTScanner input(inputString); 888 927 -
trunk/Source/WebCore/html/track/VTTCue.h
r170332 r170379 47 47 class VTTCue; 48 48 class VTTScanner; 49 class WebVTTCueData; 49 50 50 51 // ---------------------------- … … 52 53 class VTTCueBox : public HTMLElement { 53 54 public: 54 static PassRefPtr<VTTCueBox> create(Document& document, VTTCue* cue) 55 { 56 return adoptRef(new VTTCueBox(document, cue)); 57 } 55 static PassRefPtr<VTTCueBox> create(Document&, VTTCue&); 58 56 59 57 VTTCue* getCue() const; … … 63 61 64 62 protected: 65 VTTCueBox(Document&, VTTCue *);63 VTTCueBox(Document&, VTTCue&); 66 64 67 65 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 68 66 69 VTTCue *m_cue;67 VTTCue& m_cue; 70 68 }; 71 69 … … 74 72 class VTTCue : public TextTrackCue { 75 73 public: 76 static PassRefPtr<VTTCue> create(ScriptExecutionContext& context, double start, double end, const String& content) 77 { 78 return adoptRef(new VTTCue(context, start, end, content)); 79 } 74 static PassRefPtr<VTTCue> create(ScriptExecutionContext&, double start, double end, const String&); 75 static PassRefPtr<VTTCue> create(ScriptExecutionContext&, const WebVTTCueData&); 80 76 81 77 virtual ~VTTCue(); … … 165 161 protected: 166 162 VTTCue(ScriptExecutionContext&, double start, double end, const String& content); 163 VTTCue(ScriptExecutionContext&, const WebVTTCueData&); 167 164 168 165 virtual PassRefPtr<VTTCueBox> createDisplayTree(); … … 170 167 171 168 private: 169 void initialize(ScriptExecutionContext&); 172 170 void createWebVTTNodeTree(); 173 171 void copyWebVTTNodeToDOMTree(ContainerNode* WebVTTNode, ContainerNode* root); … … 212 210 std::pair<float, float> m_displayPosition; 213 211 212 double m_originalStartTime; 213 214 214 bool m_snapToLines : 1; 215 215 bool m_displayTreeShouldChange : 1; -
trunk/Source/WebCore/html/track/WebVTTParser.cpp
r170332 r170379 2 2 * Copyright (C) 2011, 2013 Google Inc. All rights reserved. 3 3 * Copyright (C) 2013 Cable Television Labs, Inc. 4 * Copyright (C) 201 4 Apple Inc. All rights reserved.4 * Copyright (C) 2011-2014 Apple Inc. All rights reserved. 5 5 * 6 6 * Redistribution and use in source and binary forms, with or without … … 37 37 #include "WebVTTParser.h" 38 38 39 #include "ISOVTTCue.h" 39 40 #include "ProcessingInstruction.h" 40 41 #include "Text.h" … … 109 110 #endif 110 111 112 void WebVTTParser::parseFileHeader(const String& data) 113 { 114 m_state = Initial; 115 m_lineReader.reset(); 116 m_lineReader.append(data); 117 parse(); 118 } 119 111 120 void WebVTTParser::parseBytes(const char* data, unsigned length) 112 121 { … … 114 123 m_lineReader.append(textData); 115 124 parse(); 125 } 126 127 void WebVTTParser::parseCueData(const ISOWebVTTCue& data) 128 { 129 RefPtr<WebVTTCueData> cue = WebVTTCueData::create(); 130 131 double startTime = data.presentationTime().toDouble(); 132 cue->setStartTime(startTime); 133 cue->setEndTime(startTime + data.duration().toDouble()); 134 135 cue->setContent(data.cueText()); 136 cue->setId(data.id()); 137 cue->setSettings(data.settings()); 138 139 double originalStartTime; 140 if (WebVTTParser::collectTimeStamp(data.originalStartTime(), originalStartTime)) 141 cue->setOriginalStartTime(originalStartTime); 142 143 m_cuelist.append(cue); 144 if (m_client) 145 m_client->newCuesParsed(); 116 146 } 117 147 … … 272 302 WebVTTParser::ParseState WebVTTParser::collectTimingsAndSettings(const String& line) 273 303 { 304 if (line.isEmpty()) 305 return BadCue; 306 274 307 VTTScanner input(line); 275 308 … … 435 468 bool WebVTTParser::collectTimeStamp(const String& line, double& timeStamp) 436 469 { 470 if (line.isEmpty()) 471 return false; 472 437 473 VTTScanner input(line); 438 474 return collectTimeStamp(input, timeStamp); -
trunk/Source/WebCore/html/track/WebVTTParser.h
r170332 r170379 50 50 51 51 class Document; 52 class ISOWebVTTCue; 52 53 class VTTScanner; 53 54 … … 83 84 String settings() const { return m_settings; } 84 85 void setSettings(String settings) { m_settings = settings; } 86 87 double originalStartTime() const { return m_originalStartTime; } 88 void setOriginalStartTime(double time) { m_originalStartTime = time; } 85 89 86 90 private: … … 88 92 : m_startTime(0) 89 93 , m_endTime(0) 94 , m_originalStartTime(0) 90 95 { 91 96 } … … 93 98 double m_startTime; 94 99 double m_endTime; 100 double m_originalStartTime; 95 101 String m_id; 96 102 String m_content; … … 141 147 142 148 // Input data to the parser to parse. 143 void parseBytes(const char* data, unsigned length); 149 void parseBytes(const char*, unsigned); 150 void parseFileHeader(const String&); 151 void parseCueData(const ISOWebVTTCue&); 144 152 void flush(); 145 153 void fileFinished(); … … 185 193 StringBuilder m_currentContent; 186 194 String m_currentSettings; 187 195 188 196 WebVTTParserClient* m_client; 189 197 -
trunk/Source/WebCore/loader/TextTrackLoader.cpp
r170332 r170379 216 216 Vector<RefPtr<WebVTTCueData>> newCues; 217 217 m_cueParser->getNewCues(newCues); 218 for (size_t i = 0; i < newCues.size(); ++i) { 219 RefPtr<WebVTTCueData> data = newCues[i]; 220 RefPtr<VTTCue> cue = VTTCue::create(*m_scriptExecutionContext, data->startTime(), data->endTime(), data->content()); 221 cue->setId(data->id()); 222 cue->setCueSettings(data->settings()); 223 outputCues.append(cue); 224 } 218 219 for (auto& cueData : newCues) 220 outputCues.append(VTTCue::create(*m_scriptExecutionContext, *cueData)); 225 221 } 226 222 } -
trunk/Source/WebCore/platform/graphics/InbandTextTrackPrivateClient.h
r170332 r170379 1 1 /* 2 * Copyright (C) 2012 , 2013Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 40 40 class InbandTextTrackPrivate; 41 class ISOWebVTTCue; 41 42 42 43 class GenericCueData : public RefCounted<GenericCueData> { … … 181 182 virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0; 182 183 184 virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) { ASSERT_NOT_REACHED(); } 183 185 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char* data, unsigned length) = 0; 186 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) = 0; 184 187 }; 185 188 -
trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp
r170332 r170379 1 1 /* 2 * Copyright (C) 2012 , 2013Apple Inc. All rights reserved.2 * Copyright (C) 2012-2014 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 #include "InbandTextTrackPrivateAVF.h" 31 31 32 #include "ISOVTTCue.h" 32 33 #include "InbandTextTrackPrivateClient.h" 33 34 #include "Logging.h" 34 35 #include "SoftLinking.h" 35 36 #include <CoreMedia/CoreMedia.h> 37 #include <runtime/ArrayBuffer.h> 38 #include <runtime/DataView.h> 39 #include <runtime/Int8Array.h> 40 #include <wtf/MediaTime.h> 41 #include <wtf/NeverDestroyed.h> 36 42 #include <wtf/PassOwnPtr.h> 37 43 #include <wtf/text/CString.h> 44 #include <wtf/text/StringBuilder.h> 38 45 #include <wtf/text/WTFString.h> 39 46 #include <wtf/unicode/CharacterNames.h> 47 48 #if !PLATFORM(WIN) 49 #include "MediaTimeMac.h" 50 #endif 40 51 41 52 #if !PLATFORM(WIN) … … 53 64 54 65 SOFT_LINK_AVF_FRAMEWORK(CoreMedia) 66 67 #if !PLATFORM(WIN) 68 SOFT_LINK(CoreMedia, CMSampleBufferGetDataBuffer, CMBlockBufferRef, (CMSampleBufferRef sbuf), (sbuf)) 69 SOFT_LINK(CoreMedia, CMBlockBufferCopyDataBytes, OSStatus, (CMBlockBufferRef theSourceBuffer, size_t offsetToData, size_t dataLength, void* destination), (theSourceBuffer, offsetToData, dataLength, destination)) 70 SOFT_LINK(CoreMedia, CMBlockBufferGetDataLength, size_t, (CMBlockBufferRef theBuffer), (theBuffer)) 71 SOFT_LINK(CoreMedia, CMSampleBufferGetSampleTimingInfo, OSStatus, (CMSampleBufferRef sbuf, CMItemIndex sampleIndex, CMSampleTimingInfo* timingInfoOut), (sbuf, sampleIndex, timingInfoOut)) 72 SOFT_LINK(CoreMedia, CMFormatDescriptionGetExtensions, CFDictionaryRef, (CMFormatDescriptionRef desc), (desc)) 73 SOFT_LINK(CoreMedia, CMSampleBufferGetFormatDescription, CMFormatDescriptionRef, (CMSampleBufferRef sbuf), (sbuf)) 74 #endif 55 75 56 76 SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_Alignment, CFStringRef) … … 73 93 SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_BackgroundColorARGB, CFStringRef) 74 94 SOFT_LINK_AVF_POINTER(CoreMedia, kCMTextMarkupAttribute_CharacterBackgroundColorARGB, CFStringRef) 95 SOFT_LINK_AVF_POINTER(CoreMedia, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, CFStringRef) 75 96 76 97 #define kCMTextMarkupAttribute_Alignment getkCMTextMarkupAttribute_Alignment() … … 93 114 #define kCMTextMarkupAttribute_BackgroundColorARGB getkCMTextMarkupAttribute_BackgroundColorARGB() 94 115 #define kCMTextMarkupAttribute_CharacterBackgroundColorARGB getkCMTextMarkupAttribute_CharacterBackgroundColorARGB() 116 #define kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms getkCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms() 117 118 namespace JSC { 119 class ArrayBuffer; 120 } 95 121 96 122 namespace WebCore { … … 100 126 } 101 127 102 InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF(AVFInbandTrackParent* owner )103 : InbandTextTrackPrivate( Generic)128 InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF(AVFInbandTrackParent* owner, CueFormat format) 129 : InbandTextTrackPrivate(format) 104 130 , m_owner(owner) 105 131 , m_pendingCueStatus(None) … … 107 133 , m_hasBeenReported(false) 108 134 , m_seeking(false) 135 , m_haveReportedVTTHeader(false) 109 136 { 110 137 } … … 354 381 } 355 382 356 void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, double time)383 void InbandTextTrackPrivateAVF::processCue(CFArrayRef attributedStrings, CFArrayRef nativeSamples, double time) 357 384 { 358 385 if (!client()) 359 386 return; 360 387 361 LOG(Media, "InbandTextTrackPrivateAVF::processCue - %li cues at time %.2f\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, time); 388 processAttributedStrings(attributedStrings, time); 389 processNativeSamples(nativeSamples, time); 390 } 391 392 void InbandTextTrackPrivateAVF::processAttributedStrings(CFArrayRef attributedStrings, double time) 393 { 394 LOG(Media, "InbandTextTrackPrivateAVF::processAttributedStrings - %li attributed strings at time %.2f\n", attributedStrings ? CFArrayGetCount(attributedStrings) : 0, time); 362 395 363 396 Vector<RefPtr<GenericCueData>> arrivingCues; … … 443 476 444 477 client()->addGenericCue(this, cueData.release()); 445 446 m_pendingCueStatus = seeking() ? DeliveredDuringSeek : Valid; 447 }478 } 479 480 m_pendingCueStatus = seeking() ? DeliveredDuringSeek : Valid; 448 481 } 449 482 … … 514 547 } 515 548 549 void InbandTextTrackPrivateAVF::processNativeSamples(CFArrayRef nativeSamples, double presentationTime) 550 { 551 #if PLATFORM(WIN) 552 UNUSED_PARAM(nativeSamples); 553 UNUSED_PARAM(presentationTime); 554 ASSERT_NOT_REACHED(); 555 #else 556 if (!nativeSamples) 557 return; 558 559 CFIndex count = CFArrayGetCount(nativeSamples); 560 if (!count) 561 return; 562 563 LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples - %li sample buffers at time %.2f\n", count, presentationTime); 564 565 for (CFIndex i = 0; i < count; i++) { 566 567 CMSampleBufferRef sampleBuffer = (CMSampleBufferRef)CFArrayGetValueAtIndex(nativeSamples, i); 568 if (!sampleBuffer) 569 continue; 570 571 CMSampleTimingInfo timingInfo; 572 OSStatus status = CMSampleBufferGetSampleTimingInfo(sampleBuffer, i, &timingInfo); 573 if (status) { 574 LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - CMSampleBufferGetSampleTimingInfo returned error %x for sample %li", this, static_cast<SInt32>(status), i); 575 continue; 576 } 577 578 CMBlockBufferRef blockBuffer = CMSampleBufferGetDataBuffer(sampleBuffer); 579 size_t bufferLength = CMBlockBufferGetDataLength(blockBuffer); 580 if (bufferLength < ISOBox::boxHeaderSize()) { 581 LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - ERROR: CMSampleBuffer size length unexpectedly small (%zu)!!", this, bufferLength); 582 continue; 583 } 584 585 m_sampleInputBuffer.resize(m_sampleInputBuffer.size() + bufferLength); 586 CMBlockBufferCopyDataBytes(blockBuffer, 0, bufferLength, m_sampleInputBuffer.data() + m_sampleInputBuffer.size() - bufferLength); 587 588 RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size()); 589 590 String type = ISOBox::peekType(buffer.get()); 591 size_t boxLength = ISOBox::peekLength(buffer.get()); 592 if (boxLength > buffer->byteLength()) { 593 LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - ERROR: chunk '%s' size (%zu) larger than buffer length (%u)!!", this, type.utf8().data(), boxLength, buffer->byteLength()); 594 continue; 595 } 596 597 LOG(Media, "InbandTextTrackPrivateAVF::processNativeSamples(%p) - chunk type = '%s', size = %zu", this, type.utf8().data(), boxLength); 598 599 if (type == ISOWebVTTCue::boxType()) { 600 #if !PLATFORM(WIN) 601 ISOWebVTTCue cueData = ISOWebVTTCue(MediaTime::createWithDouble(presentationTime), toMediaTime(timingInfo.duration), buffer.get()); 602 #else 603 ISOWebVTTCue cueData = ISOWebVTTCue(MediaTime::createWithDouble(presentationTime), MediaTime::createWithDouble(CMTimeGetSeconds(timingInfo.duration)), buffer.get()); 604 #endif 605 LOG(Media, " sample presentation time = %.2f, duration = %.2f", cueData.presentationTime().toDouble(), cueData.duration().toDouble()); 606 LOG(Media, " id = \"%s\", settings = \"%s\", cue text = \"%s\"", cueData.id().utf8().data(), cueData.settings().utf8().data(), cueData.cueText().utf8().data()); 607 LOG(Media, " sourceID = \"%s\", originalStartTime = \"%s\"", cueData.sourceID().utf8().data(), cueData.originalStartTime().utf8().data()); 608 609 client()->parseWebVTTCueData(this, cueData); 610 } 611 612 do { 613 if (m_haveReportedVTTHeader) 614 break; 615 616 CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer); 617 if (!formatDescription) 618 break; 619 620 CFDictionaryRef extensions = CMFormatDescriptionGetExtensions(formatDescription); 621 if (!extensions) 622 break; 623 624 CFDictionaryRef sampleDescriptionExtensions = static_cast<CFDictionaryRef>(CFDictionaryGetValue(extensions, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms)); 625 if (!sampleDescriptionExtensions) 626 break; 627 628 CFDataRef webvttHeaderData = static_cast<CFDataRef>(CFDictionaryGetValue(sampleDescriptionExtensions, CFSTR("vttC"))); 629 if (!webvttHeaderData) 630 break; 631 632 unsigned length = CFDataGetLength(webvttHeaderData); 633 if (!length) 634 break; 635 636 // A WebVTT header is terminated by "One or more WebVTT line terminators" so append two line feeds to make sure the parser 637 // reccognized this string as a full header. 638 StringBuilder header; 639 header.append(reinterpret_cast<const unsigned char*>(CFDataGetBytePtr(webvttHeaderData)), length); 640 header.append("\n\n"); 641 642 LOG(Media, " vtt header = \n%s", header.toString().utf8().data()); 643 client()->parseWebVTTFileHeader(this, header.toString()); 644 m_haveReportedVTTHeader = true; 645 } while (0); 646 647 m_sampleInputBuffer.remove(0, boxLength); 648 } 649 #endif 650 } 651 516 652 } // namespace WebCore 517 653 -
trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h
r170332 r170379 56 56 void setHasBeenReported(bool reported) { m_hasBeenReported = reported; } 57 57 58 virtual void processCue(CFArrayRef , double);58 virtual void processCue(CFArrayRef attributedStrings, CFArrayRef nativeSamples, double); 59 59 virtual void resetCueValues(); 60 60 … … 69 69 }; 70 70 virtual Category textTrackCategory() const = 0; 71 71 72 72 virtual double startTimeVariance() const override { return 0.25; } 73 73 74 74 protected: 75 InbandTextTrackPrivateAVF(AVFInbandTrackParent* );75 InbandTextTrackPrivateAVF(AVFInbandTrackParent*, CueFormat); 76 76 77 77 void processCueAttributes(CFAttributedStringRef, GenericCueData*); 78 void processAttributedStrings(CFArrayRef, double); 79 void processNativeSamples(CFArrayRef, double); 78 80 void removeCompletedCues(); 79 81 … … 83 85 Vector<RefPtr<GenericCueData>> m_cues; 84 86 AVFInbandTrackParent* m_owner; 87 88 Vector<char> m_sampleInputBuffer; 85 89 86 90 enum PendingCueStatus { … … 94 98 bool m_hasBeenReported; 95 99 bool m_seeking; 100 bool m_haveReportedVTTHeader; 96 101 }; 97 102 -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp
r170332 r170379 46 46 namespace WebCore { 47 47 48 InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection )49 : InbandTextTrackPrivateAVF(player )48 InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection, InbandTextTrackPrivate::CueFormat format) 49 : InbandTextTrackPrivateAVF(player, format) 50 50 , m_mediaSelectionOption(selection) 51 51 { -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h
r170332 r170379 37 37 class InbandTextTrackPrivateAVCF : public InbandTextTrackPrivateAVF { 38 38 public: 39 static PassRefPtr<InbandTextTrackPrivateAVCF> create(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection )39 static PassRefPtr<InbandTextTrackPrivateAVCF> create(AVFInbandTrackParent* player, AVCFMediaSelectionOptionRef selection, InbandTextTrackPrivate::CueFormat format) 40 40 { 41 return adoptRef(new InbandTextTrackPrivateAVCF(player, selection ));41 return adoptRef(new InbandTextTrackPrivateAVCF(player, selection, format)); 42 42 } 43 43 … … 61 61 62 62 protected: 63 InbandTextTrackPrivateAVCF(AVFInbandTrackParent*, AVCFMediaSelectionOptionRef );63 InbandTextTrackPrivateAVCF(AVFInbandTrackParent*, AVCFMediaSelectionOptionRef, InbandTextTrackPrivate::CueFormat); 64 64 65 65 RetainPtr<AVCFMediaSelectionOptionRef> m_mediaSelectionOption; -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
r170332 r170379 1094 1094 continue; 1095 1095 1096 m_textTracks.append(InbandTextTrackPrivateAVCF::create(this, option ));1096 m_textTracks.append(InbandTextTrackPrivateAVCF::create(this, option, InbandTextTrackPrivate::Generic)); 1097 1097 } 1098 1098 … … 1595 1595 struct LegibleOutputData { 1596 1596 RetainPtr<CFArrayRef> m_attributedStrings; 1597 RetainPtr<CFArrayRef> m_samples; 1597 1598 double m_time; 1598 1599 void* m_context; 1599 1600 1600 LegibleOutputData(CFArrayRef strings, double time, void* context)1601 : m_attributedStrings(strings), m_ time(time), m_context(context)1601 LegibleOutputData(CFArrayRef strings, CFArrayRef samples, double time, void* context) 1602 : m_attributedStrings(strings), m_samples(samples), m_time(time), m_context(context) 1602 1603 { 1603 1604 } … … 1624 1625 return; 1625 1626 1626 self->m_currentTextTrack->processCue(legibleOutputData->m_attributedStrings.get(), legibleOutputData->m_ time);1627 } 1628 1629 void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef legibleOutput, CFArrayRef attributedStrings, CFArrayRef /*nativeSampleBuffers*/, CMTime itemTime)1627 self->m_currentTextTrack->processCue(legibleOutputData->m_attributedStrings.get(), legibleOutputData->m_samples.get(), legibleOutputData->m_time); 1628 } 1629 1630 void AVFWrapper::legibleOutputCallback(void* context, AVCFPlayerItemLegibleOutputRef legibleOutput, CFArrayRef attributedStrings, CFArrayRef nativeSampleBuffers, CMTime itemTime) 1630 1631 { 1631 1632 ASSERT(dispatch_get_main_queue() != dispatch_get_current_queue()); … … 1641 1642 ASSERT(legibleOutput == self->m_legibleOutput); 1642 1643 1643 OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(new LegibleOutputData(attributedStrings, CMTimeGetSeconds(itemTime), context));1644 OwnPtr<LegibleOutputData> legibleOutputData = adoptPtr(new LegibleOutputData(attributedStrings, nativeSampleBuffers, CMTimeGetSeconds(itemTime), context)); 1644 1645 1645 1646 dispatch_async_f(dispatch_get_main_queue(), legibleOutputData.leakPtr(), processCue); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h
r170332 r170379 32 32 #include <wtf/RetainPtr.h> 33 33 34 OBJC_CLASS AVAsset; 34 35 OBJC_CLASS AVMediaSelectionOption; 35 36 … … 38 39 class InbandTextTrackPrivateAVFObjC : public InbandTextTrackPrivateAVF { 39 40 public: 40 static PassRefPtr<InbandTextTrackPrivateAVFObjC> create(AVFInbandTrackParent* player, AVMediaSelectionOption *selection )41 static PassRefPtr<InbandTextTrackPrivateAVFObjC> create(AVFInbandTrackParent* player, AVMediaSelectionOption *selection, InbandTextTrackPrivate::CueFormat format) 41 42 { 42 return adoptRef(new InbandTextTrackPrivateAVFObjC(player, selection ));43 return adoptRef(new InbandTextTrackPrivateAVFObjC(player, selection, format)); 43 44 } 44 45 … … 62 63 63 64 protected: 64 InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent*, AVMediaSelectionOption * );65 InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent*, AVMediaSelectionOption *, InbandTextTrackPrivate::CueFormat); 65 66 66 67 RetainPtr<AVMediaSelectionOption> m_mediaSelectionOption; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm
r170332 r170379 77 77 namespace WebCore { 78 78 79 InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent* player, AVMediaSelectionOption *selection )80 : InbandTextTrackPrivateAVF(player )79 InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC(AVFInbandTrackParent* player, AVMediaSelectionOption *selection, InbandTextTrackPrivate::CueFormat format) 80 : InbandTextTrackPrivateAVF(player, format) 81 81 , m_mediaSelectionOption(selection) 82 82 { -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm
r170332 r170379 57 57 58 58 InbandTextTrackPrivateLegacyAVFObjC::InbandTextTrackPrivateLegacyAVFObjC(MediaPlayerPrivateAVFoundationObjC* player, AVPlayerItemTrack* track) 59 : InbandTextTrackPrivateAVF(player )59 : InbandTextTrackPrivateAVF(player, InbandTextTrackPrivate::Generic) 60 60 , m_playerItemTrack(track) 61 61 { -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r170332 r170379 77 77 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) 78 78 RetainPtr<AVPlayerItem> playerItem() const { return m_avPlayerItem; } 79 void processCue(NSArray *, double);79 void processCue(NSArray *, NSArray *, double); 80 80 void flushCues(); 81 81 #endif -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r170332 r170379 677 677 return; 678 678 679 LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(%p) ", this);679 LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(%p) - url = %s", this, url.utf8().data()); 680 680 681 681 setDelayCallbacks(true); … … 809 809 const NSTimeInterval legibleOutputAdvanceInterval = 2; 810 810 811 m_legibleOutput = adoptNS([[AVPlayerItemLegibleOutput alloc] initWithMediaSubtypesForNativeRepresentation:[NSArray array]]); 811 RetainPtr<NSArray> subtypes = adoptNS([[NSArray alloc] initWithObjects:[NSNumber numberWithUnsignedInt:kCMSubtitleFormatType_WebVTT], nil]); 812 m_legibleOutput = adoptNS([[AVPlayerItemLegibleOutput alloc] initWithMediaSubtypesForNativeRepresentation:subtypes.get()]); 812 813 [m_legibleOutput.get() setSuppressesPlayerRendering:YES]; 813 814 … … 1578 1579 1579 1580 #if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP) 1580 if (AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia()) { 1581 AVMediaSelectionGroupType *legibleGroup = safeMediaSelectionGroupForLegibleMedia(); 1582 if (legibleGroup && m_cachedTracks) { 1581 1583 hasCaptions = [[AVMediaSelectionGroup playableMediaSelectionOptionsFromArray:[legibleGroup options]] count]; 1582 1584 if (hasCaptions) … … 2165 2167 #endif 2166 2168 2167 m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option ));2169 m_textTracks.append(InbandTextTrackPrivateAVFObjC::create(this, option, InbandTextTrackPrivate::Generic)); 2168 2170 } 2169 2171 … … 2181 2183 } 2182 2184 2183 void MediaPlayerPrivateAVFoundationObjC::processCue(NSArray *attributedStrings, double time)2185 void MediaPlayerPrivateAVFoundationObjC::processCue(NSArray *attributedStrings, NSArray *nativeSamples, double time) 2184 2186 { 2185 2187 if (!m_currentTextTrack) 2186 2188 return; 2187 2189 2188 m_currentTextTrack->processCue(reinterpret_cast<CFArrayRef>(attributedStrings), time);2190 m_currentTextTrack->processCue(reinterpret_cast<CFArrayRef>(attributedStrings), reinterpret_cast<CFArrayRef>(nativeSamples), time); 2189 2191 } 2190 2192 … … 2735 2737 RetainPtr<WebCoreAVFMovieObserver> strongSelf = self; 2736 2738 RetainPtr<NSArray> strongStrings = strings; 2737 callOnMainThread([strongSelf, strongStrings, itemTime] { 2739 RetainPtr<NSArray> strongSamples = nativeSamples; 2740 callOnMainThread([strongSelf, strongStrings, strongSamples, itemTime] { 2738 2741 MediaPlayerPrivateAVFoundationObjC* callback = strongSelf->m_callback; 2739 2742 if (!callback) 2740 2743 return; 2741 callback->processCue(strongStrings.get(), CMTimeGetSeconds(itemTime));2744 callback->processCue(strongStrings.get(), strongSamples.get(), CMTimeGetSeconds(itemTime)); 2742 2745 }); 2743 2746 } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/OutOfBandTextTrackPrivateAVF.h
r170332 r170379 42 42 } 43 43 44 virtual void processCue(CFArrayRef, double) override { }44 virtual void processCue(CFArrayRef, CFArrayRef, double) override { } 45 45 virtual void resetCueValues() override { } 46 46 … … 51 51 protected: 52 52 OutOfBandTextTrackPrivateAVF(AVFInbandTrackParent* player, AVMediaSelectionOption* selection) 53 : InbandTextTrackPrivateAVF(player )53 : InbandTextTrackPrivateAVF(player, InbandTextTrackPrivate::Generic) 54 54 , m_mediaSelectionOption(selection) 55 55 {
Note:
See TracChangeset
for help on using the changeset viewer.