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