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) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 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 16 matching lines...) Expand all Loading... |
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 MediaStreamSource_h | 32 #ifndef MediaStreamSource_h |
33 #define MediaStreamSource_h | 33 #define MediaStreamSource_h |
34 | 34 |
35 #include "platform/PlatformExport.h" | 35 #include "platform/PlatformExport.h" |
36 #include "platform/audio/AudioDestinationConsumer.h" | 36 #include "platform/audio/AudioDestinationConsumer.h" |
| 37 #include "platform/heap/Handle.h" |
37 #include "public/platform/WebMediaConstraints.h" | 38 #include "public/platform/WebMediaConstraints.h" |
38 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
39 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
40 #include "wtf/RefCounted.h" | |
41 #include "wtf/ThreadingPrimitives.h" | 41 #include "wtf/ThreadingPrimitives.h" |
42 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
43 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 class PLATFORM_EXPORT MediaStreamSource FINAL : public RefCounted<MediaStreamSou
rce> { | 47 class PLATFORM_EXPORT MediaStreamSource FINAL : public GarbageCollectedFinalized
<MediaStreamSource> { |
48 public: | 48 public: |
49 class Observer { | 49 class Observer : public GarbageCollectedMixin { |
50 public: | 50 public: |
51 virtual ~Observer() { } | 51 virtual ~Observer() { } |
52 virtual void sourceChangedState() = 0; | 52 virtual void sourceChangedState() = 0; |
| 53 virtual void trace(Visitor*) { } |
53 }; | 54 }; |
54 | 55 |
55 class ExtraData { | 56 class ExtraData { |
56 public: | 57 public: |
57 virtual ~ExtraData() { } | 58 virtual ~ExtraData() { } |
58 }; | 59 }; |
59 | 60 |
60 enum Type { | 61 enum Type { |
61 TypeAudio, | 62 TypeAudio, |
62 TypeVideo | 63 TypeVideo |
63 }; | 64 }; |
64 | 65 |
65 enum ReadyState { | 66 enum ReadyState { |
66 ReadyStateLive = 0, | 67 ReadyStateLive = 0, |
67 ReadyStateMuted = 1, | 68 ReadyStateMuted = 1, |
68 ReadyStateEnded = 2 | 69 ReadyStateEnded = 2 |
69 }; | 70 }; |
70 | 71 |
71 static PassRefPtr<MediaStreamSource> create(const String& id, Type, const St
ring& name, ReadyState = ReadyStateLive, bool requiresConsumer = false); | 72 static MediaStreamSource* create(const String& id, Type, const String& name,
ReadyState = ReadyStateLive, bool requiresConsumer = false); |
72 | 73 |
73 const String& id() const { return m_id; } | 74 const String& id() const { return m_id; } |
74 Type type() const { return m_type; } | 75 Type type() const { return m_type; } |
75 const String& name() const { return m_name; } | 76 const String& name() const { return m_name; } |
76 | 77 |
77 void setReadyState(ReadyState); | 78 void setReadyState(ReadyState); |
78 ReadyState readyState() const { return m_readyState; } | 79 ReadyState readyState() const { return m_readyState; } |
79 | 80 |
80 void addObserver(Observer*); | 81 void addObserver(Observer*); |
81 void removeObserver(Observer*); | 82 void removeObserver(Observer*); |
82 | 83 |
83 ExtraData* extraData() const { return m_extraData.get(); } | 84 ExtraData* extraData() const { return m_extraData.get(); } |
84 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } | 85 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } |
85 | 86 |
86 void setConstraints(blink::WebMediaConstraints constraints) { m_constraints
= constraints; } | 87 void setConstraints(blink::WebMediaConstraints constraints) { m_constraints
= constraints; } |
87 blink::WebMediaConstraints constraints() { return m_constraints; } | 88 blink::WebMediaConstraints constraints() { return m_constraints; } |
88 | 89 |
89 void setAudioFormat(size_t numberOfChannels, float sampleRate); | 90 void setAudioFormat(size_t numberOfChannels, float sampleRate); |
90 void consumeAudio(AudioBus*, size_t numberOfFrames); | 91 void consumeAudio(AudioBus*, size_t numberOfFrames); |
91 | 92 |
92 bool requiresAudioConsumer() const { return m_requiresConsumer; } | 93 bool requiresAudioConsumer() const { return m_requiresConsumer; } |
93 void addAudioConsumer(AudioDestinationConsumer*); | 94 void addAudioConsumer(AudioDestinationConsumer*); |
94 bool removeAudioConsumer(AudioDestinationConsumer*); | 95 bool removeAudioConsumer(AudioDestinationConsumer*); |
95 const HeapHashSet<Member<AudioDestinationConsumer> >& audioConsumers() { ret
urn m_audioConsumers; } | 96 const HeapHashSet<Member<AudioDestinationConsumer> >& audioConsumers() { ret
urn m_audioConsumers; } |
96 | 97 |
| 98 void trace(Visitor*); |
| 99 |
97 private: | 100 private: |
98 MediaStreamSource(const String& id, Type, const String& name, ReadyState, bo
ol requiresConsumer); | 101 MediaStreamSource(const String& id, Type, const String& name, ReadyState, bo
ol requiresConsumer); |
99 | 102 |
100 String m_id; | 103 String m_id; |
101 Type m_type; | 104 Type m_type; |
102 String m_name; | 105 String m_name; |
103 ReadyState m_readyState; | 106 ReadyState m_readyState; |
104 bool m_requiresConsumer; | 107 bool m_requiresConsumer; |
105 Vector<Observer*> m_observers; | 108 HeapHashSet<WeakMember<Observer> > m_observers; |
106 Mutex m_audioConsumersLock; | 109 Mutex m_audioConsumersLock; |
107 PersistentHeapHashSet<Member<AudioDestinationConsumer> > m_audioConsumers; | 110 HeapHashSet<Member<AudioDestinationConsumer> > m_audioConsumers; |
108 OwnPtr<ExtraData> m_extraData; | 111 OwnPtr<ExtraData> m_extraData; |
109 blink::WebMediaConstraints m_constraints; | 112 blink::WebMediaConstraints m_constraints; |
110 }; | 113 }; |
111 | 114 |
112 typedef Vector<RefPtr<MediaStreamSource> > MediaStreamSourceVector; | 115 typedef HeapVector<Member<MediaStreamSource> > MediaStreamSourceVector; |
113 | 116 |
114 } // namespace blink | 117 } // namespace blink |
115 | 118 |
116 #endif // MediaStreamSource_h | 119 #endif // MediaStreamSource_h |
OLD | NEW |