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

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: nits 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
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 171 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
172 172
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 // Steps 2-8 are implemented by SourceBuffer::removedFromMediaSource.
181 buffer->abortIfUpdating(); 181 buffer->removedFromMediaSource();
182
183 // Steps 3-8 are related to updating audioTracks, videoTracks, and textTrack s which aren't implmented yet.
184 // FIXME(91649): support track selection
185 182
186 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer fr om activeSourceBuffers ... 183 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer fr om activeSourceBuffers ...
187 m_activeSourceBuffers->remove(buffer); 184 m_activeSourceBuffers->remove(buffer);
188 185
189 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event 186 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer event
190 // on that object. 187 // on that object.
191 m_sourceBuffers->remove(buffer); 188 m_sourceBuffers->remove(buffer);
192 189
193 // 11. Destroy all resources for sourceBuffer. 190 // 11. Destroy all resources for sourceBuffer.
194 buffer->removedFromMediaSource(); 191 // This should have been done already by SourceBuffer::removedFromMediaSourc e (steps 2-8) above.
195 } 192 }
196 193
197 void MediaSource::onReadyStateChange(const AtomicString& oldState, const AtomicS tring& newState) 194 void MediaSource::onReadyStateChange(const AtomicString& oldState, const AtomicS tring& newState)
198 { 195 {
199 if (isOpen()) { 196 if (isOpen()) {
200 scheduleEvent(EventTypeNames::sourceopen); 197 scheduleEvent(EventTypeNames::sourceopen);
201 return; 198 return;
202 } 199 }
203 200
204 if (oldState == openKeyword() && newState == endedKeyword()) { 201 if (oldState == openKeyword() && newState == endedKeyword()) {
205 scheduleEvent(EventTypeNames::sourceended); 202 scheduleEvent(EventTypeNames::sourceended);
206 return; 203 return;
207 } 204 }
208 205
209 ASSERT(isClosed()); 206 ASSERT(isClosed());
210 207
211 m_activeSourceBuffers->clear(); 208 m_activeSourceBuffers->clear();
212 209
213 // Clear SourceBuffer references to this object. 210 // Clear SourceBuffer references to this object.
214 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) 211 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i)
215 m_sourceBuffers->item(i)->removedFromMediaSource(); 212 m_sourceBuffers->item(i)->removedFromMediaSource();
216 m_sourceBuffers->clear(); 213 m_sourceBuffers->clear();
217 214
215 m_attachedElement.clear();
216
218 scheduleEvent(EventTypeNames::sourceclose); 217 scheduleEvent(EventTypeNames::sourceclose);
219 } 218 }
220 219
221 bool MediaSource::isUpdating() const 220 bool MediaSource::isUpdating() const
222 { 221 {
223 // Return true if any member of |m_sourceBuffers| is updating. 222 // Return true if any member of |m_sourceBuffers| is updating.
224 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) { 223 for (unsigned long i = 0; i < m_sourceBuffers->length(); ++i) {
225 if (m_sourceBuffers->item(i)->updating()) 224 if (m_sourceBuffers->item(i)->updating())
226 return true; 225 return true;
227 } 226 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 442
444 void MediaSource::setReadyState(const AtomicString& state) 443 void MediaSource::setReadyState(const AtomicString& state)
445 { 444 {
446 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 445 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
447 446
448 AtomicString oldState = readyState(); 447 AtomicString oldState = readyState();
449 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); 448 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data());
450 449
451 if (state == closedKeyword()) { 450 if (state == closedKeyword()) {
452 m_webMediaSource.clear(); 451 m_webMediaSource.clear();
453 m_attachedElement.clear();
454 } 452 }
455 453
456 if (oldState == state) 454 if (oldState == state)
457 return; 455 return;
458 456
459 m_readyState = state; 457 m_readyState = state;
460 458
461 onReadyStateChange(oldState, state); 459 onReadyStateChange(oldState, state);
462 } 460 }
463 461
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 612
615 m_asyncEventQueue->enqueueEvent(event); 613 m_asyncEventQueue->enqueueEvent(event);
616 } 614 }
617 615
618 URLRegistry& MediaSource::registry() const 616 URLRegistry& MediaSource::registry() const
619 { 617 {
620 return MediaSourceRegistry::registry(); 618 return MediaSourceRegistry::registry();
621 } 619 }
622 620
623 } // namespace blink 621 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698