| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #if ENABLE(WEB_AUDIO) | 27 #if ENABLE(WEB_AUDIO) |
| 28 | 28 |
| 29 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" | 29 #include "modules/webaudio/MediaStreamAudioDestinationNode.h" |
| 30 | 30 |
| 31 #include "core/platform/UUID.h" | 31 #include "core/platform/UUID.h" |
| 32 #include "core/platform/mediastream/MediaStreamCenter.h" | 32 #include "core/platform/mediastream/MediaStreamCenter.h" |
| 33 #include "core/platform/mediastream/RTCPeerConnectionHandler.h" | 33 #include "core/platform/mediastream/RTCPeerConnectionHandler.h" |
| 34 #include "modules/mediastream/MediaStream.h" | 34 #include "modules/mediastream/MediaStream.h" |
| 35 #include "modules/webaudio/AudioContext.h" | 35 #include "modules/webaudio/AudioContext.h" |
| 36 #include "modules/webaudio/AudioNodeInput.h" | 36 #include "modules/webaudio/AudioNodeInput.h" |
| 37 #include "public/platform/WebMediaStream.h" | |
| 38 #include "public/platform/WebMediaStreamSource.h" | |
| 39 #include "public/platform/WebMediaStreamTrack.h" | |
| 40 #include "wtf/Locker.h" | 37 #include "wtf/Locker.h" |
| 41 | 38 |
| 42 namespace WebCore { | 39 namespace WebCore { |
| 43 | 40 |
| 44 PassRefPtr<MediaStreamAudioDestinationNode> MediaStreamAudioDestinationNode::cre
ate(AudioContext* context, size_t numberOfChannels) | 41 PassRefPtr<MediaStreamAudioDestinationNode> MediaStreamAudioDestinationNode::cre
ate(AudioContext* context, size_t numberOfChannels) |
| 45 { | 42 { |
| 46 return adoptRef(new MediaStreamAudioDestinationNode(context, numberOfChannel
s)); | 43 return adoptRef(new MediaStreamAudioDestinationNode(context, numberOfChannel
s)); |
| 47 } | 44 } |
| 48 | 45 |
| 49 MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext* c
ontext, size_t numberOfChannels) | 46 MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext* c
ontext, size_t numberOfChannels) |
| 50 : AudioBasicInspectorNode(context, context->sampleRate(), numberOfChannels) | 47 : AudioBasicInspectorNode(context, context->sampleRate(), numberOfChannels) |
| 51 , m_mixBus(AudioBus::create(numberOfChannels, ProcessingSizeInFrames)) | 48 , m_mixBus(AudioBus::create(numberOfChannels, ProcessingSizeInFrames)) |
| 52 { | 49 { |
| 53 ScriptWrappable::init(this); | 50 ScriptWrappable::init(this); |
| 54 setNodeType(NodeTypeMediaStreamAudioDestination); | 51 setNodeType(NodeTypeMediaStreamAudioDestination); |
| 55 | 52 |
| 56 m_source = MediaStreamSource::create(ASCIILiteral("WebAudio-") + createCanon
icalUUIDString(), MediaStreamSource::TypeAudio, "MediaStreamAudioDestinationNode
", MediaStreamSource::ReadyStateLive, true); | 53 m_source = MediaStreamSource::create(ASCIILiteral("WebAudio-") + createCanon
icalUUIDString(), MediaStreamSource::TypeAudio, "MediaStreamAudioDestinationNode
", MediaStreamSource::ReadyStateLive, true); |
| 57 MediaStreamSourceVector audioSources; | 54 MediaStreamSourceVector audioSources; |
| 58 audioSources.append(m_source); | 55 audioSources.append(m_source); |
| 59 MediaStreamSourceVector videoSources; | 56 MediaStreamSourceVector videoSources; |
| 60 WebKit::WebMediaStream webStream = WebKit::WebMediaStream(createCanonicalUUI
DString(), audioSources, videoSources); | 57 m_stream = MediaStream::create(context->scriptExecutionContext(), MediaStrea
mDescriptor::create(audioSources, videoSources)); |
| 61 m_stream = MediaStream::create(context->scriptExecutionContext(), webStream)
; | 58 MediaStreamCenter::instance().didCreateMediaStream(m_stream->descriptor()); |
| 62 MediaStreamCenter::instance().didCreateMediaStream(m_stream->webStream()); | |
| 63 | 59 |
| 64 m_source->setAudioFormat(numberOfChannels, context->sampleRate()); | 60 m_source->setAudioFormat(numberOfChannels, context->sampleRate()); |
| 65 | 61 |
| 66 initialize(); | 62 initialize(); |
| 67 } | 63 } |
| 68 | 64 |
| 69 MediaStreamSource* MediaStreamAudioDestinationNode::mediaStreamSource() | 65 MediaStreamSource* MediaStreamAudioDestinationNode::mediaStreamSource() |
| 70 { | 66 { |
| 71 return m_source.get(); | 67 return m_source.get(); |
| 72 } | 68 } |
| 73 | 69 |
| 74 MediaStreamAudioDestinationNode::~MediaStreamAudioDestinationNode() | 70 MediaStreamAudioDestinationNode::~MediaStreamAudioDestinationNode() |
| 75 { | 71 { |
| 76 uninitialize(); | 72 uninitialize(); |
| 77 } | 73 } |
| 78 | 74 |
| 79 void MediaStreamAudioDestinationNode::process(size_t numberOfFrames) | 75 void MediaStreamAudioDestinationNode::process(size_t numberOfFrames) |
| 80 { | 76 { |
| 81 m_mixBus->copyFrom(*input(0)->bus()); | 77 m_mixBus->copyFrom(*input(0)->bus()); |
| 82 m_source->consumeAudio(m_mixBus.get(), numberOfFrames); | 78 m_source->consumeAudio(m_mixBus.get(), numberOfFrames); |
| 83 } | 79 } |
| 84 | 80 |
| 85 void MediaStreamAudioDestinationNode::reset() | 81 void MediaStreamAudioDestinationNode::reset() |
| 86 { | 82 { |
| 87 } | 83 } |
| 88 | 84 |
| 89 } // namespace WebCore | 85 } // namespace WebCore |
| 90 | 86 |
| 91 #endif // ENABLE(WEB_AUDIO) | 87 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |