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

Side by Side 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: Address (most of) philipj@'s PS7 comments and add one more test 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 unified diff | Download patch
« no previous file with comments | « Source/modules/mediasource/TrackDefault.h ('k') | Source/modules/mediasource/TrackDefault.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // When this method is invoked, the user agent must run the following steps:
39 // 1. if |language| is not an empty string and |language| is not a BCP 47
40 // language tag, then throw an INVALID_ACCESS_ERR and abort these steps.
41 // FIXME: Implement BCP 47 language tag validation.
42
43 if (type == audioKeyword()) {
44 // 2.1. If |type| equals "audio":
45 // If any string in |kinds| contains a value that is not listed as
46 // applying to audio in the kind categories table, then throw an
47 // INVALID_ACCESS_ERR and abort these steps.
48 for (const String& kind : kinds) {
49 if (!AudioTrack::isValidKindKeyword(kind)) {
50 exceptionState.throwDOMException(InvalidAccessError, "Invalid au dio track default kind '" + kind + "'");
acolwell GONE FROM CHROMIUM 2014/11/17 22:06:48 FYI, I'll be landing a spec edit in response to ht
wolenetz 2014/11/17 22:50:22 Acknowledged.
51 return;
52 }
53 }
54 } else if (type == videoKeyword()) {
55 // 2.2. If |type| equals "video":
56 // If any string in |kinds| contains a value that is not listed as
57 // applying to video in the kind categories table, then throw an
58 // INVALID_ACCESS_ERR and abort these steps.
59 for (const String& kind : kinds) {
60 if (!VideoTrack::isValidKindKeyword(kind)) {
61 exceptionState.throwDOMException(InvalidAccessError, "Invalid vi deo track default kind '" + kind + "'");
62 return;
63 }
64 }
65 } else {
66 ASSERT(type == textKeyword());
67 // 2.3. If |type| equals "text":
68 // If any string in |kinds| contains a value that is not listed in the
69 // text track kind list, then throw an INVALID_ACCESS_ERR and abort
70 // these steps.
71 for (const String& kind : kinds) {
72 if (!TextTrack::isValidKindKeyword(kind)) {
73 exceptionState.throwDOMException(InvalidAccessError, "Invalid te xt track default kind '" + kind + "'");
74 return;
75 }
76 }
77 }
78
79 // 3. Set the type attribute on this new object to |type|.
80 m_type = type;
81
82 // 4. Set the language attribute on this new object to |language|.
83 m_language = language;
84
85 // 5. Set the label attribute on this new object to |label|.
86 m_label = label;
87
88 // 6. Set the kinds attribute on this new object to |kinds|.
89 m_kinds = kinds;
90
91 // 7. Set the byteStreamTrackID attribute on this new object to
92 // |byteStreamTrackID|.
93 m_byteStreamTrackID = byteStreamTrackID;
94 }
95
96 TrackDefault::~TrackDefault()
97 {
98 }
99
100 } // namespace blink
OLDNEW
« 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