OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" |
10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
11 #include "content/renderer/media/media_stream_source.h" | 12 #include "content/renderer/media/media_stream_source.h" |
12 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 13 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
13 #include "content/renderer/media/webrtc_audio_capturer.h" | 14 #include "content/renderer/media/webrtc_audio_capturer.h" |
14 #include "third_party/webrtc/api/mediastreaminterface.h" | 15 #include "third_party/webrtc/api/mediastreaminterface.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
| 19 // TODO(miu): In a soon-upcoming set of refactoring changes, this class will |
| 20 // become a base class for managing tracks (part of what WebRtcAudioCapturer |
| 21 // does today). Then, the rest of WebRtcAudioCapturer will be rolled into a |
| 22 // subclass. http://crbug.com/577874 |
18 class CONTENT_EXPORT MediaStreamAudioSource | 23 class CONTENT_EXPORT MediaStreamAudioSource |
19 : NON_EXPORTED_BASE(public MediaStreamSource) { | 24 : NON_EXPORTED_BASE(public MediaStreamSource) { |
20 public: | 25 public: |
21 MediaStreamAudioSource(int render_frame_id, | 26 MediaStreamAudioSource(int render_frame_id, |
22 const StreamDeviceInfo& device_info, | 27 const StreamDeviceInfo& device_info, |
23 const SourceStoppedCallback& stop_callback, | 28 const SourceStoppedCallback& stop_callback, |
24 PeerConnectionDependencyFactory* factory); | 29 PeerConnectionDependencyFactory* factory); |
25 MediaStreamAudioSource(); | 30 MediaStreamAudioSource(); |
26 ~MediaStreamAudioSource() override; | 31 ~MediaStreamAudioSource() override; |
27 | 32 |
| 33 // Returns the MediaStreamAudioSource instance owned by the given blink |
| 34 // |source| or null. |
| 35 static MediaStreamAudioSource* From(const blink::WebMediaStreamSource& track); |
| 36 |
28 void AddTrack(const blink::WebMediaStreamTrack& track, | 37 void AddTrack(const blink::WebMediaStreamTrack& track, |
29 const blink::WebMediaConstraints& constraints, | 38 const blink::WebMediaConstraints& constraints, |
30 const ConstraintsCallback& callback); | 39 const ConstraintsCallback& callback); |
31 | 40 |
32 void SetLocalAudioSource(webrtc::AudioSourceInterface* source) { | 41 WebRtcAudioCapturer* audio_capturer() const { return audio_capturer_.get(); } |
33 local_audio_source_ = source; | |
34 } | |
35 | 42 |
36 void SetAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer) { | 43 void SetAudioCapturer(scoped_ptr<WebRtcAudioCapturer> capturer) { |
37 DCHECK(!audio_capturer_.get()); | 44 DCHECK(!audio_capturer_.get()); |
38 audio_capturer_ = capturer; | 45 audio_capturer_ = std::move(capturer); |
39 } | |
40 | |
41 const scoped_refptr<WebRtcAudioCapturer>& GetAudioCapturer() { | |
42 return audio_capturer_; | |
43 } | 46 } |
44 | 47 |
45 webrtc::AudioSourceInterface* local_audio_source() { | 48 webrtc::AudioSourceInterface* local_audio_source() { |
46 return local_audio_source_.get(); | 49 return local_audio_source_.get(); |
47 } | 50 } |
48 | 51 |
| 52 void SetLocalAudioSource(scoped_refptr<webrtc::AudioSourceInterface> source) { |
| 53 local_audio_source_ = source; |
| 54 } |
| 55 |
49 protected: | 56 protected: |
50 void DoStopSource() override; | 57 void DoStopSource() override; |
51 | 58 |
52 private: | 59 private: |
53 const int render_frame_id_; | 60 const int render_frame_id_; |
54 PeerConnectionDependencyFactory* const factory_; | 61 PeerConnectionDependencyFactory* const factory_; |
55 | 62 |
| 63 scoped_ptr<WebRtcAudioCapturer> audio_capturer_; |
| 64 |
56 // This member holds an instance of webrtc::LocalAudioSource. This is used | 65 // This member holds an instance of webrtc::LocalAudioSource. This is used |
57 // as a container for audio options. | 66 // as a container for audio options. |
58 scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_; | 67 scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_; |
59 | 68 |
60 scoped_refptr<WebRtcAudioCapturer> audio_capturer_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource); | 69 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource); |
63 }; | 70 }; |
64 | 71 |
65 } // namespace content | 72 } // namespace content |
66 | 73 |
67 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ | 74 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ |
OLD | NEW |