OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 if (!set.isEmpty()) | 153 if (!set.isEmpty()) |
154 map.add(document, set); | 154 map.add(document, set); |
155 } | 155 } |
156 | 156 |
157 static ExceptionCode exceptionCodeForMediaKeyException(MediaPlayer::MediaKeyExce
ption exception) | 157 static ExceptionCode exceptionCodeForMediaKeyException(MediaPlayer::MediaKeyExce
ption exception) |
158 { | 158 { |
159 switch (exception) { | 159 switch (exception) { |
160 case MediaPlayer::NoError: | 160 case MediaPlayer::NoError: |
161 return 0; | 161 return 0; |
162 case MediaPlayer::InvalidPlayerState: | 162 case MediaPlayer::InvalidPlayerState: |
163 return INVALID_STATE_ERR; | 163 return InvalidStateError; |
164 case MediaPlayer::KeySystemNotSupported: | 164 case MediaPlayer::KeySystemNotSupported: |
165 return NotSupportedError; | 165 return NotSupportedError; |
166 } | 166 } |
167 | 167 |
168 ASSERT_NOT_REACHED(); | 168 ASSERT_NOT_REACHED(); |
169 return INVALID_STATE_ERR; | 169 return InvalidStateError; |
170 } | 170 } |
171 | 171 |
172 class TrackDisplayUpdateScope { | 172 class TrackDisplayUpdateScope { |
173 public: | 173 public: |
174 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) | 174 TrackDisplayUpdateScope(HTMLMediaElement* mediaElement) |
175 { | 175 { |
176 m_mediaElement = mediaElement; | 176 m_mediaElement = mediaElement; |
177 m_mediaElement->beginIgnoringTrackDisplayUpdateRequests(); | 177 m_mediaElement->beginIgnoringTrackDisplayUpdateRequests(); |
178 } | 178 } |
179 ~TrackDisplayUpdateScope() | 179 ~TrackDisplayUpdateScope() |
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 m_havePreparedToPlay = true; | 1819 m_havePreparedToPlay = true; |
1820 m_player->prepareToPlay(); | 1820 m_player->prepareToPlay(); |
1821 } | 1821 } |
1822 | 1822 |
1823 void HTMLMediaElement::seek(double time, ExceptionCode& ec) | 1823 void HTMLMediaElement::seek(double time, ExceptionCode& ec) |
1824 { | 1824 { |
1825 LOG(Media, "HTMLMediaElement::seek(%f)", time); | 1825 LOG(Media, "HTMLMediaElement::seek(%f)", time); |
1826 | 1826 |
1827 // 4.8.9.9 Seeking | 1827 // 4.8.9.9 Seeking |
1828 | 1828 |
1829 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an INVA
LID_STATE_ERR exception. | 1829 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva
lidStateError exception. |
1830 if (m_readyState == HAVE_NOTHING || !m_player) { | 1830 if (m_readyState == HAVE_NOTHING || !m_player) { |
1831 ec = INVALID_STATE_ERR; | 1831 ec = InvalidStateError; |
1832 return; | 1832 return; |
1833 } | 1833 } |
1834 | 1834 |
1835 // If the media engine has been told to postpone loading data, let it go ahe
ad now. | 1835 // If the media engine has been told to postpone loading data, let it go ahe
ad now. |
1836 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 1836 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) |
1837 prepareToPlay(); | 1837 prepareToPlay(); |
1838 | 1838 |
1839 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. | 1839 // Get the current time before setting m_seeking, m_lastSeekTime is returned
once it is set. |
1840 refreshCachedTime(); | 1840 refreshCachedTime(); |
1841 double now = currentTime(); | 1841 double now = currentTime(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 } | 1986 } |
1987 | 1987 |
1988 refreshCachedTime(); | 1988 refreshCachedTime(); |
1989 | 1989 |
1990 return m_cachedTime; | 1990 return m_cachedTime; |
1991 } | 1991 } |
1992 | 1992 |
1993 void HTMLMediaElement::setCurrentTime(double time, ExceptionCode& ec) | 1993 void HTMLMediaElement::setCurrentTime(double time, ExceptionCode& ec) |
1994 { | 1994 { |
1995 if (m_mediaController) { | 1995 if (m_mediaController) { |
1996 ec = INVALID_STATE_ERR; | 1996 ec = InvalidStateError; |
1997 return; | 1997 return; |
1998 } | 1998 } |
1999 seek(time, ec); | 1999 seek(time, ec); |
2000 } | 2000 } |
2001 | 2001 |
2002 double HTMLMediaElement::startTime() const | 2002 double HTMLMediaElement::startTime() const |
2003 { | 2003 { |
2004 return 0; | 2004 return 0; |
2005 } | 2005 } |
2006 | 2006 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 if (!m_mediaSource) | 2210 if (!m_mediaSource) |
2211 return; | 2211 return; |
2212 | 2212 |
2213 m_mediaSource->close(); | 2213 m_mediaSource->close(); |
2214 m_mediaSource = 0; | 2214 m_mediaSource = 0; |
2215 } | 2215 } |
2216 | 2216 |
2217 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
Ptr<Uint8Array> initData, ExceptionCode& ec) | 2217 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, PassRef
Ptr<Uint8Array> initData, ExceptionCode& ec) |
2218 { | 2218 { |
2219 if (keySystem.isEmpty()) { | 2219 if (keySystem.isEmpty()) { |
2220 ec = SYNTAX_ERR; | 2220 ec = SyntaxError; |
2221 return; | 2221 return; |
2222 } | 2222 } |
2223 | 2223 |
2224 if (!m_player) { | 2224 if (!m_player) { |
2225 ec = INVALID_STATE_ERR; | 2225 ec = InvalidStateError; |
2226 return; | 2226 return; |
2227 } | 2227 } |
2228 | 2228 |
2229 const unsigned char* initDataPointer = 0; | 2229 const unsigned char* initDataPointer = 0; |
2230 unsigned initDataLength = 0; | 2230 unsigned initDataLength = 0; |
2231 if (initData) { | 2231 if (initData) { |
2232 initDataPointer = initData->data(); | 2232 initDataPointer = initData->data(); |
2233 initDataLength = initData->length(); | 2233 initDataLength = initData->length(); |
2234 } | 2234 } |
2235 | 2235 |
2236 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst
em, initDataPointer, initDataLength); | 2236 MediaPlayer::MediaKeyException result = m_player->generateKeyRequest(keySyst
em, initDataPointer, initDataLength); |
2237 ec = exceptionCodeForMediaKeyException(result); | 2237 ec = exceptionCodeForMediaKeyException(result); |
2238 } | 2238 } |
2239 | 2239 |
2240 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti
onCode& ec) | 2240 void HTMLMediaElement::webkitGenerateKeyRequest(const String& keySystem, Excepti
onCode& ec) |
2241 { | 2241 { |
2242 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), ec); | 2242 webkitGenerateKeyRequest(keySystem, Uint8Array::create(0), ec); |
2243 } | 2243 } |
2244 | 2244 |
2245 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionCode
& ec) | 2245 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, PassRefPtr<Uint8Array> initData, const String& sessionId, ExceptionCode
& ec) |
2246 { | 2246 { |
2247 if (keySystem.isEmpty()) { | 2247 if (keySystem.isEmpty()) { |
2248 ec = SYNTAX_ERR; | 2248 ec = SyntaxError; |
2249 return; | 2249 return; |
2250 } | 2250 } |
2251 | 2251 |
2252 if (!key) { | 2252 if (!key) { |
2253 ec = SYNTAX_ERR; | 2253 ec = SyntaxError; |
2254 return; | 2254 return; |
2255 } | 2255 } |
2256 | 2256 |
2257 if (!key->length()) { | 2257 if (!key->length()) { |
2258 ec = TYPE_MISMATCH_ERR; | 2258 ec = TypeMismatchError; |
2259 return; | 2259 return; |
2260 } | 2260 } |
2261 | 2261 |
2262 if (!m_player) { | 2262 if (!m_player) { |
2263 ec = INVALID_STATE_ERR; | 2263 ec = InvalidStateError; |
2264 return; | 2264 return; |
2265 } | 2265 } |
2266 | 2266 |
2267 const unsigned char* initDataPointer = 0; | 2267 const unsigned char* initDataPointer = 0; |
2268 unsigned initDataLength = 0; | 2268 unsigned initDataLength = 0; |
2269 if (initData) { | 2269 if (initData) { |
2270 initDataPointer = initData->data(); | 2270 initDataPointer = initData->data(); |
2271 initDataLength = initData->length(); | 2271 initDataLength = initData->length(); |
2272 } | 2272 } |
2273 | 2273 |
2274 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat
a(), key->length(), initDataPointer, initDataLength, sessionId); | 2274 MediaPlayer::MediaKeyException result = m_player->addKey(keySystem, key->dat
a(), key->length(), initDataPointer, initDataLength, sessionId); |
2275 ec = exceptionCodeForMediaKeyException(result); | 2275 ec = exceptionCodeForMediaKeyException(result); |
2276 } | 2276 } |
2277 | 2277 |
2278 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, ExceptionCode& ec) | 2278 void HTMLMediaElement::webkitAddKey(const String& keySystem, PassRefPtr<Uint8Arr
ay> key, ExceptionCode& ec) |
2279 { | 2279 { |
2280 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), ec); | 2280 webkitAddKey(keySystem, key, Uint8Array::create(0), String(), ec); |
2281 } | 2281 } |
2282 | 2282 |
2283 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str
ing& sessionId, ExceptionCode& ec) | 2283 void HTMLMediaElement::webkitCancelKeyRequest(const String& keySystem, const Str
ing& sessionId, ExceptionCode& ec) |
2284 { | 2284 { |
2285 if (keySystem.isEmpty()) { | 2285 if (keySystem.isEmpty()) { |
2286 ec = SYNTAX_ERR; | 2286 ec = SyntaxError; |
2287 return; | 2287 return; |
2288 } | 2288 } |
2289 | 2289 |
2290 if (!m_player) { | 2290 if (!m_player) { |
2291 ec = INVALID_STATE_ERR; | 2291 ec = InvalidStateError; |
2292 return; | 2292 return; |
2293 } | 2293 } |
2294 | 2294 |
2295 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem
, sessionId); | 2295 MediaPlayer::MediaKeyException result = m_player->cancelKeyRequest(keySystem
, sessionId); |
2296 ec = exceptionCodeForMediaKeyException(result); | 2296 ec = exceptionCodeForMediaKeyException(result); |
2297 } | 2297 } |
2298 | 2298 |
2299 bool HTMLMediaElement::loop() const | 2299 bool HTMLMediaElement::loop() const |
2300 { | 2300 { |
2301 return fastHasAttribute(loopAttr); | 2301 return fastHasAttribute(loopAttr); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S
tring& label, const String& language, ExceptionCode& ec) | 2582 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const String& kind, const S
tring& label, const String& language, ExceptionCode& ec) |
2583 { | 2583 { |
2584 if (!RuntimeEnabledFeatures::videoTrackEnabled()) | 2584 if (!RuntimeEnabledFeatures::videoTrackEnabled()) |
2585 return 0; | 2585 return 0; |
2586 | 2586 |
2587 // 4.8.10.12.4 Text track API | 2587 // 4.8.10.12.4 Text track API |
2588 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: | 2588 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: |
2589 | 2589 |
2590 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps | 2590 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps |
2591 if (!TextTrack::isValidKindKeyword(kind)) { | 2591 if (!TextTrack::isValidKindKeyword(kind)) { |
2592 ec = SYNTAX_ERR; | 2592 ec = SyntaxError; |
2593 return 0; | 2593 return 0; |
2594 } | 2594 } |
2595 | 2595 |
2596 // 2. If the label argument was omitted, let label be the empty string. | 2596 // 2. If the label argument was omitted, let label be the empty string. |
2597 // 3. If the language argument was omitted, let language be the empty string
. | 2597 // 3. If the language argument was omitted, let language be the empty string
. |
2598 // 4. Create a new TextTrack object. | 2598 // 4. Create a new TextTrack object. |
2599 | 2599 |
2600 // 5. Create a new text track corresponding to the new object, and set its t
ext track kind to kind, its text | 2600 // 5. Create a new text track corresponding to the new object, and set its t
ext track kind to kind, its text |
2601 // track label to label, its text track language to language... | 2601 // track label to label, its text track language to language... |
2602 RefPtr<TextTrack> textTrack = TextTrack::create(ActiveDOMObject::scriptExecu
tionContext(), this, kind, label, language); | 2602 RefPtr<TextTrack> textTrack = TextTrack::create(ActiveDOMObject::scriptExecu
tionContext(), this, kind, label, language); |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3965 info.addMember(m_mediaGroup, "mediaGroup"); | 3965 info.addMember(m_mediaGroup, "mediaGroup"); |
3966 info.addMember(m_mediaController, "mediaController"); | 3966 info.addMember(m_mediaController, "mediaController"); |
3967 | 3967 |
3968 #if ENABLE(WEB_AUDIO) | 3968 #if ENABLE(WEB_AUDIO) |
3969 info.addMember(m_audioSourceNode, "audioSourceNode"); | 3969 info.addMember(m_audioSourceNode, "audioSourceNode"); |
3970 #endif | 3970 #endif |
3971 | 3971 |
3972 } | 3972 } |
3973 | 3973 |
3974 } | 3974 } |
OLD | NEW |