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 2378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 void HTMLMediaElement::togglePlayState() | 2389 void HTMLMediaElement::togglePlayState() |
2390 { | 2390 { |
2391 if (paused()) | 2391 if (paused()) |
2392 play(); | 2392 play(); |
2393 else | 2393 else |
2394 pause(); | 2394 pause(); |
2395 } | 2395 } |
2396 | 2396 |
2397 AudioTrackList& HTMLMediaElement::audioTracks() | 2397 AudioTrackList& HTMLMediaElement::audioTracks() |
2398 { | 2398 { |
2399 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2400 return *m_audioTracks; | 2399 return *m_audioTracks; |
2401 } | 2400 } |
2402 | 2401 |
2403 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e
nabled) | 2402 void HTMLMediaElement::audioTrackChanged(WebMediaPlayer::TrackId trackId, bool e
nabled) |
2404 { | 2403 { |
2405 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this << ") trackId= " << S
tring(trackId) << " enabled=" << boolString(enabled); | 2404 BLINK_MEDIA_LOG << "audioTrackChanged(" << (void*)this << ") trackId= " << S
tring(trackId) << " enabled=" << boolString(enabled); |
2406 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2407 | 2405 |
2408 audioTracks().scheduleChangeEvent(); | 2406 audioTracks().scheduleChangeEvent(); |
2409 | 2407 |
2410 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.audioTracks attribute is added. | 2408 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.audioTracks attribute is added. |
2411 | 2409 |
2412 if (!m_audioTracksTimer.isActive()) | 2410 if (!m_audioTracksTimer.isActive()) |
2413 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); | 2411 m_audioTracksTimer.startOneShot(0, BLINK_FROM_HERE); |
2414 } | 2412 } |
2415 | 2413 |
2416 void HTMLMediaElement::audioTracksTimerFired(TimerBase*) | 2414 void HTMLMediaElement::audioTracksTimerFired(TimerBase*) |
2417 { | 2415 { |
2418 Vector<WebMediaPlayer::TrackId> enabledTrackIds; | 2416 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
2419 for (unsigned i = 0; i < audioTracks().length(); ++i) { | 2417 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
2420 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); | 2418 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
2421 if (track->enabled()) | 2419 if (track->enabled()) |
2422 enabledTrackIds.append(track->id()); | 2420 enabledTrackIds.append(track->id()); |
2423 } | 2421 } |
2424 | 2422 |
2425 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | 2423 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
2426 } | 2424 } |
2427 | 2425 |
2428 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web
MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString&
language, bool enabled) | 2426 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, Web
MediaPlayerClient::AudioTrackKind kind, const WebString& label, const WebString&
language, bool enabled) |
2429 { | 2427 { |
2430 AtomicString kindString = AudioKindToString(kind); | 2428 AtomicString kindString = AudioKindToString(kind); |
2431 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id <<
"', ' " << (AtomicString)kindString | 2429 BLINK_MEDIA_LOG << "addAudioTrack(" << (void*)this << ", '" << (String)id <<
"', ' " << (AtomicString)kindString |
2432 << "', '" << (String)label << "', '" << (String)language << "', " << boo
lString(enabled) << ")"; | 2430 << "', '" << (String)label << "', '" << (String)language << "', " << boo
lString(enabled) << ")"; |
2433 | 2431 |
2434 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2435 return blink::WebMediaPlayer::TrackId(); | |
2436 | |
2437 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language,
enabled); | 2432 AudioTrack* audioTrack = AudioTrack::create(id, kindString, label, language,
enabled); |
2438 audioTracks().add(audioTrack); | 2433 audioTracks().add(audioTrack); |
2439 | 2434 |
2440 return audioTrack->id(); | 2435 return audioTrack->id(); |
2441 } | 2436 } |
2442 | 2437 |
2443 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) | 2438 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) |
2444 { | 2439 { |
2445 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; | 2440 BLINK_MEDIA_LOG << "removeAudioTrack(" << (void*)this << ")"; |
2446 | 2441 |
2447 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2448 return; | |
2449 | |
2450 audioTracks().remove(trackId); | 2442 audioTracks().remove(trackId); |
2451 } | 2443 } |
2452 | 2444 |
2453 VideoTrackList& HTMLMediaElement::videoTracks() | 2445 VideoTrackList& HTMLMediaElement::videoTracks() |
2454 { | 2446 { |
2455 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2456 return *m_videoTracks; | 2447 return *m_videoTracks; |
2457 } | 2448 } |
2458 | 2449 |
2459 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select
edTrackId) | 2450 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select
edTrackId) |
2460 { | 2451 { |
2461 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this << ") selecte
dTrackId=" << (selectedTrackId ? String(*selectedTrackId) : "none"); | 2452 BLINK_MEDIA_LOG << "selectedVideoTrackChanged(" << (void*)this << ") selecte
dTrackId=" << (selectedTrackId ? String(*selectedTrackId) : "none"); |
2462 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2463 | 2453 |
2464 if (selectedTrackId) | 2454 if (selectedTrackId) |
2465 videoTracks().trackSelected(*selectedTrackId); | 2455 videoTracks().trackSelected(*selectedTrackId); |
2466 | 2456 |
2467 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. | 2457 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. |
2468 | 2458 |
2469 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2459 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
2470 } | 2460 } |
2471 | 2461 |
2472 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web
MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString&
language, bool selected) | 2462 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, Web
MediaPlayerClient::VideoTrackKind kind, const WebString& label, const WebString&
language, bool selected) |
2473 { | 2463 { |
2474 AtomicString kindString = VideoKindToString(kind); | 2464 AtomicString kindString = VideoKindToString(kind); |
2475 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id <<
"', '" << (AtomicString)kindString | 2465 BLINK_MEDIA_LOG << "addVideoTrack(" << (void*)this << ", '" << (String)id <<
"', '" << (AtomicString)kindString |
2476 << "', '" << (String)label << "', '" << (String)language << "', " << boo
lString(selected) << ")"; | 2466 << "', '" << (String)label << "', '" << (String)language << "', " << boo
lString(selected) << ")"; |
2477 | 2467 |
2478 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2479 return blink::WebMediaPlayer::TrackId(); | |
2480 | |
2481 // If another track was selected (potentially by the user), leave it selecte
d. | 2468 // If another track was selected (potentially by the user), leave it selecte
d. |
2482 if (selected && videoTracks().selectedIndex() != -1) | 2469 if (selected && videoTracks().selectedIndex() != -1) |
2483 selected = false; | 2470 selected = false; |
2484 | 2471 |
2485 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language,
selected); | 2472 VideoTrack* videoTrack = VideoTrack::create(id, kindString, label, language,
selected); |
2486 videoTracks().add(videoTrack); | 2473 videoTracks().add(videoTrack); |
2487 | 2474 |
2488 return videoTrack->id(); | 2475 return videoTrack->id(); |
2489 } | 2476 } |
2490 | 2477 |
2491 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) | 2478 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
2492 { | 2479 { |
2493 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; | 2480 BLINK_MEDIA_LOG << "removeVideoTrack(" << (void*)this << ")"; |
2494 | 2481 |
2495 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2496 return; | |
2497 | |
2498 videoTracks().remove(trackId); | 2482 videoTracks().remove(trackId); |
2499 } | 2483 } |
2500 | 2484 |
2501 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) | 2485 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) |
2502 { | 2486 { |
2503 // 4.8.10.12.2 Sourcing in-band text tracks | 2487 // 4.8.10.12.2 Sourcing in-band text tracks |
2504 // 1. Associate the relevant data with a new text track and its correspondin
g new TextTrack object. | 2488 // 1. Associate the relevant data with a new text track and its correspondin
g new TextTrack object. |
2505 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); | 2489 InbandTextTrack* textTrack = InbandTextTrack::create(webTrack); |
2506 | 2490 |
2507 // 2. Set the new text track's kind, label, and language based on the semant
ics of the relevant data, | 2491 // 2. Set the new text track's kind, label, and language based on the semant
ics of the relevant data, |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3676 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) | 3660 DEFINE_TRACE_WRAPPERS(HTMLMediaElement) |
3677 { | 3661 { |
3678 visitor->traceWrappers(m_videoTracks); | 3662 visitor->traceWrappers(m_videoTracks); |
3679 visitor->traceWrappers(m_audioTracks); | 3663 visitor->traceWrappers(m_audioTracks); |
3680 visitor->traceWrappers(m_textTracks); | 3664 visitor->traceWrappers(m_textTracks); |
3681 HTMLElement::traceWrappers(visitor); | 3665 HTMLElement::traceWrappers(visitor); |
3682 } | 3666 } |
3683 | 3667 |
3684 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | 3668 void HTMLMediaElement::createPlaceholderTracksIfNecessary() |
3685 { | 3669 { |
3686 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
3687 return; | |
3688 | |
3689 // Create a placeholder audio track if the player says it has audio but it d
idn't explicitly announce the tracks. | 3670 // Create a placeholder audio track if the player says it has audio but it d
idn't explicitly announce the tracks. |
3690 if (hasAudio() && !audioTracks().length()) | 3671 if (hasAudio() && !audioTracks().length()) |
3691 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio
Track", "", true); | 3672 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio
Track", "", true); |
3692 | 3673 |
3693 // Create a placeholder video track if the player says it has video but it d
idn't explicitly announce the tracks. | 3674 // Create a placeholder video track if the player says it has video but it d
idn't explicitly announce the tracks. |
3694 if (hasVideo() && !videoTracks().length()) | 3675 if (hasVideo() && !videoTracks().length()) |
3695 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video
Track", "", true); | 3676 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video
Track", "", true); |
3696 } | 3677 } |
3697 | 3678 |
3698 void HTMLMediaElement::selectInitialTracksIfNecessary() | 3679 void HTMLMediaElement::selectInitialTracksIfNecessary() |
3699 { | 3680 { |
3700 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
3701 return; | |
3702 | |
3703 // Enable the first audio track if an audio track hasn't been enabled yet. | 3681 // Enable the first audio track if an audio track hasn't been enabled yet. |
3704 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | 3682 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) |
3705 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | 3683 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); |
3706 | 3684 |
3707 // Select the first video track if a video track hasn't been selected yet. | 3685 // Select the first video track if a video track hasn't been selected yet. |
3708 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | 3686 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
3709 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | 3687 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
3710 } | 3688 } |
3711 | 3689 |
3712 bool HTMLMediaElement::isLockedPendingUserGesture() const | 3690 bool HTMLMediaElement::isLockedPendingUserGesture() const |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4013 | 3991 |
4014 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 3992 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
4015 { | 3993 { |
4016 IntRect result; | 3994 IntRect result; |
4017 if (LayoutObject* object = m_element->layoutObject()) | 3995 if (LayoutObject* object = m_element->layoutObject()) |
4018 result = object->absoluteBoundingBoxRect(); | 3996 result = object->absoluteBoundingBoxRect(); |
4019 return result; | 3997 return result; |
4020 } | 3998 } |
4021 | 3999 |
4022 } // namespace blink | 4000 } // namespace blink |
OLD | NEW |