content/media/mediasource/MediaSource.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/mediasource/MediaSource.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     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_MediaSource_h_
    1.11 +#define mozilla_dom_MediaSource_h_
    1.12 +
    1.13 +#include "MediaSourceDecoder.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 "mozilla/dom/MediaSourceBinding.h"
    1.19 +#include "nsAutoPtr.h"
    1.20 +#include "nsCOMPtr.h"
    1.21 +#include "nsCycleCollectionNoteChild.h"
    1.22 +#include "nsCycleCollectionParticipant.h"
    1.23 +#include "nsID.h"
    1.24 +#include "nsISupports.h"
    1.25 +#include "nscore.h"
    1.26 +
    1.27 +struct JSContext;
    1.28 +class JSObject;
    1.29 +class nsPIDOMWindow;
    1.30 +
    1.31 +namespace mozilla {
    1.32 +
    1.33 +class ErrorResult;
    1.34 +template <typename T> class AsyncEventRunner;
    1.35 +
    1.36 +namespace dom {
    1.37 +
    1.38 +class GlobalObject;
    1.39 +class SourceBuffer;
    1.40 +class SourceBufferList;
    1.41 +template <typename T> class Optional;
    1.42 +
    1.43 +#define MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID \
    1.44 +  { 0x3839d699, 0x22c5, 0x439f, \
    1.45 +  { 0x94, 0xca, 0x0e, 0x0b, 0x26, 0xf9, 0xca, 0xbf } }
    1.46 +
    1.47 +class MediaSource MOZ_FINAL : public DOMEventTargetHelper
    1.48 +{
    1.49 +public:
    1.50 +  /** WebIDL Methods. */
    1.51 +  static already_AddRefed<MediaSource>
    1.52 +  Constructor(const GlobalObject& aGlobal,
    1.53 +              ErrorResult& aRv);
    1.54 +
    1.55 +  SourceBufferList* SourceBuffers();
    1.56 +  SourceBufferList* ActiveSourceBuffers();
    1.57 +  MediaSourceReadyState ReadyState();
    1.58 +
    1.59 +  double Duration();
    1.60 +  void SetDuration(double aDuration, ErrorResult& aRv);
    1.61 +
    1.62 +  already_AddRefed<SourceBuffer> AddSourceBuffer(const nsAString& aType, ErrorResult& aRv);
    1.63 +  void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
    1.64 +
    1.65 +  void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
    1.66 +  static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
    1.67 +  /** End WebIDL Methods. */
    1.68 +
    1.69 +  NS_DECL_ISUPPORTS_INHERITED
    1.70 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaSource, DOMEventTargetHelper)
    1.71 +  NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
    1.72 +
    1.73 +  nsPIDOMWindow* GetParentObject() const;
    1.74 +
    1.75 +  JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.76 +
    1.77 +  // Attach this MediaSource to Decoder aDecoder.  Returns false if already attached.
    1.78 +  bool Attach(MediaSourceDecoder* aDecoder);
    1.79 +  void Detach();
    1.80 +
    1.81 +  // Set mReadyState to aState and fire the required events at the MediaSource.
    1.82 +  void SetReadyState(MediaSourceReadyState aState);
    1.83 +
    1.84 + // Used by SourceBuffer to call CreateSubDecoder.
    1.85 +  MediaSourceDecoder* GetDecoder()
    1.86 +  {
    1.87 +    return mDecoder;
    1.88 +  }
    1.89 +
    1.90 +  // Called by SourceBuffers to notify this MediaSource that data has
    1.91 +  // been evicted from the buffered data. The start and end times
    1.92 +  // that were evicted are provided.
    1.93 +  void NotifyEvicted(double aStart, double aEnd);
    1.94 +
    1.95 +private:
    1.96 +  explicit MediaSource(nsPIDOMWindow* aWindow);
    1.97 +
    1.98 +  friend class AsyncEventRunner<MediaSource>;
    1.99 +  void DispatchSimpleEvent(const char* aName);
   1.100 +  void QueueAsyncSimpleEvent(const char* aName);
   1.101 +
   1.102 +  void DurationChange(double aNewDuration, ErrorResult& aRv);
   1.103 +
   1.104 +  double mDuration;
   1.105 +
   1.106 +  nsRefPtr<SourceBufferList> mSourceBuffers;
   1.107 +  nsRefPtr<SourceBufferList> mActiveSourceBuffers;
   1.108 +
   1.109 +  nsRefPtr<MediaSourceDecoder> mDecoder;
   1.110 +
   1.111 +  MediaSourceReadyState mReadyState;
   1.112 +};
   1.113 +
   1.114 +NS_DEFINE_STATIC_IID_ACCESSOR(MediaSource, MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
   1.115 +
   1.116 +} // namespace dom
   1.117 +
   1.118 +} // namespace mozilla
   1.119 +#endif /* mozilla_dom_MediaSource_h_ */

mercurial