2013-01-13 14:46:57 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_AUDIONODESTREAM_H_
|
|
|
|
#define MOZILLA_AUDIONODESTREAM_H_
|
|
|
|
|
|
|
|
#include "MediaStreamGraph.h"
|
|
|
|
#include "AudioChannelFormat.h"
|
|
|
|
#include "AudioNodeEngine.h"
|
2013-01-28 14:42:27 -08:00
|
|
|
#include "mozilla/dom/AudioParam.h"
|
2013-01-13 14:46:57 -08:00
|
|
|
|
|
|
|
#ifdef PR_LOGGING
|
|
|
|
#define LOG(type, msg) PR_LOG(gMediaStreamGraphLog, type, msg)
|
|
|
|
#else
|
|
|
|
#define LOG(type, msg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2013-03-12 08:16:42 -07:00
|
|
|
namespace dom {
|
|
|
|
struct ThreeDPoint;
|
|
|
|
}
|
|
|
|
|
2013-01-13 14:46:57 -08:00
|
|
|
class ThreadSharedFloatArrayBufferList;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An AudioNodeStream produces one audio track with ID AUDIO_TRACK.
|
|
|
|
* The start time of the AudioTrack is aligned to the start time of the
|
|
|
|
* AudioContext's destination node stream, plus some multiple of BLOCK_SIZE
|
|
|
|
* samples.
|
|
|
|
*
|
|
|
|
* An AudioNodeStream has an AudioNodeEngine plugged into it that does the
|
|
|
|
* actual audio processing. AudioNodeStream contains the glue code that
|
|
|
|
* integrates audio processing with the MediaStreamGraph.
|
|
|
|
*/
|
|
|
|
class AudioNodeStream : public ProcessedMediaStream {
|
|
|
|
public:
|
|
|
|
enum { AUDIO_TRACK = 1 };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transfers ownership of aEngine to the new AudioNodeStream.
|
|
|
|
*/
|
2013-03-17 17:37:47 -07:00
|
|
|
AudioNodeStream(AudioNodeEngine* aEngine,
|
|
|
|
MediaStreamGraph::AudioNodeStreamKind aKind)
|
|
|
|
: ProcessedMediaStream(nullptr),
|
|
|
|
mEngine(aEngine),
|
|
|
|
mKind(aKind)
|
2013-01-13 14:46:57 -08:00
|
|
|
{
|
2013-03-20 04:19:39 -07:00
|
|
|
// AudioNodes are always producing data
|
|
|
|
mHasCurrentData = true;
|
2013-04-01 13:06:55 -07:00
|
|
|
MOZ_COUNT_CTOR(AudioNodeStream);
|
2013-01-13 14:46:57 -08:00
|
|
|
}
|
|
|
|
~AudioNodeStream();
|
|
|
|
|
|
|
|
// Control API
|
|
|
|
/**
|
|
|
|
* Sets a parameter that's a time relative to some stream's played time.
|
|
|
|
* This time is converted to a time relative to this stream when it's set.
|
|
|
|
*/
|
|
|
|
void SetStreamTimeParameter(uint32_t aIndex, MediaStream* aRelativeToStream,
|
|
|
|
double aStreamTime);
|
|
|
|
void SetDoubleParameter(uint32_t aIndex, double aValue);
|
|
|
|
void SetInt32Parameter(uint32_t aIndex, int32_t aValue);
|
2013-01-28 14:42:27 -08:00
|
|
|
void SetTimelineParameter(uint32_t aIndex, const dom::AudioParamTimeline& aValue);
|
2013-03-12 08:16:42 -07:00
|
|
|
void SetThreeDPointParameter(uint32_t aIndex, const dom::ThreeDPoint& aValue);
|
2013-01-13 14:46:57 -08:00
|
|
|
void SetBuffer(already_AddRefed<ThreadSharedFloatArrayBufferList> aBuffer);
|
|
|
|
|
|
|
|
virtual AudioNodeStream* AsAudioNodeStream() { return this; }
|
|
|
|
|
|
|
|
// Graph thread only
|
|
|
|
void SetStreamTimeParameterImpl(uint32_t aIndex, MediaStream* aRelativeToStream,
|
|
|
|
double aStreamTime);
|
|
|
|
virtual void ProduceOutput(GraphTime aFrom, GraphTime aTo);
|
|
|
|
TrackTicks GetCurrentPosition();
|
|
|
|
|
|
|
|
// Any thread
|
|
|
|
AudioNodeEngine* Engine() { return mEngine; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void FinishOutput();
|
|
|
|
|
|
|
|
StreamBuffer::Track* EnsureTrack();
|
|
|
|
AudioChunk* ObtainInputBlock(AudioChunk* aTmpChunk);
|
|
|
|
|
|
|
|
// The engine that will generate output for this node.
|
|
|
|
nsAutoPtr<AudioNodeEngine> mEngine;
|
|
|
|
// The last block produced by this node.
|
2013-03-17 17:37:47 -07:00
|
|
|
AudioChunk mLastChunk;
|
|
|
|
// Whether this is an internal or external stream
|
|
|
|
MediaStreamGraph::AudioNodeStreamKind mKind;
|
2013-01-13 14:46:57 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_AUDIONODESTREAM_H_ */
|