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

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: 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 // 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
9
10 namespace blink {
11
12 const AtomicString& TrackDefault::audioKeyword()
13 {
14 DEFINE_STATIC_LOCAL(const AtomicString, audio, ("audio", AtomicString::Const ructFromLiteral));
15 return audio;
16 }
17
18 const AtomicString& TrackDefault::videoKeyword()
19 {
20 DEFINE_STATIC_LOCAL(const AtomicString, video, ("video", AtomicString::Const ructFromLiteral));
21 return video;
22 }
23
24 const AtomicString& TrackDefault::textKeyword()
25 {
26 DEFINE_STATIC_LOCAL(const AtomicString, text, ("text", AtomicString::Constru ctFromLiteral));
27 return text;
28 }
29
30 TrackDefault::TrackDefault(const AtomicString& type, const String& language, con st String& label, const Vector<String>& kinds, const String& byteStreamTrackID, ExceptionState& exceptionState)
31 {
32 // Per 06 Oct 2014 Editor's Draft
33 // https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source. html#idl-def-TrackDefault
34 // When this method is invoked, the user agent must run the following steps:
35 // 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
36 // language tag, then throw an INVALID_ACCESS_ERR and abort these steps.
37 // FIXME: Implement BCP 47 language tag validation, and confirm spec logic
38 // for this step should be s/or/and/.
39
40 if (type == audioKeyword()) {
41 // 2.1. If |type| equals "audio":
42 // If any string in |kinds| contains a value that is not listed as
43 // applying to audio in the kind categories table, then throw an
44 // 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
45 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
46 if (!AudioTrack::isValidKindKeyword(kinds[i])) {
47 exceptionState.throwDOMException(InvalidAccessError, "Invalid au dio track default kind");
48 return;
49 }
50 }
51 } else if (type == videoKeyword()) {
52 // 2.2. If |type| equals "video":
53 // If any string in |kinds| contains a value that is not listed as
54 // applying to video in the kind categories table, then throw an
55 // INVALID_ACCESS_ERR and abort these steps.
56 for (int i = 0; i < kinds.length(); ++i) {
57 if (!VideoTrack::isValidKindKeyword(kinds[i])) {
58 exceptionState.throwDOMException(InvalidAccessError, "Invalid vi deo track default kind");
59 return;
60 }
61 }
62 } else {
63 ASSERT(type == textKeyword());
64 // 2.3. If |type| equals "text":
65 // If any string in |kinds| contains a value that is not listed in the
66 // text track kind list, then throw an INVALID_ACCESS_ERR and abort
67 // these steps.
68 for (int i = 0; i < kinds.length(); ++i) {
69 if (!TextTrack::isValidKindKeyword(kinds[i])) {
70 exceptionState.throwDOMException(InvalidAccessError, "Invalid te xt track default kind");
71 return;
72 }
73 }
74 }
75
76 // 3. Set the type attribute on this new object to |type|.
77 m_type = type;
78
79 // 4. Set the language attribute on this new object to |language|.
80 m_language = language;
81
82 // 5. Set the label attribute on this new object to |label|.
83 m_label = label;
84
85 // 6. Set the kinds attribute on this new object to |kinds|.
86 m_kinds = kinds;
87
88 // 7. Set the byteStreamTrackID attribute on this new object to
89 // |byteStreamTrackID|.
90 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
91 }
92
93 } // 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