| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #ifndef MediaStreamComponent_h | 32 #ifndef MediaStreamComponent_h |
| 33 #define MediaStreamComponent_h | 33 #define MediaStreamComponent_h |
| 34 | 34 |
| 35 #include "platform/audio/AudioSourceProvider.h" | 35 #include "platform/audio/AudioSourceProvider.h" |
| 36 #include "platform/heap/Handle.h" |
| 36 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 37 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
| 38 #include "wtf/RefCounted.h" | |
| 39 #include "wtf/ThreadingPrimitives.h" | 39 #include "wtf/ThreadingPrimitives.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class MediaStreamSource; | 44 class MediaStreamSource; |
| 45 class WebAudioSourceProvider; | 45 class WebAudioSourceProvider; |
| 46 | 46 |
| 47 class PLATFORM_EXPORT MediaStreamComponent : public RefCounted<MediaStreamCompon
ent> { | 47 class PLATFORM_EXPORT MediaStreamComponent FINAL : public GarbageCollectedFinali
zed<MediaStreamComponent> { |
| 48 public: | 48 public: |
| 49 class ExtraData { | 49 class ExtraData { |
| 50 public: | 50 public: |
| 51 virtual ~ExtraData() { } | 51 virtual ~ExtraData() { } |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>
); | 54 static MediaStreamComponent* create(MediaStreamSource*); |
| 55 static PassRefPtr<MediaStreamComponent> create(const String& id, PassRefPtr<
MediaStreamSource>); | 55 static MediaStreamComponent* create(const String& id, MediaStreamSource*); |
| 56 | 56 |
| 57 MediaStreamSource* source() const { return m_source.get(); } | 57 MediaStreamSource* source() const { return m_source.get(); } |
| 58 | 58 |
| 59 String id() const { return m_id; } | 59 String id() const { return m_id; } |
| 60 bool enabled() const { return m_enabled; } | 60 bool enabled() const { return m_enabled; } |
| 61 void setEnabled(bool enabled) { m_enabled = enabled; } | 61 void setEnabled(bool enabled) { m_enabled = enabled; } |
| 62 bool muted() const { return m_muted; } | 62 bool muted() const { return m_muted; } |
| 63 | 63 |
| 64 #if ENABLE(WEB_AUDIO) | 64 #if ENABLE(WEB_AUDIO) |
| 65 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } | 65 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } |
| 66 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } | 66 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } |
| 67 #endif // ENABLE(WEB_AUDIO) | 67 #endif // ENABLE(WEB_AUDIO) |
| 68 | 68 |
| 69 ExtraData* extraData() const { return m_extraData.get(); } | 69 ExtraData* extraData() const { return m_extraData.get(); } |
| 70 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } | 70 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } |
| 71 | 71 |
| 72 void trace(Visitor*); |
| 73 void dispose(); |
| 74 |
| 72 private: | 75 private: |
| 73 MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>); | 76 MediaStreamComponent(const String& id, MediaStreamSource*); |
| 74 | 77 |
| 75 #if ENABLE(WEB_AUDIO) | 78 #if ENABLE(WEB_AUDIO) |
| 76 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() | 79 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() |
| 77 // calls into chromium to get a rendered audio stream. | 80 // calls into chromium to get a rendered audio stream. |
| 78 | 81 |
| 79 class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvi
der { | 82 class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvi
der { |
| 80 public: | 83 public: |
| 81 AudioSourceProviderImpl() | 84 AudioSourceProviderImpl() |
| 82 : m_webAudioSourceProvider(0) | 85 : m_webAudioSourceProvider(0) |
| 83 { | 86 { |
| 84 } | 87 } |
| 85 | 88 |
| 86 virtual ~AudioSourceProviderImpl() { } | 89 virtual ~AudioSourceProviderImpl() { } |
| 87 | 90 |
| 88 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. | 91 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. |
| 89 void wrap(WebAudioSourceProvider*); | 92 void wrap(WebAudioSourceProvider*); |
| 90 | 93 |
| 91 // blink::AudioSourceProvider | 94 // blink::AudioSourceProvider |
| 92 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) OVER
RIDE; | 95 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) OVER
RIDE; |
| 93 | 96 |
| 94 private: | 97 private: |
| 95 WebAudioSourceProvider* m_webAudioSourceProvider; | 98 WebAudioSourceProvider* m_webAudioSourceProvider; |
| 96 Mutex m_provideInputLock; | 99 Mutex m_provideInputLock; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 AudioSourceProviderImpl m_sourceProvider; | 102 AudioSourceProviderImpl m_sourceProvider; |
| 100 #endif // ENABLE(WEB_AUDIO) | 103 #endif // ENABLE(WEB_AUDIO) |
| 101 | 104 |
| 102 RefPtr<MediaStreamSource> m_source; | 105 Member<MediaStreamSource> m_source; |
| 103 String m_id; | 106 String m_id; |
| 104 bool m_enabled; | 107 bool m_enabled; |
| 105 bool m_muted; | 108 bool m_muted; |
| 106 OwnPtr<ExtraData> m_extraData; | 109 OwnPtr<ExtraData> m_extraData; |
| 107 }; | 110 }; |
| 108 | 111 |
| 109 typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector; | 112 typedef HeapVector<Member<MediaStreamComponent> > MediaStreamComponentVector; |
| 110 | 113 |
| 111 } // namespace blink | 114 } // namespace blink |
| 112 | 115 |
| 113 #endif // MediaStreamComponent_h | 116 #endif // MediaStreamComponent_h |
| OLD | NEW |