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" |
39 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
40 #include "wtf/ThreadingPrimitives.h" | 39 #include "wtf/ThreadingPrimitives.h" |
41 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
42 | 41 |
43 namespace blink { | 42 namespace blink { |
44 | 43 |
45 class MediaStreamSource; | 44 class MediaStreamSource; |
46 class WebAudioSourceProvider; | 45 class WebAudioSourceProvider; |
47 | 46 |
48 class PLATFORM_EXPORT MediaStreamComponent final : public GarbageCollectedFinali
zed<MediaStreamComponent> { | 47 class PLATFORM_EXPORT MediaStreamComponent final : public RefCounted<MediaStream
Component> { |
49 public: | 48 public: |
50 class ExtraData { | 49 class ExtraData { |
51 public: | 50 public: |
52 virtual ~ExtraData() { } | 51 virtual ~ExtraData() { } |
53 }; | 52 }; |
54 | 53 |
55 static MediaStreamComponent* create(MediaStreamSource*); | 54 static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>
); |
56 static MediaStreamComponent* create(const String& id, MediaStreamSource*); | 55 static PassRefPtr<MediaStreamComponent> create(const String& id, PassRefPtr<
MediaStreamSource>); |
57 | 56 |
58 MediaStreamSource* source() const { return m_source.get(); } | 57 MediaStreamSource* source() const { return m_source.get(); } |
59 | 58 |
60 String id() const { return m_id; } | 59 String id() const { return m_id; } |
61 bool enabled() const { return m_enabled; } | 60 bool enabled() const { return m_enabled; } |
62 void setEnabled(bool enabled) { m_enabled = enabled; } | 61 void setEnabled(bool enabled) { m_enabled = enabled; } |
63 bool muted() const { return m_muted; } | 62 bool muted() const { return m_muted; } |
64 void setMuted(bool muted) { m_muted = muted; } | 63 void setMuted(bool muted) { m_muted = muted; } |
65 | 64 |
66 #if ENABLE(WEB_AUDIO) | 65 #if ENABLE(WEB_AUDIO) |
67 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } | 66 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } |
68 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } | 67 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } |
69 #endif // ENABLE(WEB_AUDIO) | 68 #endif // ENABLE(WEB_AUDIO) |
70 | 69 |
71 ExtraData* extraData() const { return m_extraData.get(); } | 70 ExtraData* extraData() const { return m_extraData.get(); } |
72 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } | 71 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } |
73 | 72 |
74 // |m_extraData| may hold pointers GC objects, and it may touch them in dest
ruction. | |
75 // So this class is eagerly finalized to finalize |m_extraData| promptly. | |
76 EAGERLY_FINALIZE(); | |
77 DECLARE_TRACE(); | |
78 | |
79 private: | 73 private: |
80 MediaStreamComponent(const String& id, MediaStreamSource*); | 74 MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>); |
81 | 75 |
82 #if ENABLE(WEB_AUDIO) | 76 #if ENABLE(WEB_AUDIO) |
83 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() | 77 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() |
84 // calls into chromium to get a rendered audio stream. | 78 // calls into chromium to get a rendered audio stream. |
85 | 79 |
86 class PLATFORM_EXPORT AudioSourceProviderImpl final: public AudioSourceProvi
der { | 80 class PLATFORM_EXPORT AudioSourceProviderImpl final: public AudioSourceProvi
der { |
87 public: | 81 public: |
88 AudioSourceProviderImpl() | 82 AudioSourceProviderImpl() |
89 : m_webAudioSourceProvider(0) | 83 : m_webAudioSourceProvider(0) |
90 { | 84 { |
91 } | 85 } |
92 | 86 |
93 ~AudioSourceProviderImpl() override {} | 87 ~AudioSourceProviderImpl() override {} |
94 | 88 |
95 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. | 89 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. |
96 void wrap(WebAudioSourceProvider*); | 90 void wrap(WebAudioSourceProvider*); |
97 | 91 |
98 // blink::AudioSourceProvider | 92 // blink::AudioSourceProvider |
99 void provideInput(AudioBus*, size_t framesToProcess) override; | 93 void provideInput(AudioBus*, size_t framesToProcess) override; |
100 | 94 |
101 private: | 95 private: |
102 WebAudioSourceProvider* m_webAudioSourceProvider; | 96 WebAudioSourceProvider* m_webAudioSourceProvider; |
103 Mutex m_provideInputLock; | 97 Mutex m_provideInputLock; |
104 }; | 98 }; |
105 | 99 |
106 AudioSourceProviderImpl m_sourceProvider; | 100 AudioSourceProviderImpl m_sourceProvider; |
107 #endif // ENABLE(WEB_AUDIO) | 101 #endif // ENABLE(WEB_AUDIO) |
108 | 102 |
109 Member<MediaStreamSource> m_source; | 103 RefPtr<MediaStreamSource> m_source; |
110 String m_id; | 104 String m_id; |
111 bool m_enabled; | 105 bool m_enabled; |
112 bool m_muted; | 106 bool m_muted; |
113 OwnPtr<ExtraData> m_extraData; | 107 OwnPtr<ExtraData> m_extraData; |
114 }; | 108 }; |
115 | 109 |
116 typedef HeapVector<Member<MediaStreamComponent>> MediaStreamComponentVector; | 110 typedef Vector<RefPtr<MediaStreamComponent>> MediaStreamComponentVector; |
117 | 111 |
118 } // namespace blink | 112 } // namespace blink |
119 | 113 |
120 #endif // MediaStreamComponent_h | 114 #endif // MediaStreamComponent_h |
OLD | NEW |