| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 TypeAudio, | 62 TypeAudio, |
| 63 TypeVideo | 63 TypeVideo |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 enum ReadyState { | 66 enum ReadyState { |
| 67 ReadyStateLive = 0, | 67 ReadyStateLive = 0, |
| 68 ReadyStateMuted = 1, | 68 ReadyStateMuted = 1, |
| 69 ReadyStateEnded = 2 | 69 ReadyStateEnded = 2 |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 static MediaStreamSource* create(const String& id, StreamType, const String&
name, bool remote, bool readonly, ReadyState = ReadyStateLive, bool requiresCon
sumer = false); | 72 static MediaStreamSource* create(const String& id, StreamType, const String&
name, bool remote, ReadyState = ReadyStateLive, bool requiresConsumer = false); |
| 73 | 73 |
| 74 const String& id() const { return m_id; } | 74 const String& id() const { return m_id; } |
| 75 StreamType type() const { return m_type; } | 75 StreamType type() const { return m_type; } |
| 76 const String& name() const { return m_name; } | 76 const String& name() const { return m_name; } |
| 77 bool remote() const { return m_remote; } | 77 bool remote() const { return m_remote; } |
| 78 bool readonly() const { return m_readonly; } | |
| 79 | 78 |
| 80 void setReadyState(ReadyState); | 79 void setReadyState(ReadyState); |
| 81 ReadyState getReadyState() const { return m_readyState; } | 80 ReadyState getReadyState() const { return m_readyState; } |
| 82 | 81 |
| 83 void addObserver(Observer*); | 82 void addObserver(Observer*); |
| 84 | 83 |
| 85 ExtraData* getExtraData() const { return m_extraData.get(); } | 84 ExtraData* getExtraData() const { return m_extraData.get(); } |
| 86 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = std::move
(extraData); } | 85 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = std::move
(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 |
| 99 // |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. |
| 100 // So this class is eagerly finalized to finalize |m_extraData| promptly. | 99 // So this class is eagerly finalized to finalize |m_extraData| promptly. |
| 101 EAGERLY_FINALIZE(); | 100 EAGERLY_FINALIZE(); |
| 102 DECLARE_TRACE(); | 101 DECLARE_TRACE(); |
| 103 | 102 |
| 104 private: | 103 private: |
| 105 MediaStreamSource(const String& id, StreamType, const String& name, bool rem
ote, bool readonly, ReadyState, bool requiresConsumer); | 104 MediaStreamSource(const String& id, StreamType, const String& name, bool rem
ote, ReadyState, bool requiresConsumer); |
| 106 | 105 |
| 107 String m_id; | 106 String m_id; |
| 108 StreamType m_type; | 107 StreamType m_type; |
| 109 String m_name; | 108 String m_name; |
| 110 bool m_remote; | 109 bool m_remote; |
| 111 bool m_readonly; | |
| 112 ReadyState m_readyState; | 110 ReadyState m_readyState; |
| 113 bool m_requiresConsumer; | 111 bool m_requiresConsumer; |
| 114 HeapHashSet<WeakMember<Observer>> m_observers; | 112 HeapHashSet<WeakMember<Observer>> m_observers; |
| 115 Mutex m_audioConsumersLock; | 113 Mutex m_audioConsumersLock; |
| 116 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; | 114 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; |
| 117 OwnPtr<ExtraData> m_extraData; | 115 OwnPtr<ExtraData> m_extraData; |
| 118 WebMediaConstraints m_constraints; | 116 WebMediaConstraints m_constraints; |
| 119 }; | 117 }; |
| 120 | 118 |
| 121 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; | 119 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; |
| 122 | 120 |
| 123 } // namespace blink | 121 } // namespace blink |
| 124 | 122 |
| 125 #endif // MediaStreamSource_h | 123 #endif // MediaStreamSource_h |
| OLD | NEW |