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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(webSourceBuffer, source, asyncEventQueue))); | 58 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(webSourceBuffer, source, asyncEventQueue))); |
| 59 sourceBuffer->suspendIfNeeded(); | 59 sourceBuffer->suspendIfNeeded(); |
| 60 return sourceBuffer.release(); | 60 return sourceBuffer.release(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 SourceBuffer::SourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuffer, MediaSou rce* source, GenericEventQueue* asyncEventQueue) | 63 SourceBuffer::SourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuffer, MediaSou rce* source, GenericEventQueue* asyncEventQueue) |
| 64 : ActiveDOMObject(source->executionContext()) | 64 : ActiveDOMObject(source->executionContext()) |
| 65 , m_webSourceBuffer(webSourceBuffer) | 65 , m_webSourceBuffer(webSourceBuffer) |
| 66 , m_source(source) | 66 , m_source(source) |
| 67 , m_asyncEventQueue(asyncEventQueue) | 67 , m_asyncEventQueue(asyncEventQueue) |
| 68 , m_mode(segmentsKeyword()) | |
| 68 , m_updating(false) | 69 , m_updating(false) |
| 69 , m_timestampOffset(0) | 70 , m_timestampOffset(0) |
| 70 , m_appendWindowStart(0) | 71 , m_appendWindowStart(0) |
| 71 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) | 72 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) |
| 72 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart) | 73 , m_appendBufferAsyncPartRunner(this, &SourceBuffer::appendBufferAsyncPart) |
| 73 , m_pendingRemoveStart(-1) | 74 , m_pendingRemoveStart(-1) |
| 74 , m_pendingRemoveEnd(-1) | 75 , m_pendingRemoveEnd(-1) |
| 75 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart) | 76 , m_removeAsyncPartRunner(this, &SourceBuffer::removeAsyncPart) |
| 76 , m_streamMaxSizeValid(false) | 77 , m_streamMaxSizeValid(false) |
| 77 , m_streamMaxSize(0) | 78 , m_streamMaxSize(0) |
| 78 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart) | 79 , m_appendStreamAsyncPartRunner(this, &SourceBuffer::appendStreamAsyncPart) |
| 79 { | 80 { |
| 80 ASSERT(m_webSourceBuffer); | 81 ASSERT(m_webSourceBuffer); |
| 81 ASSERT(m_source); | 82 ASSERT(m_source); |
| 82 ScriptWrappable::init(this); | 83 ScriptWrappable::init(this); |
| 83 } | 84 } |
| 84 | 85 |
| 85 SourceBuffer::~SourceBuffer() | 86 SourceBuffer::~SourceBuffer() |
| 86 { | 87 { |
| 87 ASSERT(isRemoved()); | 88 ASSERT(isRemoved()); |
| 88 ASSERT(!m_loader); | 89 ASSERT(!m_loader); |
| 89 ASSERT(!m_stream); | 90 ASSERT(!m_stream); |
| 90 } | 91 } |
| 91 | 92 |
| 93 const AtomicString& SourceBuffer::segmentsKeyword() | |
| 94 { | |
| 95 DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments", AtomicString: :ConstructFromLiteral)); | |
| 96 return segments; | |
| 97 } | |
| 98 | |
| 99 const AtomicString& SourceBuffer::sequenceKeyword() | |
| 100 { | |
| 101 DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence", AtomicString: :ConstructFromLiteral)); | |
| 102 return sequence; | |
| 103 } | |
| 104 | |
| 105 void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptio nState) | |
| 106 { | |
| 107 // Section 3.1 On setting mode attribute steps. | |
| 108 // 1. Let new mode equal the new value being assigned to this attribute. | |
| 109 // 2. If new mode does not equal "segments" or "sequence", then throw an INV ALID_ACCESS_ERR exception and abort | |
| 110 // these steps. | |
| 111 if (newMode != segmentsKeyword() && newMode != sequenceKeyword()) { | |
| 112 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr or); | |
|
Mike West
2014/01/13 11:56:20
Hello, friendly engineer!
Please don't add new ex
| |
| 113 return; | |
| 114 } | |
| 115 | |
| 116 // 3. If this object has been removed from the sourceBuffers attribute of th e parent media source, then throw | |
| 117 // an INVALID_STATE_ERR exception and abort these steps. | |
| 118 // 4. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. | |
| 119 if (isRemoved() || m_updating) { | |
| 120 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); | |
| 121 return; | |
| 122 } | |
| 123 | |
| 124 // 5. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: | |
| 125 // 5.1 Set the readyState attribute of the parent media source to "open" | |
| 126 // 5.2 Queue a task to fire a simple event named sourceopen at the parent me dia source. | |
| 127 m_source->openIfInEndedState(); | |
| 128 | |
| 129 // 6. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALI D_STATE_ERR and abort these steps. | |
| 130 // 7. If the new mode equals "sequence", then set the group start timestamp to the highest presentation end timestamp. | |
| 131 WebSourceBuffer::AppendMode appendMode = WebSourceBuffer::AppendModeSegments ; | |
| 132 if (newMode == sequenceKeyword()) | |
| 133 appendMode = WebSourceBuffer::AppendModeSequence; | |
| 134 if (!m_webSourceBuffer->setMode(appendMode)) { | |
| 135 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); | |
| 136 return; | |
| 137 } | |
| 138 | |
| 139 // 8. Update the attribute to new mode. | |
| 140 m_mode = newMode; | |
| 141 } | |
| 142 | |
| 92 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co nst | 143 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) co nst |
| 93 { | 144 { |
| 94 // Section 3.1 buffered attribute steps. | 145 // Section 3.1 buffered attribute steps. |
| 95 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an | 146 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an |
| 96 // InvalidStateError exception and abort these steps. | 147 // InvalidStateError exception and abort these steps. |
| 97 if (isRemoved()) { | 148 if (isRemoved()) { |
| 98 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); | 149 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); |
| 99 return 0; | 150 return 0; |
| 100 } | 151 } |
| 101 | 152 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 118 if (isRemoved() || m_updating) { | 169 if (isRemoved() || m_updating) { |
| 119 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); | 170 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); |
| 120 return; | 171 return; |
| 121 } | 172 } |
| 122 | 173 |
| 123 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: | 174 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: |
| 124 // 4.1 Set the readyState attribute of the parent media source to "open" | 175 // 4.1 Set the readyState attribute of the parent media source to "open" |
| 125 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source. | 176 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source. |
| 126 m_source->openIfInEndedState(); | 177 m_source->openIfInEndedState(); |
| 127 | 178 |
| 128 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError | 179 // 5. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALI D_STATE_ERR and abort these steps. |
| 129 // and abort these steps. | 180 // 6. If the mode attribute equals "sequence", then set the group start time stamp to new timestamp offset. |
| 130 // | |
| 131 // FIXME: Add step 6 text when mode attribute is implemented. | |
| 132 if (!m_webSourceBuffer->setTimestampOffset(offset)) { | 181 if (!m_webSourceBuffer->setTimestampOffset(offset)) { |
| 133 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); | 182 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); |
| 134 return; | 183 return; |
| 135 } | 184 } |
| 136 | 185 |
| 137 // 7. Update the attribute to new timestamp offset. | 186 // 7. Update the attribute to new timestamp offset. |
| 138 m_timestampOffset = offset; | 187 m_timestampOffset = offset; |
| 139 } | 188 } |
| 140 | 189 |
| 141 double SourceBuffer::appendWindowStart() const | 190 double SourceBuffer::appendWindowStart() const |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 appendStreamDone(true); | 682 appendStreamDone(true); |
| 634 } | 683 } |
| 635 | 684 |
| 636 void SourceBuffer::didFail(FileError::ErrorCode errorCode) | 685 void SourceBuffer::didFail(FileError::ErrorCode errorCode) |
| 637 { | 686 { |
| 638 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); | 687 WTF_LOG(Media, "SourceBuffer::didFail(%d) %p", errorCode, this); |
| 639 appendStreamDone(false); | 688 appendStreamDone(false); |
| 640 } | 689 } |
| 641 | 690 |
| 642 } // namespace WebCore | 691 } // namespace WebCore |
| OLD | NEW |