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

Unified Diff: Source/modules/mediasource/TrackDefault.cpp

Issue 691313002: MSE: Implement TrackDefault object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Interim upload not ready for review. BIG TODO needs addressing. Created 6 years, 1 month 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
« no previous file with comments | « Source/modules/mediasource/TrackDefault.h ('k') | Source/modules/mediasource/TrackDefault.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediasource/TrackDefault.cpp
diff --git a/Source/modules/mediasource/TrackDefault.cpp b/Source/modules/mediasource/TrackDefault.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..96b884c036fb4360b47b2aeff59c9636035a70d9
--- /dev/null
+++ b/Source/modules/mediasource/TrackDefault.cpp
@@ -0,0 +1,101 @@
+// 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 "modules/mediasource/TrackDefault.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/html/track/AudioTrack.h"
+#include "core/html/track/TextTrack.h"
+#include "core/html/track/VideoTrack.h"
+
+// BIG TODO: start with fixing '': is it a valid trackdefault kind? is it a
+// valid audio/video/text track kind? And fix the negative layout test to not
+// test kinds one at a time, but in bulk. And add more tests...
+
+namespace blink {
+
+const AtomicString& TrackDefault::audioKeyword()
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, audio, ("audio", AtomicString::ConstructFromLiteral));
+ return audio;
+}
+
+const AtomicString& TrackDefault::videoKeyword()
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, video, ("video", AtomicString::ConstructFromLiteral));
+ return video;
+}
+
+const AtomicString& TrackDefault::textKeyword()
+{
+ DEFINE_STATIC_LOCAL(const AtomicString, text, ("text", AtomicString::ConstructFromLiteral));
+ return text;
+}
+
+TrackDefault::TrackDefault(const AtomicString& type, const String& language, const String& label, const Vector<String>& kinds, const String& byteStreamTrackID, ExceptionState& exceptionState)
+{
+ // Per 06 Oct 2014 Editor's Draft
+ // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#idl-def-TrackDefault
+ // When this method is invoked, the user agent must run the following steps:
+ // 1. if |language| is not an empty string or |language| is not a BCP 47
+ // language tag, then throw an INVALID_ACCESS_ERR and abort these steps.
+ // FIXME: Implement BCP 47 language tag validation, and confirm spec logic
+ // for this step should be s/or/and/.
+
+ if (type == audioKeyword()) {
+ // 2.1. If |type| equals "audio":
+ // If any string in |kinds| contains a value that is not listed as
+ // applying to audio in the kind categories table, then throw an
+ // INVALID_ACCESS_ERR and abort these steps.
+ for (size_t i = 0; i < kinds.size(); ++i) {
+ if (!AudioTrack::isValidKindKeyword(kinds[i])) {
+ exceptionState.throwDOMException(InvalidAccessError, "Invalid audio track default kind at index " + String::number(i));
philipj_slow 2014/11/01 23:10:22 Wouldn't it be more useful to print the kind which
wolenetz 2014/11/03 21:21:56 I was replicating other similar exceptions in Blin
+ return;
+ }
+ }
+ } else if (type == videoKeyword()) {
+ // 2.2. If |type| equals "video":
+ // If any string in |kinds| contains a value that is not listed as
+ // applying to video in the kind categories table, then throw an
+ // INVALID_ACCESS_ERR and abort these steps.
+ for (size_t i = 0; i < kinds.size(); ++i) {
+ if (!VideoTrack::isValidKindKeyword(kinds[i])) {
+ exceptionState.throwDOMException(InvalidAccessError, "Invalid video track default kind at index " + String::number(i));
+ return;
+ }
+ }
+ } else {
+ ASSERT(type == textKeyword());
+ // 2.3. If |type| equals "text":
+ // If any string in |kinds| contains a value that is not listed in the
+ // text track kind list, then throw an INVALID_ACCESS_ERR and abort
+ // these steps.
+ for (size_t i = 0; i < kinds.size(); ++i) {
+ if (!TextTrack::isValidKindKeyword(kinds[i])) {
+ exceptionState.throwDOMException(InvalidAccessError, "Invalid text track default kind at index " + String::number(i));
+ return;
+ }
+ }
+ }
+
+ // 3. Set the type attribute on this new object to |type|.
+ m_type = type;
+
+ // 4. Set the language attribute on this new object to |language|.
+ m_language = language;
+
+ // 5. Set the label attribute on this new object to |label|.
+ m_label = label;
+
+ // 6. Set the kinds attribute on this new object to |kinds|.
+ m_kinds = kinds;
+
+ // 7. Set the byteStreamTrackID attribute on this new object to
+ // |byteStreamTrackID|.
+ m_byteStreamTrackID = byteStreamTrackID;
+}
+
+} // namespace blink
« no previous file with comments | « Source/modules/mediasource/TrackDefault.h ('k') | Source/modules/mediasource/TrackDefault.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698