content/media/mediasource/SourceBufferList.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_SourceBufferList_h_
     8 #define mozilla_dom_SourceBufferList_h_
    10 #include "SourceBuffer.h"
    11 #include "js/RootingAPI.h"
    12 #include "mozilla/Assertions.h"
    13 #include "mozilla/Attributes.h"
    14 #include "mozilla/DOMEventTargetHelper.h"
    15 #include "nsAutoPtr.h"
    16 #include "nsCycleCollectionNoteChild.h"
    17 #include "nsCycleCollectionParticipant.h"
    18 #include "nsISupports.h"
    19 #include "nsTArray.h"
    21 struct JSContext;
    22 class JSObject;
    24 namespace mozilla {
    26 class ErrorResult;
    27 template <typename T> class AsyncEventRunner;
    29 namespace dom {
    31 class MediaSource;
    33 class SourceBufferList MOZ_FINAL : public DOMEventTargetHelper
    34 {
    35 public:
    36   /** WebIDL Methods. */
    37   SourceBuffer* IndexedGetter(uint32_t aIndex, bool& aFound);
    39   uint32_t Length();
    40   /** End WebIDL methods. */
    42   NS_DECL_ISUPPORTS_INHERITED
    43   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBufferList,
    44                                            DOMEventTargetHelper)
    46   explicit SourceBufferList(MediaSource* aMediaSource);
    48   MediaSource* GetParentObject() const;
    50   JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    52   // Append a SourceBuffer and fire "addsourcebuffer" at the list.
    53   void Append(SourceBuffer* aSourceBuffer);
    55   // Remove a SourceBuffer and fire "removesourcebuffer" at the list.
    56   void Remove(SourceBuffer* aSourceBuffer);
    58   // Returns true if aSourceBuffer is present in the list.
    59   bool Contains(SourceBuffer* aSourceBuffer);
    61   // Remove all SourceBuffers and fire a single "removesourcebuffer" at the list.
    62   void Clear();
    64   // True if list has zero entries.
    65   bool IsEmpty();
    67   // Returns true if updating is true on any SourceBuffers in the list.
    68   bool AnyUpdating();
    70   // Calls Remove(aStart, aEnd) on each SourceBuffer in the list.  Aborts on
    71   // first error, with result returned in aRv.
    72   void Remove(double aStart, double aEnd, ErrorResult& aRv);
    74   // Mark all SourceBuffers input buffers as ended.
    75   void Ended();
    77   // Evicts data for the given time range from each SourceBuffer in the list.
    78   void Evict(double aStart, double aEnd);
    80   // Returns true if all SourceBuffers in the list contain data for the given time.
    81   bool AllContainsTime(double aTime);
    83 private:
    84   friend class AsyncEventRunner<SourceBufferList>;
    85   void DispatchSimpleEvent(const char* aName);
    86   void QueueAsyncSimpleEvent(const char* aName);
    88   nsRefPtr<MediaSource> mMediaSource;
    89   nsTArray<nsRefPtr<SourceBuffer> > mSourceBuffers;
    90 };
    92 } // namespace dom
    94 } // namespace mozilla
    95 #endif /* mozilla_dom_SourceBufferList_h_ */

mercurial