Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/html/track/AudioTrack.h" | |
| 7 | |
| 8 #include "core/html/HTMLMediaElement.h" | |
| 9 #include "core/html/track/AudioTrackList.h" | |
| 10 | |
| 11 namespace WebCore { | |
| 12 | |
| 13 AudioTrack::AudioTrack(HTMLMediaElement* mediaElement, const AtomicString& id, c onst AtomicString& kind, const AtomicString& label, const AtomicString& language ) | |
| 14 : TrackBase(TrackBase::AudioTrack, label, language, id) | |
| 15 , m_enabled(false) | |
|
philipj_slow
2014/03/09 09:04:14
If I turn out to be right about https://www.w3.org
| |
| 16 { | |
| 17 ASSERT(mediaElement); | |
|
philipj_slow
2014/03/09 09:04:14
Make it a reference instead? That TrackBase has it
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
No. Tracks can outlive the HTMLMediaElement if JS
philipj_slow
2014/03/20 16:17:39
Ah, yes.
| |
| 18 ASSERT(!id.isEmpty()); | |
| 19 | |
| 20 ScriptWrappable::init(this); | |
| 21 setKind(kind); | |
| 22 setMediaElement(mediaElement); | |
| 23 } | |
| 24 | |
| 25 AudioTrack::~AudioTrack() | |
| 26 { | |
| 27 } | |
| 28 | |
| 29 void AudioTrack::setEnabled(bool enabled) | |
| 30 { | |
| 31 if (enabled == m_enabled) | |
| 32 return; | |
| 33 | |
| 34 m_enabled = enabled; | |
| 35 | |
| 36 if (mediaElement()) | |
| 37 mediaElement()->audioTrackChanged(id(), m_enabled); | |
| 38 } | |
| 39 | |
| 40 const AtomicString& AudioTrack::alternativeKeyword() | |
| 41 { | |
| 42 DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("alternative", AtomicStrin g::ConstructFromLiteral)); | |
| 43 return keyword; | |
| 44 } | |
| 45 | |
| 46 const AtomicString& AudioTrack::descriptionsKeyword() | |
| 47 { | |
| 48 DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("descriptions", AtomicStri ng::ConstructFromLiteral)); | |
| 49 return keyword; | |
| 50 } | |
| 51 | |
| 52 const AtomicString& AudioTrack::mainKeyword() | |
| 53 { | |
| 54 DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("main", AtomicString::Cons tructFromLiteral)); | |
| 55 return keyword; | |
| 56 } | |
| 57 | |
| 58 const AtomicString& AudioTrack::mainDescriptionsKeyword() | |
| 59 { | |
| 60 DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("main-desc", AtomicString: :ConstructFromLiteral)); | |
| 61 return keyword; | |
| 62 } | |
| 63 | |
| 64 const AtomicString& AudioTrack::translationKeyword() | |
| 65 { | |
| 66 DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("translation", AtomicStrin g::ConstructFromLiteral)); | |
| 67 return keyword; | |
| 68 } | |
| 69 | |
| 70 const AtomicString& AudioTrack::commentaryKeyword() | |
| 71 { | |
| 72 DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("commentary", AtomicString ::ConstructFromLiteral)); | |
| 73 return keyword; | |
| 74 } | |
| 75 | |
| 76 bool AudioTrack::isValidKind(const AtomicString& kind) const | |
|
philipj_slow
2014/03/09 09:04:14
I don't understand why this TrackBase::isValidKind
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
I could probably move this functionality to TextTr
philipj_slow
2014/03/20 16:17:39
Sounds like a plan. Even for out-of-band tracks we
| |
| 77 { | |
| 78 return (kind == alternativeKeyword()) | |
| 79 || (kind == descriptionsKeyword()) | |
| 80 || (kind == mainKeyword()) | |
| 81 || (kind == mainDescriptionsKeyword()) | |
| 82 || (kind == translationKeyword()) | |
| 83 || (kind == commentaryKeyword()); | |
| 84 } | |
| 85 | |
| 86 AtomicString AudioTrack::defaultKind() const | |
| 87 { | |
| 88 return emptyAtom; | |
| 89 } | |
| 90 | |
| 91 } | |
| OLD | NEW |