Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1103)

Unified Diff: Source/core/html/track/AudioTrack.cpp

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Addressed IDL comments. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6a43826358e2d5a5d2fd8f77c78bf72336a85fee
--- /dev/null
+++ b/Source/core/html/track/AudioTrack.cpp
@@ -0,0 +1,90 @@
+// 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"
+
+namespace WebCore {
+
+AudioTrack::AudioTrack(HTMLMediaElement* mediaElement, const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language)
+ : TrackBase(TrackBase::AudioTrack, label, language, id)
+ , m_enabled(false)
+{
+ ASSERT(mediaElement);
+ 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());
+}
+
+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
+{
+ return (kind == alternativeKeyword())
+ || (kind == descriptionsKeyword())
+ || (kind == mainKeyword())
+ || (kind == mainDescriptionsKeyword())
+ || (kind == translationKeyword())
+ || (kind == commentaryKeyword());
+}
+
+AtomicString AudioTrack::defaultKind() const
+{
+ return emptyAtom;
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698