This source file includes following definitions.
- create
- create
- m_enabled
- wrap
- provideInput
#include "config.h"
#include "platform/mediastream/MediaStreamComponent.h"
#include "platform/UUID.h"
#include "platform/audio/AudioBus.h"
#include "platform/mediastream/MediaStreamSource.h"
#include "public/platform/WebAudioSourceProvider.h"
namespace WebCore {
PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(PassRefPtr<MediaStreamSource> source)
{
return adoptRef(new MediaStreamComponent(createCanonicalUUIDString(), source));
}
PassRefPtr<MediaStreamComponent> MediaStreamComponent::create(const String& id, PassRefPtr<MediaStreamSource> source)
{
return adoptRef(new MediaStreamComponent(id, source));
}
MediaStreamComponent::MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource> source)
: m_source(source)
, m_id(id)
, m_enabled(true)
{
ASSERT(m_id.length());
}
#if ENABLE(WEB_AUDIO)
void MediaStreamComponent::AudioSourceProviderImpl::wrap(blink::WebAudioSourceProvider* provider)
{
MutexLocker locker(m_provideInputLock);
m_webAudioSourceProvider = provider;
}
void MediaStreamComponent::AudioSourceProviderImpl::provideInput(AudioBus* bus, size_t framesToProcess)
{
ASSERT(bus);
if (!bus)
return;
MutexTryLocker tryLocker(m_provideInputLock);
if (!tryLocker.locked() || !m_webAudioSourceProvider) {
bus->zero();
return;
}
size_t n = bus->numberOfChannels();
blink::WebVector<float*> webAudioData(n);
for (size_t i = 0; i < n; ++i)
webAudioData[i] = bus->channel(i)->mutableData();
m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
}
#endif
}