Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / media / media_stream_audio_source.h
blob5495afac4f2a1684b4e84e7fd1e6cd3757fff158
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.
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_
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/peer_connection_dependency_factory.h"
12 #include "content/renderer/media/webrtc_audio_capturer.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
15 namespace content {
17 class CONTENT_EXPORT MediaStreamAudioSource
18 : NON_EXPORTED_BASE(public MediaStreamSource) {
19 public:
20 MediaStreamAudioSource(int render_frame_id,
21 const StreamDeviceInfo& device_info,
22 const SourceStoppedCallback& stop_callback,
23 PeerConnectionDependencyFactory* factory);
24 MediaStreamAudioSource();
25 virtual ~MediaStreamAudioSource();
27 void AddTrack(const blink::WebMediaStreamTrack& track,
28 const blink::WebMediaConstraints& constraints,
29 const ConstraintsCallback& callback);
31 void SetLocalAudioSource(webrtc::AudioSourceInterface* source) {
32 local_audio_source_ = source;
35 void SetAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer) {
36 DCHECK(!audio_capturer_.get());
37 audio_capturer_ = capturer;
40 const scoped_refptr<WebRtcAudioCapturer>& GetAudioCapturer() {
41 return audio_capturer_;
44 webrtc::AudioSourceInterface* local_audio_source() {
45 return local_audio_source_.get();
48 protected:
49 void DoStopSource() override;
51 private:
52 const int render_frame_id_;
53 PeerConnectionDependencyFactory* const factory_;
55 // This member holds an instance of webrtc::LocalAudioSource. This is used
56 // as a container for audio options.
57 scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_;
59 scoped_refptr<WebRtcAudioCapturer> audio_capturer_;
61 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource);
64 } // namespace content
66 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_