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

Side by Side Diff: third_party/WebKit/Source/core/html/track/AutomaticTrackSelection.cpp

Issue 2003543002: media/track: Replace wtf/Assertions.h macros in favor of base/logging.h macros (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/track/CueTimeline.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "core/html/track/AutomaticTrackSelection.h" 5 #include "core/html/track/AutomaticTrackSelection.h"
6 6
7 #include "core/html/track/TextTrack.h" 7 #include "core/html/track/TextTrack.h"
8 #include "core/html/track/TextTrackList.h" 8 #include "core/html/track/TextTrackList.h"
9 #include "platform/Language.h" 9 #include "platform/Language.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { 65 {
66 if (m_configuration.textTrackKindUserPreference == TextTrackKindUserPreferen ce::Subtitles) 66 if (m_configuration.textTrackKindUserPreference == TextTrackKindUserPreferen ce::Subtitles)
67 return TextTrack::subtitlesKeyword(); 67 return TextTrack::subtitlesKeyword();
68 if (m_configuration.textTrackKindUserPreference == TextTrackKindUserPreferen ce::Captions) 68 if (m_configuration.textTrackKindUserPreference == TextTrackKindUserPreferen ce::Captions)
69 return TextTrack::captionsKeyword(); 69 return TextTrack::captionsKeyword();
70 return nullAtom; 70 return nullAtom;
71 } 71 }
72 72
73 void AutomaticTrackSelection::performAutomaticTextTrackSelection(const TrackGrou p& group) 73 void AutomaticTrackSelection::performAutomaticTextTrackSelection(const TrackGrou p& group)
74 { 74 {
75 ASSERT(group.tracks.size()); 75 DCHECK(group.tracks.size());
76 76
77 // First, find the track in the group that should be enabled (if any). 77 // First, find the track in the group that should be enabled (if any).
78 HeapVector<Member<TextTrack>> currentlyEnabledTracks; 78 HeapVector<Member<TextTrack>> currentlyEnabledTracks;
79 TextTrack* trackToEnable = nullptr; 79 TextTrack* trackToEnable = nullptr;
80 TextTrack* defaultTrack = nullptr; 80 TextTrack* defaultTrack = nullptr;
81 TextTrack* preferredTrack = nullptr; 81 TextTrack* preferredTrack = nullptr;
82 TextTrack* fallbackTrack = nullptr; 82 TextTrack* fallbackTrack = nullptr;
83 int highestTrackScore = 0; 83 int highestTrackScore = 0;
84 84
85 for (size_t i = 0; i < group.tracks.size(); ++i) { 85 for (size_t i = 0; i < group.tracks.size(); ++i) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 textTrack->setMode(TextTrack::disabledKeyword()); 135 textTrack->setMode(TextTrack::disabledKeyword());
136 } 136 }
137 } 137 }
138 138
139 if (trackToEnable) 139 if (trackToEnable)
140 trackToEnable->setMode(TextTrack::showingKeyword()); 140 trackToEnable->setMode(TextTrack::showingKeyword());
141 } 141 }
142 142
143 void AutomaticTrackSelection::enableDefaultMetadataTextTracks(const TrackGroup& group) 143 void AutomaticTrackSelection::enableDefaultMetadataTextTracks(const TrackGroup& group)
144 { 144 {
145 ASSERT(group.tracks.size()); 145 DCHECK(group.tracks.size());
146 146
147 // https://html.spec.whatwg.org/multipage/embedded-content.html#honor-user-p references-for-automatic-text-track-selection 147 // https://html.spec.whatwg.org/multipage/embedded-content.html#honor-user-p references-for-automatic-text-track-selection
148 148
149 // 4. If there are any text tracks in the media element's list of text 149 // 4. If there are any text tracks in the media element's list of text
150 // tracks whose text track kind is metadata that correspond to track 150 // tracks whose text track kind is metadata that correspond to track
151 // elements with a default attribute set whose text track mode is set to 151 // elements with a default attribute set whose text track mode is set to
152 // disabled, then set the text track mode of all such tracks to hidden 152 // disabled, then set the text track mode of all such tracks to hidden
153 for (auto& textTrack : group.tracks) { 153 for (auto& textTrack : group.tracks) {
154 if (textTrack->mode() != TextTrack::disabledKeyword()) 154 if (textTrack->mode() != TextTrack::disabledKeyword())
155 continue; 155 continue;
(...skipping 17 matching lines...) Expand all
173 173
174 String kind = textTrack->kind(); 174 String kind = textTrack->kind();
175 TrackGroup* currentGroup; 175 TrackGroup* currentGroup;
176 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword()) { 176 if (kind == TextTrack::subtitlesKeyword() || kind == TextTrack::captions Keyword()) {
177 currentGroup = &captionAndSubtitleTracks; 177 currentGroup = &captionAndSubtitleTracks;
178 } else if (kind == TextTrack::descriptionsKeyword()) { 178 } else if (kind == TextTrack::descriptionsKeyword()) {
179 currentGroup = &descriptionTracks; 179 currentGroup = &descriptionTracks;
180 } else if (kind == TextTrack::chaptersKeyword()) { 180 } else if (kind == TextTrack::chaptersKeyword()) {
181 currentGroup = &chapterTracks; 181 currentGroup = &chapterTracks;
182 } else { 182 } else {
183 ASSERT(kind == TextTrack::metadataKeyword()); 183 DCHECK_EQ(kind, TextTrack::metadataKeyword());
184 currentGroup = &metadataTracks; 184 currentGroup = &metadataTracks;
185 } 185 }
186 186
187 if (!currentGroup->visibleTrack && textTrack->mode() == TextTrack::showi ngKeyword()) 187 if (!currentGroup->visibleTrack && textTrack->mode() == TextTrack::showi ngKeyword())
188 currentGroup->visibleTrack = textTrack; 188 currentGroup->visibleTrack = textTrack;
189 if (!currentGroup->defaultTrack && textTrack->isDefault()) 189 if (!currentGroup->defaultTrack && textTrack->isDefault())
190 currentGroup->defaultTrack = textTrack; 190 currentGroup->defaultTrack = textTrack;
191 191
192 // Do not add this track to the group if it has already been automatical ly configured 192 // Do not add this track to the group if it has already been automatical ly configured
193 // as we only want to perform selection once per track so that adding an other track 193 // as we only want to perform selection once per track so that adding an other track
(...skipping 13 matching lines...) Expand all
207 performAutomaticTextTrackSelection(captionAndSubtitleTracks); 207 performAutomaticTextTrackSelection(captionAndSubtitleTracks);
208 if (descriptionTracks.tracks.size()) 208 if (descriptionTracks.tracks.size())
209 performAutomaticTextTrackSelection(descriptionTracks); 209 performAutomaticTextTrackSelection(descriptionTracks);
210 if (chapterTracks.tracks.size()) 210 if (chapterTracks.tracks.size())
211 performAutomaticTextTrackSelection(chapterTracks); 211 performAutomaticTextTrackSelection(chapterTracks);
212 if (metadataTracks.tracks.size()) 212 if (metadataTracks.tracks.size())
213 enableDefaultMetadataTextTracks(metadataTracks); 213 enableDefaultMetadataTextTracks(metadataTracks);
214 } 214 }
215 215
216 } // namespace blink 216 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/track/CueTimeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698