| 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 "modules/mediasource/TrackDefault.h" |
| 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/html/track/AudioTrack.h" |
| 11 #include "core/html/track/TextTrack.h" |
| 12 #include "core/html/track/VideoTrack.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 static const AtomicString& audioKeyword() |
| 17 { |
| 18 DEFINE_STATIC_LOCAL(const AtomicString, audio, ("audio", AtomicString::Const
ructFromLiteral)); |
| 19 return audio; |
| 20 } |
| 21 |
| 22 static const AtomicString& videoKeyword() |
| 23 { |
| 24 DEFINE_STATIC_LOCAL(const AtomicString, video, ("video", AtomicString::Const
ructFromLiteral)); |
| 25 return video; |
| 26 } |
| 27 |
| 28 static const AtomicString& textKeyword() |
| 29 { |
| 30 DEFINE_STATIC_LOCAL(const AtomicString, text, ("text", AtomicString::Constru
ctFromLiteral)); |
| 31 return text; |
| 32 } |
| 33 |
| 34 TrackDefault::TrackDefault(const AtomicString& type, const String& language, con
st String& label, const Vector<String>& kinds, const String& byteStreamTrackID,
ExceptionState& exceptionState) |
| 35 { |
| 36 // Per 11 Nov 2014 Editor's Draft |
| 37 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.
html#idl-def-TrackDefault |
| 38 // with expectation that |
| 39 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=27352 will be fixed soon: |
| 40 // When this method is invoked, the user agent must run the following steps: |
| 41 // 1. if |language| is not an empty string and |language| is not a BCP 47 |
| 42 // language tag, then throw an INVALID_ACCESS_ERR and abort these steps. |
| 43 // FIXME: Implement BCP 47 language tag validation. |
| 44 |
| 45 if (type == audioKeyword()) { |
| 46 // 2.1. If |type| equals "audio": |
| 47 // If any string in |kinds| contains a value that is not listed as |
| 48 // applying to audio in the kind categories table, then throw a |
| 49 // TypeError and abort these steps. |
| 50 for (const String& kind : kinds) { |
| 51 if (!AudioTrack::isValidKindKeyword(kind)) { |
| 52 exceptionState.throwTypeError("Invalid audio track default kind
'" + kind + "'"); |
| 53 return; |
| 54 } |
| 55 } |
| 56 } else if (type == videoKeyword()) { |
| 57 // 2.2. If |type| equals "video": |
| 58 // If any string in |kinds| contains a value that is not listed as |
| 59 // applying to video in the kind categories table, then throw a |
| 60 // TypeError and abort these steps. |
| 61 for (const String& kind : kinds) { |
| 62 if (!VideoTrack::isValidKindKeyword(kind)) { |
| 63 exceptionState.throwTypeError("Invalid video track default kind
'" + kind + "'"); |
| 64 return; |
| 65 } |
| 66 } |
| 67 } else if (type == textKeyword()) { |
| 68 // 2.3. If |type| equals "text": |
| 69 // If any string in |kinds| contains a value that is not listed in
the |
| 70 // text track kind list, then throw a TypeError and abort these |
| 71 // steps. |
| 72 for (const String& kind : kinds) { |
| 73 if (!TextTrack::isValidKindKeyword(kind)) { |
| 74 exceptionState.throwTypeError("Invalid text track default kind '
" + kind + "'"); |
| 75 return; |
| 76 } |
| 77 } |
| 78 } else { |
| 79 ASSERT_NOT_REACHED(); // IDL enforcement should prevent this case. |
| 80 } |
| 81 |
| 82 // 3. Set the type attribute on this new object to |type|. |
| 83 m_type = type; |
| 84 |
| 85 // 4. Set the language attribute on this new object to |language|. |
| 86 m_language = language; |
| 87 |
| 88 // 5. Set the label attribute on this new object to |label|. |
| 89 m_label = label; |
| 90 |
| 91 // 6. Set the kinds attribute on this new object to |kinds|. |
| 92 m_kinds = kinds; |
| 93 |
| 94 // 7. Set the byteStreamTrackID attribute on this new object to |
| 95 // |byteStreamTrackID|. |
| 96 m_byteStreamTrackID = byteStreamTrackID; |
| 97 } |
| 98 |
| 99 TrackDefault::~TrackDefault() |
| 100 { |
| 101 } |
| 102 |
| 103 } // namespace blink |
| OLD | NEW |