Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/modules/mediasource/MediaSource.cpp

Issue 1846863002: Remove SourceBuffer media tracks on detach from media element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: CR feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 162 matching lines...)
173 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then 173 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then
174 // throw a NotFoundError exception and abort these steps. 174 // throw a NotFoundError exception and abort these steps.
175 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { 175 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
176 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer provided is not contained in this MediaSource."); 176 logAndThrowDOMException(exceptionState, NotFoundError, "The SourceBuffer provided is not contained in this MediaSource.");
177 return; 177 return;
178 } 178 }
179 179
180 // 2. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ... 180 // 2. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ...
181 buffer->abortIfUpdating(); 181 buffer->abortIfUpdating();
182 182
183 // Steps 3-8 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet. 183 // Steps 3-8 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet.
wolenetz 2016/04/28 00:46:47 This is fixed by this CL (except text), right? Ple
servolk 2016/04/28 18:37:53 Done.
184 // FIXME(91649): support track selection 184 // FIXME(91649): support track selection
185 185
186 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer fr om activeSourceBuffers ... 186 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer fr om activeSourceBuffers ...
187 m_activeSourceBuffers->remove(buffer); 187 m_activeSourceBuffers->remove(buffer);
188 188
189 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event 189 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event
190 // on that object. 190 // on that object.
191 m_sourceBuffers->remove(buffer); 191 m_sourceBuffers->remove(buffer);
192 192
193 // 11. Destroy all resources for sourceBuffer. 193 // 11. Destroy all resources for sourceBuffer.
(...skipping 14 matching lines...)
208 208
209 ASSERT(isClosed()); 209 ASSERT(isClosed());
210 210
211 m_activeSourceBuffers->clear(); 211 m_activeSourceBuffers->clear();
212 212
213 // Clear SourceBuffer references to this object. 213 // Clear SourceBuffer references to this object.
214 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) 214 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i)
215 m_sourceBuffers->item(i)->removedFromMediaSource(); 215 m_sourceBuffers->item(i)->removedFromMediaSource();
216 m_sourceBuffers->clear(); 216 m_sourceBuffers->clear();
217 217
218 m_attachedElement.clear();
219
218 scheduleEvent(EventTypeNames::sourceclose); 220 scheduleEvent(EventTypeNames::sourceclose);
219 } 221 }
220 222
221 bool MediaSource::isUpdating() const 223 bool MediaSource::isUpdating() const
222 { 224 {
223 // Return true if any member of |m_sourceBuffers| is updating. 225 // Return true if any member of |m_sourceBuffers| is updating.
224 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) { 226 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) {
225 if (m_sourceBuffers->item(i)->updating()) 227 if (m_sourceBuffers->item(i)->updating())
226 return true; 228 return true;
227 } 229 }
(...skipping 215 matching lines...)
443 445
444 void MediaSource::setReadyState(const AtomicString& state) 446 void MediaSource::setReadyState(const AtomicString& state)
445 { 447 {
446 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 448 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
447 449
448 AtomicString oldState = readyState(); 450 AtomicString oldState = readyState();
449 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); 451 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data());
450 452
451 if (state == closedKeyword()) { 453 if (state == closedKeyword()) {
452 m_webMediaSource.clear(); 454 m_webMediaSource.clear();
453 m_attachedElement.clear();
454 } 455 }
455 456
456 if (oldState == state) 457 if (oldState == state)
457 return; 458 return;
458 459
459 m_readyState = state; 460 m_readyState = state;
460 461
461 onReadyStateChange(oldState, state); 462 onReadyStateChange(oldState, state);
462 } 463 }
463 464
(...skipping 150 matching lines...)
614 615
615 m_asyncEventQueue->enqueueEvent(event); 616 m_asyncEventQueue->enqueueEvent(event);
616 } 617 }
617 618
618 URLRegistry& MediaSource::registry() const 619 URLRegistry& MediaSource::registry() const
619 { 620 {
620 return MediaSourceRegistry::registry(); 621 return MediaSourceRegistry::registry();
621 } 622 }
622 623
623 } // namespace blink 624 } // namespace blink
OLDNEW

Powered by Google App Engine