michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_SourceBufferList_h_ michael@0: #define mozilla_dom_SourceBufferList_h_ michael@0: michael@0: #include "SourceBuffer.h" michael@0: #include "js/RootingAPI.h" michael@0: #include "mozilla/Assertions.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsCycleCollectionNoteChild.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsISupports.h" michael@0: #include "nsTArray.h" michael@0: michael@0: struct JSContext; michael@0: class JSObject; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class ErrorResult; michael@0: template class AsyncEventRunner; michael@0: michael@0: namespace dom { michael@0: michael@0: class MediaSource; michael@0: michael@0: class SourceBufferList MOZ_FINAL : public DOMEventTargetHelper michael@0: { michael@0: public: michael@0: /** WebIDL Methods. */ michael@0: SourceBuffer* IndexedGetter(uint32_t aIndex, bool& aFound); michael@0: michael@0: uint32_t Length(); michael@0: /** End WebIDL methods. */ michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBufferList, michael@0: DOMEventTargetHelper) michael@0: michael@0: explicit SourceBufferList(MediaSource* aMediaSource); michael@0: michael@0: MediaSource* GetParentObject() const; michael@0: michael@0: JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; michael@0: michael@0: // Append a SourceBuffer and fire "addsourcebuffer" at the list. michael@0: void Append(SourceBuffer* aSourceBuffer); michael@0: michael@0: // Remove a SourceBuffer and fire "removesourcebuffer" at the list. michael@0: void Remove(SourceBuffer* aSourceBuffer); michael@0: michael@0: // Returns true if aSourceBuffer is present in the list. michael@0: bool Contains(SourceBuffer* aSourceBuffer); michael@0: michael@0: // Remove all SourceBuffers and fire a single "removesourcebuffer" at the list. michael@0: void Clear(); michael@0: michael@0: // True if list has zero entries. michael@0: bool IsEmpty(); michael@0: michael@0: // Returns true if updating is true on any SourceBuffers in the list. michael@0: bool AnyUpdating(); michael@0: michael@0: // Calls Remove(aStart, aEnd) on each SourceBuffer in the list. Aborts on michael@0: // first error, with result returned in aRv. michael@0: void Remove(double aStart, double aEnd, ErrorResult& aRv); michael@0: michael@0: // Mark all SourceBuffers input buffers as ended. michael@0: void Ended(); michael@0: michael@0: // Evicts data for the given time range from each SourceBuffer in the list. michael@0: void Evict(double aStart, double aEnd); michael@0: michael@0: // Returns true if all SourceBuffers in the list contain data for the given time. michael@0: bool AllContainsTime(double aTime); michael@0: michael@0: private: michael@0: friend class AsyncEventRunner; michael@0: void DispatchSimpleEvent(const char* aName); michael@0: void QueueAsyncSimpleEvent(const char* aName); michael@0: michael@0: nsRefPtr mMediaSource; michael@0: nsTArray > mSourceBuffers; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: michael@0: } // namespace mozilla michael@0: #endif /* mozilla_dom_SourceBufferList_h_ */