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 18 matching lines...) Expand all Loading... |
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 "public/platform/WebMediaConstraints.h" | 37 #include "public/platform/WebMediaConstraints.h" |
38 #include "wtf/Allocator.h" | 38 #include "wtf/Allocator.h" |
| 39 #include "wtf/OwnPtr.h" |
| 40 #include "wtf/PassOwnPtr.h" |
39 #include "wtf/ThreadingPrimitives.h" | 41 #include "wtf/ThreadingPrimitives.h" |
40 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
41 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
42 #include <memory> | |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 | 46 |
46 class PLATFORM_EXPORT MediaStreamSource final : public GarbageCollectedFinalized
<MediaStreamSource> { | 47 class PLATFORM_EXPORT MediaStreamSource final : public GarbageCollectedFinalized
<MediaStreamSource> { |
47 public: | 48 public: |
48 class PLATFORM_EXPORT Observer : public GarbageCollectedMixin { | 49 class PLATFORM_EXPORT Observer : public GarbageCollectedMixin { |
49 public: | 50 public: |
50 virtual ~Observer() { } | 51 virtual ~Observer() { } |
51 virtual void sourceChangedState() = 0; | 52 virtual void sourceChangedState() = 0; |
52 }; | 53 }; |
(...skipping 21 matching lines...) Expand all Loading... |
74 StreamType type() const { return m_type; } | 75 StreamType type() const { return m_type; } |
75 const String& name() const { return m_name; } | 76 const String& name() const { return m_name; } |
76 bool remote() const { return m_remote; } | 77 bool remote() const { return m_remote; } |
77 | 78 |
78 void setReadyState(ReadyState); | 79 void setReadyState(ReadyState); |
79 ReadyState getReadyState() const { return m_readyState; } | 80 ReadyState getReadyState() const { return m_readyState; } |
80 | 81 |
81 void addObserver(Observer*); | 82 void addObserver(Observer*); |
82 | 83 |
83 ExtraData* getExtraData() const { return m_extraData.get(); } | 84 ExtraData* getExtraData() const { return m_extraData.get(); } |
84 void setExtraData(std::unique_ptr<ExtraData> extraData) { m_extraData = std:
:move(extraData); } | 85 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = std::move
(extraData); } |
85 | 86 |
86 void setConstraints(WebMediaConstraints constraints) { m_constraints = const
raints; } | 87 void setConstraints(WebMediaConstraints constraints) { m_constraints = const
raints; } |
87 WebMediaConstraints constraints() { return m_constraints; } | 88 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() { retu
rn m_audioConsumers; } | 96 const HeapHashSet<Member<AudioDestinationConsumer>>& audioConsumers() { retu
rn m_audioConsumers; } |
96 | 97 |
97 // |m_extraData| may hold pointers to GC objects, and it may touch them in d
estruction. | 98 // |m_extraData| may hold pointers to GC objects, and it may touch them in d
estruction. |
98 // So this class is eagerly finalized to finalize |m_extraData| promptly. | 99 // So this class is eagerly finalized to finalize |m_extraData| promptly. |
99 EAGERLY_FINALIZE(); | 100 EAGERLY_FINALIZE(); |
100 DECLARE_TRACE(); | 101 DECLARE_TRACE(); |
101 | 102 |
102 private: | 103 private: |
103 MediaStreamSource(const String& id, StreamType, const String& name, bool rem
ote, ReadyState, bool requiresConsumer); | 104 MediaStreamSource(const String& id, StreamType, const String& name, bool rem
ote, ReadyState, bool requiresConsumer); |
104 | 105 |
105 String m_id; | 106 String m_id; |
106 StreamType m_type; | 107 StreamType m_type; |
107 String m_name; | 108 String m_name; |
108 bool m_remote; | 109 bool m_remote; |
109 ReadyState m_readyState; | 110 ReadyState m_readyState; |
110 bool m_requiresConsumer; | 111 bool m_requiresConsumer; |
111 HeapHashSet<WeakMember<Observer>> m_observers; | 112 HeapHashSet<WeakMember<Observer>> m_observers; |
112 Mutex m_audioConsumersLock; | 113 Mutex m_audioConsumersLock; |
113 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; | 114 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; |
114 std::unique_ptr<ExtraData> m_extraData; | 115 OwnPtr<ExtraData> m_extraData; |
115 WebMediaConstraints m_constraints; | 116 WebMediaConstraints m_constraints; |
116 }; | 117 }; |
117 | 118 |
118 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; | 119 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; |
119 | 120 |
120 } // namespace blink | 121 } // namespace blink |
121 | 122 |
122 #endif // MediaStreamSource_h | 123 #endif // MediaStreamSource_h |
OLD | NEW |