Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 476 void SourceBuffer::scheduleEvent(const AtomicString& eventName) | 476 void SourceBuffer::scheduleEvent(const AtomicString& eventName) |
| 477 { | 477 { |
| 478 ASSERT(m_asyncEventQueue); | 478 ASSERT(m_asyncEventQueue); |
| 479 | 479 |
| 480 RefPtr<Event> event = Event::create(eventName); | 480 RefPtr<Event> event = Event::create(eventName); |
| 481 event->setTarget(this); | 481 event->setTarget(this); |
| 482 | 482 |
| 483 m_asyncEventQueue->enqueueEvent(event.release()); | 483 m_asyncEventQueue->enqueueEvent(event.release()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void SourceBuffer::appendAndUpdateTimestampOffset(const unsigned char* data, uns igned length) | |
| 487 { | |
| 488 double newTimestampOffset; | |
|
jamesr
2014/02/27 01:49:56
this value is completely unininitialized
wolenetz
2014/02/27 03:29:58
Done.
| |
| 489 if (m_webSourceBuffer->append(data, length, &newTimestampOffset)) | |
| 490 m_timestampOffset = newTimestampOffset; | |
|
jamesr
2014/02/27 01:49:56
so if it's used here (i.e. the append() function r
wolenetz
2014/02/27 03:29:58
Done.
| |
| 491 } | |
| 492 | |
| 486 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size , ExceptionState& exceptionState) | 493 void SourceBuffer::appendBufferInternal(const unsigned char* data, unsigned size , ExceptionState& exceptionState) |
| 487 { | 494 { |
| 488 // Section 3.2 appendBuffer() | 495 // Section 3.2 appendBuffer() |
| 489 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data | 496 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data |
| 490 | 497 |
| 491 // Step 1 is enforced by the caller. | 498 // Step 1 is enforced by the caller. |
| 492 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an InvalidStateError exception and abort these steps. | 499 // 2. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an InvalidStateError exception and abort these steps. |
| 493 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. | 500 // 3. If the updating attribute equals true, then throw an InvalidStateError exception and abort these steps. |
| 494 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) | 501 if (throwExceptionIfRemovedOrUpdating(isRemoved(), m_updating, exceptionStat e)) |
| 495 return; | 502 return; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 534 |
| 528 // 1. Run the segment parser loop algorithm. | 535 // 1. Run the segment parser loop algorithm. |
| 529 // Step 2 doesn't apply since we run Step 1 synchronously here. | 536 // Step 2 doesn't apply since we run Step 1 synchronously here. |
| 530 size_t appendSize = m_pendingAppendData.size(); | 537 size_t appendSize = m_pendingAppendData.size(); |
| 531 if (!appendSize) { | 538 if (!appendSize) { |
| 532 // Resize buffer for 0 byte appends so we always have a valid pointer. | 539 // Resize buffer for 0 byte appends so we always have a valid pointer. |
| 533 // We need to convey all appends, even 0 byte ones to |m_webSourceBuffer | | 540 // We need to convey all appends, even 0 byte ones to |m_webSourceBuffer | |
| 534 // so that it can clear its end of stream state if necessary. | 541 // so that it can clear its end of stream state if necessary. |
| 535 m_pendingAppendData.resize(1); | 542 m_pendingAppendData.resize(1); |
| 536 } | 543 } |
| 537 m_webSourceBuffer->append(m_pendingAppendData.data(), appendSize); | 544 appendAndUpdateTimestampOffset(m_pendingAppendData.data(), appendSize); |
| 538 | 545 |
| 539 // 3. Set the updating attribute to false. | 546 // 3. Set the updating attribute to false. |
| 540 m_updating = false; | 547 m_updating = false; |
| 541 m_pendingAppendData.clear(); | 548 m_pendingAppendData.clear(); |
| 542 | 549 |
| 543 // 4. Queue a task to fire a simple event named update at this SourceBuffer object. | 550 // 4. Queue a task to fire a simple event named update at this SourceBuffer object. |
| 544 scheduleEvent(EventTypeNames::update); | 551 scheduleEvent(EventTypeNames::update); |
| 545 | 552 |
| 546 // 5. Queue a task to fire a simple event named updateend at this SourceBuff er object. | 553 // 5. Queue a task to fire a simple event named updateend at this SourceBuff er object. |
| 547 scheduleEvent(EventTypeNames::updateend); | 554 scheduleEvent(EventTypeNames::updateend); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 { | 689 { |
| 683 WTF_LOG(Media, "SourceBuffer::didStartLoading() %p", this); | 690 WTF_LOG(Media, "SourceBuffer::didStartLoading() %p", this); |
| 684 } | 691 } |
| 685 | 692 |
| 686 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength ) | 693 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength ) |
| 687 { | 694 { |
| 688 WTF_LOG(Media, "SourceBuffer::didReceiveDataForClient(%d) %p", dataLength, t his); | 695 WTF_LOG(Media, "SourceBuffer::didReceiveDataForClient(%d) %p", dataLength, t his); |
| 689 ASSERT(m_updating); | 696 ASSERT(m_updating); |
| 690 ASSERT(m_loader); | 697 ASSERT(m_loader); |
| 691 | 698 |
| 692 m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), data Length); | 699 appendAndUpdateTimestampOffset(reinterpret_cast<const unsigned char*>(data), dataLength); |
| 693 } | 700 } |
| 694 | 701 |
| 695 void SourceBuffer::didFinishLoading() | 702 void SourceBuffer::didFinishLoading() |
| 696 { | 703 { |
| 697 WTF_LOG(Media, "SourceBuffer::didFinishLoading() %p", this); | 704 WTF_LOG(Media, "SourceBuffer::didFinishLoading() %p", this); |
| 698 appendStreamDone(true); | 705 appendStreamDone(true); |
| 699 } | 706 } |
| 700 | 707 |
| 701 void SourceBuffer::didFail(FileError::ErrorCode errorCode) | 708 void SourceBuffer::didFail(FileError::ErrorCode errorCode) |
| 702 { | 709 { |
| 703 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); | 710 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); |
| 704 appendStreamDone(false); | 711 appendStreamDone(false); |
| 705 } | 712 } |
| 706 | 713 |
| 707 void SourceBuffer::trace(Visitor* visitor) | 714 void SourceBuffer::trace(Visitor* visitor) |
| 708 { | 715 { |
| 709 visitor->trace(m_source); | 716 visitor->trace(m_source); |
| 710 } | 717 } |
| 711 | 718 |
| 712 } // namespace WebCore | 719 } // namespace WebCore |
| OLD | NEW |