| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 | 55 |
| 56 WebKitSourceBuffer::~WebKitSourceBuffer() | 56 WebKitSourceBuffer::~WebKitSourceBuffer() |
| 57 { | 57 { |
| 58 } | 58 } |
| 59 | 59 |
| 60 PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionCode& ec) const | 60 PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionCode& ec) const |
| 61 { | 61 { |
| 62 // Section 3.1 buffered attribute steps. | 62 // Section 3.1 buffered attribute steps. |
| 63 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an | 63 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an |
| 64 // INVALID_STATE_ERR exception and abort these steps. | 64 // InvalidStateError exception and abort these steps. |
| 65 if (isRemoved()) { | 65 if (isRemoved()) { |
| 66 ec = INVALID_STATE_ERR; | 66 ec = InvalidStateError; |
| 67 return 0; | 67 return 0; |
| 68 } | 68 } |
| 69 | 69 |
| 70 // 2. Return a new static normalized TimeRanges object for the media segment
s buffered. | 70 // 2. Return a new static normalized TimeRanges object for the media segment
s buffered. |
| 71 return m_private->buffered(); | 71 return m_private->buffered(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 double WebKitSourceBuffer::timestampOffset() const | 74 double WebKitSourceBuffer::timestampOffset() const |
| 75 { | 75 { |
| 76 return m_timestampOffset; | 76 return m_timestampOffset; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec) | 79 void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec) |
| 80 { | 80 { |
| 81 // Section 3.1 timestampOffset attribute setter steps. | 81 // Section 3.1 timestampOffset attribute setter steps. |
| 82 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an | 82 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source then throw an |
| 83 // INVALID_STATE_ERR exception and abort these steps. | 83 // InvalidStateError exception and abort these steps. |
| 84 if (isRemoved()) { | 84 if (isRemoved()) { |
| 85 ec = INVALID_STATE_ERR; | 85 ec = InvalidStateError; |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 | 88 |
| 89 // 4. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: | 89 // 4. If the readyState attribute of the parent media source is in the "ende
d" state then run the following steps: |
| 90 // 4.1 Set the readyState attribute of the parent media source to "open" | 90 // 4.1 Set the readyState attribute of the parent media source to "open" |
| 91 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me
dia source. | 91 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me
dia source. |
| 92 m_source->openIfInEndedState(); | 92 m_source->openIfInEndedState(); |
| 93 | 93 |
| 94 // 5. If this object is waiting for the end of a media segment to be appende
d, then throw an INVALID_STATE_ERR | 94 // 5. If this object is waiting for the end of a media segment to be appende
d, then throw an InvalidStateError |
| 95 // and abort these steps. | 95 // and abort these steps. |
| 96 if (!m_private->setTimestampOffset(offset)) { | 96 if (!m_private->setTimestampOffset(offset)) { |
| 97 ec = INVALID_STATE_ERR; | 97 ec = InvalidStateError; |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 | 100 |
| 101 // 6. Update the attribute to the new value. | 101 // 6. Update the attribute to the new value. |
| 102 m_timestampOffset = offset; | 102 m_timestampOffset = offset; |
| 103 } | 103 } |
| 104 | 104 |
| 105 void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec) | 105 void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec) |
| 106 { | 106 { |
| 107 // SourceBuffer.append() steps from October 1st version of the Media Source
Extensions spec. | 107 // SourceBuffer.append() steps from October 1st version of the Media Source
Extensions spec. |
| 108 // https://dvcs.w3.org/hg/html-media/raw-file/7bab66368f2c/media-source/medi
a-source.html#dom-append | 108 // https://dvcs.w3.org/hg/html-media/raw-file/7bab66368f2c/media-source/medi
a-source.html#dom-append |
| 109 | 109 |
| 110 // 2. If data is null then throw an INVALID_ACCESS_ERR exception and abort t
hese steps. | 110 // 2. If data is null then throw an InvalidAccessError exception and abort t
hese steps. |
| 111 if (!data) { | 111 if (!data) { |
| 112 ec = INVALID_ACCESS_ERR; | 112 ec = InvalidAccessError; |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // 3. If this object has been removed from the sourceBuffers attribute of me
dia source then throw | 116 // 3. If this object has been removed from the sourceBuffers attribute of me
dia source then throw |
| 117 // an INVALID_STATE_ERR exception and abort these steps. | 117 // an InvalidStateError exception and abort these steps. |
| 118 if (isRemoved()) { | 118 if (isRemoved()) { |
| 119 ec = INVALID_STATE_ERR; | 119 ec = InvalidStateError; |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // 5. If the readyState attribute of media source is in the "ended" state th
en run the following steps: | 123 // 5. If the readyState attribute of media source is in the "ended" state th
en run the following steps: |
| 124 // 5.1. Set the readyState attribute of media source to "open" | 124 // 5.1. Set the readyState attribute of media source to "open" |
| 125 // 5.2. Queue a task to fire a simple event named sourceopen at media source
. | 125 // 5.2. Queue a task to fire a simple event named sourceopen at media source
. |
| 126 m_source->openIfInEndedState(); | 126 m_source->openIfInEndedState(); |
| 127 | 127 |
| 128 // Steps 6 & beyond are handled by the private implementation. | 128 // Steps 6 & beyond are handled by the private implementation. |
| 129 m_private->append(data->data(), data->length()); | 129 m_private->append(data->data(), data->length()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void WebKitSourceBuffer::abort(ExceptionCode& ec) | 132 void WebKitSourceBuffer::abort(ExceptionCode& ec) |
| 133 { | 133 { |
| 134 // Section 3.2 abort() method steps. | 134 // Section 3.2 abort() method steps. |
| 135 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source | 135 // 1. If this object has been removed from the sourceBuffers attribute of th
e parent media source |
| 136 // then throw an INVALID_STATE_ERR exception and abort these steps. | 136 // then throw an InvalidStateError exception and abort these steps. |
| 137 // 2. If the readyState attribute of the parent media source is not in the "
open" state | 137 // 2. If the readyState attribute of the parent media source is not in the "
open" state |
| 138 // then throw an INVALID_STATE_ERR exception and abort these steps. | 138 // then throw an InvalidStateError exception and abort these steps. |
| 139 if (isRemoved() || !m_source->isOpen()) { | 139 if (isRemoved() || !m_source->isOpen()) { |
| 140 ec = INVALID_STATE_ERR; | 140 ec = InvalidStateError; |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // 4. Run the reset parser state algorithm. | 144 // 4. Run the reset parser state algorithm. |
| 145 m_private->abort(); | 145 m_private->abort(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void WebKitSourceBuffer::removedFromMediaSource() | 148 void WebKitSourceBuffer::removedFromMediaSource() |
| 149 { | 149 { |
| 150 if (isRemoved()) | 150 if (isRemoved()) |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 m_private->removedFromMediaSource(); | 153 m_private->removedFromMediaSource(); |
| 154 m_source.clear(); | 154 m_source.clear(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool WebKitSourceBuffer::isRemoved() const | 157 bool WebKitSourceBuffer::isRemoved() const |
| 158 { | 158 { |
| 159 return !m_source; | 159 return !m_source; |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace WebCore | 162 } // namespace WebCore |
| OLD | NEW |