2012-09-18 23:07:33 +00: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 21:39:38 +00:00
|
|
|
#ifndef AudioDestinationNode_h_
|
|
|
|
#define AudioDestinationNode_h_
|
2012-09-18 23:07:33 +00:00
|
|
|
|
2013-10-29 00:08:14 +00:00
|
|
|
#include "mozilla/dom/AudioChannelBinding.h"
|
2012-09-18 23:07:33 +00:00
|
|
|
#include "AudioNode.h"
|
2013-10-08 18:20:33 +00:00
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIAudioChannelAgent.h"
|
2013-10-11 11:55:47 +00:00
|
|
|
#include "AudioChannelCommon.h"
|
2012-09-18 23:07:33 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class AudioContext;
|
|
|
|
|
2013-04-15 01:52:55 +00:00
|
|
|
class AudioDestinationNode : public AudioNode
|
2013-10-08 18:20:33 +00:00
|
|
|
, public nsIDOMEventListener
|
|
|
|
, public nsIAudioChannelAgentCallback
|
2013-12-09 05:08:02 +00:00
|
|
|
, public MainThreadMediaStreamListener
|
2012-09-18 23:07:33 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-05-16 23:30:42 +00: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 09:23:36 +00:00
|
|
|
AudioChannel aChannel = AudioChannel::Normal,
|
2013-05-16 23:30:42 +00:00
|
|
|
uint32_t aNumberOfChannels = 0,
|
|
|
|
uint32_t aLength = 0,
|
|
|
|
float aSampleRate = 0.0f);
|
2012-09-18 23:07:33 +00:00
|
|
|
|
2013-09-10 05:05:22 +00:00
|
|
|
virtual void DestroyMediaStream() MOZ_OVERRIDE;
|
|
|
|
|
2012-09-18 23:07:33 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2013-10-08 18:20:33 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioDestinationNode, AudioNode)
|
2014-03-11 10:46:55 +00:00
|
|
|
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
2012-09-18 23:07:33 +00:00
|
|
|
|
2014-04-08 22:27:18 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2012-09-18 23:07:33 +00:00
|
|
|
|
2013-05-05 15:48:45 +00:00
|
|
|
virtual uint16_t NumberOfOutputs() const MOZ_FINAL MOZ_OVERRIDE
|
2012-09-25 03:31:58 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-10 17:32:28 +00:00
|
|
|
uint32_t MaxChannelCount() const;
|
|
|
|
virtual void SetChannelCount(uint32_t aChannelCount,
|
|
|
|
ErrorResult& aRv) MOZ_OVERRIDE;
|
|
|
|
|
2013-07-04 00:44:32 +00:00
|
|
|
void Mute();
|
|
|
|
void Unmute();
|
|
|
|
|
2013-05-16 23:30:42 +00:00
|
|
|
void StartRendering();
|
|
|
|
|
2013-09-10 05:10:53 +00:00
|
|
|
void OfflineShutdown();
|
2013-05-16 23:31:08 +00:00
|
|
|
|
2013-10-08 18:20:33 +00:00
|
|
|
// nsIDOMEventListener
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
2013-10-11 11:55:47 +00:00
|
|
|
AudioChannel MozAudioChannelType() const;
|
|
|
|
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
|
|
|
|
|
2013-12-09 05:08:02 +00:00
|
|
|
virtual void NotifyMainThreadStateChanged() MOZ_OVERRIDE;
|
|
|
|
void FireOfflineCompletionEvent();
|
|
|
|
|
2014-01-15 11:08:20 +00: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-04-13 18:08:10 +00: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-25 05:15:36 +00:00
|
|
|
void InputMuted(bool aInputMuted);
|
|
|
|
|
2014-07-08 21:23:17 +00:00
|
|
|
protected:
|
|
|
|
virtual ~AudioDestinationNode();
|
|
|
|
|
2013-05-16 23:30:42 +00:00
|
|
|
private:
|
2013-10-11 11:55:47 +00:00
|
|
|
bool CheckAudioChannelPermissions(AudioChannel aValue);
|
|
|
|
void CreateAudioChannelAgent();
|
|
|
|
|
2013-10-08 18:20:33 +00:00
|
|
|
void SetCanPlay(bool aCanPlay);
|
|
|
|
|
2014-01-15 11:08:20 +00:00
|
|
|
void NotifyStableState();
|
|
|
|
void ScheduleStableStateNotification();
|
|
|
|
|
2013-09-10 05:10:53 +00:00
|
|
|
SelfReference<AudioDestinationNode> mOfflineRenderingRef;
|
2013-05-16 23:30:42 +00:00
|
|
|
uint32_t mFramesToProduce;
|
2013-10-08 18:20:33 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
2013-10-11 11:55:47 +00:00
|
|
|
|
|
|
|
// Audio Channel Type.
|
|
|
|
AudioChannel mAudioChannel;
|
2013-12-09 05:08:02 +00:00
|
|
|
bool mIsOffline;
|
|
|
|
bool mHasFinished;
|
2014-06-06 07:06:18 +00:00
|
|
|
bool mAudioChannelAgentPlaying;
|
2014-01-15 11:08:20 +00:00
|
|
|
|
|
|
|
TimeStamp mStartedBlockingDueToBeingOnlyNode;
|
|
|
|
double mExtraCurrentTime;
|
|
|
|
double mExtraCurrentTimeSinceLastStartedBlocking;
|
|
|
|
bool mExtraCurrentTimeUpdatedSinceLastStableState;
|
2012-09-18 23:07:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 21:39:38 +00:00
|
|
|
#endif
|
|
|
|
|