diff options
Diffstat (limited to 'Source/WebCore/html/MediaFragmentURIParser.cpp')
| -rw-r--r-- | Source/WebCore/html/MediaFragmentURIParser.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/Source/WebCore/html/MediaFragmentURIParser.cpp b/Source/WebCore/html/MediaFragmentURIParser.cpp index 723b53097..35046f9a2 100644 --- a/Source/WebCore/html/MediaFragmentURIParser.cpp +++ b/Source/WebCore/html/MediaFragmentURIParser.cpp @@ -10,10 +10,10 @@ * 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 + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -42,7 +42,7 @@ namespace WebCore { const int secondsPerHour = 3600; const int secondsPerMinute = 60; -const unsigned nptIdentifierLength = 4; // "npt:" +const unsigned nptIdentiferLength = 4; // "npt:" static String collectDigits(const LChar* input, unsigned length, unsigned& position) { @@ -70,27 +70,32 @@ static String collectFraction(const LChar* input, unsigned length, unsigned& pos return digits.toString(); } +double MediaFragmentURIParser::invalidTimeValue() +{ + return MediaPlayer::invalidTime(); +} + MediaFragmentURIParser::MediaFragmentURIParser(const URL& url) : m_url(url) , m_timeFormat(None) - , m_startTime(MediaTime::invalidTime()) - , m_endTime(MediaTime::invalidTime()) + , m_startTime(MediaPlayer::invalidTime()) + , m_endTime(MediaPlayer::invalidTime()) { } -MediaTime MediaFragmentURIParser::startTime() +double MediaFragmentURIParser::startTime() { if (!m_url.isValid()) - return MediaTime::invalidTime(); + return MediaPlayer::invalidTime(); if (m_timeFormat == None) parseTimeFragment(); return m_startTime; } -MediaTime MediaFragmentURIParser::endTime() +double MediaFragmentURIParser::endTime() { if (!m_url.isValid()) - return MediaTime::invalidTime(); + return MediaPlayer::invalidTime(); if (m_timeFormat == None) parseTimeFragment(); return m_endTime; @@ -179,8 +184,8 @@ void MediaFragmentURIParser::parseTimeFragment() // in the same format. The format is specified by name, followed by a colon (:), with npt: being // the default. - MediaTime start = MediaTime::invalidTime(); - MediaTime end = MediaTime::invalidTime(); + double start = MediaPlayer::invalidTime(); + double end = MediaPlayer::invalidTime(); if (parseNPTFragment(fragment.second.characters8(), fragment.second.length(), start, end)) { m_startTime = start; m_endTime = end; @@ -197,11 +202,11 @@ void MediaFragmentURIParser::parseTimeFragment() m_fragments.clear(); } -bool MediaFragmentURIParser::parseNPTFragment(const LChar* timeString, unsigned length, MediaTime& startTime, MediaTime& endTime) +bool MediaFragmentURIParser::parseNPTFragment(const LChar* timeString, unsigned length, double& startTime, double& endTime) { unsigned offset = 0; - if (length >= nptIdentifierLength && timeString[0] == 'n' && timeString[1] == 'p' && timeString[2] == 't' && timeString[3] == ':') - offset += nptIdentifierLength; + if (length >= nptIdentiferLength && timeString[0] == 'n' && timeString[1] == 'p' && timeString[2] == 't' && timeString[3] == ':') + offset += nptIdentiferLength; if (offset == length) return false; @@ -210,7 +215,7 @@ bool MediaFragmentURIParser::parseNPTFragment(const LChar* timeString, unsigned // If a single number only is given, this corresponds to the begin time except if it is preceded // by a comma that would in this case indicate the end time. if (timeString[offset] == ',') - startTime = MediaTime::zeroTime(); + startTime = 0; else { if (!parseNPTTime(timeString, length, offset, startTime)) return false; @@ -236,7 +241,7 @@ bool MediaFragmentURIParser::parseNPTFragment(const LChar* timeString, unsigned return true; } -bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned length, unsigned& offset, MediaTime& time) +bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned length, unsigned& offset, double& time) { enum Mode { minutes, hours }; Mode mode = minutes; @@ -266,17 +271,17 @@ bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned leng String digits1 = collectDigits(timeString, length, offset); int value1 = digits1.toInt(); if (offset >= length || timeString[offset] == ',') { - time = MediaTime::createWithDouble(value1); + time = value1; return true; } - MediaTime fraction; + double fraction = 0; if (timeString[offset] == '.') { if (offset == length) return true; String digits = collectFraction(timeString, length, offset); - fraction = MediaTime::createWithDouble(digits.toDouble()); - time = MediaTime::createWithDouble(value1) + fraction; + fraction = digits.toDouble(); + time = value1 + fraction; return true; } @@ -313,9 +318,9 @@ bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned leng } if (offset < length && timeString[offset] == '.') - fraction = MediaTime::createWithDouble(collectFraction(timeString, length, offset).toDouble()); + fraction = collectFraction(timeString, length, offset).toDouble(); - time = MediaTime::createWithDouble((value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3) + fraction; + time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + fraction; return true; } |
