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

Side by Side Diff: third_party/WebKit/Source/core/html/track/TrackListBase.h

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: rebase to ToT Created 4 years, 6 months 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TrackListBase_h 5 #ifndef TrackListBase_h
6 #define TrackListBase_h 6 #define TrackListBase_h
7 7
8 #include "core/events/EventTarget.h" 8 #include "core/events/EventTarget.h"
9 9
10 #include "core/html/HTMLMediaElement.h" 10 #include "core/html/HTMLMediaElement.h"
(...skipping 18 matching lines...) Expand all
29 T* anonymousIndexedGetter(unsigned index) const 29 T* anonymousIndexedGetter(unsigned index) const
30 { 30 {
31 if (index >= m_tracks.size()) 31 if (index >= m_tracks.size())
32 return nullptr; 32 return nullptr;
33 return m_tracks[index].get(); 33 return m_tracks[index].get();
34 } 34 }
35 35
36 T* getTrackById(const String& id) const 36 T* getTrackById(const String& id) const
37 { 37 {
38 for (unsigned i = 0; i < m_tracks.size(); ++i) { 38 for (unsigned i = 0; i < m_tracks.size(); ++i) {
39 if (m_tracks[i]->id() == id) 39 if (String(m_tracks[i]->id()) == id)
40 return m_tracks[i].get(); 40 return m_tracks[i].get();
41 } 41 }
42 42
43 return nullptr; 43 return nullptr;
44 } 44 }
45 45
46 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); 46 DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
47 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack); 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(addtrack);
48 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack); 48 DEFINE_ATTRIBUTE_EVENT_LISTENER(removetrack);
49 49
50 // EventTarget interface 50 // EventTarget interface
51 ExecutionContext* getExecutionContext() const override 51 ExecutionContext* getExecutionContext() const override
52 { 52 {
53 if (m_mediaElement) 53 if (m_mediaElement)
54 return m_mediaElement->getExecutionContext(); 54 return m_mediaElement->getExecutionContext();
55 return nullptr; 55 return nullptr;
56 } 56 }
57 57
58 void add(T* track) 58 void add(T* track)
59 { 59 {
60 track->setMediaElement(m_mediaElement); 60 track->setMediaElement(m_mediaElement);
61 m_tracks.append(track); 61 m_tracks.append(track);
62 scheduleTrackEvent(EventTypeNames::addtrack, track); 62 scheduleTrackEvent(EventTypeNames::addtrack, track);
63 } 63 }
64 64
65 void remove(WebMediaPlayer::TrackId trackId) 65 void remove(WebMediaPlayer::TrackId trackId)
66 { 66 {
67 for (unsigned i = 0; i < m_tracks.size(); ++i) { 67 for (unsigned i = 0; i < m_tracks.size(); ++i) {
68 if (m_tracks[i]->trackId() != trackId) 68 if (m_tracks[i]->id() != trackId)
69 continue; 69 continue;
70 70
71 m_tracks[i]->setMediaElement(0); 71 m_tracks[i]->setMediaElement(0);
72 scheduleTrackEvent(EventTypeNames::removetrack, m_tracks[i]); 72 scheduleTrackEvent(EventTypeNames::removetrack, m_tracks[i]);
73 m_tracks.remove(i); 73 m_tracks.remove(i);
74 return; 74 return;
75 } 75 }
76 NOTREACHED(); 76 NOTREACHED();
77 } 77 }
78 78
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 m_mediaElement->scheduleEvent(event); 115 m_mediaElement->scheduleEvent(event);
116 } 116 }
117 117
118 HeapVector<Member<T>> m_tracks; 118 HeapVector<Member<T>> m_tracks;
119 Member<HTMLMediaElement> m_mediaElement; 119 Member<HTMLMediaElement> m_mediaElement;
120 }; 120 };
121 121
122 } // namespace blink 122 } // namespace blink
123 123
124 #endif 124 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/track/TrackBase.cpp ('k') | third_party/WebKit/Source/core/html/track/VideoTrack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698