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