| 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 11 matching lines...) Expand all Loading... |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/mediasource/SourceBufferList.h" | 32 #include "modules/mediasource/WebKitSourceBufferList.h" |
| 33 | 33 |
| 34 #include "core/dom/Event.h" | 34 #include "core/dom/Event.h" |
| 35 #include "core/dom/GenericEventQueue.h" | 35 #include "core/dom/GenericEventQueue.h" |
| 36 #include "modules/mediasource/SourceBuffer.h" | 36 #include "modules/mediasource/WebKitSourceBuffer.h" |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 SourceBufferList::SourceBufferList(ScriptExecutionContext* context, | 40 WebKitSourceBufferList::WebKitSourceBufferList(ScriptExecutionContext* context,
GenericEventQueue* asyncEventQueue) |
| 41 GenericEventQueue* asyncEventQueue) | |
| 42 : m_scriptExecutionContext(context) | 41 : m_scriptExecutionContext(context) |
| 43 , m_asyncEventQueue(asyncEventQueue) | 42 , m_asyncEventQueue(asyncEventQueue) |
| 44 { | 43 { |
| 45 } | 44 } |
| 46 | 45 |
| 47 unsigned long SourceBufferList::length() const | 46 unsigned long WebKitSourceBufferList::length() const |
| 48 { | 47 { |
| 49 return m_list.size(); | 48 return m_list.size(); |
| 50 } | 49 } |
| 51 | 50 |
| 52 SourceBuffer* SourceBufferList::item(unsigned index) const | 51 WebKitSourceBuffer* WebKitSourceBufferList::item(unsigned index) const |
| 53 { | 52 { |
| 54 if (index >= m_list.size()) | 53 if (index >= m_list.size()) |
| 55 return 0; | 54 return 0; |
| 56 return m_list[index].get(); | 55 return m_list[index].get(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void SourceBufferList::add(PassRefPtr<SourceBuffer> buffer) | 58 void WebKitSourceBufferList::add(PassRefPtr<WebKitSourceBuffer> buffer) |
| 60 { | 59 { |
| 61 m_list.append(buffer); | 60 m_list.append(buffer); |
| 62 createAndFireEvent(eventNames().webkitaddsourcebufferEvent); | 61 createAndFireEvent(eventNames().webkitaddsourcebufferEvent); |
| 63 } | 62 } |
| 64 | 63 |
| 65 bool SourceBufferList::remove(SourceBuffer* buffer) | 64 bool WebKitSourceBufferList::remove(WebKitSourceBuffer* buffer) |
| 66 { | 65 { |
| 67 size_t index = m_list.find(buffer); | 66 size_t index = m_list.find(buffer); |
| 68 if (index == notFound) | 67 if (index == notFound) |
| 69 return false; | 68 return false; |
| 70 | 69 |
| 71 buffer->removedFromMediaSource(); | 70 buffer->removedFromMediaSource(); |
| 72 m_list.remove(index); | 71 m_list.remove(index); |
| 73 createAndFireEvent(eventNames().webkitremovesourcebufferEvent); | 72 createAndFireEvent(eventNames().webkitremovesourcebufferEvent); |
| 74 return true; | 73 return true; |
| 75 } | 74 } |
| 76 | 75 |
| 77 void SourceBufferList::clear() | 76 void WebKitSourceBufferList::clear() |
| 78 { | 77 { |
| 79 for (size_t i = 0; i < m_list.size(); ++i) | 78 for (size_t i = 0; i < m_list.size(); ++i) |
| 80 m_list[i]->removedFromMediaSource(); | 79 m_list[i]->removedFromMediaSource(); |
| 81 m_list.clear(); | 80 m_list.clear(); |
| 82 createAndFireEvent(eventNames().webkitremovesourcebufferEvent); | 81 createAndFireEvent(eventNames().webkitremovesourcebufferEvent); |
| 83 } | 82 } |
| 84 | 83 |
| 85 void SourceBufferList::createAndFireEvent(const AtomicString& eventName) | 84 void WebKitSourceBufferList::createAndFireEvent(const AtomicString& eventName) |
| 86 { | 85 { |
| 87 ASSERT(m_asyncEventQueue); | 86 ASSERT(m_asyncEventQueue); |
| 88 | 87 |
| 89 RefPtr<Event> event = Event::create(eventName, false, false); | 88 RefPtr<Event> event = Event::create(eventName, false, false); |
| 90 event->setTarget(this); | 89 event->setTarget(this); |
| 91 | 90 |
| 92 m_asyncEventQueue->enqueueEvent(event.release()); | 91 m_asyncEventQueue->enqueueEvent(event.release()); |
| 93 } | 92 } |
| 94 | 93 |
| 95 const AtomicString& SourceBufferList::interfaceName() const | 94 const AtomicString& WebKitSourceBufferList::interfaceName() const |
| 96 { | 95 { |
| 97 return eventNames().interfaceForSourceBufferList; | 96 return eventNames().interfaceForWebKitSourceBufferList; |
| 98 } | 97 } |
| 99 | 98 |
| 100 ScriptExecutionContext* SourceBufferList::scriptExecutionContext() const | 99 ScriptExecutionContext* WebKitSourceBufferList::scriptExecutionContext() const |
| 101 { | 100 { |
| 102 return m_scriptExecutionContext; | 101 return m_scriptExecutionContext; |
| 103 } | 102 } |
| 104 | 103 |
| 105 EventTargetData* SourceBufferList::eventTargetData() | 104 EventTargetData* WebKitSourceBufferList::eventTargetData() |
| 106 { | 105 { |
| 107 return &m_eventTargetData; | 106 return &m_eventTargetData; |
| 108 } | 107 } |
| 109 | 108 |
| 110 EventTargetData* SourceBufferList::ensureEventTargetData() | 109 EventTargetData* WebKitSourceBufferList::ensureEventTargetData() |
| 111 { | 110 { |
| 112 return &m_eventTargetData; | 111 return &m_eventTargetData; |
| 113 } | 112 } |
| 114 | 113 |
| 115 } // namespace WebCore | 114 } // namespace WebCore |
| OLD | NEW |