| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 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 #ifndef MediaSourceBase_h | 31 #ifndef SourceBuffer_h |
| 32 #define MediaSourceBase_h | 32 #define SourceBuffer_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptWrappable.h" |
| 34 #include "core/dom/ActiveDOMObject.h" | 35 #include "core/dom/ActiveDOMObject.h" |
| 35 #include "core/dom/EventTarget.h" | 36 #include "core/dom/EventTarget.h" |
| 36 #include "core/html/URLRegistry.h" | 37 #include "core/dom/ExceptionCode.h" |
| 37 #include "core/platform/graphics/MediaSourcePrivate.h" | 38 #include "core/platform/Timer.h" |
| 38 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 39 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
| 41 #include "wtf/text/WTFString.h" |
| 40 | 42 |
| 41 namespace WebCore { | 43 namespace WebCore { |
| 44 class GenericEventQueue; |
| 45 class MediaSource; |
| 46 class SourceBufferPrivate; |
| 47 class TimeRanges; |
| 42 | 48 |
| 43 class GenericEventQueue; | 49 class SourceBuffer : public RefCounted<SourceBuffer>, public ActiveDOMObject, pu
blic EventTarget, public ScriptWrappable { |
| 50 public: |
| 51 static PassRefPtr<SourceBuffer> create(PassOwnPtr<SourceBufferPrivate>, Medi
aSource*, GenericEventQueue*); |
| 44 | 52 |
| 45 class MediaSourceBase : public RefCounted<MediaSourceBase>, public ActiveDOMObje
ct, public EventTarget, public URLRegistrable { | 53 virtual ~SourceBuffer(); |
| 46 public: | |
| 47 static const AtomicString& openKeyword(); | |
| 48 static const AtomicString& closedKeyword(); | |
| 49 static const AtomicString& endedKeyword(); | |
| 50 | 54 |
| 51 virtual ~MediaSourceBase(); | 55 // SourceBuffer.idl methods |
| 56 bool updating() const { return m_updating; } |
| 57 PassRefPtr<TimeRanges> buffered(ExceptionCode&) const; |
| 58 double timestampOffset() const; |
| 59 void setTimestampOffset(double, ExceptionCode&); |
| 60 void appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionCode&); |
| 61 void appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionCode&); |
| 62 void abort(ExceptionCode&); |
| 52 | 63 |
| 53 void setPrivateAndOpen(PassOwnPtr<MediaSourcePrivate>); | 64 void abortIfUpdating(); |
| 54 void addedToRegistry(); | 65 void removedFromMediaSource(); |
| 55 void removedFromRegistry(); | |
| 56 void openIfInEndedState(); | |
| 57 bool isOpen() const; | |
| 58 bool isClosed() const; | |
| 59 void close(); | |
| 60 | |
| 61 double duration() const; | |
| 62 void setDuration(double, ExceptionCode&); | |
| 63 const AtomicString& readyState() const { return m_readyState; } | |
| 64 virtual void setReadyState(const AtomicString&); | |
| 65 void endOfStream(const AtomicString& error, ExceptionCode&); | |
| 66 | |
| 67 | 66 |
| 68 // ActiveDOMObject interface | 67 // ActiveDOMObject interface |
| 69 virtual bool hasPendingActivity() const OVERRIDE; | 68 virtual bool hasPendingActivity() const OVERRIDE; |
| 70 virtual void stop() OVERRIDE; | 69 virtual void stop() OVERRIDE; |
| 71 | 70 |
| 72 // EventTarget interface | 71 // EventTarget interface |
| 73 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; | 72 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
| 73 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 74 |
| 75 using RefCounted<SourceBuffer>::ref; |
| 76 using RefCounted<SourceBuffer>::deref; |
| 77 |
| 78 protected: |
| 79 // EventTarget interface |
| 74 virtual EventTargetData* eventTargetData() OVERRIDE; | 80 virtual EventTargetData* eventTargetData() OVERRIDE; |
| 75 virtual EventTargetData* ensureEventTargetData() OVERRIDE; | 81 virtual EventTargetData* ensureEventTargetData() OVERRIDE; |
| 76 virtual void refEventTarget() OVERRIDE { ref(); } | 82 virtual void refEventTarget() OVERRIDE { ref(); } |
| 77 virtual void derefEventTarget() OVERRIDE { deref(); } | 83 virtual void derefEventTarget() OVERRIDE { deref(); } |
| 78 | 84 |
| 79 // URLRegistrable interface | 85 private: |
| 80 virtual URLRegistry& registry() const OVERRIDE; | 86 SourceBuffer(PassOwnPtr<SourceBufferPrivate>, MediaSource*, GenericEventQueu
e*); |
| 81 | 87 |
| 82 virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE; | 88 bool isRemoved() const; |
| 89 void scheduleEvent(const AtomicString& eventName); |
| 83 | 90 |
| 84 using RefCounted<MediaSourceBase>::ref; | 91 void appendBufferInternal(unsigned char*, unsigned, ExceptionCode&); |
| 85 using RefCounted<MediaSourceBase>::deref; | 92 void appendBufferTimerFired(Timer<SourceBuffer>*); |
| 86 | 93 |
| 87 protected: | 94 OwnPtr<SourceBufferPrivate> m_private; |
| 88 explicit MediaSourceBase(ScriptExecutionContext*); | 95 MediaSource* m_source; |
| 96 GenericEventQueue* m_asyncEventQueue; |
| 97 EventTargetData m_eventTargetData; |
| 89 | 98 |
| 90 PassOwnPtr<SourceBufferPrivate> createSourceBufferPrivate(const String& type
, const MediaSourcePrivate::CodecsArray&, ExceptionCode&); | 99 bool m_updating; |
| 91 void scheduleEvent(const AtomicString& eventName); | 100 double m_timestampOffset; |
| 92 GenericEventQueue* asyncEventQueue() const { return m_asyncEventQueue.get();
} | |
| 93 | 101 |
| 94 private: | 102 Vector<unsigned char> m_pendingAppendData; |
| 95 OwnPtr<MediaSourcePrivate> m_private; | 103 Timer<SourceBuffer> m_appendBufferTimer; |
| 96 EventTargetData m_eventTargetData; | |
| 97 AtomicString m_readyState; | |
| 98 OwnPtr<GenericEventQueue> m_asyncEventQueue; | |
| 99 }; | 104 }; |
| 100 | 105 |
| 101 } | 106 } // namespace WebCore |
| 102 | 107 |
| 103 #endif | 108 #endif |
| OLD | NEW |