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" | |
37 #include "wtf/PassOwnPtr.h" | 36 #include "wtf/PassOwnPtr.h" |
38 #include "wtf/PassRefPtr.h" | 37 #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 final : public GarbageCollectedFinali
zed<MediaStreamComponent> { | 47 class PLATFORM_EXPORT MediaStreamComponent final : public RefCounted<MediaStream
Component> { |
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 MediaStreamComponent* create(MediaStreamSource*); | 54 static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>
); |
55 static MediaStreamComponent* create(const String& id, MediaStreamSource*); | 55 static PassRefPtr<MediaStreamComponent> create(const String& id, PassRefPtr<
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 void setMuted(bool muted) { m_muted = muted; } | 63 void setMuted(bool muted) { m_muted = muted; } |
64 | 64 |
65 #if ENABLE(WEB_AUDIO) | 65 #if ENABLE(WEB_AUDIO) |
66 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } | 66 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } |
67 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } | 67 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } |
68 #endif // ENABLE(WEB_AUDIO) | 68 #endif // ENABLE(WEB_AUDIO) |
69 | 69 |
70 ExtraData* extraData() const { return m_extraData.get(); } | 70 ExtraData* extraData() const { return m_extraData.get(); } |
71 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } | 71 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } |
72 | 72 |
73 void trace(Visitor*); | |
74 void dispose(); | |
75 | |
76 private: | 73 private: |
77 MediaStreamComponent(const String& id, MediaStreamSource*); | 74 MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>); |
78 | 75 |
79 #if ENABLE(WEB_AUDIO) | 76 #if ENABLE(WEB_AUDIO) |
80 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() | 77 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() |
81 // calls into chromium to get a rendered audio stream. | 78 // calls into chromium to get a rendered audio stream. |
82 | 79 |
83 class PLATFORM_EXPORT AudioSourceProviderImpl final: public AudioSourceProvi
der { | 80 class PLATFORM_EXPORT AudioSourceProviderImpl final: public AudioSourceProvi
der { |
84 public: | 81 public: |
85 AudioSourceProviderImpl() | 82 AudioSourceProviderImpl() |
86 : m_webAudioSourceProvider(0) | 83 : m_webAudioSourceProvider(0) |
87 { | 84 { |
88 } | 85 } |
89 | 86 |
90 virtual ~AudioSourceProviderImpl() { } | 87 virtual ~AudioSourceProviderImpl() { } |
91 | 88 |
92 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. | 89 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. |
93 void wrap(WebAudioSourceProvider*); | 90 void wrap(WebAudioSourceProvider*); |
94 | 91 |
95 // blink::AudioSourceProvider | 92 // blink::AudioSourceProvider |
96 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) over
ride; | 93 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) over
ride; |
97 | 94 |
98 private: | 95 private: |
99 WebAudioSourceProvider* m_webAudioSourceProvider; | 96 WebAudioSourceProvider* m_webAudioSourceProvider; |
100 Mutex m_provideInputLock; | 97 Mutex m_provideInputLock; |
101 }; | 98 }; |
102 | 99 |
103 AudioSourceProviderImpl m_sourceProvider; | 100 AudioSourceProviderImpl m_sourceProvider; |
104 #endif // ENABLE(WEB_AUDIO) | 101 #endif // ENABLE(WEB_AUDIO) |
105 | 102 |
106 Member<MediaStreamSource> m_source; | 103 RefPtr<MediaStreamSource> m_source; |
107 String m_id; | 104 String m_id; |
108 bool m_enabled; | 105 bool m_enabled; |
109 bool m_muted; | 106 bool m_muted; |
110 OwnPtr<ExtraData> m_extraData; | 107 OwnPtr<ExtraData> m_extraData; |
111 }; | 108 }; |
112 | 109 |
113 typedef HeapVector<Member<MediaStreamComponent> > MediaStreamComponentVector; | 110 typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector; |
114 | 111 |
115 } // namespace blink | 112 } // namespace blink |
116 | 113 |
117 #endif // MediaStreamComponent_h | 114 #endif // MediaStreamComponent_h |
OLD | NEW |