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