| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #ifndef MediaSource_h | |
| 32 #define MediaSource_h | |
| 33 | |
| 34 #if ENABLE(MEDIA_SOURCE) | |
| 35 | |
| 36 #include "ContextDestructionObserver.h" | |
| 37 #include "MediaPlayer.h" | |
| 38 #include "SourceBuffer.h" | |
| 39 #include "SourceBufferList.h" | |
| 40 #include <wtf/RefCounted.h> | |
| 41 | |
| 42 namespace WebCore { | |
| 43 | |
| 44 class MediaSource : public RefCounted<MediaSource>, public EventTarget, public C
ontextDestructionObserver { | |
| 45 public: | |
| 46 static const String& openKeyword() | |
| 47 { | |
| 48 DEFINE_STATIC_LOCAL(const String, open, ("open")); | |
| 49 return open; | |
| 50 } | |
| 51 | |
| 52 static const String& closedKeyword() | |
| 53 { | |
| 54 DEFINE_STATIC_LOCAL(const String, closed, ("closed")); | |
| 55 return closed; | |
| 56 } | |
| 57 | |
| 58 static const String& endedKeyword() | |
| 59 { | |
| 60 DEFINE_STATIC_LOCAL(const String, ended, ("ended")); | |
| 61 return ended; | |
| 62 } | |
| 63 | |
| 64 static PassRefPtr<MediaSource> create(ScriptExecutionContext*); | |
| 65 virtual ~MediaSource() { } | |
| 66 | |
| 67 SourceBufferList* sourceBuffers(); | |
| 68 SourceBufferList* activeSourceBuffers(); | |
| 69 | |
| 70 SourceBuffer* addSourceBuffer(const String& type, ExceptionCode&); | |
| 71 void removeSourceBuffer(SourceBuffer*, ExceptionCode&); | |
| 72 | |
| 73 const String& readyState() const; | |
| 74 void setReadyState(const String&); | |
| 75 | |
| 76 void endOfStream(const String& error, ExceptionCode&); | |
| 77 | |
| 78 void setMediaPlayer(MediaPlayer* player) { m_player = player; } | |
| 79 | |
| 80 PassRefPtr<TimeRanges> buffered(const String& id, ExceptionCode&) const; | |
| 81 void append(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode&); | |
| 82 void abort(const String& id, ExceptionCode&); | |
| 83 | |
| 84 // EventTarget interface | |
| 85 virtual const AtomicString& interfaceName() const OVERRIDE; | |
| 86 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; | |
| 87 | |
| 88 using RefCounted<MediaSource>::ref; | |
| 89 using RefCounted<MediaSource>::deref; | |
| 90 | |
| 91 private: | |
| 92 explicit MediaSource(ScriptExecutionContext*); | |
| 93 | |
| 94 virtual EventTargetData* eventTargetData() OVERRIDE; | |
| 95 virtual EventTargetData* ensureEventTargetData() OVERRIDE; | |
| 96 | |
| 97 virtual void refEventTarget() OVERRIDE { ref(); } | |
| 98 virtual void derefEventTarget() OVERRIDE { deref(); } | |
| 99 | |
| 100 EventTargetData m_eventTargetData; | |
| 101 | |
| 102 String m_readyState; | |
| 103 MediaPlayer* m_player; | |
| 104 | |
| 105 RefPtr<SourceBufferList> m_sourceBuffers; | |
| 106 RefPtr<SourceBufferList> m_activeSourceBuffers; | |
| 107 int m_nextSourceBufferId; | |
| 108 }; | |
| 109 | |
| 110 } // namespace WebCore | |
| 111 | |
| 112 #endif | |
| 113 #endif | |
| OLD | NEW |