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

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

Issue 2395543002: reflow comments in modules/[mediasource,plugins] (Closed)
Patch Set: Created 4 years, 2 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/modules/mediasource/SourceBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void MediaSource::logAndThrowTypeError(ExceptionState& exceptionState, 143 void MediaSource::logAndThrowTypeError(ExceptionState& exceptionState,
144 const String& message) { 144 const String& message) {
145 BLINK_MSLOG << __func__ << " (message=" << message << ")"; 145 BLINK_MSLOG << __func__ << " (message=" << message << ")";
146 exceptionState.throwTypeError(message); 146 exceptionState.throwTypeError(message);
147 } 147 }
148 148
149 SourceBuffer* MediaSource::addSourceBuffer(const String& type, 149 SourceBuffer* MediaSource::addSourceBuffer(const String& type,
150 ExceptionState& exceptionState) { 150 ExceptionState& exceptionState) {
151 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type; 151 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type;
152 152
153 // 2.2 https://www.w3.org/TR/media-source/#widl-MediaSource-addSourceBuffer-So urceBuffer-DOMString-type/ 153 // 2.2
154 // https://www.w3.org/TR/media-source/#widl-MediaSource-addSourceBuffer-Source Buffer-DOMString-type/
dcheng 2016/10/04 21:45:52 This formatting is unfortunate (maybe put the sect
154 // 1. If type is an empty string then throw a TypeError exception 155 // 1. If type is an empty string then throw a TypeError exception
155 // and abort these steps. 156 // and abort these steps.
156 if (type.isEmpty()) { 157 if (type.isEmpty()) {
157 logAndThrowTypeError(exceptionState, "The type provided is empty"); 158 logAndThrowTypeError(exceptionState, "The type provided is empty");
158 return 0; 159 return 0;
159 } 160 }
160 161
161 // 2. If type contains a MIME type that is not supported ..., then throw a 162 // 2. If type contains a MIME type that is not supported ..., then throw a
162 // NotSupportedError exception and abort these steps. 163 // NotSupportedError exception and abort these steps.
163 if (!isTypeSupported(type)) { 164 if (!isTypeSupported(type)) {
164 logAndThrowDOMException( 165 logAndThrowDOMException(
165 exceptionState, NotSupportedError, 166 exceptionState, NotSupportedError,
(...skipping 11 matching lines...) Expand all
177 178
178 // 5. Create a new SourceBuffer object and associated resources. 179 // 5. Create a new SourceBuffer object and associated resources.
179 ContentType contentType(type); 180 ContentType contentType(type);
180 String codecs = contentType.parameter("codecs"); 181 String codecs = contentType.parameter("codecs");
181 std::unique_ptr<WebSourceBuffer> webSourceBuffer = 182 std::unique_ptr<WebSourceBuffer> webSourceBuffer =
182 createWebSourceBuffer(contentType.type(), codecs, exceptionState); 183 createWebSourceBuffer(contentType.type(), codecs, exceptionState);
183 184
184 if (!webSourceBuffer) { 185 if (!webSourceBuffer) {
185 DCHECK(exceptionState.code() == NotSupportedError || 186 DCHECK(exceptionState.code() == NotSupportedError ||
186 exceptionState.code() == QuotaExceededError); 187 exceptionState.code() == QuotaExceededError);
187 // 2. If type contains a MIME type that is not supported ..., then throw a N otSupportedError exception and abort these steps. 188 // 2. If type contains a MIME type that is not supported ..., then throw a
188 // 3. If the user agent can't handle any more SourceBuffer objects then thro w a QuotaExceededError exception and abort these steps 189 // NotSupportedError exception and abort these steps.
190 // 3. If the user agent can't handle any more SourceBuffer objects then
191 // throw a QuotaExceededError exception and abort these steps
189 return 0; 192 return 0;
190 } 193 }
191 194
192 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this, 195 SourceBuffer* buffer = SourceBuffer::create(std::move(webSourceBuffer), this,
193 m_asyncEventQueue.get()); 196 m_asyncEventQueue.get());
194 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that o bject. 197 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
198 // object.
195 m_sourceBuffers->add(buffer); 199 m_sourceBuffers->add(buffer);
196 200
197 // 7. Return the new object to the caller. 201 // 7. Return the new object to the caller.
198 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type << " -> " 202 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type << " -> "
199 << buffer; 203 << buffer;
200 return buffer; 204 return buffer;
201 } 205 }
202 206
203 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, 207 void MediaSource::removeSourceBuffer(SourceBuffer* buffer,
204 ExceptionState& exceptionState) { 208 ExceptionState& exceptionState) {
205 BLINK_MSLOG << __func__ << " this=" << this << " buffer=" << buffer; 209 BLINK_MSLOG << __func__ << " this=" << this << " buffer=" << buffer;
206 210
207 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-s ource.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer 211 // 2.2
dcheng 2016/10/04 21:45:52 Similarly here and elsewhere.
212 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer
208 213
209 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then 214 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then
210 // throw a NotFoundError exception and abort these steps. 215 // throw a NotFoundError exception and abort these steps.
211 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) { 216 if (!m_sourceBuffers->length() || !m_sourceBuffers->contains(buffer)) {
212 logAndThrowDOMException( 217 logAndThrowDOMException(
213 exceptionState, NotFoundError, 218 exceptionState, NotFoundError,
214 "The SourceBuffer provided is not contained in this MediaSource."); 219 "The SourceBuffer provided is not contained in this MediaSource.");
215 return; 220 return;
216 } 221 }
217 222
218 // Steps 2-8 are implemented by SourceBuffer::removedFromMediaSource. 223 // Steps 2-8 are implemented by SourceBuffer::removedFromMediaSource.
219 buffer->removedFromMediaSource(); 224 buffer->removedFromMediaSource();
220 225
221 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer from activeSourceBuffers ... 226 // 9. If sourceBuffer is in activeSourceBuffers, then remove sourceBuffer from
227 // activeSourceBuffers ...
222 m_activeSourceBuffers->remove(buffer); 228 m_activeSourceBuffers->remove(buffer);
223 229
224 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer ev ent 230 // 10. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer
225 // on that object. 231 // event on that object.
226 m_sourceBuffers->remove(buffer); 232 m_sourceBuffers->remove(buffer);
227 233
228 // 11. Destroy all resources for sourceBuffer. 234 // 11. Destroy all resources for sourceBuffer.
229 // This should have been done already by SourceBuffer::removedFromMediaSource (steps 2-8) above. 235 // This should have been done already by
236 // SourceBuffer::removedFromMediaSource (steps 2-8) above.
230 } 237 }
231 238
232 void MediaSource::onReadyStateChange(const AtomicString& oldState, 239 void MediaSource::onReadyStateChange(const AtomicString& oldState,
233 const AtomicString& newState) { 240 const AtomicString& newState) {
234 if (isOpen()) { 241 if (isOpen()) {
235 scheduleEvent(EventTypeNames::sourceopen); 242 scheduleEvent(EventTypeNames::sourceopen);
236 return; 243 return;
237 } 244 }
238 245
239 if (oldState == openKeyword() && newState == endedKeyword()) { 246 if (oldState == openKeyword() && newState == endedKeyword()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 283
277 ContentType contentType(type); 284 ContentType contentType(type);
278 String codecs = contentType.parameter("codecs"); 285 String codecs = contentType.parameter("codecs");
279 286
280 // 2. If type does not contain a valid MIME type string, then return false. 287 // 2. If type does not contain a valid MIME type string, then return false.
281 if (contentType.type().isEmpty()) { 288 if (contentType.type().isEmpty()) {
282 BLINK_MSLOG << __func__ << "(" << type << ") -> false (invalid mime type)"; 289 BLINK_MSLOG << __func__ << "(" << type << ") -> false (invalid mime type)";
283 return false; 290 return false;
284 } 291 }
285 292
286 // Note: MediaSource.isTypeSupported() returning true implies that HTMLMediaEl ement.canPlayType() will return "maybe" or "probably" 293 // Note: MediaSource.isTypeSupported() returning true implies that
287 // since it does not make sense for a MediaSource to support a type the HTMLMe diaElement knows it cannot play. 294 // HTMLMediaElement.canPlayType() will return "maybe" or "probably" since it
295 // does not make sense for a MediaSource to support a type the
296 // HTMLMediaElement knows it cannot play.
288 if (HTMLMediaElement::supportsType(contentType) == 297 if (HTMLMediaElement::supportsType(contentType) ==
289 WebMimeRegistry::IsNotSupported) { 298 WebMimeRegistry::IsNotSupported) {
290 BLINK_MSLOG << __func__ << "(" << type 299 BLINK_MSLOG << __func__ << "(" << type
291 << ") -> false (not supported by HTMLMediaElement)"; 300 << ") -> false (not supported by HTMLMediaElement)";
292 return false; 301 return false;
293 } 302 }
294 303
295 // 3. If type contains a media type or media subtype that the MediaSource does not support, then return false. 304 // 3. If type contains a media type or media subtype that the MediaSource does
296 // 4. If type contains at a codec that the MediaSource does not support, then return false. 305 // not support, then return false.
297 // 5. If the MediaSource does not support the specified combination of media t ype, media subtype, and codecs then return false. 306 // 4. If type contains at a codec that the MediaSource does not support, then
307 // return false.
308 // 5. If the MediaSource does not support the specified combination of media
309 // type, media subtype, and codecs then return false.
298 // 6. Return true. 310 // 6. Return true.
299 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType( 311 bool result = MIMETypeRegistry::isSupportedMediaSourceMIMEType(
300 contentType.type(), codecs); 312 contentType.type(), codecs);
301 BLINK_MSLOG << __func__ << "(" << type << ") -> " 313 BLINK_MSLOG << __func__ << "(" << type << ") -> "
302 << (result ? "true" : "false"); 314 << (result ? "true" : "false");
303 return result; 315 return result;
304 } 316 }
305 317
306 const AtomicString& MediaSource::interfaceName() const { 318 const AtomicString& MediaSource::interfaceName() const {
307 return EventTargetNames::MediaSource; 319 return EventTargetNames::MediaSource;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 : m_webMediaSource->duration(); 359 : m_webMediaSource->duration();
348 } 360 }
349 361
350 TimeRanges* MediaSource::buffered() const { 362 TimeRanges* MediaSource::buffered() const {
351 // Implements MediaSource algorithm for HTMLMediaElement.buffered. 363 // Implements MediaSource algorithm for HTMLMediaElement.buffered.
352 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#htmlmediaelement-extensions 364 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sourc e.html#htmlmediaelement-extensions
353 HeapVector<Member<TimeRanges>> ranges(m_activeSourceBuffers->length()); 365 HeapVector<Member<TimeRanges>> ranges(m_activeSourceBuffers->length());
354 for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i) 366 for (size_t i = 0; i < m_activeSourceBuffers->length(); ++i)
355 ranges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXCEPTION); 367 ranges[i] = m_activeSourceBuffers->item(i)->buffered(ASSERT_NO_EXCEPTION);
356 368
357 // 1. If activeSourceBuffers.length equals 0 then return an empty TimeRanges o bject and abort these steps. 369 // 1. If activeSourceBuffers.length equals 0 then return an empty TimeRanges
370 // object and abort these steps.
358 if (ranges.isEmpty()) 371 if (ranges.isEmpty())
359 return TimeRanges::create(); 372 return TimeRanges::create();
360 373
361 // 2. Let active ranges be the ranges returned by buffered for each SourceBuff er object in activeSourceBuffers. 374 // 2. Let active ranges be the ranges returned by buffered for each
375 // SourceBuffer object in activeSourceBuffers.
362 // 3. Let highest end time be the largest range end time in the active ranges. 376 // 3. Let highest end time be the largest range end time in the active ranges.
363 double highestEndTime = -1; 377 double highestEndTime = -1;
364 for (size_t i = 0; i < ranges.size(); ++i) { 378 for (size_t i = 0; i < ranges.size(); ++i) {
365 unsigned length = ranges[i]->length(); 379 unsigned length = ranges[i]->length();
366 if (length) 380 if (length)
367 highestEndTime = std::max( 381 highestEndTime = std::max(
368 highestEndTime, ranges[i]->end(length - 1, ASSERT_NO_EXCEPTION)); 382 highestEndTime, ranges[i]->end(length - 1, ASSERT_NO_EXCEPTION));
369 } 383 }
370 384
371 // Return an empty range if all ranges are empty. 385 // Return an empty range if all ranges are empty.
372 if (highestEndTime < 0) 386 if (highestEndTime < 0)
373 return TimeRanges::create(); 387 return TimeRanges::create();
374 388
375 // 4. Let intersection ranges equal a TimeRange object containing a single ran ge from 0 to highest end time. 389 // 4. Let intersection ranges equal a TimeRange object containing a single
390 // range from 0 to highest end time.
376 TimeRanges* intersectionRanges = TimeRanges::create(0, highestEndTime); 391 TimeRanges* intersectionRanges = TimeRanges::create(0, highestEndTime);
377 392
378 // 5. For each SourceBuffer object in activeSourceBuffers run the following st eps: 393 // 5. For each SourceBuffer object in activeSourceBuffers run the following
394 // steps:
379 bool ended = readyState() == endedKeyword(); 395 bool ended = readyState() == endedKeyword();
380 for (size_t i = 0; i < ranges.size(); ++i) { 396 for (size_t i = 0; i < ranges.size(); ++i) {
381 // 5.1 Let source ranges equal the ranges returned by the buffered attribute on the current SourceBuffer. 397 // 5.1 Let source ranges equal the ranges returned by the buffered attribute
398 // on the current SourceBuffer.
382 TimeRanges* sourceRanges = ranges[i].get(); 399 TimeRanges* sourceRanges = ranges[i].get();
383 400
384 // 5.2 If readyState is "ended", then set the end time on the last range in source ranges to highest end time. 401 // 5.2 If readyState is "ended", then set the end time on the last range in
402 // source ranges to highest end time.
385 if (ended && sourceRanges->length()) 403 if (ended && sourceRanges->length())
386 sourceRanges->add( 404 sourceRanges->add(
387 sourceRanges->start(sourceRanges->length() - 1, ASSERT_NO_EXCEPTION), 405 sourceRanges->start(sourceRanges->length() - 1, ASSERT_NO_EXCEPTION),
388 highestEndTime); 406 highestEndTime);
389 407
390 // 5.3 Let new intersection ranges equal the the intersection between the in tersection ranges and the source ranges. 408 // 5.3 Let new intersection ranges equal the the intersection between the
391 // 5.4 Replace the ranges in intersection ranges with the new intersection r anges. 409 // intersection ranges and the source ranges.
410 // 5.4 Replace the ranges in intersection ranges with the new intersection
411 // ranges.
392 intersectionRanges->intersectWith(sourceRanges); 412 intersectionRanges->intersectWith(sourceRanges);
393 } 413 }
394 414
395 return intersectionRanges; 415 return intersectionRanges;
396 } 416 }
397 417
398 TimeRanges* MediaSource::seekable() const { 418 TimeRanges* MediaSource::seekable() const {
399 // Implements MediaSource algorithm for HTMLMediaElement.seekable. 419 // Implements MediaSource algorithm for HTMLMediaElement.seekable.
400 // http://w3c.github.io/media-source/#htmlmediaelement-extensions 420 // http://w3c.github.io/media-source/#htmlmediaelement-extensions
401 421
(...skipping 18 matching lines...) Expand all
420 m_liveSeekableRange->start(0, ASSERT_NO_EXCEPTION), 440 m_liveSeekableRange->start(0, ASSERT_NO_EXCEPTION),
421 m_liveSeekableRange->end(0, ASSERT_NO_EXCEPTION)); 441 m_liveSeekableRange->end(0, ASSERT_NO_EXCEPTION));
422 } 442 }
423 443
424 return TimeRanges::create( 444 return TimeRanges::create(
425 std::min(m_liveSeekableRange->start(0, ASSERT_NO_EXCEPTION), 445 std::min(m_liveSeekableRange->start(0, ASSERT_NO_EXCEPTION),
426 buffered->start(0, ASSERT_NO_EXCEPTION)), 446 buffered->start(0, ASSERT_NO_EXCEPTION)),
427 std::max(m_liveSeekableRange->end(0, ASSERT_NO_EXCEPTION), 447 std::max(m_liveSeekableRange->end(0, ASSERT_NO_EXCEPTION),
428 buffered->end(buffered->length() - 1, ASSERT_NO_EXCEPTION))); 448 buffered->end(buffered->length() - 1, ASSERT_NO_EXCEPTION)));
429 } 449 }
430 // 2. If the HTMLMediaElement.buffered attribute returns an empty TimeRanges object, then 450 // 2. If the HTMLMediaElement.buffered attribute returns an empty TimeRanges
431 // return an empty TimeRanges object and abort these steps. 451 // object, then return an empty TimeRanges object and abort these steps.
432 if (buffered->length() == 0) 452 if (buffered->length() == 0)
433 return TimeRanges::create(); 453 return TimeRanges::create();
434 454
435 // 3. Return a single range with a start time of 0 and an end time equal to the highest end 455 // 3. Return a single range with a start time of 0 and an end time equal to
436 // time reported by the HTMLMediaElement.buffered attribute. 456 // the highest end time reported by the HTMLMediaElement.buffered
457 // attribute.
437 return TimeRanges::create( 458 return TimeRanges::create(
438 0, buffered->end(buffered->length() - 1, ASSERT_NO_EXCEPTION)); 459 0, buffered->end(buffered->length() - 1, ASSERT_NO_EXCEPTION));
439 } 460 }
440 461
441 // 3. Otherwise: Return a single range with a start time of 0 and an end time equal to duration. 462 // 3. Otherwise: Return a single range with a start time of 0 and an end time
463 // equal to duration.
442 return TimeRanges::create(0, sourceDuration); 464 return TimeRanges::create(0, sourceDuration);
443 } 465 }
444 466
445 void MediaSource::onTrackChanged(TrackBase* track) { 467 void MediaSource::onTrackChanged(TrackBase* track) {
446 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 468 DCHECK(RuntimeEnabledFeatures::audioVideoTracksEnabled());
447 SourceBuffer* sourceBuffer = 469 SourceBuffer* sourceBuffer =
448 SourceBufferTrackBaseSupplement::sourceBuffer(*track); 470 SourceBufferTrackBaseSupplement::sourceBuffer(*track);
449 if (!sourceBuffer) 471 if (!sourceBuffer)
450 return; 472 return;
451 473
(...skipping 20 matching lines...) Expand all
472 duration, "duration")); 494 duration, "duration"));
473 return; 495 return;
474 } 496 }
475 if (duration < 0.0) { 497 if (duration < 0.0) {
476 logAndThrowTypeError( 498 logAndThrowTypeError(
477 exceptionState, 499 exceptionState,
478 ExceptionMessages::indexExceedsMinimumBound("duration", duration, 0.0)); 500 ExceptionMessages::indexExceedsMinimumBound("duration", duration, 0.0));
479 return; 501 return;
480 } 502 }
481 503
482 // 2. If the readyState attribute is not "open" then throw an InvalidStateErro r 504 // 2. If the readyState attribute is not "open" then throw an
483 // exception and abort these steps. 505 // InvalidStateError exception and abort these steps.
484 // 3. If the updating attribute equals true on any SourceBuffer in sourceBuffe rs, 506 // 3. If the updating attribute equals true on any SourceBuffer in
485 // then throw an InvalidStateError exception and abort these steps. 507 // sourceBuffers, then throw an InvalidStateError exception and abort these
508 // steps.
486 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState)) 509 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState))
487 return; 510 return;
488 511
489 // 4. Run the duration change algorithm with new duration set to the value bei ng 512 // 4. Run the duration change algorithm with new duration set to the value
490 // assigned to this attribute. 513 // being assigned to this attribute.
491 durationChangeAlgorithm(duration, exceptionState); 514 durationChangeAlgorithm(duration, exceptionState);
492 } 515 }
493 516
494 void MediaSource::durationChangeAlgorithm(double newDuration, 517 void MediaSource::durationChangeAlgorithm(double newDuration,
495 ExceptionState& exceptionState) { 518 ExceptionState& exceptionState) {
496 // http://w3c.github.io/media-source/#duration-change-algorithm 519 // http://w3c.github.io/media-source/#duration-change-algorithm
497 // 1. If the current value of duration is equal to new duration, then return. 520 // 1. If the current value of duration is equal to new duration, then return.
498 if (newDuration == duration()) 521 if (newDuration == duration())
499 return; 522 return;
500 523
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 if (!RuntimeEnabledFeatures::mediaSourceNewAbortAndDurationEnabled() && 563 if (!RuntimeEnabledFeatures::mediaSourceNewAbortAndDurationEnabled() &&
541 newDuration < oldDuration) { 564 newDuration < oldDuration) {
542 // Deprecated behavior: if the new duration is less than old duration, 565 // Deprecated behavior: if the new duration is less than old duration,
543 // then call remove(new duration, old duration) on all all objects in 566 // then call remove(new duration, old duration) on all all objects in
544 // sourceBuffers. 567 // sourceBuffers.
545 for (size_t i = 0; i < m_sourceBuffers->length(); ++i) 568 for (size_t i = 0; i < m_sourceBuffers->length(); ++i)
546 m_sourceBuffers->item(i)->remove(newDuration, oldDuration, 569 m_sourceBuffers->item(i)->remove(newDuration, oldDuration,
547 ASSERT_NO_EXCEPTION); 570 ASSERT_NO_EXCEPTION);
548 } 571 }
549 572
550 // 5. If a user agent is unable to partially render audio frames or text cues that start before and end after the duration, then run the following steps: 573 // 5. If a user agent is unable to partially render audio frames or text cues
551 // NOTE: Currently we assume that the media engine is able to render partial f rames/cues. If a media 574 // that start before and end after the duration, then run the following ste ps:
552 // engine gets added that doesn't support this, then we'll need to add logic t o handle the substeps. 575 // NOTE: Currently we assume that the media engine is able to render
576 // partial frames/cues. If a media engine gets added that doesn't support
577 // this, then we'll need to add logic to handle the substeps.
553 578
554 // 6. Update the media controller duration to new duration and run the HTMLMed iaElement duration change algorithm. 579 // 6. Update the media controller duration to new duration and run the
580 // HTMLMediaElement duration change algorithm.
555 m_attachedElement->durationChanged(newDuration, requestSeek); 581 m_attachedElement->durationChanged(newDuration, requestSeek);
556 } 582 }
557 583
558 void MediaSource::setReadyState(const AtomicString& state) { 584 void MediaSource::setReadyState(const AtomicString& state) {
559 DCHECK(state == openKeyword() || state == closedKeyword() || 585 DCHECK(state == openKeyword() || state == closedKeyword() ||
560 state == endedKeyword()); 586 state == endedKeyword());
561 587
562 AtomicString oldState = readyState(); 588 AtomicString oldState = readyState();
563 BLINK_MSLOG << __func__ << " this=" << this << " : " << oldState << " -> " 589 BLINK_MSLOG << __func__ << " this=" << this << " : " << oldState << " -> "
564 << state; 590 << state;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 666
641 // 3. If live seekable range contains a range, then set live seekable range 667 // 3. If live seekable range contains a range, then set live seekable range
642 // to be a new empty TimeRanges object. 668 // to be a new empty TimeRanges object.
643 if (m_liveSeekableRange->length() != 0) 669 if (m_liveSeekableRange->length() != 0)
644 m_liveSeekableRange = TimeRanges::create(); 670 m_liveSeekableRange = TimeRanges::create();
645 } 671 }
646 672
647 void MediaSource::endOfStreamInternal( 673 void MediaSource::endOfStreamInternal(
648 const WebMediaSource::EndOfStreamStatus eosStatus, 674 const WebMediaSource::EndOfStreamStatus eosStatus,
649 ExceptionState& exceptionState) { 675 ExceptionState& exceptionState) {
650 // 2.2 http://www.w3.org/TR/media-source/#widl-MediaSource-endOfStream-void-En dOfStreamError-error 676 // 2.2
677 // http://www.w3.org/TR/media-source/#widl-MediaSource-endOfStream-void-EndOfS treamError-error
651 // 1. If the readyState attribute is not in the "open" state then throw an 678 // 1. If the readyState attribute is not in the "open" state then throw an
652 // InvalidStateError exception and abort these steps. 679 // InvalidStateError exception and abort these steps.
653 // 2. If the updating attribute equals true on any SourceBuffer in sourceBuffe rs, then throw an 680 // 2. If the updating attribute equals true on any SourceBuffer in
654 // InvalidStateError exception and abort these steps. 681 // sourceBuffers, then throw an InvalidStateError exception and abort these
682 // steps.
655 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState)) 683 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState))
656 return; 684 return;
657 685
658 // 3. Run the end of stream algorithm with the error parameter set to error. 686 // 3. Run the end of stream algorithm with the error parameter set to error.
659 // 1. Change the readyState attribute value to "ended". 687 // 1. Change the readyState attribute value to "ended".
660 // 2. Queue a task to fire a simple event named sourceended at the MediaSour ce. 688 // 2. Queue a task to fire a simple event named sourceended at the
689 // MediaSource.
661 setReadyState(endedKeyword()); 690 setReadyState(endedKeyword());
662 691
663 // 3. Do various steps based on |eosStatus|. 692 // 3. Do various steps based on |eosStatus|.
664 m_webMediaSource->markEndOfStream(eosStatus); 693 m_webMediaSource->markEndOfStream(eosStatus);
665 } 694 }
666 695
667 bool MediaSource::isOpen() const { 696 bool MediaSource::isOpen() const {
668 return readyState() == openKeyword(); 697 return readyState() == openKeyword();
669 } 698 }
670 699
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 const String& type, 774 const String& type,
746 const String& codecs, 775 const String& codecs,
747 ExceptionState& exceptionState) { 776 ExceptionState& exceptionState) {
748 WebSourceBuffer* webSourceBuffer = 0; 777 WebSourceBuffer* webSourceBuffer = 0;
749 778
750 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { 779 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) {
751 case WebMediaSource::AddStatusOk: 780 case WebMediaSource::AddStatusOk:
752 return wrapUnique(webSourceBuffer); 781 return wrapUnique(webSourceBuffer);
753 case WebMediaSource::AddStatusNotSupported: 782 case WebMediaSource::AddStatusNotSupported:
754 DCHECK(!webSourceBuffer); 783 DCHECK(!webSourceBuffer);
755 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/med ia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 784 // 2.2
756 // Step 2: If type contains a MIME type ... that is not supported with the types 785 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-s ource.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
757 // specified for the other SourceBuffer objects in sourceBuffers, then thr ow 786 // Step 2: If type contains a MIME type ... that is not supported with the
758 // a NotSupportedError exception and abort these steps. 787 // types specified for the other SourceBuffer objects in sourceBuffers,
788 // then throw a NotSupportedError exception and abort these steps.
759 logAndThrowDOMException( 789 logAndThrowDOMException(
760 exceptionState, NotSupportedError, 790 exceptionState, NotSupportedError,
761 "The type provided ('" + type + "') is not supported."); 791 "The type provided ('" + type + "') is not supported.");
762 return nullptr; 792 return nullptr;
763 case WebMediaSource::AddStatusReachedIdLimit: 793 case WebMediaSource::AddStatusReachedIdLimit:
764 DCHECK(!webSourceBuffer); 794 DCHECK(!webSourceBuffer);
765 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/med ia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type 795 // 2.2
766 // Step 3: If the user agent can't handle any more SourceBuffer objects th en throw 796 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-s ource.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type
767 // a QuotaExceededError exception and abort these steps. 797 // Step 3: If the user agent can't handle any more SourceBuffer objects
798 // then throw a QuotaExceededError exception and abort these steps.
768 logAndThrowDOMException(exceptionState, QuotaExceededError, 799 logAndThrowDOMException(exceptionState, QuotaExceededError,
769 "This MediaSource has reached the limit of " 800 "This MediaSource has reached the limit of "
770 "SourceBuffer objects it can handle. No " 801 "SourceBuffer objects it can handle. No "
771 "additional SourceBuffer objects may be added."); 802 "additional SourceBuffer objects may be added.");
772 return nullptr; 803 return nullptr;
773 } 804 }
774 805
775 NOTREACHED(); 806 NOTREACHED();
776 return nullptr; 807 return nullptr;
777 } 808 }
778 809
779 void MediaSource::scheduleEvent(const AtomicString& eventName) { 810 void MediaSource::scheduleEvent(const AtomicString& eventName) {
780 DCHECK(m_asyncEventQueue); 811 DCHECK(m_asyncEventQueue);
781 812
782 Event* event = Event::create(eventName); 813 Event* event = Event::create(eventName);
783 event->setTarget(this); 814 event->setTarget(this);
784 815
785 m_asyncEventQueue->enqueueEvent(event); 816 m_asyncEventQueue->enqueueEvent(event);
786 } 817 }
787 818
788 URLRegistry& MediaSource::registry() const { 819 URLRegistry& MediaSource::registry() const {
789 return MediaSourceRegistry::registry(); 820 return MediaSourceRegistry::registry();
790 } 821 }
791 822
792 } // namespace blink 823 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasource/SourceBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698