#ifndef MediaStreamComponent_h
#define MediaStreamComponent_h
#include "platform/audio/AudioSourceProvider.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/ThreadingPrimitives.h"
#include "wtf/text/WTFString.h"
namespace blink {
class WebAudioSourceProvider;
}
namespace WebCore {
class MediaStreamDescriptor;
class MediaStreamSource;
class PLATFORM_EXPORT MediaStreamComponent : public RefCounted<MediaStreamComponent> {
public:
class ExtraData {
public:
virtual ~ExtraData() { }
};
static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>);
static PassRefPtr<MediaStreamComponent> create(const String& id, PassRefPtr<MediaStreamSource>);
MediaStreamSource* source() const { return m_source.get(); }
String id() const { return m_id; }
bool enabled() const { return m_enabled; }
void setEnabled(bool enabled) { m_enabled = enabled; }
#if ENABLE(WEB_AUDIO)
AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; }
void setSourceProvider(blink::WebAudioSourceProvider* provider) { m_sourceProvider.wrap(provider); }
#endif
ExtraData* extraData() const { return m_extraData.get(); }
void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData; }
private:
MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>);
#if ENABLE(WEB_AUDIO)
class AudioSourceProviderImpl FINAL: public AudioSourceProvider {
public:
AudioSourceProviderImpl()
: m_webAudioSourceProvider(0)
{
}
virtual ~AudioSourceProviderImpl() { }
void wrap(blink::WebAudioSourceProvider*);
virtual void provideInput(WebCore::AudioBus*, size_t framesToProcess) OVERRIDE;
private:
blink::WebAudioSourceProvider* m_webAudioSourceProvider;
Mutex m_provideInputLock;
};
AudioSourceProviderImpl m_sourceProvider;
#endif
RefPtr<MediaStreamSource> m_source;
String m_id;
bool m_enabled;
OwnPtr<ExtraData> m_extraData;
};
typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector;
}
#endif