Chromium Code Reviews| Index: Source/core/html/track/AudioTrack.cpp |
| diff --git a/Source/core/html/track/AudioTrack.cpp b/Source/core/html/track/AudioTrack.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb46dbc068e2fbfd1184c419e65950331d3aa291 |
| --- /dev/null |
| +++ b/Source/core/html/track/AudioTrack.cpp |
| @@ -0,0 +1,91 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/html/track/AudioTrack.h" |
| + |
| +#include "core/html/HTMLMediaElement.h" |
| +#include "core/html/track/AudioTrackList.h" |
| + |
| +namespace WebCore { |
| + |
| +AudioTrack::AudioTrack(HTMLMediaElement* mediaElement, const AtomicString& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language) |
| + : TrackBase(TrackBase::AudioTrack, label, language, id) |
| + , m_enabled(false) |
|
philipj_slow
2014/03/09 09:04:14
If I turn out to be right about https://www.w3.org
|
| +{ |
| + 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.
|
| + ASSERT(!id.isEmpty()); |
| + |
| + ScriptWrappable::init(this); |
| + setKind(kind); |
| + setMediaElement(mediaElement); |
| +} |
| + |
| +AudioTrack::~AudioTrack() |
| +{ |
| +} |
| + |
| +void AudioTrack::setEnabled(bool enabled) |
| +{ |
| + if (enabled == m_enabled) |
| + return; |
| + |
| + m_enabled = enabled; |
| + |
| + if (mediaElement()) |
| + mediaElement()->audioTrackChanged(id(), m_enabled); |
| +} |
| + |
| +const AtomicString& AudioTrack::alternativeKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("alternative", AtomicString::ConstructFromLiteral)); |
| + return keyword; |
| +} |
| + |
| +const AtomicString& AudioTrack::descriptionsKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("descriptions", AtomicString::ConstructFromLiteral)); |
| + return keyword; |
| +} |
| + |
| +const AtomicString& AudioTrack::mainKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("main", AtomicString::ConstructFromLiteral)); |
| + return keyword; |
| +} |
| + |
| +const AtomicString& AudioTrack::mainDescriptionsKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("main-desc", AtomicString::ConstructFromLiteral)); |
| + return keyword; |
| +} |
| + |
| +const AtomicString& AudioTrack::translationKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("translation", AtomicString::ConstructFromLiteral)); |
| + return keyword; |
| +} |
| + |
| +const AtomicString& AudioTrack::commentaryKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("commentary", AtomicString::ConstructFromLiteral)); |
| + return keyword; |
| +} |
| + |
| +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
|
| +{ |
| + return (kind == alternativeKeyword()) |
| + || (kind == descriptionsKeyword()) |
| + || (kind == mainKeyword()) |
| + || (kind == mainDescriptionsKeyword()) |
| + || (kind == translationKeyword()) |
| + || (kind == commentaryKeyword()); |
| +} |
| + |
| +AtomicString AudioTrack::defaultKind() const |
| +{ |
| + return emptyAtom; |
| +} |
| + |
| +} |