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 GarbageCollectedFinalized
<MediaStreamSource> { | 47 class PLATFORM_EXPORT MediaStreamSource final : public RefCounted<MediaStreamSou
rce> { |
48 public: | 48 public: |
49 class PLATFORM_EXPORT Observer : public GarbageCollectedMixin { | 49 class PLATFORM_EXPORT Observer { |
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 MediaStreamSource* create(const String& id, Type, const String& name,
bool remote, bool readonly, ReadyState = ReadyStateLive, bool requiresConsumer
= false); | 71 static PassRefPtr<MediaStreamSource> create(const String& id, Type, const St
ring& name, bool remote, bool readonly, ReadyState = ReadyStateLive, bool requir
esConsumer = 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*); |
83 | 84 |
84 ExtraData* extraData() const { return m_extraData.get(); } | 85 ExtraData* extraData() const { return m_extraData.get(); } |
85 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } | 86 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } |
86 | 87 |
87 void setConstraints(WebMediaConstraints constraints) { m_constraints = const
raints; } | 88 void setConstraints(WebMediaConstraints constraints) { m_constraints = const
raints; } |
88 WebMediaConstraints constraints() { return m_constraints; } | 89 WebMediaConstraints constraints() { return m_constraints; } |
89 | 90 |
90 void setAudioFormat(size_t numberOfChannels, float sampleRate); | 91 void setAudioFormat(size_t numberOfChannels, float sampleRate); |
91 void consumeAudio(AudioBus*, size_t numberOfFrames); | 92 void consumeAudio(AudioBus*, size_t numberOfFrames); |
92 | 93 |
93 bool requiresAudioConsumer() const { return m_requiresConsumer; } | 94 bool requiresAudioConsumer() const { return m_requiresConsumer; } |
94 void addAudioConsumer(AudioDestinationConsumer*); | 95 void addAudioConsumer(AudioDestinationConsumer*); |
95 bool removeAudioConsumer(AudioDestinationConsumer*); | 96 bool removeAudioConsumer(AudioDestinationConsumer*); |
96 const HeapHashSet<Member<AudioDestinationConsumer>>& audioConsumers() { retu
rn m_audioConsumers; } | 97 const HeapHashSet<Member<AudioDestinationConsumer>>& audioConsumers() { retu
rn m_audioConsumers; } |
97 | 98 |
98 DECLARE_TRACE(); | |
99 | |
100 private: | 99 private: |
101 MediaStreamSource(const String& id, Type, const String& name, bool remote, b
ool readonly, ReadyState, bool requiresConsumer); | 100 MediaStreamSource(const String& id, Type, const String& name, bool remote, b
ool readonly, ReadyState, bool requiresConsumer); |
102 | 101 |
103 String m_id; | 102 String m_id; |
104 Type m_type; | 103 Type m_type; |
105 String m_name; | 104 String m_name; |
106 bool m_remote; | 105 bool m_remote; |
107 bool m_readonly; | 106 bool m_readonly; |
108 ReadyState m_readyState; | 107 ReadyState m_readyState; |
109 bool m_requiresConsumer; | 108 bool m_requiresConsumer; |
110 HeapHashSet<WeakMember<Observer>> m_observers; | 109 Vector<Observer*> m_observers; |
111 Mutex m_audioConsumersLock; | 110 Mutex m_audioConsumersLock; |
112 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; | 111 PersistentHeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; |
113 OwnPtr<ExtraData> m_extraData; | 112 OwnPtr<ExtraData> m_extraData; |
114 WebMediaConstraints m_constraints; | 113 WebMediaConstraints m_constraints; |
115 }; | 114 }; |
116 | 115 |
117 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; | 116 typedef Vector<RefPtr<MediaStreamSource>> MediaStreamSourceVector; |
118 | 117 |
119 } // namespace blink | 118 } // namespace blink |
120 | 119 |
121 #endif // MediaStreamSource_h | 120 #endif // MediaStreamSource_h |
OLD | NEW |