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

Side by Side Diff: Source/modules/mediasource/TrackDefaultList.cpp

Issue 702583002: MSE: Implement TrackDefaultList object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@WIP_blink_trackdefaults_and_add_tracks_to_init_segment_processing
Patch Set: Implementation for realz Created 6 years 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
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
7 #include "modules/mediasource/TrackDefaultList.h"
8
9 #include "bindings/core/v8/ExceptionState.h"
10 #include "core/dom/ExceptionCode.h"
11
12 namespace blink {
13
14 TrackDefault* TrackDefaultList::item(unsigned index) const
15 {
16 // Per 18 Nov 2014 Editor's Draft
17 // https://w3c.github.io/media-source/#trackdefaultlist
18 // When this method is invoked, the user agent must run the following steps:
19 // 1. If |index| is greater than or equal to the length attribute then
20 // return undefined and abort these steps.
21 if (index >= m_trackDefaults.size())
22 return 0;
23
24 // 2. Return the |index|'th TrackDefault object in the list.
25 return m_trackDefaults[index].get();
26 }
27
28 TrackDefaultList::TrackDefaultList(const HeapVector<Member<TrackDefault>>& track Defaults, ExceptionState& exceptionState)
29 {
30 // Per 18 Nov 2014 Editor's Draft
sof 2014/12/03 19:15:40 I think it would be tidier if the static factory m
philipj_slow 2014/12/04 15:29:14 I agree, m_typeAndIDToTrackDefaultMap is only used
wolenetz 2014/12/11 23:52:39 Thanks for pointing out these issues. I'll address
31 // https://w3c.github.io/media-source/#trackdefaultlist
32 // When this method is invoked, the user agent must run the following steps:
33 // 1. If |trackDefaults| contains two or more TrackDefault objects with the
34 // same type and the same byteStreamTrackID, then throw an
35 // InvalidAccessError and abort these steps.
36 // Note: This also applies when byteStreamTrackID contains an empty
37 // string and ensures that there is only one "byteStreamTrackID
38 // independent" default for each TrackDefaultType value.
39 for (const auto& trackDefault : trackDefaults) {
40 TypeAndID key = TypeAndID(trackDefault->type(), trackDefault->byteStream TrackID());
41 if (!m_typeAndIDToTrackDefaultMap.add(key, trackDefault).isNewEntry) {
42 exceptionState.throwDOMException(InvalidAccessError, "Duplicate Trac kDefault type (" + key.first + ") and byteStreamTrackID (" + key.second + ")");
43 return;
44 }
45 }
46
47 // 2. Store a copy of |trackDefaults| in this new object so the values can
haraken 2014/12/04 11:29:51 This is a shadow copy, is it OK? I guess this need
philipj_slow 2014/12/04 15:29:14 The spec says "Store a copy of trackDefaults in th
wolenetz 2014/12/11 23:52:39 Thanks to discussion on this CL, a w3c bug (https:
48 // be returned by the accessor methods.
49 m_trackDefaults = trackDefaults;
50 }
51
52 void TrackDefaultList::trace(Visitor* visitor)
53 {
54 visitor->trace(m_trackDefaults);
55 visitor->trace(m_typeAndIDToTrackDefaultMap);
56 }
57
58 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698