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

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

Issue 12440027: Do not pass the string device_id via IPC message to create an audio input stream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changed the pepper code to use OpenDevice() for default device, and fixed a minor mistake in MediaS… Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_WEBRTC_AUDIO_CAPTURER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 15 matching lines...) Expand all
26 class WebRtcLocalAudioRenderer; 26 class WebRtcLocalAudioRenderer;
27 27
28 // This class manages the capture data flow by getting data from its 28 // This class manages the capture data flow by getting data from its
29 // |source_|, and passing it to its |sink_|. 29 // |source_|, and passing it to its |sink_|.
30 // It allows clients to inject their own capture data source by calling 30 // It allows clients to inject their own capture data source by calling
31 // SetCapturerSource(). 31 // SetCapturerSource().
32 // The threading model for this class is rather complex since it will be 32 // The threading model for this class is rather complex since it will be
33 // created on the main render thread, captured data is provided on a dedicated 33 // created on the main render thread, captured data is provided on a dedicated
34 // AudioInputDevice thread, and methods can be called either on the Libjingle 34 // AudioInputDevice thread, and methods can be called either on the Libjingle
35 // thread or on the main render thread but also other client threads 35 // thread or on the main render thread but also other client threads
36 // if an alternative AudioCapturerSource has been set. In addition, the 36 // if an alternative AudioCapturerSource has been set.
37 // AudioCapturerSource::CaptureEventHandler methods are called on the IO thread
38 // and requests for data to render is done on the AudioOutputDevice thread.
39 class CONTENT_EXPORT WebRtcAudioCapturer 37 class CONTENT_EXPORT WebRtcAudioCapturer
40 : public base::RefCountedThreadSafe<WebRtcAudioCapturer>, 38 : public base::RefCountedThreadSafe<WebRtcAudioCapturer>,
41 NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback), 39 NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) {
42 NON_EXPORTED_BASE(
43 public media::AudioCapturerSource::CaptureEventHandler) {
44 public: 40 public:
45 // Use to construct the audio capturer. 41 // Use to construct the audio capturer.
46 // Called on the main render thread. 42 // Called on the main render thread.
47 static scoped_refptr<WebRtcAudioCapturer> CreateCapturer(); 43 static scoped_refptr<WebRtcAudioCapturer> CreateCapturer();
48 44
49 // Creates and configures the default audio capturing source using the 45 // Creates and configures the default audio capturing source using the
50 // provided audio parameters. 46 // provided audio parameters, |session_id| is used to be passed to the
miu 2013/03/18 23:19:05 nit: /is used to be passed/is passed/
no longer working on chromium 2013/03/19 14:06:49 Done.
47 // browser to decide which device to use.
51 // Called on the main render thread. 48 // Called on the main render thread.
52 bool Initialize(media::ChannelLayout channel_layout, int sample_rate); 49 bool Initialize(media::ChannelLayout channel_layout,
50 int sample_rate,
51 int session_id);
53 52
54 // Called by the client on the sink side to add a sink. 53 // Called by the client on the sink side to add a sink.
55 // WebRtcAudioDeviceImpl calls this method on the main render thread but 54 // WebRtcAudioDeviceImpl calls this method on the main render thread but
56 // other clients may call it from other threads. The current implementation 55 // other clients may call it from other threads. The current implementation
57 // does not support multi-thread calling. 56 // does not support multi-thread calling.
58 // Called on the main render thread. 57 // Called on the main render thread.
59 void AddCapturerSink(WebRtcAudioCapturerSink* sink); 58 void AddCapturerSink(WebRtcAudioCapturerSink* sink);
60 59
61 // Called by the client on the sink side to remove a sink. 60 // Called by the client on the sink side to remove a sink.
62 // Called on the main render thread. 61 // Called on the main render thread.
(...skipping 14 matching lines...) Expand all
77 void Start(); 76 void Start();
78 77
79 // Stops recording audio. 78 // Stops recording audio.
80 // Called on the main render thread or a Libjingle working thread. 79 // Called on the main render thread or a Libjingle working thread.
81 void Stop(); 80 void Stop();
82 81
83 // Sets the microphone volume. 82 // Sets the microphone volume.
84 // Called on the AudioInputDevice audio thread. 83 // Called on the AudioInputDevice audio thread.
85 void SetVolume(double volume); 84 void SetVolume(double volume);
86 85
87 // Specifies the |session_id| to query which device to use.
88 // Called on the main render thread.
89 void SetDevice(int session_id);
90
91 // Enables or disables the WebRtc AGC control. 86 // Enables or disables the WebRtc AGC control.
92 // Called from a Libjingle working thread. 87 // Called from a Libjingle working thread.
93 void SetAutomaticGainControl(bool enable); 88 void SetAutomaticGainControl(bool enable);
94 89
95 bool is_recording() const { return running_; } 90 bool is_recording() const { return running_; }
96 91
97 // Audio parameters utilized by the audio capturer. Can be utilized by 92 // Audio parameters utilized by the audio capturer. Can be utilized by
98 // a local renderer to set up a renderer using identical parameters as the 93 // a local renderer to set up a renderer using identical parameters as the
99 // capturer. 94 // capturer.
100 // TODO(phoglund): This accessor is inherently unsafe since the returned 95 // TODO(phoglund): This accessor is inherently unsafe since the returned
101 // parameters can become outdated at any time. Think over the implications 96 // parameters can become outdated at any time. Think over the implications
102 // of this accessor and if we can remove it. 97 // of this accessor and if we can remove it.
103 media::AudioParameters audio_parameters() const; 98 media::AudioParameters audio_parameters() const;
104 99
105 // AudioCapturerSource::CaptureCallback implementation. 100 // AudioCapturerSource::CaptureCallback implementation.
106 // Called on the AudioInputDevice audio thread. 101 // Called on the AudioInputDevice audio thread.
107 virtual void Capture(media::AudioBus* audio_source, 102 virtual void Capture(media::AudioBus* audio_source,
108 int audio_delay_milliseconds, 103 int audio_delay_milliseconds,
109 double volume) OVERRIDE; 104 double volume) OVERRIDE;
110 virtual void OnCaptureError() OVERRIDE; 105 virtual void OnCaptureError() OVERRIDE;
111 106
112 // AudioCapturerSource::CaptureEventHandler implementation.
113 // Called on the IO thread.
114 virtual void OnDeviceStarted(const std::string& device_id) OVERRIDE;
115 virtual void OnDeviceStopped() OVERRIDE;
116
117 protected: 107 protected:
118 friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>; 108 friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>;
119 virtual ~WebRtcAudioCapturer(); 109 virtual ~WebRtcAudioCapturer();
120 110
121 private: 111 private:
122 class SinkOwner; 112 class SinkOwner;
123 typedef std::list<scoped_refptr<SinkOwner> > SinkList; 113 typedef std::list<scoped_refptr<SinkOwner> > SinkList;
124 114
125 WebRtcAudioCapturer(); 115 WebRtcAudioCapturer();
126 116
(...skipping 11 matching lines...) Expand all
138 // A list of sinks that the audio data is fed to. 128 // A list of sinks that the audio data is fed to.
139 SinkList sinks_; 129 SinkList sinks_;
140 130
141 // The audio data source from the browser process. 131 // The audio data source from the browser process.
142 scoped_refptr<media::AudioCapturerSource> source_; 132 scoped_refptr<media::AudioCapturerSource> source_;
143 133
144 // Buffers used for temporary storage during capture callbacks. 134 // Buffers used for temporary storage during capture callbacks.
145 // Allocated during initialization. 135 // Allocated during initialization.
146 class ConfiguredBuffer; 136 class ConfiguredBuffer;
147 scoped_refptr<ConfiguredBuffer> buffer_; 137 scoped_refptr<ConfiguredBuffer> buffer_;
148 std::string device_id_;
149 bool running_; 138 bool running_;
150 139
151 // True when automatic gain control is enabled, false otherwise. 140 // True when automatic gain control is enabled, false otherwise.
152 bool agc_is_enabled_; 141 bool agc_is_enabled_;
153 142
143 // The media session ID used to identify which input device to be started.
144 int session_id_;
145
154 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); 146 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer);
155 }; 147 };
156 148
157 } // namespace content 149 } // namespace content
158 150
159 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 151 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698