| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| 7 | 7 |
| 8 #include "content/renderer/media/media_stream_audio_source.h" | 8 #include "content/renderer/media/media_stream_audio_source.h" |
| 9 #include "media/base/audio_capturer_source.h" | 9 #include "media/base/audio_capturer_source.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 // Represents a local source of audio data generated by an AudioInputDevice. | 13 // Represents a local source of audio data generated by an AudioInputDevice. |
| 14 // Uses content::AudioDeviceFactory to auto-create the AudioInputDevice, using | 14 // Uses content::AudioDeviceFactory to auto-create the AudioInputDevice, using |
| 15 // the parameters and session ID found in StreamDeviceInfo, just before the | 15 // the parameters and session ID found in StreamDeviceInfo, just before the |
| 16 // first track is connected. Audio data is transported directly to the tracks | 16 // first track is connected. Audio data is transported directly to the tracks |
| 17 // (i.e., there is no audio processing). | 17 // (i.e., there is no audio processing). |
| 18 class CONTENT_EXPORT LocalMediaStreamAudioSource | 18 class CONTENT_EXPORT LocalMediaStreamAudioSource |
| 19 : NON_EXPORTED_BASE(public MediaStreamAudioSource), | 19 : NON_EXPORTED_BASE(public MediaStreamAudioSource), |
| 20 NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) { | 20 NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) { |
| 21 public: | 21 public: |
| 22 // |consumer_render_frame_id| references the RenderFrame that will consume the | 22 // |consumer_render_frame_id| references the RenderFrame that will consume the |
| 23 // audio data. Audio parameters and (optionally) a pre-existing audio session | 23 // audio data. Audio parameters and (optionally) a pre-existing audio session |
| 24 // ID are read from |device_info|. | 24 // ID are read from |device_info|. |
| 25 LocalMediaStreamAudioSource(int consumer_render_frame_id, | 25 LocalMediaStreamAudioSource(int consumer_render_frame_id, |
| 26 const StreamDeviceInfo& device_info); | 26 const StreamDeviceInfo& device_info, |
| 27 const ConstraintsCallback& started_callback); |
| 27 | 28 |
| 28 ~LocalMediaStreamAudioSource() final; | 29 ~LocalMediaStreamAudioSource() final; |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 // MediaStreamAudioSource implementation. | 32 // MediaStreamAudioSource implementation. |
| 32 bool EnsureSourceIsStarted() final; | 33 bool EnsureSourceIsStarted() final; |
| 33 void EnsureSourceIsStopped() final; | 34 void EnsureSourceIsStopped() final; |
| 34 | 35 |
| 35 // media::AudioCapturerSource::CaptureCallback implementation. | 36 // media::AudioCapturerSource::CaptureCallback implementation. |
| 37 void OnCaptureStarted() final; |
| 36 void Capture(const media::AudioBus* audio_bus, | 38 void Capture(const media::AudioBus* audio_bus, |
| 37 int audio_delay_milliseconds, | 39 int audio_delay_milliseconds, |
| 38 double volume, | 40 double volume, |
| 39 bool key_pressed) final; | 41 bool key_pressed) final; |
| 40 void OnCaptureError(const std::string& message) final; | 42 void OnCaptureError(const std::string& message) final; |
| 41 | 43 |
| 42 // The RenderFrame that will consume the audio data. Used when creating | 44 // The RenderFrame that will consume the audio data. Used when creating |
| 43 // AudioInputDevices via the AudioDeviceFactory. | 45 // AudioInputDevices via the AudioDeviceFactory. |
| 44 const int consumer_render_frame_id_; | 46 const int consumer_render_frame_id_; |
| 45 | 47 |
| 46 // The device created by the AudioDeviceFactory in EnsureSourceIsStarted(). | 48 // The device created by the AudioDeviceFactory in EnsureSourceIsStarted(). |
| 47 scoped_refptr<media::AudioCapturerSource> source_; | 49 scoped_refptr<media::AudioCapturerSource> source_; |
| 48 | 50 |
| 51 // Callback that's called when the audio source has been initialized. |
| 52 ConstraintsCallback started_callback_; |
| 53 |
| 49 // In debug builds, check that all methods that could cause object graph | 54 // In debug builds, check that all methods that could cause object graph |
| 50 // or data flow changes are being called on the main thread. | 55 // or data flow changes are being called on the main thread. |
| 51 base::ThreadChecker thread_checker_; | 56 base::ThreadChecker thread_checker_; |
| 52 | 57 |
| 53 DISALLOW_COPY_AND_ASSIGN(LocalMediaStreamAudioSource); | 58 DISALLOW_COPY_AND_ASSIGN(LocalMediaStreamAudioSource); |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 } // namespace content | 61 } // namespace content |
| 57 | 62 |
| 58 #endif // CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ | 63 #endif // CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| OLD | NEW |