Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: content/renderer/media/media_stream_audio_source.h

Issue 1780653002: Revert of MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/weak_ptr.h"
12 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
13 #include "content/renderer/media/media_stream_source.h" 11 #include "content/renderer/media/media_stream_source.h"
14 #include "content/renderer/media/webaudio_capturer_source.h"
15 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 12 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
16 #include "content/renderer/media/webrtc_audio_capturer.h" 13 #include "content/renderer/media/webrtc_audio_capturer.h"
17 #include "third_party/webrtc/api/mediastreaminterface.h" 14 #include "third_party/webrtc/api/mediastreaminterface.h"
18 15
19 namespace content { 16 namespace content {
20 17
21 class MediaStreamAudioTrack;
22
23 // TODO(miu): In a soon-upcoming set of refactoring changes, this class will
24 // become a base class for managing tracks (part of what WebRtcAudioCapturer
25 // does today). Then, the rest of WebRtcAudioCapturer will be rolled into a
26 // subclass. http://crbug.com/577874
27 class CONTENT_EXPORT MediaStreamAudioSource 18 class CONTENT_EXPORT MediaStreamAudioSource
28 : NON_EXPORTED_BASE(public MediaStreamSource) { 19 : NON_EXPORTED_BASE(public MediaStreamSource) {
29 public: 20 public:
30 MediaStreamAudioSource(int render_frame_id, 21 MediaStreamAudioSource(int render_frame_id,
31 const StreamDeviceInfo& device_info, 22 const StreamDeviceInfo& device_info,
32 const SourceStoppedCallback& stop_callback, 23 const SourceStoppedCallback& stop_callback,
33 PeerConnectionDependencyFactory* factory); 24 PeerConnectionDependencyFactory* factory);
34 MediaStreamAudioSource(); 25 MediaStreamAudioSource();
35 ~MediaStreamAudioSource() override; 26 ~MediaStreamAudioSource() override;
36 27
37 // Returns the MediaStreamAudioSource instance owned by the given blink
38 // |source| or null.
39 static MediaStreamAudioSource* From(const blink::WebMediaStreamSource& track);
40
41 void AddTrack(const blink::WebMediaStreamTrack& track, 28 void AddTrack(const blink::WebMediaStreamTrack& track,
42 const blink::WebMediaConstraints& constraints, 29 const blink::WebMediaConstraints& constraints,
43 const ConstraintsCallback& callback); 30 const ConstraintsCallback& callback);
44 31
45 base::WeakPtr<MediaStreamAudioSource> GetWeakPtr() { 32 void SetLocalAudioSource(webrtc::AudioSourceInterface* source) {
46 return weak_factory_.GetWeakPtr(); 33 local_audio_source_ = source;
47 } 34 }
48 35
49 // Removes |track| from the list of instances that get a copy of the source 36 void SetAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer) {
50 // audio data. 37 DCHECK(!audio_capturer_.get());
51 void StopAudioDeliveryTo(MediaStreamAudioTrack* track); 38 audio_capturer_ = capturer;
39 }
52 40
53 WebRtcAudioCapturer* audio_capturer() const { return audio_capturer_.get(); } 41 const scoped_refptr<WebRtcAudioCapturer>& GetAudioCapturer() {
54 42 return audio_capturer_;
55 void SetAudioCapturer(scoped_ptr<WebRtcAudioCapturer> capturer) {
56 DCHECK(!audio_capturer_.get());
57 audio_capturer_ = std::move(capturer);
58 } 43 }
59 44
60 webrtc::AudioSourceInterface* local_audio_source() { 45 webrtc::AudioSourceInterface* local_audio_source() {
61 return local_audio_source_.get(); 46 return local_audio_source_.get();
62 } 47 }
63 48
64 void SetLocalAudioSource(scoped_refptr<webrtc::AudioSourceInterface> source) {
65 local_audio_source_ = std::move(source);
66 }
67
68 WebAudioCapturerSource* webaudio_capturer() const {
69 return webaudio_capturer_.get();
70 }
71
72 void SetWebAudioCapturer(scoped_ptr<WebAudioCapturerSource> capturer) {
73 DCHECK(!webaudio_capturer_.get());
74 webaudio_capturer_ = std::move(capturer);
75 }
76
77 protected: 49 protected:
78 void DoStopSource() override; 50 void DoStopSource() override;
79 51
80 private: 52 private:
81 const int render_frame_id_; 53 const int render_frame_id_;
82 PeerConnectionDependencyFactory* const factory_; 54 PeerConnectionDependencyFactory* const factory_;
83 55
84 // MediaStreamAudioSource is the owner of either a WebRtcAudioCapturer or a
85 // WebAudioCapturerSource.
86 //
87 // TODO(miu): In a series of soon-upcoming changes, WebRtcAudioCapturer and
88 // WebAudioCapturerSource will become subclasses of MediaStreamAudioSource
89 // instead.
90 scoped_ptr<WebRtcAudioCapturer> audio_capturer_;
91 scoped_ptr<WebAudioCapturerSource> webaudio_capturer_;
92
93 // This member holds an instance of webrtc::LocalAudioSource. This is used 56 // This member holds an instance of webrtc::LocalAudioSource. This is used
94 // as a container for audio options. 57 // as a container for audio options.
95 scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_; 58 scoped_refptr<webrtc::AudioSourceInterface> local_audio_source_;
96 59
97 // Provides weak pointers so that MediaStreamAudioTracks won't call 60 scoped_refptr<WebRtcAudioCapturer> audio_capturer_;
98 // StopAudioDeliveryTo() if this instance dies first.
99 base::WeakPtrFactory<MediaStreamAudioSource> weak_factory_;
100 61
101 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource); 62 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource);
102 }; 63 };
103 64
104 } // namespace content 65 } // namespace content
105 66
106 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ 67 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_level_calculator.cc ('k') | content/renderer/media/media_stream_audio_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698