2012-08-31 13:59:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2012-10-30 14:39:38 -07:00
|
|
|
#ifndef AudioContext_h_
|
|
|
|
#define AudioContext_h_
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2012-08-31 13:59:37 -07:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2012-09-07 15:13:26 -07:00
|
|
|
#include "EnableWebAudioCheck.h"
|
2012-09-18 16:07:33 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2013-02-01 14:13:23 -08:00
|
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "mozilla/dom/AudioContextBinding.h"
|
|
|
|
#include "MediaBufferDecoder.h"
|
2013-02-04 15:07:25 -08:00
|
|
|
#include "StreamBuffer.h"
|
|
|
|
#include "MediaStreamGraph.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2012-08-31 13:59:37 -07:00
|
|
|
|
2012-11-14 18:38:26 -08:00
|
|
|
struct JSContext;
|
2013-02-01 15:11:25 -08:00
|
|
|
class JSObject;
|
2012-08-31 13:59:37 -07:00
|
|
|
class nsIDOMWindow;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
2013-02-01 14:13:23 -08:00
|
|
|
struct WebAudioDecodeJob;
|
2012-08-31 13:59:37 -07:00
|
|
|
|
2012-09-07 15:13:26 -07:00
|
|
|
namespace dom {
|
|
|
|
|
2012-09-21 15:42:14 -07:00
|
|
|
class AudioBuffer;
|
2012-11-05 16:26:03 -08:00
|
|
|
class AudioBufferSourceNode;
|
|
|
|
class AudioDestinationNode;
|
|
|
|
class AudioListener;
|
2012-11-07 17:59:14 -08:00
|
|
|
class BiquadFilterNode;
|
2012-10-31 17:26:03 -07:00
|
|
|
class DelayNode;
|
2012-11-06 17:01:11 -08:00
|
|
|
class DynamicsCompressorNode;
|
2012-11-05 16:26:03 -08:00
|
|
|
class GainNode;
|
2012-12-03 08:07:49 -08:00
|
|
|
class GlobalObject;
|
2012-11-05 18:14:13 -08:00
|
|
|
class PannerNode;
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2012-10-09 11:50:26 -07:00
|
|
|
class AudioContext MOZ_FINAL : public nsWrapperCache,
|
2012-09-07 15:13:26 -07:00
|
|
|
public EnableWebAudioCheck
|
2012-08-31 13:59:37 -07:00
|
|
|
{
|
|
|
|
explicit AudioContext(nsIDOMWindow* aParentWindow);
|
2013-02-04 15:07:25 -08:00
|
|
|
~AudioContext();
|
2012-08-31 13:59:37 -07:00
|
|
|
|
|
|
|
public:
|
2012-10-09 11:50:26 -07:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AudioContext)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AudioContext)
|
2012-08-31 13:59:37 -07:00
|
|
|
|
|
|
|
nsIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mWindow;
|
|
|
|
}
|
|
|
|
|
2013-02-01 14:13:23 -08:00
|
|
|
void Shutdown()
|
|
|
|
{
|
|
|
|
mDecoder.Shutdown();
|
|
|
|
}
|
2012-11-23 15:33:41 -08:00
|
|
|
|
2012-08-31 13:59:37 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
|
|
|
|
bool* aTriedToWrap);
|
|
|
|
|
|
|
|
static already_AddRefed<AudioContext>
|
2012-12-03 08:07:49 -08:00
|
|
|
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
2012-08-31 13:59:37 -07:00
|
|
|
|
2012-09-18 16:07:33 -07:00
|
|
|
AudioDestinationNode* Destination() const
|
|
|
|
{
|
|
|
|
return mDestination;
|
|
|
|
}
|
|
|
|
|
2012-11-29 19:31:39 -08:00
|
|
|
float SampleRate() const
|
|
|
|
{
|
2013-02-04 15:07:25 -08:00
|
|
|
return float(IdealAudioRate());
|
2012-11-29 19:31:39 -08:00
|
|
|
}
|
|
|
|
|
2012-11-05 16:26:03 -08:00
|
|
|
AudioListener* Listener();
|
|
|
|
|
2012-09-18 16:07:33 -07:00
|
|
|
already_AddRefed<AudioBufferSourceNode> CreateBufferSource();
|
|
|
|
|
2012-09-21 15:42:14 -07:00
|
|
|
already_AddRefed<AudioBuffer>
|
|
|
|
CreateBuffer(JSContext* aJSContext, uint32_t aNumberOfChannels,
|
|
|
|
uint32_t aLength, float aSampleRate,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2012-10-31 12:09:32 -07:00
|
|
|
already_AddRefed<GainNode>
|
|
|
|
CreateGain();
|
|
|
|
|
2012-10-31 17:26:03 -07:00
|
|
|
already_AddRefed<DelayNode>
|
2012-11-19 12:52:29 -08:00
|
|
|
CreateDelay(double aMaxDelayTime, ErrorResult& aRv);
|
2012-10-31 17:26:03 -07:00
|
|
|
|
2012-11-05 18:14:13 -08:00
|
|
|
already_AddRefed<PannerNode>
|
|
|
|
CreatePanner();
|
|
|
|
|
2012-11-06 17:01:11 -08:00
|
|
|
already_AddRefed<DynamicsCompressorNode>
|
|
|
|
CreateDynamicsCompressor();
|
|
|
|
|
2012-11-07 17:59:14 -08:00
|
|
|
already_AddRefed<BiquadFilterNode>
|
|
|
|
CreateBiquadFilter();
|
|
|
|
|
2013-02-01 14:13:23 -08:00
|
|
|
void DecodeAudioData(const ArrayBuffer& aBuffer,
|
|
|
|
DecodeSuccessCallback& aSuccessCallback,
|
|
|
|
const Optional<OwningNonNull<DecodeErrorCallback> >& aFailureCallback);
|
|
|
|
|
2013-02-04 15:07:25 -08:00
|
|
|
uint32_t GetRate() const { return IdealAudioRate(); }
|
|
|
|
|
|
|
|
MediaStreamGraph* Graph() const;
|
|
|
|
MediaStream* DestinationStream() const;
|
|
|
|
|
2013-02-01 14:13:23 -08:00
|
|
|
private:
|
|
|
|
void RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob);
|
|
|
|
|
|
|
|
friend struct ::mozilla::WebAudioDecodeJob;
|
|
|
|
|
2012-08-31 13:59:37 -07:00
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
2012-09-18 16:07:33 -07:00
|
|
|
nsRefPtr<AudioDestinationNode> mDestination;
|
2012-11-05 16:26:03 -08:00
|
|
|
nsRefPtr<AudioListener> mListener;
|
2013-02-01 14:13:23 -08:00
|
|
|
MediaBufferDecoder mDecoder;
|
|
|
|
nsTArray<nsAutoPtr<WebAudioDecodeJob> > mDecodeJobs;
|
2012-08-31 13:59:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2012-09-07 15:13:26 -07:00
|
|
|
}
|
2012-08-31 13:59:37 -07:00
|
|
|
|
2012-10-30 14:39:38 -07:00
|
|
|
#endif
|
|
|
|
|