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