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

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

Issue 2416123002: Stop media stream source when audio capture error occurs. (Closed)
Patch Set: Fix unit tests. Created 4 years, 2 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/renderer/media/media_stream_audio_deliverer.h" 15 #include "content/renderer/media/media_stream_audio_deliverer.h"
16 #include "content/renderer/media/media_stream_source.h" 16 #include "content/renderer/media/media_stream_source.h"
17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
19 19
20 namespace base {
21 class SingleThreadTaskRunner;
22 }
23
20 namespace content { 24 namespace content {
21 25
22 class MediaStreamAudioTrack; 26 class MediaStreamAudioTrack;
23 27
24 // Represents a source of audio, and manages the delivery of audio data between 28 // Represents a source of audio, and manages the delivery of audio data between
25 // the source implementation and one or more MediaStreamAudioTracks. This is a 29 // the source implementation and one or more MediaStreamAudioTracks. This is a
26 // base class providing all the necessary functionality to connect tracks and 30 // base class providing all the necessary functionality to connect tracks and
27 // have audio data delivered to them. Subclasses provide the actual audio source 31 // have audio data delivered to them. Subclasses provide the actual audio source
28 // implementation (e.g., media::AudioCapturerSource), and should implement the 32 // implementation (e.g., media::AudioCapturerSource), and should implement the
29 // EnsureSourceIsStarted() and EnsureSourceIsStopped() methods, and call 33 // EnsureSourceIsStarted() and EnsureSourceIsStopped() methods, and call
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // source to the sinks. This may be called at any time, before or after 120 // source to the sinks. This may be called at any time, before or after
117 // tracks have been connected; but must be called at least once before 121 // tracks have been connected; but must be called at least once before
118 // DeliverDataToTracks(). This method is thread-safe. 122 // DeliverDataToTracks(). This method is thread-safe.
119 void SetFormat(const media::AudioParameters& params); 123 void SetFormat(const media::AudioParameters& params);
120 124
121 // Called by subclasses to deliver audio data to the currently-connected 125 // Called by subclasses to deliver audio data to the currently-connected
122 // tracks. This method is thread-safe. 126 // tracks. This method is thread-safe.
123 void DeliverDataToTracks(const media::AudioBus& audio_bus, 127 void DeliverDataToTracks(const media::AudioBus& audio_bus,
124 base::TimeTicks reference_time); 128 base::TimeTicks reference_time);
125 129
130 // Called by subclasses when capture error occurs.
miu 2016/10/19 22:43:22 Please add: // Note: This can be called on any t
xjz 2016/10/19 23:59:36 Done.
131 void OnAudioCaptureError(const std::string& why);
miu 2016/10/19 22:43:22 naming nit (says what it does more accurately): St
xjz 2016/10/19 23:59:36 Done.
132
126 private: 133 private:
127 // MediaStreamSource override. 134 // MediaStreamSource override.
128 void DoStopSource() final; 135 void DoStopSource() final;
129 136
130 // Removes |track| from the list of instances that get a copy of the source 137 // Removes |track| from the list of instances that get a copy of the source
131 // audio data. The "stop callback" that was provided to the track calls 138 // audio data. The "stop callback" that was provided to the track calls
132 // this. 139 // this.
133 void StopAudioDeliveryTo(MediaStreamAudioTrack* track); 140 void StopAudioDeliveryTo(MediaStreamAudioTrack* track);
134 141
135 // True if the source of audio is a local device. False if the source is 142 // True if the source of audio is a local device. False if the source is
136 // remote (e.g., streamed-in from a server). 143 // remote (e.g., streamed-in from a server).
137 const bool is_local_source_; 144 const bool is_local_source_;
138 145
139 // In debug builds, check that all methods that could cause object graph 146 // In debug builds, check that all methods that could cause object graph
140 // or data flow changes are being called on the main thread. 147 // or data flow changes are being called on the main thread.
141 base::ThreadChecker thread_checker_; 148 base::ThreadChecker thread_checker_;
miu 2016/10/19 22:43:22 |thread_checker_| isn't needed anymore. The DCHECK
xjz 2016/10/19 23:59:36 Done.
142 149
143 // Set to true once this source has been permanently stopped. 150 // Set to true once this source has been permanently stopped.
144 bool is_stopped_; 151 bool is_stopped_;
145 152
146 // Manages tracks connected to this source and the audio format and data flow. 153 // Manages tracks connected to this source and the audio format and data flow.
147 MediaStreamAudioDeliverer<MediaStreamAudioTrack> deliverer_; 154 MediaStreamAudioDeliverer<MediaStreamAudioTrack> deliverer_;
148 155
156 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
miu 2016/10/19 22:43:22 Please add comment (mostly the same as the one for
xjz 2016/10/19 23:59:36 Done.
157
149 // Provides weak pointers so that MediaStreamAudioTracks won't call 158 // Provides weak pointers so that MediaStreamAudioTracks won't call
150 // StopAudioDeliveryTo() if this instance dies first. 159 // StopAudioDeliveryTo() if this instance dies first.
151 base::WeakPtrFactory<MediaStreamAudioSource> weak_factory_; 160 base::WeakPtrFactory<MediaStreamAudioSource> weak_factory_;
152 161
153 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource); 162 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioSource);
154 }; 163 };
155 164
156 } // namespace content 165 } // namespace content
157 166
158 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_ 167 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_SOURCE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/local_media_stream_audio_source.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