| 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 11 matching lines...) Expand all Loading... |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef MediaStreamAudioSourceNode_h | 25 #ifndef MediaStreamAudioSourceNode_h |
| 26 #define MediaStreamAudioSourceNode_h | 26 #define MediaStreamAudioSourceNode_h |
| 27 | 27 |
| 28 #include "modules/mediastream/MediaStream.h" | 28 #include "modules/mediastream/MediaStream.h" |
| 29 #include "modules/webaudio/AudioSourceNode.h" | 29 #include "modules/webaudio/AudioSourceNode.h" |
| 30 #include "platform/audio/AudioSourceProvider.h" | 30 #include "platform/audio/AudioSourceProvider.h" |
| 31 #include "platform/audio/AudioSourceProviderClient.h" | 31 #include "platform/audio/AudioSourceProviderClient.h" |
| 32 #include "wtf/OwnPtr.h" | |
| 33 #include "wtf/PassRefPtr.h" | 32 #include "wtf/PassRefPtr.h" |
| 34 #include "wtf/Threading.h" | 33 #include "wtf/Threading.h" |
| 34 #include <memory> |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 class AbstractAudioContext; | 38 class AbstractAudioContext; |
| 39 | 39 |
| 40 class MediaStreamAudioSourceHandler final : public AudioHandler { | 40 class MediaStreamAudioSourceHandler final : public AudioHandler { |
| 41 public: | 41 public: |
| 42 static PassRefPtr<MediaStreamAudioSourceHandler> create(AudioNode&, MediaStr
eam&, MediaStreamTrack*, PassOwnPtr<AudioSourceProvider>); | 42 static PassRefPtr<MediaStreamAudioSourceHandler> create(AudioNode&, MediaStr
eam&, MediaStreamTrack*, std::unique_ptr<AudioSourceProvider>); |
| 43 ~MediaStreamAudioSourceHandler() override; | 43 ~MediaStreamAudioSourceHandler() override; |
| 44 | 44 |
| 45 MediaStream* getMediaStream() { return m_mediaStream.get(); } | 45 MediaStream* getMediaStream() { return m_mediaStream.get(); } |
| 46 | 46 |
| 47 // AudioHandler | 47 // AudioHandler |
| 48 void process(size_t framesToProcess) override; | 48 void process(size_t framesToProcess) override; |
| 49 | 49 |
| 50 // A helper for AudioSourceProviderClient implementation of | 50 // A helper for AudioSourceProviderClient implementation of |
| 51 // MediaStreamAudioSourceNode. | 51 // MediaStreamAudioSourceNode. |
| 52 void setFormat(size_t numberOfChannels, float sampleRate); | 52 void setFormat(size_t numberOfChannels, float sampleRate); |
| 53 | 53 |
| 54 AudioSourceProvider* getAudioSourceProvider() const { return m_audioSourcePr
ovider.get(); } | 54 AudioSourceProvider* getAudioSourceProvider() const { return m_audioSourcePr
ovider.get(); } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 MediaStreamAudioSourceHandler(AudioNode&, MediaStream&, MediaStreamTrack*, P
assOwnPtr<AudioSourceProvider>); | 57 MediaStreamAudioSourceHandler(AudioNode&, MediaStream&, MediaStreamTrack*, s
td::unique_ptr<AudioSourceProvider>); |
| 58 // As an audio source, we will never propagate silence. | 58 // As an audio source, we will never propagate silence. |
| 59 bool propagatesSilence() const override { return false; } | 59 bool propagatesSilence() const override { return false; } |
| 60 | 60 |
| 61 // These Persistents don't make reference cycles including the owner | 61 // These Persistents don't make reference cycles including the owner |
| 62 // MediaStreamAudioSourceNode. | 62 // MediaStreamAudioSourceNode. |
| 63 Persistent<MediaStream> m_mediaStream; | 63 Persistent<MediaStream> m_mediaStream; |
| 64 Persistent<MediaStreamTrack> m_audioTrack; | 64 Persistent<MediaStreamTrack> m_audioTrack; |
| 65 OwnPtr<AudioSourceProvider> m_audioSourceProvider; | 65 std::unique_ptr<AudioSourceProvider> m_audioSourceProvider; |
| 66 | 66 |
| 67 Mutex m_processLock; | 67 Mutex m_processLock; |
| 68 | 68 |
| 69 unsigned m_sourceNumberOfChannels; | 69 unsigned m_sourceNumberOfChannels; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 class MediaStreamAudioSourceNode final : public AudioSourceNode, public AudioSou
rceProviderClient { | 72 class MediaStreamAudioSourceNode final : public AudioSourceNode, public AudioSou
rceProviderClient { |
| 73 DEFINE_WRAPPERTYPEINFO(); | 73 DEFINE_WRAPPERTYPEINFO(); |
| 74 USING_GARBAGE_COLLECTED_MIXIN(MediaStreamAudioSourceNode); | 74 USING_GARBAGE_COLLECTED_MIXIN(MediaStreamAudioSourceNode); |
| 75 public: | 75 public: |
| 76 static MediaStreamAudioSourceNode* create(AbstractAudioContext&, MediaStream
&, ExceptionState&); | 76 static MediaStreamAudioSourceNode* create(AbstractAudioContext&, MediaStream
&, ExceptionState&); |
| 77 DECLARE_VIRTUAL_TRACE(); | 77 DECLARE_VIRTUAL_TRACE(); |
| 78 MediaStreamAudioSourceHandler& mediaStreamAudioSourceHandler() const; | 78 MediaStreamAudioSourceHandler& mediaStreamAudioSourceHandler() const; |
| 79 | 79 |
| 80 MediaStream* getMediaStream() const; | 80 MediaStream* getMediaStream() const; |
| 81 | 81 |
| 82 // AudioSourceProviderClient functions: | 82 // AudioSourceProviderClient functions: |
| 83 void setFormat(size_t numberOfChannels, float sampleRate) override; | 83 void setFormat(size_t numberOfChannels, float sampleRate) override; |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 MediaStreamAudioSourceNode(AbstractAudioContext&, MediaStream&, MediaStreamT
rack*, PassOwnPtr<AudioSourceProvider>); | 86 MediaStreamAudioSourceNode(AbstractAudioContext&, MediaStream&, MediaStreamT
rack*, std::unique_ptr<AudioSourceProvider>); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace blink | 89 } // namespace blink |
| 90 | 90 |
| 91 #endif // MediaStreamAudioSourceNode_h | 91 #endif // MediaStreamAudioSourceNode_h |
| OLD | NEW |