Chromium Code Reviews| 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..70cbe2d595dc852d56dce202100894c286e162c7 |
| --- /dev/null |
| +++ b/Source/modules/mediasource/TrackDefault.cpp |
| @@ -0,0 +1,93 @@ |
| +// 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" |
| + |
| +// BIG TODO other includes... |
|
philipj_slow
2014/10/31 11:48:10
What other includes? Much to my surprise, this pat
wolenetz
2014/11/01 00:24:02
Hah! This was a note-to-self I forgot to remove. T
|
| + |
| +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 |
|
philipj_slow
2014/10/31 11:48:10
Spec issue: I don't think throwing here is a good
acolwell GONE FROM CHROMIUM
2014/10/31 19:14:30
It appears that the HTML spec is underspecified in
philipj_slow
2014/10/31 19:55:16
Yes, HTML does say "This is a string (a BCP 47 lan
wolenetz
2014/11/01 00:24:02
I've asked acolwell@ separately to take a look at
|
| + // 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. |
|
philipj_slow
2014/10/31 11:48:10
Spec issue: INVALID_ACCESS_ERR is a bit odd I thin
acolwell GONE FROM CHROMIUM
2014/10/31 19:14:30
I don't particularly agree with this. I think it m
philipj_slow
2014/10/31 19:55:16
Sure, TypeError would be better, and in line with
wolenetz
2014/11/01 00:24:02
The code in this CL will only be the TrackDefault
|
| + for (int i = 0; i < kinds.length(); ++i) { |
|
philipj_slow
2014/10/31 11:48:10
for (const String& kind : kinds) should work.
wolenetz
2014/11/01 00:24:02
Patch set 2 includes reference to i now. Otherwise
|
| + if (!AudioTrack::isValidKindKeyword(kinds[i])) { |
| + exceptionState.throwDOMException(InvalidAccessError, "Invalid audio track default kind"); |
| + 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 (int i = 0; i < kinds.length(); ++i) { |
| + if (!VideoTrack::isValidKindKeyword(kinds[i])) { |
| + exceptionState.throwDOMException(InvalidAccessError, "Invalid video track default kind"); |
| + 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 (int i = 0; i < kinds.length(); ++i) { |
| + if (!TextTrack::isValidKindKeyword(kinds[i])) { |
| + exceptionState.throwDOMException(InvalidAccessError, "Invalid text track default kind"); |
| + 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; |
|
philipj_slow
2014/10/31 11:48:10
I'd be interested to see how this ends up being us
wolenetz
2014/11/01 00:24:02
There could be adjustments in later CLs (especiall
|
| +} |
| + |
| +} // namespace blink |