| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "content/renderer/media/media_stream_source.h" |
| 11 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 12 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 class CONTENT_EXPORT MediaStreamAudioSource |
| 17 : NON_EXPORTED_BASE(public MediaStreamSource) { |
| 18 public: |
| 19 MediaStreamAudioSource(const StreamDeviceInfo& device_info, |
| 20 const SourceStopCallback& stop_callback); |
| 21 MediaStreamAudioSource(); |
| 22 virtual ~MediaStreamAudioSource(); |
| 23 |
| 24 virtual void ApplyConstraints(const blink::WebMediaStreamTrack& track, |
| 25 const blink::WebMediaConstraints& constraints, |
| 26 const ConstraintsCallback& callback) OVERRIDE; |
| 27 |
| 28 void SetLocalAudioSource(webrtc::AudioSourceInterface* source) { |
| 29 local_audio_source_ = source; |
| 30 } |
| 31 |
| 32 void SetAudioCapturer(WebRtcAudioCapturer* capturer) { |
| 33 DCHECK(!audio_capturer_); |
| 34 audio_capturer_ = capturer; |
| 35 } |
| 36 |
| 37 WebRtcAudioCapturer* GetAudioCapturer() const { |
| 38 // TODO(perkj): |audio_capturer_| can currently be reconfigured to use |
| 39 // another microphone even after it has been created since only one |
| 40 // capturer is supported. See issue crbug/262117. |
| 41 // It would make more sense if a WebRtcAudioCapturer represent one and only |
| 42 // one audio source. |
| 43 if (audio_capturer_ && |
| 44 device_info_.session_id == audio_capturer_->session_id()) { |
| 45 return audio_capturer_; |
| 46 } |
| 47 return NULL; |
| 48 } |
| 49 |
| 50 webrtc::AudioSourceInterface* local_audio_source() { |
| 51 return local_audio_source_.get(); |
| 52 } |
| 53 |
| 54 protected: |
| 55 virtual void DoStopSource() OVERRIDE; |
| 56 |
| 57 private: |
| 58 StreamDeviceInfo device_info_; |
| 59 |
| 60 // This member holds an instance of webrtc::LocalAudioSource. This is used |
| 61 // as a container for audio options. |
| 62 // TODO(hclam): This should be merged with |audio_source_| such that it |
| 63 // carries audio options. |
| 64 scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_; |
| 65 |
| 66 scoped_refptr<WebRtcAudioCapturer> audio_capturer_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource); |
| 69 }; |
| 70 |
| 71 } // namespace content |
| 72 |
| 73 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| OLD | NEW |