content/media/mediasource/SourceBufferList.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/mediasource/SourceBufferList.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_SourceBufferList_h_
    1.11 +#define mozilla_dom_SourceBufferList_h_
    1.12 +
    1.13 +#include "SourceBuffer.h"
    1.14 +#include "js/RootingAPI.h"
    1.15 +#include "mozilla/Assertions.h"
    1.16 +#include "mozilla/Attributes.h"
    1.17 +#include "mozilla/DOMEventTargetHelper.h"
    1.18 +#include "nsAutoPtr.h"
    1.19 +#include "nsCycleCollectionNoteChild.h"
    1.20 +#include "nsCycleCollectionParticipant.h"
    1.21 +#include "nsISupports.h"
    1.22 +#include "nsTArray.h"
    1.23 +
    1.24 +struct JSContext;
    1.25 +class JSObject;
    1.26 +
    1.27 +namespace mozilla {
    1.28 +
    1.29 +class ErrorResult;
    1.30 +template <typename T> class AsyncEventRunner;
    1.31 +
    1.32 +namespace dom {
    1.33 +
    1.34 +class MediaSource;
    1.35 +
    1.36 +class SourceBufferList MOZ_FINAL : public DOMEventTargetHelper
    1.37 +{
    1.38 +public:
    1.39 +  /** WebIDL Methods. */
    1.40 +  SourceBuffer* IndexedGetter(uint32_t aIndex, bool& aFound);
    1.41 +
    1.42 +  uint32_t Length();
    1.43 +  /** End WebIDL methods. */
    1.44 +
    1.45 +  NS_DECL_ISUPPORTS_INHERITED
    1.46 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBufferList,
    1.47 +                                           DOMEventTargetHelper)
    1.48 +
    1.49 +  explicit SourceBufferList(MediaSource* aMediaSource);
    1.50 +
    1.51 +  MediaSource* GetParentObject() const;
    1.52 +
    1.53 +  JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.54 +
    1.55 +  // Append a SourceBuffer and fire "addsourcebuffer" at the list.
    1.56 +  void Append(SourceBuffer* aSourceBuffer);
    1.57 +
    1.58 +  // Remove a SourceBuffer and fire "removesourcebuffer" at the list.
    1.59 +  void Remove(SourceBuffer* aSourceBuffer);
    1.60 +
    1.61 +  // Returns true if aSourceBuffer is present in the list.
    1.62 +  bool Contains(SourceBuffer* aSourceBuffer);
    1.63 +
    1.64 +  // Remove all SourceBuffers and fire a single "removesourcebuffer" at the list.
    1.65 +  void Clear();
    1.66 +
    1.67 +  // True if list has zero entries.
    1.68 +  bool IsEmpty();
    1.69 +
    1.70 +  // Returns true if updating is true on any SourceBuffers in the list.
    1.71 +  bool AnyUpdating();
    1.72 +
    1.73 +  // Calls Remove(aStart, aEnd) on each SourceBuffer in the list.  Aborts on
    1.74 +  // first error, with result returned in aRv.
    1.75 +  void Remove(double aStart, double aEnd, ErrorResult& aRv);
    1.76 +
    1.77 +  // Mark all SourceBuffers input buffers as ended.
    1.78 +  void Ended();
    1.79 +
    1.80 +  // Evicts data for the given time range from each SourceBuffer in the list.
    1.81 +  void Evict(double aStart, double aEnd);
    1.82 +
    1.83 +  // Returns true if all SourceBuffers in the list contain data for the given time.
    1.84 +  bool AllContainsTime(double aTime);
    1.85 +
    1.86 +private:
    1.87 +  friend class AsyncEventRunner<SourceBufferList>;
    1.88 +  void DispatchSimpleEvent(const char* aName);
    1.89 +  void QueueAsyncSimpleEvent(const char* aName);
    1.90 +
    1.91 +  nsRefPtr<MediaSource> mMediaSource;
    1.92 +  nsTArray<nsRefPtr<SourceBuffer> > mSourceBuffers;
    1.93 +};
    1.94 +
    1.95 +} // namespace dom
    1.96 +
    1.97 +} // namespace mozilla
    1.98 +#endif /* mozilla_dom_SourceBufferList_h_ */

mercurial