| 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) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 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 22 matching lines...) Expand all Loading... |
| 33 #define MediaStreamComponent_h | 33 #define MediaStreamComponent_h |
| 34 | 34 |
| 35 #include "platform/audio/AudioSourceProvider.h" | 35 #include "platform/audio/AudioSourceProvider.h" |
| 36 #include "wtf/PassOwnPtr.h" | 36 #include "wtf/PassOwnPtr.h" |
| 37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 39 #include "wtf/ThreadingPrimitives.h" | 39 #include "wtf/ThreadingPrimitives.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 class WebAudioSourceProvider; | |
| 44 } | |
| 45 | |
| 46 namespace blink { | |
| 47 | 43 |
| 48 class MediaStreamDescriptor; | 44 class MediaStreamDescriptor; |
| 49 class MediaStreamSource; | 45 class MediaStreamSource; |
| 46 class WebAudioSourceProvider; |
| 50 | 47 |
| 51 class PLATFORM_EXPORT MediaStreamComponent : public RefCounted<MediaStreamCompon
ent> { | 48 class PLATFORM_EXPORT MediaStreamComponent : public RefCounted<MediaStreamCompon
ent> { |
| 52 public: | 49 public: |
| 53 class ExtraData { | 50 class ExtraData { |
| 54 public: | 51 public: |
| 55 virtual ~ExtraData() { } | 52 virtual ~ExtraData() { } |
| 56 }; | 53 }; |
| 57 | 54 |
| 58 static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>
); | 55 static PassRefPtr<MediaStreamComponent> create(PassRefPtr<MediaStreamSource>
); |
| 59 static PassRefPtr<MediaStreamComponent> create(const String& id, PassRefPtr<
MediaStreamSource>); | 56 static PassRefPtr<MediaStreamComponent> create(const String& id, PassRefPtr<
MediaStreamSource>); |
| 60 | 57 |
| 61 MediaStreamSource* source() const { return m_source.get(); } | 58 MediaStreamSource* source() const { return m_source.get(); } |
| 62 | 59 |
| 63 String id() const { return m_id; } | 60 String id() const { return m_id; } |
| 64 bool enabled() const { return m_enabled; } | 61 bool enabled() const { return m_enabled; } |
| 65 void setEnabled(bool enabled) { m_enabled = enabled; } | 62 void setEnabled(bool enabled) { m_enabled = enabled; } |
| 66 bool muted() const { return m_muted; } | 63 bool muted() const { return m_muted; } |
| 67 | 64 |
| 68 #if ENABLE(WEB_AUDIO) | 65 #if ENABLE(WEB_AUDIO) |
| 69 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } | 66 AudioSourceProvider* audioSourceProvider() { return &m_sourceProvider; } |
| 70 void setSourceProvider(blink::WebAudioSourceProvider* provider) { m_sourcePr
ovider.wrap(provider); } | 67 void setSourceProvider(WebAudioSourceProvider* provider) { m_sourceProvider.
wrap(provider); } |
| 71 #endif // ENABLE(WEB_AUDIO) | 68 #endif // ENABLE(WEB_AUDIO) |
| 72 | 69 |
| 73 ExtraData* extraData() const { return m_extraData.get(); } | 70 ExtraData* extraData() const { return m_extraData.get(); } |
| 74 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } | 71 void setExtraData(PassOwnPtr<ExtraData> extraData) { m_extraData = extraData
; } |
| 75 | 72 |
| 76 private: | 73 private: |
| 77 MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>); | 74 MediaStreamComponent(const String& id, PassRefPtr<MediaStreamSource>); |
| 78 | 75 |
| 79 #if ENABLE(WEB_AUDIO) | 76 #if ENABLE(WEB_AUDIO) |
| 80 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() | 77 // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput() |
| 81 // calls into chromium to get a rendered audio stream. | 78 // calls into chromium to get a rendered audio stream. |
| 82 | 79 |
| 83 class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvi
der { | 80 class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvi
der { |
| 84 public: | 81 public: |
| 85 AudioSourceProviderImpl() | 82 AudioSourceProviderImpl() |
| 86 : m_webAudioSourceProvider(0) | 83 : m_webAudioSourceProvider(0) |
| 87 { | 84 { |
| 88 } | 85 } |
| 89 | 86 |
| 90 virtual ~AudioSourceProviderImpl() { } | 87 virtual ~AudioSourceProviderImpl() { } |
| 91 | 88 |
| 92 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. | 89 // Wraps the given blink::WebAudioSourceProvider to blink::AudioSourcePr
ovider. |
| 93 void wrap(blink::WebAudioSourceProvider*); | 90 void wrap(WebAudioSourceProvider*); |
| 94 | 91 |
| 95 // blink::AudioSourceProvider | 92 // blink::AudioSourceProvider |
| 96 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) OVER
RIDE; | 93 virtual void provideInput(blink::AudioBus*, size_t framesToProcess) OVER
RIDE; |
| 97 | 94 |
| 98 private: | 95 private: |
| 99 blink::WebAudioSourceProvider* m_webAudioSourceProvider; | 96 WebAudioSourceProvider* m_webAudioSourceProvider; |
| 100 Mutex m_provideInputLock; | 97 Mutex m_provideInputLock; |
| 101 }; | 98 }; |
| 102 | 99 |
| 103 AudioSourceProviderImpl m_sourceProvider; | 100 AudioSourceProviderImpl m_sourceProvider; |
| 104 #endif // ENABLE(WEB_AUDIO) | 101 #endif // ENABLE(WEB_AUDIO) |
| 105 | 102 |
| 106 RefPtr<MediaStreamSource> m_source; | 103 RefPtr<MediaStreamSource> m_source; |
| 107 String m_id; | 104 String m_id; |
| 108 bool m_enabled; | 105 bool m_enabled; |
| 109 bool m_muted; | 106 bool m_muted; |
| 110 OwnPtr<ExtraData> m_extraData; | 107 OwnPtr<ExtraData> m_extraData; |
| 111 }; | 108 }; |
| 112 | 109 |
| 113 typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector; | 110 typedef Vector<RefPtr<MediaStreamComponent> > MediaStreamComponentVector; |
| 114 | 111 |
| 115 } // namespace blink | 112 } // namespace blink |
| 116 | 113 |
| 117 #endif // MediaStreamComponent_h | 114 #endif // MediaStreamComponent_h |
| OLD | NEW |