| 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::updateTimestampOffsetIfNecessary() |
| 487 { |
| 488 double offset = m_webSourceBuffer->updatedTimestampOffset(); |
| 489 if (!std::isnan(offset)) |
| 490 m_timestampOffset = offset; |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 m_webSourceBuffer->append(m_pendingAppendData.data(), appendSize); |
| 538 | 545 |
| 546 // Update our cached |m_timestampOffset| since the implementation may change |
| 547 // it during append() processing. |
| 548 updateTimestampOffsetIfNecessary(); |
| 549 |
| 539 // 3. Set the updating attribute to false. | 550 // 3. Set the updating attribute to false. |
| 540 m_updating = false; | 551 m_updating = false; |
| 541 m_pendingAppendData.clear(); | 552 m_pendingAppendData.clear(); |
| 542 | 553 |
| 543 // 4. Queue a task to fire a simple event named update at this SourceBuffer
object. | 554 // 4. Queue a task to fire a simple event named update at this SourceBuffer
object. |
| 544 scheduleEvent(EventTypeNames::update); | 555 scheduleEvent(EventTypeNames::update); |
| 545 | 556 |
| 546 // 5. Queue a task to fire a simple event named updateend at this SourceBuff
er object. | 557 // 5. Queue a task to fire a simple event named updateend at this SourceBuff
er object. |
| 547 scheduleEvent(EventTypeNames::updateend); | 558 scheduleEvent(EventTypeNames::updateend); |
| 548 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); | 559 TRACE_EVENT_ASYNC_END0("media", "SourceBuffer::appendBuffer", this); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 WTF_LOG(Media, "SourceBuffer::didStartLoading() %p", this); | 694 WTF_LOG(Media, "SourceBuffer::didStartLoading() %p", this); |
| 684 } | 695 } |
| 685 | 696 |
| 686 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength
) | 697 void SourceBuffer::didReceiveDataForClient(const char* data, unsigned dataLength
) |
| 687 { | 698 { |
| 688 WTF_LOG(Media, "SourceBuffer::didReceiveDataForClient(%d) %p", dataLength, t
his); | 699 WTF_LOG(Media, "SourceBuffer::didReceiveDataForClient(%d) %p", dataLength, t
his); |
| 689 ASSERT(m_updating); | 700 ASSERT(m_updating); |
| 690 ASSERT(m_loader); | 701 ASSERT(m_loader); |
| 691 | 702 |
| 692 m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), data
Length); | 703 m_webSourceBuffer->append(reinterpret_cast<const unsigned char*>(data), data
Length); |
| 704 |
| 705 // Update our cached |m_timestampOffset| since the implementation may change |
| 706 // it during append() processing. |
| 707 updateTimestampOffsetIfNecessary(); |
| 693 } | 708 } |
| 694 | 709 |
| 695 void SourceBuffer::didFinishLoading() | 710 void SourceBuffer::didFinishLoading() |
| 696 { | 711 { |
| 697 WTF_LOG(Media, "SourceBuffer::didFinishLoading() %p", this); | 712 WTF_LOG(Media, "SourceBuffer::didFinishLoading() %p", this); |
| 698 appendStreamDone(true); | 713 appendStreamDone(true); |
| 699 } | 714 } |
| 700 | 715 |
| 701 void SourceBuffer::didFail(FileError::ErrorCode errorCode) | 716 void SourceBuffer::didFail(FileError::ErrorCode errorCode) |
| 702 { | 717 { |
| 703 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); | 718 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); |
| 704 appendStreamDone(false); | 719 appendStreamDone(false); |
| 705 } | 720 } |
| 706 | 721 |
| 707 void SourceBuffer::trace(Visitor* visitor) | 722 void SourceBuffer::trace(Visitor* visitor) |
| 708 { | 723 { |
| 709 visitor->trace(m_source); | 724 visitor->trace(m_source); |
| 710 } | 725 } |
| 711 | 726 |
| 712 } // namespace WebCore | 727 } // namespace WebCore |
| OLD | NEW |