| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 virtual ~Observer() { } | 52 virtual ~Observer() { } |
| 53 virtual void sourceChangedState() = 0; | 53 virtual void sourceChangedState() = 0; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class ExtraData { | 56 class ExtraData { |
| 57 USING_FAST_MALLOC(ExtraData); | 57 USING_FAST_MALLOC(ExtraData); |
| 58 public: | 58 public: |
| 59 virtual ~ExtraData() { } | 59 virtual ~ExtraData() { } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 enum Type { | 62 enum StreamType { |
| 63 TypeAudio, | 63 TypeAudio, |
| 64 TypeVideo | 64 TypeVideo |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 enum ReadyState { | 67 enum ReadyState { |
| 68 ReadyStateLive = 0, | 68 ReadyStateLive = 0, |
| 69 ReadyStateMuted = 1, | 69 ReadyStateMuted = 1, |
| 70 ReadyStateEnded = 2 | 70 ReadyStateEnded = 2 |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 static MediaStreamSource* create(const String& id, Type, const String& name,
bool remote, bool readonly, ReadyState = ReadyStateLive, bool requiresConsumer
= false); | 73 static MediaStreamSource* create(const String& id, StreamType, const String&
name, bool remote, bool readonly, ReadyState = ReadyStateLive, bool requiresCon
sumer = false); |
| 74 | 74 |
| 75 const String& id() const { return m_id; } | 75 const String& id() const { return m_id; } |
| 76 Type type() const { return m_type; } | 76 StreamType type() const { return m_type; } |
| 77 const String& name() const { return m_name; } | 77 const String& name() const { return m_name; } |
| 78 bool remote() const { return m_remote; } | 78 bool remote() const { return m_remote; } |
| 79 bool readonly() const { return m_readonly; } | 79 bool readonly() const { return m_readonly; } |
| 80 | 80 |
| 81 void setReadyState(ReadyState); | 81 void setReadyState(ReadyState); |
| 82 ReadyState readyState() const { return m_readyState; } | 82 ReadyState getReadyState() const { return m_readyState; } |
| 83 | 83 |
| 84 void addObserver(Observer*); | 84 void addObserver(Observer*); |
| 85 | 85 |
| 86 ExtraData* extraData() const { return m_extraData.get(); } | 86 ExtraData* extraData() const { return m_extraData.get(); } |
| 87 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = std::move
(extraData); } | 87 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = std::move
(extraData); } |
| 88 | 88 |
| 89 void setConstraints(WebMediaConstraints constraints) { m_constraints = const
raints; } | 89 void setConstraints(WebMediaConstraints constraints) { m_constraints = const
raints; } |
| 90 WebMediaConstraints constraints() { return m_constraints; } | 90 WebMediaConstraints constraints() { return m_constraints; } |
| 91 | 91 |
| 92 void setAudioFormat(size_t numberOfChannels, float sampleRate); | 92 void setAudioFormat(size_t numberOfChannels, float sampleRate); |
| 93 void consumeAudio(AudioBus*, size_t numberOfFrames); | 93 void consumeAudio(AudioBus*, size_t numberOfFrames); |
| 94 | 94 |
| 95 bool requiresAudioConsumer() const { return m_requiresConsumer; } | 95 bool requiresAudioConsumer() const { return m_requiresConsumer; } |
| 96 void addAudioConsumer(AudioDestinationConsumer*); | 96 void addAudioConsumer(AudioDestinationConsumer*); |
| 97 bool removeAudioConsumer(AudioDestinationConsumer*); | 97 bool removeAudioConsumer(AudioDestinationConsumer*); |
| 98 const HeapHashSet<Member<AudioDestinationConsumer>>& audioConsumers() { retu
rn m_audioConsumers; } | 98 const HeapHashSet<Member<AudioDestinationConsumer>>& audioConsumers() { retu
rn m_audioConsumers; } |
| 99 | 99 |
| 100 // |m_extraData| may hold pointers to GC objects, and it may touch them in d
estruction. | 100 // |m_extraData| may hold pointers to GC objects, and it may touch them in d
estruction. |
| 101 // So this class is eagerly finalized to finalize |m_extraData| promptly. | 101 // So this class is eagerly finalized to finalize |m_extraData| promptly. |
| 102 EAGERLY_FINALIZE(); | 102 EAGERLY_FINALIZE(); |
| 103 DECLARE_TRACE(); | 103 DECLARE_TRACE(); |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 MediaStreamSource(const String& id, Type, const String& name, bool remote, b
ool readonly, ReadyState, bool requiresConsumer); | 106 MediaStreamSource(const String& id, StreamType, const String& name, bool rem
ote, bool readonly, ReadyState, bool requiresConsumer); |
| 107 | 107 |
| 108 String m_id; | 108 String m_id; |
| 109 Type m_type; | 109 StreamType m_type; |
| 110 String m_name; | 110 String m_name; |
| 111 bool m_remote; | 111 bool m_remote; |
| 112 bool m_readonly; | 112 bool m_readonly; |
| 113 ReadyState m_readyState; | 113 ReadyState m_readyState; |
| 114 bool m_requiresConsumer; | 114 bool m_requiresConsumer; |
| 115 HeapHashSet<WeakMember<Observer>> m_observers; | 115 HeapHashSet<WeakMember<Observer>> m_observers; |
| 116 Mutex m_audioConsumersLock; | 116 Mutex m_audioConsumersLock; |
| 117 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; | 117 HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers; |
| 118 OwnPtr<ExtraData> m_extraData; | 118 OwnPtr<ExtraData> m_extraData; |
| 119 WebMediaConstraints m_constraints; | 119 WebMediaConstraints m_constraints; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; | 122 typedef HeapVector<Member<MediaStreamSource>> MediaStreamSourceVector; |
| 123 | 123 |
| 124 } // namespace blink | 124 } // namespace blink |
| 125 | 125 |
| 126 #endif // MediaStreamSource_h | 126 #endif // MediaStreamSource_h |
| OLD | NEW |