2012-09-18 16:07:33 -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 AudioDestinationNode_h_
|
|
|
|
#define AudioDestinationNode_h_
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2013-10-28 17:08:14 -07:00
|
|
|
#include "mozilla/dom/AudioChannelBinding.h"
|
2012-09-18 16:07:33 -07:00
|
|
|
#include "AudioNode.h"
|
2013-10-08 11:20:33 -07:00
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIAudioChannelAgent.h"
|
2013-10-11 04:55:47 -07:00
|
|
|
#include "AudioChannelCommon.h"
|
2012-09-18 16:07:33 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class AudioContext;
|
2014-07-29 08:30:40 -07:00
|
|
|
class EventProxyHandler;
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2013-04-14 18:52:55 -07:00
|
|
|
class AudioDestinationNode : public AudioNode
|
2013-10-08 11:20:33 -07:00
|
|
|
, public nsIDOMEventListener
|
|
|
|
, public nsIAudioChannelAgentCallback
|
2013-12-08 21:08:02 -08:00
|
|
|
, public MainThreadMediaStreamListener
|
2012-09-18 16:07:33 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-05-16 16:30:42 -07:00
|
|
|
// This node type knows what MediaStreamGraph to use based on
|
|
|
|
// whether it's in offline mode.
|
|
|
|
AudioDestinationNode(AudioContext* aContext,
|
|
|
|
bool aIsOffline,
|
2014-04-18 02:23:36 -07:00
|
|
|
AudioChannel aChannel = AudioChannel::Normal,
|
2013-05-16 16:30:42 -07:00
|
|
|
uint32_t aNumberOfChannels = 0,
|
|
|
|
uint32_t aLength = 0,
|
|
|
|
float aSampleRate = 0.0f);
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2013-09-09 22:05:22 -07:00
|
|
|
virtual void DestroyMediaStream() MOZ_OVERRIDE;
|
|
|
|
|
2012-09-18 16:07:33 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-10-08 11:20:33 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioDestinationNode, AudioNode)
|
2014-03-11 03:46:55 -07:00
|
|
|
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2012-09-18 16:07:33 -07:00
|
|
|
|
2013-05-05 08:48:45 -07:00
|
|
|
virtual uint16_t NumberOfOutputs() const MOZ_FINAL MOZ_OVERRIDE
|
2012-09-24 20:31:58 -07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-10 10:32:28 -07:00
|
|
|
uint32_t MaxChannelCount() const;
|
|
|
|
virtual void SetChannelCount(uint32_t aChannelCount,
|
|
|
|
ErrorResult& aRv) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-03 17:44:32 -07:00
|
|
|
void Mute();
|
|
|
|
void Unmute();
|
|
|
|
|
2013-05-16 16:30:42 -07:00
|
|
|
void StartRendering();
|
|
|
|
|
2013-09-09 22:10:53 -07:00
|
|
|
void OfflineShutdown();
|
2013-05-16 16:31:08 -07:00
|
|
|
|
2014-07-29 08:30:40 -07:00
|
|
|
// nsIDOMEventListener - by proxy
|
2013-10-08 11:20:33 -07:00
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
2013-10-11 04:55:47 -07:00
|
|
|
AudioChannel MozAudioChannelType() const;
|
|
|
|
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
|
|
|
|
|
2013-12-08 21:08:02 -08:00
|
|
|
virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
|
|
|
|
void FireOfflineCompletionEvent();
|
|
|
|
|
2014-01-15 03:08:20 -08:00
|
|
|
// An amount that should be added to the MediaStream's current time to
|
|
|
|
// get the AudioContext.currentTime.
|
|
|
|
double ExtraCurrentTime();
|
|
|
|
|
|
|
|
// When aIsOnlyNode is true, this is the only node for the AudioContext.
|
|
|
|
void SetIsOnlyNodeForContext(bool aIsOnlyNode);
|
|
|
|
|
2014-07-29 08:30:40 -07:00
|
|
|
void CreateAudioChannelAgent();
|
|
|
|
|
2014-04-13 11:08:10 -07:00
|
|
|
virtual const char* NodeType() const
|
|
|
|
{
|
|
|
|
return "AudioDestinationNode";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
|
|
|
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
|
|
|
|
2014-06-24 22:15:36 -07:00
|
|
|
void InputMuted(bool aInputMuted);
|
|
|
|
|
2014-07-08 14:23:17 -07:00
|
|
|
protected:
|
|
|
|
virtual ~AudioDestinationNode();
|
|
|
|
|
2013-05-16 16:30:42 -07:00
|
|
|
private:
|
2013-10-11 04:55:47 -07:00
|
|
|
bool CheckAudioChannelPermissions(AudioChannel aValue);
|
|
|
|
|
2013-10-08 11:20:33 -07:00
|
|
|
void SetCanPlay(bool aCanPlay);
|
|
|
|
|
2014-01-15 03:08:20 -08:00
|
|
|
void NotifyStableState();
|
|
|
|
void ScheduleStableStateNotification();
|
|
|
|
|
2013-09-09 22:10:53 -07:00
|
|
|
SelfReference<AudioDestinationNode> mOfflineRenderingRef;
|
2013-05-16 16:30:42 -07:00
|
|
|
uint32_t mFramesToProduce;
|
2013-10-08 11:20:33 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
2013-10-11 04:55:47 -07:00
|
|
|
|
2014-07-29 08:30:40 -07:00
|
|
|
nsRefPtr<EventProxyHandler> mEventProxyHelper;
|
|
|
|
|
2013-10-11 04:55:47 -07:00
|
|
|
// Audio Channel Type.
|
|
|
|
AudioChannel mAudioChannel;
|
2013-12-08 21:08:02 -08:00
|
|
|
bool mIsOffline;
|
|
|
|
bool mHasFinished;
|
2014-06-06 00:06:18 -07:00
|
|
|
bool mAudioChannelAgentPlaying;
|
2014-01-15 03:08:20 -08:00
|
|
|
|
|
|
|
TimeStamp mStartedBlockingDueToBeingOnlyNode;
|
|
|
|
double mExtraCurrentTime;
|
|
|
|
double mExtraCurrentTimeSinceLastStartedBlocking;
|
|
|
|
bool mExtraCurrentTimeUpdatedSinceLastStableState;
|
2012-09-18 16:07:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 14:39:38 -07:00
|
|
|
#endif
|
|
|
|
|