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 : public RefCounted<MediaStreamCompon
ent> { |
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 | 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 | |
75 private: | 72 private: |
76 MediaStreamComponent(const String& id, MediaStreamSource*); | 73 MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>); |
77 | 74 |
78 #if ENABLE(WEB_AUDIO) | 75 #if ENABLE(WEB_AUDIO) |
79 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() | 76 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() |
80 // calls into chromium to get a rendered audio stream. | 77 // calls into chromium to get a rendered audio stream. |
81 | 78 |
82 class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvi
der { | 79 class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvi
der { |
83 public: | 80 public: |
84 AudioSourceProviderImpl() | 81 AudioSourceProviderImpl() |
85 : m_webAudioSourceProvider(0) | 82 : m_webAudioSourceProvider(0) |
86 { | 83 { |
87 } | 84 } |
88 | 85 |
89 virtual ~AudioSourceProviderImpl() { } | 86 virtual ~AudioSourceProviderImpl() { } |
90 | 87 |
91 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. | 88 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. |
92 void wrap(WebAudioSourceProvider*); | 89 void wrap(WebAudioSourceProvider*); |
93 | 90 |
94 // blink::AudioSourceProvider | 91 // blink::AudioSourceProvider |
95 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) OVER
RIDE; | 92 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) OVER
RIDE; |
96 | 93 |
97 private: | 94 private: |
98 WebAudioSourceProvider* m_webAudioSourceProvider; | 95 WebAudioSourceProvider* m_webAudioSourceProvider; |
99 Mutex m_provideInputLock; | 96 Mutex m_provideInputLock; |
100 }; | 97 }; |
101 | 98 |
102 AudioSourceProviderImpl m_sourceProvider; | 99 AudioSourceProviderImpl m_sourceProvider; |
103 #endif // ENABLE(WEB_AUDIO) | 100 #endif // ENABLE(WEB_AUDIO) |
104 | 101 |
105 Member<MediaStreamSource> m_source; | 102 RefPtr<MediaStreamSource> m_source; |
106 String m_id; | 103 String m_id; |
107 bool m_enabled; | 104 bool m_enabled; |
108 bool m_muted; | 105 bool m_muted; |
109 OwnPtr<ExtraData> m_extraData; | 106 OwnPtr<ExtraData> m_extraData; |
110 }; | 107 }; |
111 | 108 |
112 typedef HeapVector<Member<MediaStreamComponent> > MediaStreamComponentVector; | 109 typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector; |
113 | 110 |
114 } // namespace blink | 111 } // namespace blink |
115 | 112 |
116 #endif // MediaStreamComponent_h | 113 #endif // MediaStreamComponent_h |
OLD | NEW |